Custom Universes
Key Concepts
Receive Custom Data
The universe selector function receives a list of your custom objects and must return a list of Symbol
objects. In the selector function definition, you can use any of the properties of your custom data type. The Symbol
objects that you return from the selector function set the constituents of the universe.
class MyCustomUniverseAlgorithm(QCAlgorithm): def _selector_function(self, data: List[MyCustomUniverseDataClass]) -> List[Symbol]: sorted_data = sorted([ x for x in data if x["CustomAttribute1"] > 0 ], key=lambda x: x["CustomAttribute2"], reverse=True) return [x.symbol for x in sorted_data[:5]]
Historical Data
To get historical data for a custom data universe, call the history
method with the Universe
object.
For more information about historical data, see Universes.