My setup is I go through a minute candle dataset.
For each invocation of the handle_data() function the logical time is at the start of that minute. At least that’s what context.get_datetime() says.
It turns out the protocol.BarData.current()
method looks a bit in the future by returning the corresponding high/low/close, which shouldn’t be actually known until the end of the minute.
For example this is the data fed to the algorithm:
And this is what BarData.current() yields:
context.get_datetime()=2021-01-01 00:00:00+00:00
price=28991.010000000002
last_traded=2021-01-01 00:00:00+00:00
open=28948.190000000002
high=28997.16
low=28935.3
close=28991.010000000002
volume=143