Difference between historic and live data

My algorithms are working off the 4h data stream.
However, I’m getting differences between live data and historic data.
For example ENJUSBT, 4h:
Live data:
2021-04-21 18:00 - 2.68
But historic data a couple of hours later show:
2021-04-21 22:00 2.47

This difference is almost 9%!!
My back testing will not work at all with these.

Hi. Can you clarify how you got the live data and the historical data?
Correct me if I understand you wrongly, were you comparing one of the order data with the timestamp pointed to 2021-04-21 18:00 to another one executed at 2021-04-21 22:00? It’s possible that the price changed that much within 4hrs. You can check it by observing kline 4hr data’s highest and lowest price.

Sorry, both prices are for 22:00 (I made a mistake writing the post).

If I get the 4h price from binance at 22:00, I got 2.68.
But if I wait until 23:00 and get the price for 22:00, I get 2.47 instead.
So apparently Binance is changing the closing prices?

Can you check again if these 2 records have the same timestamps? i.e. if they have the same start time and end time.

I have a bot running that places orders live. I get this difference on every time stamp. For example
ENJ/BUSD - 30m stream:
At one minute after bar close (2021-04-26 12:31:02) i fetched the price for
2021-04-26 12:30:00 closing price 2.31

4 minutes later, at 2021-04-26 12:35:01
2021-04-26 12:30:00 closing price price 2.30

10 minutes after bas close, at 2021-04-26 12:40:02
2021-04-26 12:30:00 closing price 2.29

So you can see here that during the 10 minute period after the bar close for 12:30, the price has changed from 2.31 to 2.30 and finally 2.29.

Is this the stream you subscribe to, wss://stream.binance.com:9443/ws/ENJBUSD@kline_30m ?

Thanks for your response. I checked the API return.
It might be confusing that the latest object returns something like this, take the current timestamp as 1619571941000 (Wednesday, 28 April 2021 01:05:41) for example. The current time does not equal to the end time of the sample returned array. Hence the numbers keep changing until reaching the end time.

        1619568000000, <-- start time
        1619582399999, <-- end time, future timestamp

For now, I would suggest you to either check if the current time already passed the end time of the time frame specified or subscribe to the websocket stream. Will feedback to the team about this.

Here is an example for the 4h prices:


I’m calling the API via the CCXT python framework

I see, I obviously misunderstood the timestamp. Thanks.