Skip to content

Add IEnumerator<T> #91

@DerekMelchin

Description

@DerekMelchin

Expected Behavior

This algorithm compiles with mypy without error

class FutureOptionsHistoryAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 12, 19)
        self.set_end_date(2024, 12, 31)
        # Select a Futures contract.
        future = self.add_future(Futures.Indices.SP_500_E_MINI)
        futures_contract = list(self.futures_chain(future.symbol))[0]
        # Create the canoncial Option Symbol for this Futures contract.
        canonical = Symbol.create_canonical_option(futures_contract.symbol)
        # OptionUniverse example:
        history = self.history[OptionUniverse](canonical, 3)
        for universe in history:
            end_time = universe.end_time
            for contract in universe:
                symbol = contract.symbol
                expiry = contract.id.date
                price = contract.close

Actual Behavior

I get

abc_test.py:28: error: "BaseData" has no attribute "id" [attr-defined]
abc_test.py:29: error: "BaseData" has no attribute "close"; maybe "clone"? [attr-defined]

Potential Solution

GetEnumerator should return OptionUniverse objects instead of BaseData objects

Reproducing the Problem

Compile the algorithm above with mypy

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

Metadata

Metadata

Assignees

No one assigned

    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