Watching ohlcv on Binance results in ccxt.base.errors.NetworkError: 1000
See original GitHub issueI am getting this error (ccxt.base.errors.NetworkError: 1000) for the Binance exchange after a couple of hours. This also occurs for BNB/USDT. However, strangely I don’t get this error for btc/usdt.
- OS: Linux (Ubuntu)
- Programming Language version: Python 3.7
- CCXT version: latest
Function giving the error (ccxt.base.errors.NetworkError: 1000):
exchange = getattr(ccxtpro, 'binance')({'enableRateLimit': True})
if not exchange.has['fetchOHLCV']:
raise KeyError('Exchange does not provide the ability to fetch OHLCV candles.')
if not exchange.has['watchOHLCV']:
raise KeyError('Exchange does not provide the ability to watch OHLCV candles.')
ohlcvs = await exchange.watch_ohlcv(symbol="ETH/USDT", timeframe="1m", limit=2)
if len(ohlcvs) < 2:
return False
# Copies the ohlcv candles, since ccxt cannot handle in-reference edits
candles = [ohlcvs[0][:], ohlcvs[1][:]]
candles[0][0] = from_unix(candles[0][0]) # Official formed candle, with previous timestamp
candles[1][0] = from_unix(candles[1][0]) # Unofficial candle, representing current timestamp
if not self.last_candles or candles[1][0] > self.last_candles[1][0]:
self.last_candles = candles
return True
return False
Other function using the data
last_candle = DataFrame([self.last_candles[0]], columns=TOHLCV.get_values()).set_index(TOHLCV.TIMESTAMP.value)
self.historical_minute = self.historical_minute.append(last_candle).tail(min_candles)
File "/src/mia/blotter/blotter/blotter.py", line 140, in __get_last_candle
ohlcvs = await self.exchange.watch_ohlcv(symbol=self.strategy.ccxt_pair, timeframe=timeframe, limit=2)
File "/venv/lib/python3.8/site-packages/ccxtpro/binance.py", line 394, in watch_ohlcv
return await self.after(future, self.filter_by_since_limit, since, limit, 0, True)
File "/venv/lib/python3.8/site-packages/ccxtpro/base/exchange.py", line 81, in after
return method(await future, *args)
File "/venv/lib/python3.8/site-packages/ccxtpro/binance.py", line 481, in watch_public
return await self.watch(url, messageHash, self.extend(request, query), messageHash, subscribe)
ccxt.base.errors.NetworkError: 1000
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Exchanges — ccxt 2.4.71 documentation
Each class implements the public and private API for a particular crypto exchange. All exchanges are derived from the base Exchange class and...
Read more >ccxt-dev/ccxt - Gitter
Anyone here have much experience with Binance's "Signature is not valid" error? I'm currently watching it but it seems like it might be...
Read more >How To Handle CCXT Binance Intermittent Network Error
1 Answer 1. Sorted by: Reset to default. Highest score (default) ...
Read more >ccxt - Bountysource
ccxt. A JavaScript / Python / PHP library for cryptocurrency trading and ... new ccxt['binance']; while (true) { try { // How to...
Read more >Python Scripts for CCXT Crypto Candlestick (OHLCV ...
CCXT Example. Jumping right into the first example, we will take the LTC/BTC trading pair and collect the OHLCV candles from Binance. Once...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to provide additional context, I too have experienced this issue. And I can confirm it was due to an underlying network connection issue unrelated to CCXT and the crypto-currency exchange. After adding an execption handler to restart things it is now a non-issue. I have provided my code below, which handles the exception by restarting.
The service, which my code is a part of, has been running without issue for over 14 months. I hope this helps someone. Cheers.
I ran the code you gave me in a Kubernetes container and it had one restart. I also attached the logs of that container. ccxt version: 1.30.94 ccxt pro version: 0.2.89 ccxt_previous.log