Coinbase Pro historical data not working

1

I'm trying to pull historic data from the Coinbase Pro api using Python with the cbpro package. For some reason I either hit an error, or can only pull data from the last 350 days.

If I run the following:

import time
import cbpro
import csv
import json
import shutil
import os
start_time = time.time()
end_time = start_time-(86400*300)
public_client = cbpro.PublicClient()
public_client.get_product_historic_rates('ETH-USD')
data = public_client.get_product_historic_rates('ETH-USD', granularity=86400,
                                                start = start_time,
                                                end = end_time)

Then I get an "invalid interval" error. If however I remove either the "start = start_time" or "end = end_time" part of the code I get the last 350 days worth of historic data. No matter ISO 8601 time I list as "start" or "end," I'm always getting back the last 350 days starting with today.

What am I doing wrong?

Victor

Posted 2019-02-10T00:07:18.677

Reputation: 21

Answers

1

The reason it was pulling data when I dropped the "start" or "end" part of the code was because the API then ignored that parameter and returned the default result.

the solution was to import the 'datetime' package and format the 'start_time" and "end_time" objects using datetime. for example:

start_time = datetime.datetime(year,month,day)

Victor

Posted 2019-02-10T00:07:18.677

Reputation: 21