0

I have a bit of code that will download minute to minute data historically from binance, and combine it all into their own CSV. EG: BCHUSDT-1m-data.csv, BTCUSDT-1m-data.csv, etc for whatever pairs I want. However, I keep getting a requests.exceptions.ChunkedEncodingError connectionreset error 10054 (closed by remote host).

Is there a better way to go about getting this information than using the client.get_historical_klines(interval) method? Ideally I would want even more granular data (30s, 15, or even 1s if at all possible historically). Thanks in advance!

Link to API: Python-Binance API

Ajay
  • 5,267
  • 2
  • 23
  • 30
  • Take a look at their [websocket](https://python-binance.readthedocs.io/en/latest/websockets.html) page, it allows you to stream data and get updates every second however I believe [Binance API](https://github.com/binance-us/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams) is limited to 1m granularity – Andrew Stone Feb 06 '21 at 04:29

1 Answers1

0

For less than 1m trades you need to use

trades = client.get_historical_trades(symbol='BNBBTC') 

or

trades = client.get_aggregate_trades(symbol='BNBBTC') 

The last one is better it cost less weight and contains more information Then if you want to combine it to candles/klines you can use pandas resample or ohlc function.

Mike Malyi
  • 983
  • 8
  • 18