使用 ccxt 创建 OKEx 订单
Creating OKEx orders using ccxt
我正在尝试使用 ccxt 模块在 DEMO 交易模式下使用 StopLoss 和 TakeProfit 在 OKEx 中创建 SWAP 订单的程序。
但是我得到了错误:The current account mode does not support this API interface.
我该如何解决,是否有一些创建订单的例子?
我的尝试:
params = {
'tdMode': 'isolated',
'tpOrdPx': '-1',
'slOrdPx': '-1',
'tpTriggerPx': take_profit,
'slTriggerPx': stop_loss,
'headers': {
'x-simulated-trading': '1'
}
}
order = exchange.create_order(
f"XRP/USDT:USDT", 'market', 'buy', summa, price, params=params)
错误代码:
File "/home/excl/.local/lib/python3.10/site-packages/ccxt/base/exchange.py", line 561, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.AccountNotEnabled: okx {"code":"1","data":[{"clOrdId":"*id*","ordId":"","sCode":"51010","sMsg":"The current account mode does not support this API interface. ","tag":""}],"msg":"Operation failed."}
通过将账户模式从简单更改为投资组合模式解决。
https://www.okx.com/academy/en/guide-to-portfolio-margin-mode-on-okex
我正在尝试使用 ccxt 模块在 DEMO 交易模式下使用 StopLoss 和 TakeProfit 在 OKEx 中创建 SWAP 订单的程序。
但是我得到了错误:The current account mode does not support this API interface.
我该如何解决,是否有一些创建订单的例子?
我的尝试:
params = {
'tdMode': 'isolated',
'tpOrdPx': '-1',
'slOrdPx': '-1',
'tpTriggerPx': take_profit,
'slTriggerPx': stop_loss,
'headers': {
'x-simulated-trading': '1'
}
}
order = exchange.create_order(
f"XRP/USDT:USDT", 'market', 'buy', summa, price, params=params)
错误代码:
File "/home/excl/.local/lib/python3.10/site-packages/ccxt/base/exchange.py", line 561, in throw_exactly_matched_exception
raise exact[string](message)
ccxt.base.errors.AccountNotEnabled: okx {"code":"1","data":[{"clOrdId":"*id*","ordId":"","sCode":"51010","sMsg":"The current account mode does not support this API interface. ","tag":""}],"msg":"Operation failed."}
通过将账户模式从简单更改为投资组合模式解决。 https://www.okx.com/academy/en/guide-to-portfolio-margin-mode-on-okex