joseska
joseska

Reputation: 1

python cctx Kucoin futures take profit

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

Upvotes: 0

Views: 1844

Answers (1)

A.Dadkhah
A.Dadkhah

Reputation: 118

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)

Upvotes: 1

Related Questions