*Opened for incoming PRs
Expected Behavior
Have LEAN provide a brokerage-neutral way for algorithms to understand and manage the individual accounts behind a master or advisor brokerage account.
When supported by the connected brokerage, C# and Python algorithms should be able to:
- request a current snapshot of accessible managed accounts;
- see which accounts belong to each account group;
- identify unassigned accounts and duplicate group memberships;
- inspect account-level cash, values, and exact positions;
- determine when the snapshot was collected and whether it is ready, stale, or incomplete;
- request that an account be moved to an existing group or removed from all groups;
- request an update to an existing group’s saved allocation; and
- verify whether an asynchronous account-group operation completed successfully.
The algorithm should explicitly request refreshes and decide how fresh the information must be before acting.
This would enable important multi-account workflows such as:
- reconciling strategy intent with actual account-level brokerage state.
- discovering newly attached client accounts;
- identifying accounts that need onboarding or exception handling;
- detecting deposits, withdrawals, or externally changed holdings;
- finding accounts that are outside their intended strategy group;
- safely coordinating account-group changes; and
- Brokerages that do not support these capabilities should continue to operate normally.
Related feature requests:
IB Brokerage: QuantConnect/Lean.Brokerages.InteractiveBrokers#259
IBAutomater: QuantConnect/IBAutomater#112
Documentation: QuantConnect/Documentation#2624
Actual Behavior
LEAN’s portfolio represents the algorithm’s trading portfolio, but it does not expose a standard model for the individual managed accounts behind a Financial Advisor or other master account.
An algorithm currently cannot reliably determine:
- per-account cash, values, state, and positions of their client's individual accounts;
- all managed accounts accessible through the brokerage session;
- current account-group membership;
- which accounts are unassigned or assigned to groups;
- whether account-group configuration changed after the algorithm observed it; or
Potential Solution
Add optional, brokerage-neutral account-service interfaces and immutable result models.
Expose algorithm APIs for:
- reading the latest cached account snapshot;
- requesting complete or scoped snapshot refreshes;
- requesting assignment to an existing group or removal from all groups;
- replacing an existing group’s complete saved allocation; and
- reading the latest verified result of those requests.
- The models should support account relationships, group membership, aliases, family relationships, financial state, positions, freshness, completeness, and optimistic version information.
The implementation should remain additive:
- existing algorithms should not require modification;
- unsupported brokerages should return unavailable results;
- existing accounting and transaction processing should remain unchanged; and
- brokerage-specific request IDs, XML, and protocol handling should remain outside LEAN core.
- Equivalent Python properties and methods should be included.
Checklist
*Opened for incoming PRs
Expected Behavior
Have LEAN provide a brokerage-neutral way for algorithms to understand and manage the individual accounts behind a master or advisor brokerage account.
When supported by the connected brokerage, C# and Python algorithms should be able to:
The algorithm should explicitly request refreshes and decide how fresh the information must be before acting.
This would enable important multi-account workflows such as:
Related feature requests:
IB Brokerage: QuantConnect/Lean.Brokerages.InteractiveBrokers#259
IBAutomater: QuantConnect/IBAutomater#112
Documentation: QuantConnect/Documentation#2624
Actual Behavior
LEAN’s portfolio represents the algorithm’s trading portfolio, but it does not expose a standard model for the individual managed accounts behind a Financial Advisor or other master account.
An algorithm currently cannot reliably determine:
Potential Solution
Add optional, brokerage-neutral account-service interfaces and immutable result models.
Expose algorithm APIs for:
The implementation should remain additive:
Checklist
masterbranch