can someone please help with this. This is the same code i use for backtesting a couple months back. Now it is not working. Options are not filtering correctly.
QUANTCONNECT COMMUNITY
can someone please help with this. This is the same code i use for backtesting a couple months back. Now it is not working. Options are not filtering correctly.
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.
Mia Alissi
Based on the provided code, it seems like the issue might be related to the options filtering. In the
Initialize
method, the option filter is set with a minimum expiry of 648 and a maximum expiry of 99999 days. However, in theOnData
method, there is a condition to liquidate the option if the current time plus the maximum expiry is greater than the option's expiry date. This could potentially cause issues if the maximum expiry is set too high.Here is the relevant code:
You might want to adjust the maximum expiry to a more reasonable value. Also, ensure that the option data is available for the date range you are backtesting. As mentioned in the forum discussion, the options data might not be available for certain dates.
If the issue persists, you might want to debug your code by logging the option chains and checking if the options are being filtered as expected. You can do this in the
OnData
method:This will print the option chains to the console, which can help you identify any issues with the options filtering.
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.
Muhammad Yusuf Bin Salleh
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!