12

I'm trying to retrieve 3 months history of 30-minute candles from Kraken using the REST API: https://www.kraken.com/help/api

Following the documentation, I made this POST request to URL: https://api.kraken.com/0/public/OHLC

passing the following parameters in JSON format:

{
  "pair":"EOSETH",
  "interval":30,
  "since":1514404800
}

where 1514404800 corresponds to the timestamp (in seconds) to the date:
27/10/2017 20H00m UTC
This is not clear from the API documentation, they call it an 'ID', but I came to this conclusion by looking to the returned values.

So I was expecting returned response with entries starting on this date. Then I would fetch subsequent entries using the last id returned.

However the first entry I get corresponds exactly to 15 days ago. Actually, if I don't pass the parameter 'since' at all, I get exactly the same result, so it seems the parameter is being ignored completely.

Maybe Kraken changed the API and this parameter 'since' was replaced by some other?
Or I missunderstood the syntax of this parameter and I'm doing something wrong?

xsilmarx
  • 729
  • 5
  • 22
  • Fun fact: 1m data gives you 24h. One thing to note is that the data is inconsistent (it will change if you refresh a few times). So don't be too reliant on this data – Joe Phillips Jun 05 '19 at 20:17

2 Answers2

13

They call it an 'ID' but you are right this is the UNIX TimeStamp.

I agree that it is not clear from the API documentation.

There is a limit in the number of results returned, see https://support.kraken.com/hc/en-us/articles/218198197-How-to-pull-all-trade-data-using-the-Kraken-REST-API

I tried and indeed you cannot get all 30 min data from 27/10/2017.

It seems the since parameter is useless once you reach the limit. It works great if not (i.e. data from yesterday https://api.kraken.com/0/public/OHLC?pair=EOSETH&since=1517774700&interval=30).

As soon as you reach the limit the count starts from today to the past and you get only last 15 days data...

Maybe a solution is, as stated in the article, to build your own OHLC from trades data...

Try to contact the support to clarify this point (I already contacted them for another problem and they reply pretty fast).

(I'm writing this as an answer because too much text the for a comment, sorry if it does not answer your question)

Yann39
  • 14,285
  • 11
  • 56
  • 84
  • It seems the only solution is to build the OHLC from the Trades, as you mentioned. I think this is how, for instance, Gekko (an open-source trading bot) is able to retrieve history from Kraken. Maybe I can try to contact the support just in case. Thanks for the help. – xsilmarx Feb 06 '18 at 18:51
7

This bypasses the API part of the question, but you can download historical data from their website: https://support.kraken.com/hc/en-us/articles/360047124832-Downloadable-historical-OHLCVT-Open-High-Low-Close-Volume-Trades-data

tehfink
  • 447
  • 8
  • 7