ccxt: Bug - unable to open short position with TP/SL on v1.84.40 (OKX)
- OS: Big Sur 11.6
- Programming Language version: Python 3.8.10
- CCXT version: 1.84.40
- Exchange used: OKX
Hi, there seems to be a bug in recent version of CCXT with code that used to work in version 1.62.40. Issue arises in creating TakeProfit/StopLoss when creating a Short position in OKX.
Validated through testing that below code works on 1.62.40 but not on 1.84.40. Basically saying TakeProfit cannot be lower than order price even though it is a Sell order
Errors:
- “TP trigger price can not be lower than the mark price”
- “SL trigger price can not be higher than the last price”
symbol = 'GMT/USDT:USDT'
params = {'mgnMode': 'cross'}
OKX.setLeverage(symbol=symbol,leverage=leverage,params=params)
current_price = OKX.fetchTicker(symbol = symbol)['last']
side ='sell'
amount = 15
tp = current_price*(1-0.05)
sl = current_price+(current_price*0.05)
params = {
'side': 'sell',
'positionSide':'short',
'slTriggerPxType': 'mark',
'tpTriggerPxType': 'mark'
'tpTriggerPx': tp,
'tpOrdPx': tp,
'slTriggerPx': sl,
'slOrdPx': sl,
'tdMode': 'cross'
}
# market order
order = OKX.createOrder(type = 'market', symbol=symbol, side=side, amount=amount, price = current_price, params = params)
okex5 {"code":"1","data":[{"algoId":"","sCode":"51280","sMsg":"SL trigger price can not be higher than the last price."}],"msg":""}
okex5 {"code":"1","data":[{"algoId":"","sCode":"51303","sMsg":"TP trigger price can not be lower than the mark price."}],"msg":""}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (10 by maintainers)
@bzhongy the new build should arrive in around 15mins, if you can update ccxt and try again after it arrives and report the results here that would be really appreciated!
@bzhongy thanks for reporting, will try to fix it now