coinbasepro-python icon indicating copy to clipboard operation
coinbasepro-python copied to clipboard

Issue with "get_product_historic_rates" start and end dates

Open Bainsbe opened this issue 4 years ago • 2 comments

The "get_product_historic_rates" function seems to return more values than needed when "start" or "end" variables get passed in.

import cbpro as cbp

client = cbp.PublicClient()
response = client.get_product_historic_rates( 'BTC-USD', start = '2021-05-01T01:00:00', granularity = 86400)

The above returns 300 values despite granularity being daily and the start time being only 7 days ago. The endpoint seems to be returning correct values for the query when tested separately. Tested it on: https://gdaxurl.surge.sh/

Bainsbe avatar May 08 '21 02:05 Bainsbe

Specify the "end" date 1 Day later and it should work

response = client.get_product_historic_rates( 'BTC-USD', start = '2021-05-01T01:00:00', end = '2021-05-02T01:00:00', granularity = 86400)

ensingerphilipp avatar May 11 '21 09:05 ensingerphilipp

@ensingerphilipp Thanks, that works!

Maybe worth looking into implementing a fix for this on the back end - so end defaults to today if start is passed in alone and end defaults to end date minus 300 periods if passed in alone.

Bainsbe avatar May 11 '21 15:05 Bainsbe