Search code examples
pythonsdkcryptocurrencykucoin

executing a market buy order through Kucoin API


I have just started with the Kucoin API but I'm having trouble executing a market buy order in the futures market using python. I'm using this Github as a reference:

 https://github.com/Kucoin/kucoin-futures-python-sdk

heres the code I tried:

from kucoin_futures.client import Trade
client = Trade(key='myKey', secret='mySecret', passphrase='myPP')

client.create_market_order(symbol="ZEROUSDTM", side="buy",funds=1, lever=1)

however this returns the following error:

File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\kucoin_futures\base_request\base_request.py", line 128, in check_response_data
raise Exception("{}-{}".format(response_data.status_code, response_data.text))
Exception: 200-{"msg":"Quantity parameter cannot be empty.","code":"100001"}

does anyone know where I'm going wrong? Thanks for reading


Solution

  • by default orders are limit orders. So you need to specify price and size attributes. This is according the API manual: https://www.kucoin.com/docs/rest/spot-trading/orders/place-order