Lean icon indicating copy to clipboard operation
Lean copied to clipboard

OpenInterestFutureUniverseSelectionModel doesn't work with Python

Open DerekMelchin opened this issue 2 years ago • 1 comments

Expected Behavior

We can add a OpenInterestFutureUniverseSelectionModel to a Python algorithm.

Actual Behavior

We can add a OpenInterestFutureUniverseSelectionModel to a C# algorithm but not a Python algorithm.

Potential Solution

N/A

Reproducing the Problem

Run the following algorithm:

from AlgorithmImports import *

class CasualApricotBaboon(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 11, 24)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.symbols = [
            Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME),
            Symbol.Create(Futures.Metals.Gold, SecurityType.Future, Market.COMEX)
        ]
        universe = OpenInterestFutureUniverseSelectionModel(self, lambda date_time: symbols )
        self.AddUniverseSelection(universe)

We get the following error: image

System Information

QC Cloud

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

DerekMelchin avatar May 25 '22 17:05 DerekMelchin

Potential Solution

OpenInterestFutureUniverseSelectionModel can't handle the PyObject lambda -> Func<DateTime, IEnumerable<Symbol>> conversion automatically. Needs to be converted, like done in other cases, like coarse/fine selection

Martin-Molinero avatar May 25 '22 22:05 Martin-Molinero

👍🏽🤙🏽

algo-dude avatar May 19 '23 01:05 algo-dude