Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Historical Universe Chains

Open DerekMelchin opened this issue 9 months ago • 1 comments

Expected Behavior

We can get historical Future chains data in an algorithm.

Actual Behavior

self.futures_chain returns the current chain.

This algorithm

class USFutureDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2020, 6, 1)
        self.set_end_date(2021, 6, 1)
        self._future = self.add_future(Futures.Metals.GOLD)
        self._future.set_filter(lambda universe: universe.standards_only().front_month())
        history = self.history[FuturesChain](self._future.symbol, self.time-timedelta(30), self.time)
        for c in history:
            pass

throws

During the algorithm initialization, the following exception has occurred: Data type 'FuturesChain' missing parameterless constructor. E.g. public FuturesChain() { } at initialize for c in history: in main.py: line 10 Data type 'FuturesChain' missing parameterless constructor. E.g. public FuturesChain() { }

Potential Solution

N/A

Reproducing the Problem

Run the algorithm above

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 Mar 28 '25 19:03 DerekMelchin

We don't support FuturesChain or OptionChain history requests. This is different than FutureUniverse and OptionUniverse requests which will give you the chains (see https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/OptionUniverseHistoryRegressionAlgorithm.py and https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/FutureUniverseHistoryRegressionAlgorithm.py).

I'm labeling this one as a feature request for now.

jhonabreul avatar Apr 01 '25 15:04 jhonabreul