Back

AfterMarketOpen() error

Hi,

I can't use the AfterMarketOpen function. In my initialize function, I'm calling

self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen( "SPY", -1 ), my_function)

in order to execute my_function just before market open. However, I get the following error:

TypeError : unindexable object     (Open Stacktrace)

In the QC documentation it says the AfterMarketOpen function can be called as such:

TimeRules.AfterMarketOpen("SPY", 10)
(https://www.quantconnect.com/blog/scheduled-events-lean/)

On the other hand, the API says the first parameter should be of type QuantConnect.Symbol. I tried that, but it still won't work. What should I do?

Update Backtest







...Nevermind! Been looking at this for a while, and as soon as I posted on the forum I realized the error was in the my_function code, and not in the time rules!

1

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