fix: query live orders per account#44
Merged
NitayRabi merged 1 commit intoMay 12, 2026
Merged
Conversation
|
🎉 This PR is included in version 1.21.10 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Fixes
get_live_orders({})so the advertised “all accounts” behavior is actually account-scoped under the hood.Today the tool calls
/iserver/account/orderswithoutaccountIdwhen no account is passed. In live Client Portal Gateway sessions this can return an emptyorderslist even when account-scoped requests such as/iserver/account/orders?accountId=<account>return working/recent orders. That makes the MCP tool unreliable for validating fills, brackets, stops, and other live order state.This PR changes the no-
accountIdpath to:/iserver/accounts/portfolio/accountsif needed/iserver/account/orders?accountId=<id>for each discovered accountordersaccountResultsfor debugging/auditingThe explicit
getOrders(accountId)path is unchanged and still returns the raw single-account response.Why
IBKR’s Web API documentation describes
/iserver/account/ordersas retrieving orders in a given account, and live testing showed that omittingaccountIdcan produce a false-empty response. The MCP tool description says{}should get all live/open orders, so the implementation should enumerate accounts rather than depend on an unscoped Client Portal response.Test Plan
npm testnpm run buildNew/updated unit coverage verifies:
accountIdcalls discover accounts with/iserver/accountsand then query orders per account/portfolio/accountsis used as a fallback account source/iserver/account/ordersremains a fallback when no accounts can be discoveredaccountIddirectly