python cctx Kucoin futures take profit

1.7k Views Asked by At

I´m using ccxt on python to make a bot with Kucoin. Is there a way to make a Kucoin futures Order with take profit. take and order is easy

kucoin_futures.create_order('XBTUSDTM', "market", "buy", 1, None, {'leverage': 1})

but not a way to add take profit to order

thanks....

1

There are 1 best solutions below

0
On

For take profit, create a limit order with same size, opposite side and 'reduceOnly':true parameter.

def setTp(exchange, symbol: str, side: str, size: int, tp: float):
    params = dict(reduceOnly=True)
    side = 'sell' if side=='buy' else 'buy'
    try:
        res = exchange.createOrder(symbol, 'limit', side, size, price=tp, params=params)
        return res
    except Exception as e:
        print(e)