Is there any way I can get callbacks at a periodic rate that's decoupled from OnData? With second resolution data, at least you get callbacks at 1 Hz, but with tick data, the time between callbacks can vary arbitrarily it would seem?
Of course, this is pretty trivial for me to implement in live version in a timer thread or similar, but it needs to work in backtest as well.
Alexandre Catarino
We use Schedule Events to achieve this goal:
Schedule.On( DateRules.EveryDay(), TimeRules.Every(TimeSpan.FromSeconds(1)), () => { Log("Fired at: " + Time); });
Petter Hansson
Alright, awesome! Is it restricted to one second intervals in backtesting or can I make the intervals smaller?
Alexandre Catarino
No, there is no restriction. Please keep in mind that tiny intervals will slow the algorithm exectution. Also, second-resolution data is only regular when we use "fill foward", otherwise we will not receive new data in OnData event handler if there is no new data within a second.
Petter Hansson
That sounds great, it means I can use this to do some small checks at e.g. 10 Hz to improve my order execution simulation for backtests. The checks are ultra-simple (just checking if a queue has any item that passed current time) and don't run anything else most of time.
Thanks for the help, these details do matter when trying to improve backtest accuracy.
Petter Hansson
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!