Ok so I tried to run it on Windows subsystem for linux and that didn’t work either. I’m about to spin up a virtual machine to try that, but at this point I have tried so much and am beginning to wonder why an official library simply doesn’t work, or is based on libraries that have very clear issues on windows that cause the library to not work without stating that it wont work on windows (or only work on certain operating systems).
By the way the error I get when running on WSL (windows subsystem for linux):
INFO:root:Connection with URL: wss://stream.binance.com:9443/ws
INFO:root:Start to connect....
INFO:root:Server connected
INFO:root:Sending message to Server: b'{"method": "SUBSCRIBE", "params": ["btcusdt@depth@1000ms"], "id": 1}'
INFO:root:Out of sync, re-syncing...
Unhandled Error
Traceback (most recent call last):
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 85, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 83, in callWithContext
return func(*args, **kw)
--- <exception caught here> ---
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py", line 687, in _doReadOrWrite
why = selectable.doRead()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 246, in doRead
return self._dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 251, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 324, in dataReceived
self._flushReceiveBIO()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 290, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py", line 107, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 290, in dataReceived
self._dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1207, in _dataReceived
self.consumeData()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1219, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1579, in processData
fr = self.onFrameEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1704, in onFrameEnd
self._onMessageEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 318, in _onMessageEnd
self.onMessageEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 628, in onMessageEnd
self._onMessage(payload, self.message_is_binary)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 321, in _onMessage
self.onMessage(payload, isBinary)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py", line 30, in onMessage
self.factory.callback(payload_obj)
File "manage_local_order_book.py", line 113, in message_handler
order_book = get_snapshot()
File "manage_local_order_book.py", line 44, in get_snapshot
return client.depth(symbol, limit=1000)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py", line 62, in depth
return self.query("/api/v3/depth", params)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 67, in query
return self.send_request("GET", url_path, payload=payload)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 116, in send_request
self._handle_exception(response)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 169, in _handle_exception
raise ClientError(status_code, err["code"], err["msg"], response.headers)
binance.error.ClientError: (400, -1100, "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:34 GMT', 'Server': 'nginx', 'x-mbx-uuid': '3ef51bc8-1a87-4182-90ca-a0abd1c3fc46', 'x-mbx-used-weight': '10', 'x-mbx-used-weight-1m': '10', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': '6f5P9LxLM5k4loBTAbXeCa_9Ir7c-KunLm3ne63wzNyIf88dJ3uPVA=='})
WARNING:root:WebSocket connection closed: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake), code: 1006, clean: False, reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
ERROR:root:Lost connection to Server. Reason: [Failure instance: Traceback: <class 'binance.error.ClientError'>: (400, -1100, "Illegal characters found in parameter
'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:34 GMT', 'Server': 'nginx', 'x-mbx-uuid': '3ef51bc8-1a87-4182-90ca-a0abd1c3fc46', 'x-mbx-used-weight': '10', 'x-mbx-used-weight-1m': '10', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': '6f5P9LxLM5k4loBTAbXeCa_9Ir7c-KunLm3ne63wzNyIf88dJ3uPVA=='})
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py:85:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:118:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:83:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:700:_doReadOrWrite
--- <exception caught here> ---
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:687:_doReadOrWrite
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:246:doRead
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:251:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:324:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:290:_flushReceiveBIO
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py:107:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:290:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1207:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1219:consumeData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1579:processData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1704:onFrameEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:318:_onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:628:onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:321:_onMessage
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py:30:onMessage
manage_local_order_book.py:113:message_handler
manage_local_order_book.py:44:get_snapshot
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py:62:depth
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:67:query
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:116:send_request
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:169:_handle_exception
]. Retrying: 1
INFO:root:Start to connect....
INFO:root:Server connected
INFO:root:Sending message to Server: b'{"method": "SUBSCRIBE", "params": ["btcusdt@depth@1000ms"], "id": 1}'
INFO:root:Out of sync, re-syncing...
Unhandled Error
Traceback (most recent call last):
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py", line 85, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py", line 83, in callWithContext
return func(*args, **kw)
--- <exception caught here> ---
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py", line 687, in _doReadOrWrite
why = selectable.doRead()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 246, in doRead
return self._dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py", line 251, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 324, in dataReceived
self._flushReceiveBIO()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py", line 290, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py", line 107, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 290, in dataReceived
self._dataReceived(data)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1207, in _dataReceived
self.consumeData()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1219, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1579, in processData
fr = self.onFrameEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 1704, in onFrameEnd
self._onMessageEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 318, in _onMessageEnd
self.onMessageEnd()
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py", line 628, in onMessageEnd
self._onMessage(payload, self.message_is_binary)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py", line 321, in _onMessage
self.onMessage(payload, isBinary)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py", line 30, in onMessage
self.factory.callback(payload_obj)
File "manage_local_order_book.py", line 113, in message_handler
order_book = get_snapshot()
File "manage_local_order_book.py", line 44, in get_snapshot
return client.depth(symbol, limit=1000)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py", line 62, in depth
return self.query("/api/v3/depth", params)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 67, in query
return self.send_request("GET", url_path, payload=payload)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 116, in send_request
self._handle_exception(response)
File "/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py", line 169, in _handle_exception
raise ClientError(status_code, err["code"], err["msg"], response.headers)
binance.error.ClientError: (400, -1100, "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:36 GMT', 'Server': 'nginx', 'x-mbx-uuid': 'a8859ae7-0935-4764-995e-ff8e2105217b', 'x-mbx-used-weight': '20', 'x-mbx-used-weight-1m': '20', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': 'h_yoGk29UvtjI_uFrubzpNRiHigG0_6cuZRPa79ikZ-6y_NbQLvH1g=='})
^CTraceback (most recent call last):
WARNING:root:WebSocket connection closed: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake), code: 1006, clean: False, reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)
File "manage_local_order_book.py", line 147, in <module>
ERROR:root:Lost connection to Server. Reason: [Failure instance: Traceback: <class 'binance.error.ClientError'>: (400, -1100, "Illegal characters found in parameter
'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'.", {'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '108', 'Connection': 'keep-alive', 'Date': 'Sat, 17 Jul 2021 22:12:36 GMT', 'Server': 'nginx', 'x-mbx-uuid': 'a8859ae7-0935-4764-995e-ff8e2105217b', 'x-mbx-used-weight': '20', 'x-mbx-used-weight-1m': '20', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains', 'X-Frame-Options': 'SAMEORIGIN', 'X-Xss-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "default-src 'self'", 'X-Content-Security-Policy': "default-src 'self'", 'X-WebKit-CSP': "default-src 'self'", 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 76f9985b0c929a023355db8e462592f0.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'MIA3-C2', 'X-Amz-Cf-Id': 'h_yoGk29UvtjI_uFrubzpNRiHigG0_6cuZRPa79ikZ-6y_NbQLvH1g=='})
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/log.py:85:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:118:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/python/context.py:83:callWithContext
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:700:_doReadOrWrite
--- <exception caught here> ---
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/posixbase.py:687:_doReadOrWrite
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:246:doRead
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/internet/tcp.py:251:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:324:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/tls.py:290:_flushReceiveBIO
/home/art/binanceTest/venv/lib/python3.8/site-packages/twisted/protocols/policies.py:107:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:290:dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1207:_dataReceived
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1219:consumeData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1579:processData
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:1704:onFrameEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:318:_onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/websocket/protocol.py:628:onMessageEnd
/home/art/binanceTest/venv/lib/python3.8/site-packages/autobahn/twisted/websocket.py:321:_onMessage
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/websocket/binance_client_protocol.py:30:onMessage
manage_local_order_book.py:113:message_handler
manage_local_order_book.py:44:get_snapshot
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/spot/market.py:62:depth
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:67:query
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:116:send_request
/home/art/binanceTest/venv/lib/python3.8/site-packages/binance/api.py:169:_handle_exception
].