common-close-0
BYDFi
Trade wherever you are!
header-more-option
header-global
header-download
header-skin-grey-0

How can I use the Kraken Python API to retrieve historical price data for cryptocurrencies?

avatarT KirtleyNov 25, 2021 · 3 years ago1 answers

I want to retrieve historical price data for cryptocurrencies using the Kraken Python API. Can you guide me on how to do it?

How can I use the Kraken Python API to retrieve historical price data for cryptocurrencies?

1 answers

  • avatarNov 25, 2021 · 3 years ago
    Absolutely! Here's how you can use the Kraken Python API to retrieve historical price data for cryptocurrencies: 1. Start by installing the Kraken API Python library. You can do this by running 'pip install krakenex' in your command prompt or terminal. 2. Next, import the necessary modules in your Python script: 'import krakenex' and 'import time'. 3. Create an instance of the Kraken API client: 'kraken = krakenex.API()'. 4. Set the public API URL by loading your public API key: 'kraken.load_public_key('YOUR_PUBLIC_API_KEY')'. 5. Use the 'kraken.query_public' method to retrieve the historical price data. For example, you can use 'kraken.query_public('OHLC', {'pair': 'XBTUSD', 'interval': '1', 'since': '1609459200'})' to get the OHLC data for the XBT/USD pair with a 1-minute interval since January 1, 2021. 6. Once you have the data, you can process and analyze it as per your requirements. I hope this helps! If you have any more questions, feel free to ask.