Hello,

I'm having trouble using a QuoteBarConsolidator - the minute (or second) data is offset by one bar, meaning the period reported for the consolidated bar is different from the actual data used to construct the bar: the minute (or second) data is off by one bar.

For example:
Create a backtest for Oanda "EURJPY" forex data, using Resolution.Minute data
Build a QuoteBarConsolidator using a TimeSpan.FromHours(1)

The resulting hourly bar is emited every hour with the correct Time, but uses the wrong span:

Expected:

00:00 to 01:00 bar should use 00:00 open price and 00:59 close price for the hour.

Observed:

00:00 to 01:00 bar uses the 00:01 open price and the 01:01 close price for the hour - off by 1 bar

I've tested using 1 second and 1 minute Resolution data; and the behavour is the same.

 

You can see this in the log below:

2018-05-01 00:00:00 Launching analysis for 6f9472b6d2abdb66e7781da9c917d361 with LEAN Engine v2.4.0.0.3729
...

2018-05-01 00:00:00 Start of hour --> 2018-05-01T00:00:00 - 2018-05-01T00:01:00 : o 132.0975, c 132.1005
2018-05-01 00:01:00 Next bar      --> 2018-05-01T00:01:00 - 2018-05-01T00:02:00 : o 132.097, c 132.0935
2018-05-01 00:59:00 End of hour   --> 2018-05-01T00:59:00 - 2018-05-01T01:00:00 : o 132.0775, c 132.0775
2018-05-01 01:00:00 We got a new HOUR
2018-05-01 01:00:00 2018-05-01T01:00:00 new HOURLY bar from  2018-05-01T00:00:00 to 2018-05-01T01:00:00 : 132.097 132.121 132.071 132.085

 

2018-05-01 01:00:00 Start of hour --> 2018-05-01T01:00:00 - 2018-05-01T01:01:00 : o 132.081, c 132.085
2018-05-01 01:01:00 Next bar      --> 2018-05-01T01:01:00 - 2018-05-01T01:02:00 : o 132.0815, c 132.081
2018-05-01 01:59:00 End of hour   --> 2018-05-01T01:59:00 - 2018-05-01T02:00:00 : o 132.0535, c 132.0535
2018-05-01 02:00:00 We got a new HOUR
2018-05-01 02:00:00 2018-05-01T02:00:00 new HOURLY bar from  2018-05-01T01:00:00 to 2018-05-01T02:00:00 : 132.0815 132.082 132.022 132.06
2018-05-01 02:00:00 .    
2018-05-01 02:00:00 ..    
2018-05-01 02:00:00 ...   
2018-05-01 02:00:00 Start of hour --> 2018-05-01T02:00:00 - 2018-05-01T02:01:00 : o 132.0565, c 132.06

Am I doing the wrong thing here, or is this a bug. I haven't seen anyone else mention this problem.

My use case is that I want to use fine grain data to make trading decisions, but need hourly data to provide context for those decisions. I thought a consolidator was the correct approach to take.

Thanks,

Kel.