QuantConnect / QuantConnect/Lean
Enable FA managed brokerage accounts and account group visibility in algorithms
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 21.7k
- Forks
- 5.3k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 34
Description
*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
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by locating LEAN's existing portfolio and brokerage interfaces, then map the additive account-service scope against the requested snapshots, group operations, unsupported-brokerage behavior, and equivalent Python APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100