How will this scheduled event actually process?
In the backtest log, I get the following result:
2017-02-21 09:31:00 :BTS
2017-02-21 09:31:00 :2017-02-21 09:00:00
...
self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(9, 0), Action(self.BeforeTradingStart))
def BeforeTradingStart(self):
# This is where we will run daily code checks to ensure lists are synced with positions.
# additionally, will determine how many days a position has been held in Portfolio
self.Log("BTS")
now = self.Time
self.Log(str(now))
So, whether backtesting, papertrading, or live trading, when is the function BeforeTradingStart actually executing? at 9:00 am, or 9:31 am?
Petter Hansson
Two notes although I don't know whether they specifically apply to your problem:
1) I recommend using AfterMarketOpen with a negative parameter to turn it into before market open, This means it will handle daylight savings correctly, etc.
2) The timestamps observed in backtests are aliased on the highest resolution your have chosen, because of the engine running in timesteps of the highest resolution. As long as the event (which however doesn't appear to be the case...) executes before market open and thus in the correct order, I would ignore the timestamp in backtest. If you run it live, you should see it being triggered at exactly the correct time.
Jared Broad
Hey -- Its been a while since I looked at this code but I think its firing at 9am but because the data is the clock in backtesting mode its appearing as 931 (log glitch not modelling one); in live trading it would've been fired at 9am.
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.
AMDQuant
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!