Back

An example of trading Options using AddUniverse

I could only find static symbol examples for options trading and wanted to share how I implemented AddUniverse in an options contract writing example. I hope someone finds it useful.
 

I took my alpha out before I shared, so I don't think this example will make you money -  this example trades short strangles indescriminately.

As is, this thing is slow, scanning a massive options dataset. Definitely need to filter down to expand on the timeframe that you can reasonably backtest on. Backtesting 1 year can take 30 min to an hour. enjoy!

Update Backtest








0

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.


Hi Stephan Vanwoezik ,

Thank you for your contribution. Allow me to make some considerations. :-)

When the algorithm subscribes to options with
option = self.AddOption(security.Symbol.Value)
it creates an Options Universe that will select and subscribe options contracts in the following iteration.

Therefore 
chain = slice.OptionChains.GetValue(option.Symbol)
will be None/null/empty. I would recomment subscribing to options data in the OnSecuritiesChanged method.

At the moment, subscribe to options using AddOption in Universe Selection algorithms is not recommended because the algorithm cannot remove it when the underlying is removed by the Universe Selection. Instead, we advise using OptionChainProvider+AddOptionContract.

0

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.


Hi Alexandre, I appreciate your feedback. I'll update this post when I get a chance to implement your suggestions. thanks!

0

maybe somebody else will take up the challenge to implement your suggestions - I had difficulty .... Alexandre could you offer pros and cons. Is it purely performance concerns? Also why does warmup happen? I'm new here and the framework puzzles me. Haven't been able to spend much time but I'm lost at times and just run a lot of code that seems 'magical', if you know what I mean.

0

Update Backtest





0

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.


Loading...

This discussion is closed