QuantConnect / QuantConnect/Lean

[Feature Request] Concise Factor-Based Algorithms

Open
#8,403 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

depth feature
Dominant language
C#
Stars
21.7k
Forks
5.3k
Avg merge
2d 22h
Merged PRs (30d)
34

Description

Expected Behavior

We can simply calculate factor scores for each asset in a universe, where LEAN manages the required dataset and rebalancing for us.

class FactorAlgorithm(QCAlgorithm):
    
    def __init__(self):
        universe_settings.resolution = Resolution.DAILY
        universe = self.add_universe(
            lambda fundamentals: [f.symbol for f in sorted(fundamentals, key=lambda f: f.market_cap)[-10:]]
        )
        universe.add_factors([InverseCorrelation(252, Field.OPEN)])


class InverseCorrelation(CrossAssetFactor):

    def update(self, data):
        factor_value_by_symbol = 1/data.dropna(axis=1).corr().abs().sum()
        return factor_value_by_symbol / factor_value_by_symbol.sum()
Actual Behavior

Not currently supported

Potential Solution

N/A

Reproducing the Problem
System Information
Checklist
  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the QCAlgorithm, add_universe, add_factors, and CrossAssetFactor entry points shown in the example, then compare them with the current factor-calculation support. Done means users can calculate and normalize factor scores across a universe while LEAN manages the dataset and rebalancing.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, python
Domain
backend, data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.