kucoin-futures-python-sdk icon indicating copy to clipboard operation
kucoin-futures-python-sdk copied to clipboard

updating websocket example for Future Pyhton SDK

Open progressivehed opened this issue 2 years ago • 0 comments

Example update for deprectaing endpoint

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['topic'] == '/contractMarket/level2:XBTUSDM': print(f'Get XBTUSDM Ticker:{msg["data"]}')

# is public

client = WsToken(is_sandbox=True)
ws_client = await KucoinFuturesWsClient.create(loop, client, deal_msg, private=False)
await ws_client.subscribe('/contractMarket/level2:XBTUSDM')

while True:
    await asyncio.sleep(60)

if name == "main": loop = asyncio.get_event_loop() loop.run_until_complete(main())

progressivehed avatar Jun 15 '22 17:06 progressivehed