Back

Option strategy utilities modules?

Does anyone know if something like this has already been done and shared by someone? I am thinking some set of wrapper/util functions that can facilitate working with options in backtesting, with features such as

  • Quickly identifying a call option with strike level closest to 0.92 * spot and expiry cloest to 3 months
  • Automatically close out option positions on last trading day (by the way am I right in thinking that the current engine does not hadle expiry/auto-exercise properly? Seems to me it will always expire worthless)
  • Implied vol <=> absolute price conversion
I understand these would only require a 'thin' wrapper layer, but it would be nice to avoid re-inventing the wheel. Thanks!
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 Pfchang,

Yes. Very often, our users find useful utility functions from our demonstration strategies, code snippets in tutorials, and community posts shared by other users. Regarding your questions:

(1) `option.SetFilter()` method can filter the options contracts using the specified min and max strike and expiration range values. Then, you can sort the selected contracts by strikes or expiry and pin down the exact contract you need. This documentation section and this community post are very useful.

(2) We don't support automatic exercise for European options currently. Instead, the strategy should use `ExerciseOption()` method to make option exercise orders manually.

(3) This tutorial contains a `bsm_price()` method to calculate option price and an `implied_vol()` method to solve implied volatility using bisection approach.

Xin

1

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.


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