Documentation for option

Hi, I couldn't find a lot of useful documentation for writing up option tradings. I need some serious help. For example, in 

1. what data type 'option' is in option = self.AddOption("GOOG"). It seems like a list but when I tried to find it in the API tab, it says AddOption returns QuantConnect.Securities.Option.Option, which has property 'Strike'. This doesn't look like a list. How can a list of options only have one strike attribute?

2. variable 'option' was not used when the code was trying to retrieve option quotes. Instead, it uses slice.OptionChain. Then I couldn't find how does the OptionChain structure look like. How is the filtered option in the initializing phase impacting the chain? I don't know.

3. I found self.Sell(OptionStrategies.Straddle(self.option_symbol, atmStraddle.Strike, atmStraddle.Expiry), 2) in another example but I couldn't find a list of available strategies under OptionStrategies in the API tab. I tried to guess, it tells me that OptionStrategies doesn't have IronCondor.

4. How can I exam a variable? like what value or structure it is? I tried to log and print with no luck. I need this if the type is not fully documented. 

5. How is OnData is called? Is it a loop called every minute when reads in a minute bar? If I have some calculation in OnData, will it update the self.attributes I put under BasicTemplateOptionsAlgorithm class?

6. How can I filter option based on delta? How can I get IV30 for a symbol at each minute other than writing my own calculation functions?

7. If I want to do some machine learning, how to properly train a model? It seems that I can only write it in the and train it on the fly? How can I preserve the model and use it later in live trading and keep optimizing it?

8. I think I can get started faster if I can just get access to the option data and write my own functions from scratch, is this an option here? Is downloading data an option?

Update Backtest

I accidentally found this page. It seems answering a few questions above. I don't know how I got there and I don't see it in the navigation bar in the documentation page. I guess I will just bookmark it.

I also figured out how to use Log for simple string. But does it support concatination like print, e.g. Self.Log('var x: ', x)?


Do I have to iterate through the entire OptionChains like this "for kvp in slice.OptionChains: if kvp.Key != self.option_symbol: continue" every time I want to get the IV of a certain option contract? Is there something similar to OptionChains['SPY']? I am adding 100 stock options but I don't need to monitor all of them every day.


How can I place order on an option strategy and set taking profit or stop loss on it? For example: assuming same expiration date, how to implement this:

1. place order on an iron condor: sell 1 googl 1000 put, sell 1 googl 1100 call, buy 1 googl 950 put, buy 1 googl 1150 call. This resulted credit X

2. take profit: 

when the price on the above strategy falls to 0.5X, close it: buy 1 googl 1000 put, buy 1 googl 1100 call, sell 1 googl 950 put, sell 1 googl 1150 call. This resulted debit 0.5X 


stop loss:

when the price on the above starty raise to 2X, close it: buy 1 googl 1000 put, buy 1 googl 1100 call, sell 1 googl 950 put, sell 1 googl 1150 call. This resulted debit 2X 


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed