I searched almost all internet and I am currently seeking the solution of this problem.
I need to pass broker id and name when placing limit order to kucoin using ccxt library.
I have this code order stream code.
async def order_stream(self):
while self.info.userStreamActive and len(self.watch) != 0:
try:
ws = await self.ccxt.ws_connect('wss://ws-api-spot.kucoin.com/?', {
'apiKey': self.ccxt.apiKey,
'secret': self.ccxt.secret,
'passphrase': self.ccxt.password,
})
msg = await ws.recv()
msg = json.loads(msg)
if 'data' in msg and 'subject' in msg['data'] and msg['data']['subject'] == 'trade.order':
order = msg['data']['data']
order_id = str(order['orderId'])
status = order['status']
symbol = str(order['symbol']).replace('-', '').lower()
data = kucoin_order_stream(order)
logging.debug('Order Stream:', data)
order = self.orders.update(order_id, data)
if '_id' in order:
logging.warning(
f"kucoin order stream: {order['symbol']} - {order['status']} - {order['orderId']}")
await db.update_one(ORDERS, {'_id': order['_id']}, {'status': order['status']})
except Exception as err:
logging.warning(
f'kucoin user data msg websocket error (outer) - {str(err)}')
await asyncio.sleep(30)