QuantConnect / QuantConnect/Lean
Suggestions for Improvements to `PortfolioConstructionModel`
Open
Nobody has claimed this yet.
framework
- Dominant language
- C#
- Stars
- 21.7k
- Forks
- 5.3k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 34
Description
Expected Behavior
- The method
GetTargetInsightsshould correctly handle insights emitted simultaneously from multiple Alpha Models. - The method
DetermineTargetPercentshould provide target portfolio weights per symbol instead of per insight.
Actual Behavior
- Currently,
GetTargetInsightsonly supports a singleAlphaModel. If two or more Alpha Models emit insights simultaneously, only the insights from the most recently addedAlphaModelare considered, ignoring the otherAlphaModelentirely. See also this backtest. DetermineTargetPercentreturns aDictionary<Insight, double>. Assigning weights based on insights is uncommon and impractical since insights themselves cannot be traded. Additionally, having multiple active insights for the same symbol results in multiplePortfolioTargetobjects for that symbol at the same time, causing unnecessay trades in theExecutionModel.
Potential Solution
- Adjust
GetTargetInsightsto group insights by bothSymbolandAlphaModel/SourceModel, providing condideration of insights from all Alpha Models. - Since method overloading by return type isn't possible, consider either:
- Introducing an overload method such as:
Dictionary<Symbol, double> DetermineTargetPercent(List<Insight> activeInsights, bool groupBySymbol = false) - Or creating a separate method explicitly named:
DetermineTargetPercentBySymbol()
- Introducing an overload method such as:
Open for additional suggestions or alternative ideas. 😊
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
Start by reading PortfolioConstructionModel's GetTargetInsights and DetermineTargetPercent entry points. Trace how simultaneous insights from multiple Alpha Models are selected and how target weights are keyed. Done means the behavior accounts for all relevant Alpha Models and supports symbol-level portfolio targets, with the API choice resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100