You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
Also if you do or do not correct it to msg.get you get the following:
Traceback (most recent call last):
File "/home/paul.webster/Work/Trading/activebook/wsreader/kucoin-websocket.py", line 28, in
loop.run_until_complete(main())
File "/home/paul.webster/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/paul.webster/Work/Trading/activebook/wsreader/kucoin-websocket.py", line 23, in main
await asyncio.sleep(60, loop=loop)
TypeError: sleep() got an unexpected keyword argument 'loop'
Purely non modified example code(except msg.get):
import asyncio
from kucoin_futures.client import WsToken
from kucoin_futures.ws_client import KucoinFuturesWsClient
async def main():
async def deal_msg(msg):
if msg.get('topic') == '/contractMarket/level2:XBTUSDM':
print(f'Get XBTUSDM Ticker:{msg["data"]}')
elif msg.get('topic') == '/contractMarket/level3:XBTUSDTM':
print(f'Get XBTUSDTM level3:{msg["data"]}')
# is public
# client = WsToken()
# is private
client = WsToken(key='', secret='', passphrase='', is_sandbox=False, url='')
# is sandbox
# client = WsToken(is_sandbox=True)
ws_client = await KucoinFuturesWsClient.create(loop, client, deal_msg, private=False)
await ws_client.subscribe('/contractMarket/level2:XBTUSDM')
await ws_client.subscribe('/contractMarket/level3:XBTUSDM')
while True:
await asyncio.sleep(60, loop=loop)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
The sample needs to change from msg['topic'] to msg.get('topic'). It creates an error that causes the websockets to stop working.
The text was updated successfully, but these errors were encountered: