Repository navigation
Add contingent orders support: attached orders and OCA groups - #265
Merged
Merged
Conversation
5 of 11 tasks
Martin-Molinero
force-pushed
the
feature-contingent-orders
branch
2 times, most recently
from
September 24, 2026 13:23
225b1dd to
86b6019
Compare
Places OCO, OTO, OUO and bracket order sets atomically through parent ids and OCA groups, transmitting only the last order. Triggered children are reported once their parent fills and open orders rebuild their contingencies best effort from parent ids and OCA groups. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Martin-Molinero
force-pushed
the
feature-contingent-orders
branch
from
September 24, 2026 14:21
86b6019 to
a680b68
Compare
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Places contingent order sets (OCO, OTO, OUO and brackets, including combo orders) atomically at IB:
parentId. An order is held back, not transmitted, only when a later order of the set will carry it: its child or a sibling under the same parent. Anything else, like plain OCA members, is transmitted on its own.IBPlaceOrderpath, with the contingent attributes on top.201 OCA group is already filledrejection of a member is reported asCanceled, which is the one cancels other semantic.10148cancel reply for an order IB already canceled, like the children of a canceled parent, isn't reported asInvalid.OnContingentOrdersTriggeredhelper.OrderContingency.Trigger/Relate.Related Issue
Requires QuantConnect/Lean#9828, which adds contingent orders to Lean. This PR builds against it, so CI will pass once it's merged and released.
Motivation and Context
Support for Lean contingent orders (OCO, OTO, OUO, brackets) using the brokerage's native functionality, so the sets are placed atomically and managed on the brokerage side.
Requires Documentation Change
The supported contingent order shapes of this brokerage, see its brokerage model in Lean.
How Has This Been Tested?
Existing order types (plain API and
order_factory)New; same on masterContingent orders
Invalid321)Contingent orders on derivatives: SPY option, SPXW index option, MES future, MES future option
201 Guaranteed-to-Lose combination), and the combo parent held back with it was canceled. This is the rejected-transmitting-order handling.Lean
BrokerageTestscontingent orders suite (InteractiveBrokersContingentOrderTests, SPY)The combos are SPY call spreads (combo limit / combo market orders), the combo OTO exit is the combo sell order of the spread.
Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>🤖 Generated with Claude Code