Back

SetFilter does not correctly choose the ATM strike price

The SetFilter funciton does not correctly choose the ATM strike price, making it difficult to backtest. I have not been able to figure out exactly how it chooses its median value for the ATM strike price, but it seems pretty random. It can sometimes be off by 15 dollars or more. I have created a backtest that shows this issue. I have logged the underlying price and the chosen strike price when options are traded.

From the docs:

By default, the option universe is filtered down to contracts that expire within 35 days, one contract below and another above ATM, and exclude weeklys.

Also, how do you set the SetFilter function to include weeklys?

Update Backtest








I think I figured it out. The equity prices are dividend adjusted while the option algorithm is not.

0

Correct! Option backtests must use raw data to handle the strike prices properly.

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.


Are you sure you need that abs() call in sorting function?

Weeklys can be included as follows (I'm not sure if that's the correct way, but it works):

f = lambda x: x.IncludeWeeklys().Strikes(-1, +1).Expiration(timedelta(0), timedelta(15))
func = Func[OptionFilterUniverse, OptionFilterUniverse](f)
option.SetFilter(func)
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