QuantBook Universe Selection (#7587)

* QuantBook Universe Selection

- QuantBook universe selection helper method. Adding new unit tests.
- Universe selection data sets improvements

* QuantBook API renames
This commit is contained in:
Martin-Molinero
2023-11-21 17:05:02 -03:00
committed by GitHub
parent adaa2f5862
commit 7498d2e6e2
16 changed files with 415 additions and 72 deletions
@@ -28,6 +28,9 @@ class FundamentalRegressionAlgorithm(QCAlgorithm):
self.UniverseSettings.Resolution = Resolution.Daily
# before we add any symbol
self.AssertFundamentalUniverseData();
self.AddEquity("SPY")
self.AddEquity("AAPL")
@@ -53,6 +56,14 @@ class FundamentalRegressionAlgorithm(QCAlgorithm):
if data["value"][0] == 0:
raise ValueError(f"Unexpected {data} fundamental data")
self.AssertFundamentalUniverseData();
self.AddUniverse(self.SelectionFunction)
self.changes = None
self.numberOfSymbolsFundamental = 2
def AssertFundamentalUniverseData(self):
# Request historical fundamental data for all symbols
history2 = self.History(Fundamentals, TimeSpan(1, 0, 0, 0))
if len(history2) != 1:
@@ -64,11 +75,6 @@ class FundamentalRegressionAlgorithm(QCAlgorithm):
if type(fundamental) is not Fundamental:
raise ValueError(f"Unexpected Fundamentals data type! {fundamental}")
self.AddUniverse(self.SelectionFunction)
self.changes = None
self.numberOfSymbolsFundamental = 2
# return a list of three fixed symbol objects
def SelectionFunction(self, fundamental):
# sort descending by daily dollar volume