Create limit order with take profit and stop loss in Kucoin future with ccxt
See original GitHub issueHi, I want to create a limit order with take profit and stop loss in Kucoin future exchange.
For ex: I created a long contract and I wanna close it when profit = %4 AND loss = %10 so, what are the params, types, etc.?
I tried with the below code but I think it’s wrong.
Thank you.
- Windows:
- Programming Language version: Python
- CCXT version: 1.77.34
exchange = ccxt.kucoinfutures({
'apiKey': config.MOH_BUY_API_KEY,
'secret': config.MOH_BUY_API_SECRET,
'password': config.MOH_BUY_API_PASSPHRASE
})
symbol = 'AVAX/USDT:USDT'
amount = 1
leverage = 10
side = 'buy'
price = 'Market close price for the symbol in 1 min candels ' #9.75
stopPrice = (100-config.STOPLOSS)*0.01*price
params = {'leverage': leverage, 'stop': 'loss', 'stopPrice': stopPrice , 'stopPriceType': 'TP'}
order = exchange.create_order(symbol=symbol, type='limit', side=side, amount=amount, price=price, params=params)
ccxt.base.errors.BadRequest: kucoinfutures error.createOrder.stopInvalid
Issue Analytics
- State:
- Created a year ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How To Set Take Profit and Stop Loss When Placing ... - KuCoin
In the order-placing panel for Limit and Market order, click "Take Profit & Stop Loss", and choose "Last Price" or "Mark Price" to...
Read more >api - python cctx Kucoin futures take profit - Stack Overflow
For take profit, create a limit order with same size, opposite side and 'reduceOnly':true parameter. def setTp(exchange, symbol: str, ...
Read more >How to Create a STOP LOSS algorithmically (python & phemex)
in this video i show you exactly how to make a stop loss order in python using the ccxt pro package. it took...
Read more >KuCoin Futures: Setting Take Profit & Stop Loss (Step-by-Step)
In this video I'll show you step by step how to set a take profit and stop loss order on KuCoin futures.▽ KuCoin...
Read more >Exchanges — ccxt 2.4.71 documentation
Besides making basic market and limit orders, some exchanges offer margin trading ... your stop loss price } // for a take profit...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@YuxinSUN89 @MohammadTaherkhani Guys! Kucoin give me answer!
Dear User,
Thank you for contacting us.
The Futures has two directions so they need to be discussed separately.
They all use the same API, but the input parameters are different.
POST /api/v1/orders
Param type Description
side String buy or sell
stop String [optional] Either down or up. Requires stopPrice and stopPriceType to be defined
stopPriceType String [optional] Either TP, IP or MP, Need to be defined if stop is specified.
stopPrice String [optional] Need to be defined if stop is specified.
when your side is buy, stop-loss and take-profit price set as follows
1) stop-loss: side=buy, stop=down, stopPriceType and stopPrice are set according to your needs
when your side is sell, stop-loss and take-profit price set as follows
1) stop-loss: side=sell, stop=up, stopPriceType and stopPrice are set according to your needs
python demo:
If you have any questions or concerns regarding this process, please don’t hesitate to let us know.
Kind regards,
Aaron
KuCoin API Team
CORRECT:
1)when your main order side is buy, stop-loss and take-profit order set as follows
2)when your main order side is sell, stop-loss and take-profit order set as follows
NOTIC: For stop-loss and take-profit order, reduceOnly: true