Retrieving Full Historical Data for Every Cryptocurrency on Binance & Bitmex Using the Python APIs

A single function to read, update, save and gather data.

Peter Nistrup
The Startup

--

Disclaimer: I know this isn’t what I typically post but since it’s an interest of mine — just like traditional finance, machine learning, and data science — I think some of you might find this interesting as well.

I’ve recently been investigating the relationship between data science and the cryptocurrency market for a pretty long article I’m writing. During the process, I needed to retrieve price history and other data, so I decided to write a supplementary piece about how I accomplished that.

I hope you find it useful. Make sure to follow me if you enjoy this piece and want to see more!

TL;DR

To retrieve Bitcoin prices and data (1m klines):

  1. Sign-up on Binance and/or BitMex to get API access.
  2. Import the functions I’ve created for easy-of-use and add your API details.
  3. a. Call the function: get_all_binance(“BTCUSDT”, “1m”, save = True)
    b. Call the function: get_all_bitmex(“XBTUSD”, “1m”, save = True)

Example use:

--

--