ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.54k stars 7.47k forks source link

Problem sending new orders to Kucoin #23324

Closed nsanchez1980 closed 1 month ago

nsanchez1980 commented 1 month ago

Operating System

Linux

Programming Languages

Python

CCXT Version

4.3.73

Description

This problem started ocurring around when Kucoin merged the HFT with the standard API. A lot of the times when sending a new order, CCXT returns a dictionary as if the order was correctly created, but consisting of mostly null values, except the orderID:

Example: {'info': {'orderId': '66b033cd693a4f0007d4e2f9'}, 'id': '66b033cd693a4f0007d4e2f9', 'clientOrderId': None, 'symbol': 'MTRG/USDT', 'type': None, 'timeInForce': None, 'postOnly': None, 'side': None, 'amount': None, 'price': None, 'stopPrice': None, 'triggerPrice': None, 'cost': None, 'filled': None, 'remaining': None, 'timestamp': None, 'datetime': None, 'fee': {'currency': None, 'cost': None}, 'status': None, 'lastTradeTimestamp': None, 'average': None, 'trades': [], 'fees': [{'currency': None, 'cost': None}], 'lastUpdateTimestamp': None, 'reduceOnly': None, 'takeProfitPrice': None, 'stopLossPrice': None}

The exception getting caught states "Order does not exist" when querying for that specific id (exchange.fetch_order)

This happens both with limit and market orders, with the amount verified via amount_to_precision and with enough funds, using exchange.create_order(pair,"market",side,amount)

Anybody else with this issue?

Code

  
sc0Vu commented 1 month ago

@nsanchez1980 Could you paste code snippet that we can reproduce this?

nsanchez1980 commented 1 month ago

Just by creating a limit or market spot order using create_order is enough, the issue is sporadic: for example, now it works ok, but yesterday and up to a couple of hours it was almost impossible to create an order. Most likely is an issue on the Kucoin side, but why does ccxt returns an order ID with all null values? Wouldn't it be nice to return an error or an exception?

carlosmiei commented 1 month ago

@nsanchez1980 Hello, returning only the orderId does not mean the order was not successful, many exchanges return only the OrderId upon placing an order.

For instance I just tested createOrder+fetchOrder and it worked

CCXT v4.3.73
kucoin.createOrder(LTC/USDT,market,buy,0.1)
{'amount': None,
 'average': None,
 'clientOrderId': None,
 'cost': None,
 'datetime': None,
 'fee': {'cost': None, 'currency': None},
 'fees': [{'cost': None, 'currency': None}],
 'filled': None,
 'id': '66b0faee31561300071536b4',
 'info': {'orderId': '66b0faee31561300071536b4'},
 'lastTradeTimestamp': None,
 'lastUpdateTimestamp': None,
 'postOnly': None,
 'price': None,
 'reduceOnly': None,
 'remaining': None,
 'side': None,
 'status': None,
 'stopLossPrice': None,
 'stopPrice': None,
 'symbol': 'LTC/USDT',
 'takeProfitPrice': None,
 'timeInForce': None,
 'timestamp': None,
 'trades': [],
 'triggerPrice': None,
 'type': None}

p kucoin fetchOrder "66b0faee31561300071536b4" 
Python v3.11.9
CCXT v4.3.73
kucoin.fetchOrder(66b0faee31561300071536b4)
{'amount': 0.1,
 'average': None,
 'clientOrderId': 'c3a2c18a-7f99-41d9-a441-fbdf93d70cde',
 'cost': 0.0,
 'datetime': '2024-08-05T16:16:46.371Z',
 'fee': {'cost': 0.0, 'currency': 'USDT'},
 'fees': [{'cost': 0.0, 'currency': 'USDT'}],
 'filled': 0.0,
 'id': '66b0faee31561300071536b4',
 'info': {'cancelAfter': 0,
          'cancelExist': False,
          'channel': 'API',
          'clientOid': 'c3a2c18a-7f99-41d9-a441-fbdf93d70cde',
          'createdAt': 1722874606371,
          'dealFunds': '0',
          'dealSize': '0',
          'fee': '0',
          'feeCurrency': 'USDT',
          'funds': '0',
          'hidden': False,
          'iceberg': False,
nsanchez1980 commented 1 month ago

Yeah, fortunately now is running ok. What should I do when the error presents itself again? Any logs or something specific that could help pinpoint the issue?