Is this a bug that when I specify the start time as few days ago and the API returns recent data only?
Here is the description on the API doc. https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
The difference between startTime and endTime can only be up to 200 days
Between startTime and endTime, the most recent limit data from endTime will be returned:
- If startTime and endTime are not sent, current timestamp will be set as endTime, and the most recent data will be returned.
- If startTime is sent only, the timestamp of 200 days after startTime will be set as endTime(up to the current time)
- If endTime is sent only, the timestamp of 200 days before endTime will be set as startTime
Let me rephrase the description about this unique logic so that it may be easier to understand (hopefully).
- If
startTime
andendTime
are not sent, the most recent data will be returned. -
startTime
andendTime
can be set to filter the most recent data tuples. The number of data tuples depends on thelimit
parameter.- If only
startTime
is sent,endTime
is set to 200 days (up to the current timestamp) after it. - If only
endTime
is sent, thestartTime
is 200 days before it.
- If only
In the above example, even though the startTime
is just a few days ago, obviously within the 200 days, it is outside of the recent data due to the large number of records. Candlestick data API only allows to query the latest 1500 records. If the interval is not set as 1m
but 1d
, the data may include that specific startTime
.