SPY options trading based on TLT change

Back

Hi, community!

I love this project, but I was not able to find any relevant tutorials about options trading, so I decided to do it by myself. The underlying idea is pretty simple, but I stuck in realization. I want to buy a call or put at the begging of each week based on the moving average of TLT, then on each Thursday close all options positions, because I don't want to exercise them and sell it with their theta.  I've got a pretty strange error:

Runtime Error: In Scheduled Event 'Monday: SPY: 120 min after MarketOpen', IndexError : list index out of range at OpenPosition in main.py:line 99 IndexError : list index out of range

Can someone help me to find where an error is?

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.


Hello Илья,

I think the problems are two:

1- Weekly options are created on thursdays and expire next friday, I think your filter 4 to 7 will return always 0 option contracts, it can be made 3 to 7 as it is 4 days until expiration.

2- The scheduled events for suscribing to the option and operating with the option have to be separate, otherwise the contract will not have received a single price.

Maybe this helps you a little bit:

2


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