Back

Why is this algorithm being stopped automatically?

The algorithm is being stopped before the end date. I can't see the reason why. If I add the option in the OnData function, the result is the same. 

Also, the tutorial says "OptionChains is a collection of OptionChain keyed by the option's underlying symbol." but the tutorial algorithm checks the following condition:

if kvp.Key != self.option_symbol: continue

However, if I Debug

kvp.Key

and 

self.option_symbol

they are only ever equal to ?GOOG. Shouldn't it be that the key is equal to the option_symbol?

 

Regards,

 

 

 

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 Pier-Olivier,

The guard

if kvp.Key != self.option_symbol: continue

is helpful when iterating through the option chains when we call AddOption multiple times in a single algorithm.

The algorithm above runs into issues with exceeding the portfolio's available margin. By opening up the Console at the bottom of the screen in the Algorithm Lab, we can see all the error messages. This error is happening because the OnData logic leads to submitting a market order every minute. To resolve this, we can add the following guard to the top of OnData:

if self.Portfolio.Invested:
return

After making this change, we can see there is still another error.

MarketOnClose order and exchange not open.

We can fix this one by ensuring the market is open before submitting the market order

if self.IsMarketOpen(symbol):
self.MarketOrder(symbol, 1)
self.MarketOnCloseOrder(symbol, -1)

See the attached backtest for reference.

Best,
Derek Melchin

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.


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