You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

IBKR API修改Bracket Order报错:被修改订单与原订单不匹配

Fix for "Order being modified does not match original order" when modifying IBKR Bracket Order

Root Cause

Your code resubmits the entire bracket order (parent, take-profit, stop-loss) during modification, which violates IBKR's order rules:

  • The original parent order was already activated (transmitted) by the stop-loss order's Transmit=true flag in the initial submission.
  • Resending the parent order with Transmit=false creates a mismatch between the existing order's state and the modification request, triggering the error.
  • Resubmitting unchanged orders (parent and stop-loss) is unnecessary and causes conflicts with the active order book.

Corrected Modification Code

Instead of recreating the entire bracket, only send the modified take-profit order (the only component you want to change):

// Original bracket creation (unchanged)
int ParentOrderId = EWI.NextOrderId;
List<Order> bracket = BracketOrder(ParentOrderId, "BUY", 100, 30, 40, 20);
foreach (Order o in bracket)
    client.placeOrder(o.OrderId, Contract, o);

// Modify ONLY the take-profit order
Order modifiedTakeProfit = new Order();
modifiedTakeProfit.OrderId = ParentOrderId + 1; // Match original take-profit order ID
modifiedTakeProfit.Action = "SELL"; // Opposite of parent's BUY action
modifiedTakeProfit.OrderType = "LMT"; // Same as original take-profit order type
modifiedTakeProfit.TotalQuantity = 100; // Same quantity as original
modifiedTakeProfit.LmtPrice = 50; // New take-profit price
modifiedTakeProfit.ParentId = ParentOrderId; // Link to parent order ID
modifiedTakeProfit.Transmit = true; // Critical: send this standalone order to activate modification

client.placeOrder(modifiedTakeProfit.OrderId, Contract, modifiedTakeProfit);

Key Rules for Modifying IBKR Bracket Orders

  • Only modify changed orders: Don't resubmit the parent or unchanged child orders.
  • Match original order attributes: Keep OrderId, ParentId, Action, OrderType, and TotalQuantity identical to the original order (only update the specific field you want to change, e.g., LmtPrice).
  • Set Transmit=true for modifications: Since you're sending a standalone request, not part of a bracket submission chain.
  • Avoid conflicting flags: Never resend a parent order with Transmit=false after it's already been activated by the initial bracket submission.

内容的提问来源于stack exchange,提问作者nitinsy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 11:53:21