XTB API JSON 无法修改现有交易头寸

问题描述 投票:0回答:2

我正在使用 xAPI Playground 进行测试,链接在这里: https://playground.xapi.pro/ 我想使用命令编辑/修改现有头寸:tradeTransaction 文档说要修改现有头寸,我应该使用“type”作为 3,“cmd”应该匹配现有头寸(0 表示买入,1 表示卖出)

{
    "command": "tradeTransaction",
    "arguments": {
        "tradeTransInfo": {
            "cmd": 1,
            "customComment": "Some text",
            "expiration": 0,
            "order": order_number_as_int ,
            "price": open_price_as_double,
            "sl": my_double_value,
            "tp": my_another_double_value,
            "symbol": "f.e. OIL.WTI",
            "type": 3,
            "volume": 0.01
        }
    }
}

错误代码

{
    "status": false,
    "errorCode": "SE199",
    "errorDescr": "Internal error"
}

从 API 收集的有关现有职位的所有可能数据:

{'cmd': 1, 'order': 474325736, 'digits': 2, 'offset': 0, 'order2': 474325838, 'position': 474325736, 'symbol': 'OIL.WTI', 'comment': '', 'customComment': '', 'commission': 0.0, 'storage': 0.0, 'margin_rate': 0.0, 'close_price': 76.65, 'open_price': 76.57, 'nominalValue': 0.0, 'profit': -3.56, 'volume': 0.01, 'sl': 80.0, 'tp': 70.0, 'closed': False, 'timestamp': 1676665564666, 'spread': 0, 'taxes': 0.0, 'open_time': 1676663063081, 'open_timeString': 'Fri Feb 17 20:44:23 CET 2023', 'close_time': None, 'close_timeString': None, 'expiration': None, 'expirationString': None},

API 文档在这里: http://developers.xstore.pro/documentation/#tradeTransaction

Ofc 我在“cmd”和“type”中尝试了所有可能的值,但它没有帮助。 错误代码有时是不同的,f。电子:

{
    "command": "tradeTransaction",
    "arguments": {
        "tradeTransInfo": {
            "cmd": 3,
            "customComment": "Some text",
            "expiration": 0,
            "order": 474325838,
            "price": 0,
            "sl": 0,
            "tp": 0,
            "symbol": "OIL.WTI",
            "type": 3,
            "volume": 0.01
        }
    }
}

错误代码:

{
    "status": false,
    "errorCode": "BE4",
    "errorDescr": "remaining nominal must be greater than zero"
}

有什么想法我会做错吗? 我正在与 XTB 支持联系,仍在等待回复。

提前感谢您的帮助!

json api sp
2个回答
0
投票

使用 getTrades 查看您的 仓位 ID 它与您的 order ID 不同,但位数相同。

在命令中使用位置 ID 而不是订单 ID。

编辑: 这有点复杂,但重点是:

XTB App 为您提供订单 ID 和头寸 ID。 您必须使用头寸ID来关闭订单。

API :

tradeTransaction 响应给你“订单”字段 - 你 can't 使用这个来关闭订单

但是

getTrades 为您提供 3 个字段: “订单”、“订单 2”和“位置”。

“订单”似乎与“头寸”相同 - 您可以用它来关闭您的订单

'order2' 似乎与 tradeTransaction 的 'order' 相同 - 你又一次 can't 使用这个。

希望这有帮助


0
投票

我在修改未平仓头寸时遇到了完全相同的问题。我看到这里没有解决问题的答案。仅建议在 tradeTransaction 中关闭 cmd。 当我想执行 MODIFY 并将位置(第 3 个订单 ID)作为订单参数传递时,出现错误。对于那个 CLOSE_ORDER 这种方式工作正常。

但是,当我通过作为开仓时建立的订单的订单ID时,我设法修改了止损订单。此订单处于待定状态。 唯一的问题是此订单有不同的订单 ID,我无法使用 XTB 上可用的 xAPI 检索它。 我没有在 getTrades 或未结订单中看到它。我刚刚从 xStation 控制台读取了 id。

你有没有在 XTB 支持下解决任何问题?你解决了这个问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.