Skip to content

ConstantAlphaModel Overloads #9044

@DerekMelchin

Description

@DerekMelchin

Expected Behavior

This works without error:

ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(1), weight=0.1)

Actual Behavior

During the algorithm initialization, the following exception has occurred: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'datetime.timedelta'>) method. Please checkout the API documentation.
  at initialize
    self.add_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(1), weight=0.1))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 in main.py: line 15
 No method matches given arguments for .ctor: (<class 'QuantConnect.Algorithm.Framework.Alphas.InsightType'>, <class 'QuantConnect.Algorithm.Framework.Alphas.InsightDirection'>, <class 'datetime.timedelta'>) (Open Stack Trace)

Instead, we are forced to write

ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(1), None, None, 0.1)

Potential Solution

N/A

Reproducing the Problem

class UpcomingIPOsExampleAlgorithm(QCAlgorithm):
    
    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        self.add_universe(self.universe.dollar_volume.top(5))
        self.add_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(1), weight=0.1))

System Information

QC Cloud

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions