How to set leverage for Kucoin futures using ccxt in Python?

1k Views Asked by At

I am trying to place a market order with the leverage of 20 but when the order is placed I am getting the leverage of 1.

I placed the market order like this:

exchange = ccxt.kucoinfutures({
    'adjustForTimeDifference': True,
    "apiKey": '...', # Api key here
    "secret": '...', # Api Secret here
    'password': '...', # Passphrase when making the Api
    'enableRateLimit': True,
})

order_response = exchange.createOrder('DOGEUSDTM', 'market', 'buy', 5, {'leverage': 20})
print(order_response)
1

There are 1 best solutions below

0
On BEST ANSWER

Just resolved this issue you are not sending the leverage for the market in correct format. Giving leverage like this would work only for limit orders as the 'price' is NONE ccxt kucoin futures library. So the correct way to call this function for market orders will be

order_response = exchange.createOrder('DOGEUSDTM', 'market', 'buy', 5, params={'leverage': 20})