使用CCXT创建Okex订单

发布于 2025-01-27 07:50:50 字数 981 浏览 4 评论 0原文

我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

友谊不毕业 2025-02-03 07:50:50

通过将帐户模式从简单更改为投资组合模式来解决。
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文