Incomplete candles data

Hi,

I’m trying to get candles between two timestamp with a granularity of 1 minute but I’m having an incomplete response.

When I do a get request on https://api.exchange.coinbase.com/products/USDT-EUR/candles?granularity=60&start=1688649744&end=1688650044

I got the following response

[
    [
        1688650020,
        0.91877,
        0.91908,
        0.91908,
        0.91888,
        10000
    ]
]

From my understanding, I should have 5 candles since start is 1688649744 (Thursday, July 6, 2023 1:22:24 PM GMT) and end is 1688650044 (Thursday, July 6, 2023 1:27:24 PM GMT) so the timespan is 5 minutes and since I ask a resolution of 60 seconds, I should have 5 candles.

The response candle has a timestamp at 1688650020 (Thursday, July 6, 2023 1:27:00 PM GMT), which is indeed into the asked interval, however I should get more data.

Why do I only get a single candle and not five ?

hi @arkaik

Thank you for using Coinbase forum, we are happy to help you.

To get the five candles you are expecting, you need to make sure that the start and end timestamps are aligned with the granularity you are requesting. In this case, you need to make sure that the start timestamp is a multiple of 60 seconds (e.g. 1688649740) and the end timestamp is a multiple of 60 seconds plus 59 seconds (e.g. 1688650099). This will ensure that you get the five candles you are expecting.

Hope this helps, have good day.

Hi,

Thanks for your answer, I didn’t had much time to check this subject recently, but I just tried what you said, and indeed it fixes most of the request calls.

However I still found a particular case where no candle was returned, even if the timestamps were aligned with the interval.

For example with the candle on USDT-EUR between 2023-07-06 23:10:44 and 2023-07-06 23:11:44

Timestamps are the following ones:

start_timestamp : 1688685000
stop_timestamp : 1688685119

And here is the request with the response:

REQUEST:

GET https://api.exchange.coinbase.com/products/USDT-EUR/candles?granularity=60&start=1688685000&end=1688685119

RESPONSE:

<Response [200]> -

I don’t have any candle returned.

However, if I ask for an 2 minutes interval I do have one candle.

Edit:

Got the same error with the following intervals

Start date : 2023-05-26 12:16:24
End date : 2023-05-26 12:18:24
start_timestamp : 1685103360
stop_timestamp : 1685103539