I am trying to get historic OHLC data using the bitfinex REST api, docs here: https://bitfinex.readme.io/v2/reference#rest-public-candles
I have the following code:
try:
url = 'https://api.bitfinex.com/v2/candles/trade:1m:tBTCUSD/hist'
params = { 'start': 1506816000, 'end': 1509674567 }
r = requests.get(url, params = params)
data = r.json()
print(json.dumps(data, indent=2))
except Exception, e:
print e
When I run the code I get a list with only 100 elements and not all bars within the given period, I have tried changing the 'limit' parameter but it maxes out at 1000, which is less then a day for 1 minute bars.
I also tried to use the market data API from cryptowatch using the following url: https://api.cryptowat.ch/markets/gdax/btcusd/ohlc but no matter what parameters I pass for the start and end time it just gives back the last 500 bars. (However I want to be able to specify the time frame and get multiple months of data, as with most other API's)
Is there any way to get historic data from Bitfinex? For the most part their API is well documented so I am surprised that just getting historic data is so hard.
Bitfinex API takes unix time * 1000, meaning:
you can also add a "sort=" parameter to sort the response by ascending or descending order, also enabling you to provide only a 'start' param or 'end' param example:
will return a response where the first row is the closest trade occured to '1509674567000' timestamp ('1509674567' in regular unix time) and the last row would just be 999 trade before '1509674567000' (should be at '1509673162000').