Bug - unable to open short position with TP/SL on v1.84.40 (OKX)
See original GitHub issue- 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":""}
Issue Analytics
- State:
- Created a year ago
- Comments:16 (10 by maintainers)
Top Results From Across the Web
Shorting Bitcoin — how to profit from BTC bear markets and ...
If BTC's price falls while your position is open, it becomes profitable, as you can “cover” the short by buying back the asset...
Read more >Short Selling: The Risks and Rewards | Charles Schwab
Short selling involves borrowing a security whose price you think is going to fall from your brokerage and selling it on the open...
Read more >Short Selling: Definition, Pros, Cons, and Examples
Short selling occurs when an investor borrows a security, sells it on the open market, and expects to buy it back later for...
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
@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