Back

TradeBar arrival coordination

My understand is, trade bars from various instruments in the same resolution (even from the same source, e.g. your equitity stream) might arrive in different OnData calls at entirely different times in live (as opposed to backtest).

Thus, if I'm using ranking logic it is necessary to wait until I have enough bars to rank on, resulting in use of delayed data (which would be a problem).

Is this correct? I suppose I can test this live further but it would help w/ verbal confirmation.

Update Backtest








Petter,

I had a similar issue. Eventually I ended up fixing it by making a Dictionary and adding the bars to it every time that a new bar arrives. Then if an OnData doesn't have a bar, I pull the latest bar for that symbol from the doctionary. It deosn't work for all situations but if you have an indicator that needs to be fed, this seems to be the best way.

 

1

Thanks, was about to email you Patrick. ;-)

I'm considering to use a scheduled event for this run at the rate I want my indicators to have data, then simply use Security.Price. Won't work for warmup/historical data though...

The scary part is how this works differently from backtests where you get (mostly) nicely synchronized bars.

0

Live is slightly trickier than backtesting. Thinking of it in wall-clock time -- when the bar endtime rolls around (say T + 1ms) we can either emit what we have or wait another few milliseconds for the rest of the data to become available. In earlier versions of LEAN we'd wait 50ms for the bar to be ready before assuming it wasn't there. Now with the improved live-feed we wait 1ms. On Windows machines the minimum thread increment is 15.6ms so you will always be 15ms after the second.

If you're getting bars not synchronized together it might be a "bug" -- we can try tweaking the wait time to allow more time for people who don't really need 0ms latency. Perhaps for algorithms using mainly minute resolution we can increase the wait time to 200ms etc. No matter what its always a trade off as there is no perfect answer.

Petter Hansson -- If possible please share a ticket with support and we can use it as a test case we can fix.

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.


Right, length is not necessarily the same as time when you don't have data for all the past n time slices. For example an EMA of len=50 is set based on length that is more rigid. I think time-based indicators could be more accurate. Even better than that, I would like to have indicators that are time/length flexible. Something like Lasso or Elastic Net that adopt themselves based on data and not a predefined fixed length array.

0

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