[OKX PERP Swaps]: Cannot set leverage in the code.
See original GitHub issueI am trying to set leverage=1 for all perp swaps in the code. However, when I ran the code, the position is always opened with default leverage setting. It seems I can only manually set leverage in web browser.
Someone raised a similar question , but I dont think it has been answered properly.
OS: Mac OS Programming Language version: Python CCXT version: 1.84.70
exchange = ccxt.okx({
'subName' : config.OKX_SUB_NAME,
'apiKey': config.OKX_API_KEY,
'secret': config.OKX_API_SECRET,
'password': config.OKX_PASS_PHRASE,
"options": {'defaultType': 'swap'}
})
markets = exchange.load_markets()
qty = 10
inst = 'CHZ/USDT:USDT'
params = {"mgnMode" : "isolated", "posSide": "net" }
exchange.set_leverage(1, inst, params)
order = exchange.create_order(inst, type='market', side='sell', amount=qty)
Then I can see ‘CHZ/USDT:USDT’ short position opened with 2X leverage. Can anyone advise ? Thanks
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
I. Perpetual swaps – Help center - OKX
Traders can take a long/short position on cryptocurrencies with up to 125x leverage to make a profit when the price goes up/down.
Read more >How to trade perpetual swaps on OKX
Step 4: Choose the type of leverage for swap trading. After funding your swaps account, you can select the margin mode (either “Isolated”...
Read more >Overview – OKX API guide | OKX technical support
Welcome to the OKX API guide, OKEx technical support. OKX is a leading BTC exchange with highly secure SSL encryption and cold storage...
Read more >II. What is margin in Perpetual swaps? – Help center - OKX
Isolated Margin is the margin balance allocated to an individual position, allowing traders to manage their risk on each position. For crypto- ...
Read more >OKX's solution for spot, margin and perpetual swap ...
So far, OKX supports spot, margin, and perpetual swap trading — as well ... the actual leverage multiples or closing positions in advance....
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 FreeTop 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
Top GitHub Comments
@carlosmiei Thank you for solving my question !
Hello @YuxinSUN89 in the screenshot I see a
cross
margin position, but your code sets the leverage for theisolated
mode. I think that might be the problem.