Python script to automatically download trading data from binance

Ashwini Kumar Maurya
1 min readAug 16, 2020

If you are into cryptocurrency trading, you must be familiar with high volatility of cryptocurrency coins. To place an order, one needs to quickly derive insights by analyzing the realtime trading data. While making an intelligent trading bot is definitely lots of work and involves number of steps. I will talk about some of my insights in a series of posts. Before we get into that, first I will talk about how we can automatically download realtime trading data using Binance API.

While OHLC data can be download for past many time points at various intervals, the trading data i.e. buy/sell price and quantity can be downloaded for maximum of 500 data points. Therefore if one wants to download trading data for some time, it is good idea to automate the code and keep your code running on a machine. One good place is AWS EC2 and S3 for cloud computing and storage. Usually an instance with 8 vCPUs like c4.2xlarge is quite sufficient. I do not recommend the free tier t2.micro as it often runs into issues. I have tried for quite few times and every time job gets automatically killed with varying exceptions.

Below is the code with some descriptions.

To automate the downloading of trading data, just run this code as .py file from terminal.

--

--