Downloading Cryptocurrency OHLC Data Using Binance’s Python API

Ashwini Kumar Maurya
2 min readAug 3, 2020

Binance API makes it easy to download the trading data. While you can download most of historical data like OHLC (open, high, low, close etc), recent trades, order books without providing your API keys, for orders related to your account such as deposit, withdrawal etc you need to provide your API secret key.

As you may be aware, Bitcoin and other alt coins change price trajectory quite frequently and that is 24 hours and 7 days a week. It is not uncommon to be over excited and start contemplating ideas with profitable strategy. While it is true that the cryptocurrency trading offers unique opportunity to make good money in short term but same time if not traded carefully, it can drive your entire portfolio to zero.

While these cryptocurrencies exchanges are not regulated, there is good amount of manipulation. The price is often driven by speculation and that makes it quite dangerous to trade. However I do believe that one can always look into the data to derive better trading strategies.

Over the past few weeks, I have invested some time to automate some of data download and generating plots to gain insights. I would like to share some in series of posts.

In a first post, we start with downloading the historical klines using binance api . The below function reshapes the data as pandas data frame object .

Fig: Sample output of downloaded historical klines.

In next post, we will discuss about how to cryptocurrencies info on price, circulating supply, market cap from Coinmarketcap.com.

--

--