使用CCXT创建Okex订单
我正在尝试使用CCXT模块在演示交易模式下使用Stoploss和TakeProfit在Okex中创建交换订单的程序。 但是我遇到了错误:当前帐户模式不支持此API接口。
我如何解决它,并且是否有一些创建订单的示例? 我的尝试:
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."}
I'm trying to make program for creating SWAP orders in OKEx with StopLoss and TakeProfit in DEMO trading mode using ccxt module.
But I got error: The current account mode does not support this API interface.
How I can solve it, and is there some examples of creating orders?
My attempt:
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)
Error code:
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."}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过将帐户模式从简单更改为投资组合模式来解决。
https://www.okx.com/ Academy/en en/of-portfolio-margin-mode-okex
Solved by changing account mode from simple to portfolio mode.
https://www.okx.com/academy/en/guide-to-portfolio-margin-mode-on-okex