0

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....

joseska
  • 1
  • 2
  • Take profit orders aren't unified for kucoinfutures yet, I'll add it to my list of things to do if it's possible, so check back in a few weeks, you can however set a a closing limit order like described in A. Dadkhah's answer – Sam Mar 26 '22 at 09:34

1 Answers1

1

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)
A.Dadkhah
  • 78
  • 1
  • 7