ccxt: Network Errors. Unable to download even one complete set of historical candles.
No matter how low I set the limit, the connection always drops out. Usually it is able to get about 1 year of data before the errors below occur. Since this is public data, I am not using a key. Does that effect how much data can be downloaded? Thanks for looking.
- OS: Mac
- Programming Language version: Python 3.8
- CCXT version:most recent
def scrape_ohlcv(symbol):
exchange = ccxt.binance({
'rateLimit': 200,
'enableRateLimit': True,
#'verbose': True,
})
start_timestamp = exchange.fetch_ohlcv(symbol, '1m', since=0, limit=1)[0][0]
now = exchange.milliseconds()
data = []
while start_timestamp < end_time:
try:
print(exchange.iso8601(exchange.milliseconds()))
print(f'Fetching {symbol} minutes from:')
print(exchange.iso8601(start_timestamp))
ohlcvs = exchange.fetch_ohlcv(symbol, '1m', since=start_timestamp, limit=200 )
print('Fetched', len(ohlcvs), 'minutes')
print()
start_timestamp = ohlcvs[-1][0]
data += ohlcvs
time.sleep(1)
except (ccxt.ExchangeError, ccxt.AuthenticationError, ccxt.ExchangeNotAvailable, ccxt.RequestTimeout) as error:
print('Got an error', type(error).__name__, error.args, ', retrying in', hold, 'seconds...')
time.sleep(hold)
return data```
Traceback (most recent call last)
ConnectionResetError: [Errno 104] Connection reset by peer
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))
requests.exceptions.ConnectionError: (‘Connection aborted.’, ConnectionResetError(104, ‘Connection reset by peer’))
ccxt.base.errors.NetworkError: binance GET https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&startTime=1540008480000&limit=200
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (9 by maintainers)
Commits related to this issue
- examples/py/binance-fetch-ohlcv-to-csv.py fix #8599 — committed to ccxt/ccxt by kroitor 3 years ago
- examples/py/binance-fetch-ohlcv-to-csv.py minor edit #8599 — committed to ccxt/ccxt by kroitor 3 years ago
thanks again.
Thanks for your help, I’ll try to get it to work. Cheers.