Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Concise Factor-Based Algorithms #8403

Open
3 of 4 tasks
DerekMelchin opened this issue Nov 13, 2024 · 0 comments
Open
3 of 4 tasks

[Feature Request] Concise Factor-Based Algorithms #8403

DerekMelchin opened this issue Nov 13, 2024 · 0 comments

Comments

@DerekMelchin
Copy link
Collaborator

DerekMelchin commented Nov 13, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants