CryptoUniverseFactory
QuantConnect.Data.UniverseSelection.CryptoUniverseFactory
CryptoUniverseFactory(
market: str,
universe_settings: UniverseSettings,
selector: Any,
)
CryptoUniverseFactory(
market: str,
universe_settings: UniverseSettings,
selector: Callable[
[List[CryptoUniverse]], List[Symbol]
],
)
Bases: Universe
Defines a universe that reads crypto coarse data
Initializes a new instance of the CryptoUniverseFactory class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
market
|
str
|
The target crypto market |
required |
universe_settings
|
UniverseSettings
|
The settings used for new subscriptions generated by this universe |
required |
selector
|
Any | Callable[[List[CryptoUniverse]], List[Symbol]]
|
Returns the symbols that should be included in the universe |
required |
UNCHANGED
UNCHANGED: UnchangedUniverse = ...
Gets a value indicating that no change to the universe should be made
securities
Gets the internal security collection used to define membership in this universe
asynchronous
asynchronous: bool
True if this universe filter can run async in the data stack
selection_changed
selection_changed: _EventContainer[
Callable[[Object, EventArgs], Any], Any
]
Event fired when the universe selection has changed
market
market: str
Gets the market of this universe
data_type
data_type: Type
Gets the data type of this universe
dispose_requested
dispose_requested: bool
Flag indicating if disposal of this universe has been requested
universe_settings
universe_settings: UniverseSettings
Gets the settings used for subscriptions added for this universe
configuration
configuration: SubscriptionDataConfig
Gets the configuration used to get universe data
members
Gets the current listing of members in this universe. Modifications to this dictionary do not change universe membership.
UnchangedUniverse
Bases: Object, Iterable[str]
Provides a value to indicate that no changes should be made to the universe. This value is intended to be returned by reference via Universe.select_symbols
Member
Member(
added: Union[datetime, date],
security: Security,
is_internal: bool,
)
Bases: Object
Member of the Universe
Initialize a new member for the universe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
added
|
Union[datetime, date]
|
DateTime added |
required |
security
|
Security
|
Security to add |
required |
is_internal
|
bool
|
True if internal member |
required |
added
added: datetime
DateTime when added
is_internal
is_internal: bool
True if the security was added as internal by this universe
SelectionEventArgs
SelectionEventArgs(current_selection: HashSet[Symbol])
Bases: EventArgs
Event fired when the universe selection changes
Creates a new instance
create_configuration
create_configuration(
symbol: Union[Symbol, str, BaseContract, Security],
) -> SubscriptionDataConfig
Creates a CryptoUniverse subscription configuration for the selected Crypto market
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract, Security]
|
The symbol used in the returned configuration |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionDataConfig
|
A coarse fundamental subscription configuration with the specified symbol. |
select_symbols
select_symbols(
utc_time: Union[datetime, date],
data: BaseDataCollection,
) -> Sequence[Symbol]
Performs universe selection using the data specified
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_time
|
Union[datetime, date]
|
The current utc time |
required |
data
|
BaseDataCollection
|
The symbols to remain in the universe |
required |
Returns:
| Type | Description |
|---|---|
Sequence[Symbol]
|
The data that passes the filter. |
try_get_universe
try_get_universe(
result: Optional[
QuantConnect_Data_UniverseSelection_UniverseExtensions_TryGetUniverse_T
],
) -> Tuple[
bool,
QuantConnect_Data_UniverseSelection_UniverseExtensions_TryGetUniverse_T,
]
Gets the given universe as the requested type, checking the universe it decorates, if any
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Optional[QuantConnect_Data_UniverseSelection_UniverseExtensions_TryGetUniverse_T]
|
The universe as the requested type, if any |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, QuantConnect_Data_UniverseSelection_UniverseExtensions_TryGetUniverse_T]
|
True if the universe, or one it decorates, is of the requested type. |
can_remove_member
can_remove_member(
utc_time: Union[datetime, date], security: Security
) -> bool
Determines whether or not the specified security can be removed from this universe. This is useful to prevent securities from being taken out of a universe before the algorithm has had enough time to make decisions on the security
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_time
|
Union[datetime, date]
|
The current utc time |
required |
security
|
Security
|
The security to check if its ok to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if we can remove the security, false otherwise. |
chained_to
Creates a new universe that logically is the result of wiring the two universes together such that the first will produce subscriptions for the second and the second will only select on data that has passed the first.
NOTE: The first and second universe instances provided to this method should not be manually added to the algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
second
|
Universe
|
The second universe in this 'chain' |
required |
configuration_per_symbol
|
bool
|
True if each symbol as its own configuration, false otherwise |
required |
Returns:
| Type | Description |
|---|---|
Universe
|
A new universe that can be added to the algorithm that represents invoking the first universe and then the second universe using the outputs of the first. |
contains_member
contains_member(
symbol: Union[Symbol, str, BaseContract, Security],
) -> bool
Determines whether or not the specified symbol is currently a member of this universe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract, Security]
|
The symbol whose membership is to be checked |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the specified symbol is part of this universe, false otherwise. |
create_security
create_security(
symbol: Union[Symbol, str, BaseContract, Security],
algorithm: IAlgorithm,
market_hours_database: MarketHoursDatabase,
symbol_properties_database: SymbolPropertiesDatabase,
) -> Security
Creates and configures a security for the specified symbol
CreateSecurity is obsolete and will not be called. The system will create the required Securities based on selected symbols
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract, Security]
|
The symbol of the security to be created |
required |
algorithm
|
IAlgorithm
|
The algorithm instance |
required |
market_hours_database
|
MarketHoursDatabase
|
The market hours database |
required |
symbol_properties_database
|
SymbolPropertiesDatabase
|
The symbol properties database |
required |
Returns:
| Type | Description |
|---|---|
Security
|
The newly initialized security object. |
dispose
dispose() -> None
Marks this universe as disposed and ready to remove all child subscriptions
get_subscription_requests
get_subscription_requests(
security: Security,
current_time_utc: Union[datetime, date],
maximum_end_time_utc: Union[datetime, date],
subscription_service: ISubscriptionDataConfigService,
) -> Sequence[SubscriptionRequest]
Gets the subscription requests to be added for the specified security
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security to get subscriptions for |
required |
current_time_utc
|
Union[datetime, date]
|
The current time in utc. This is the frontier time of the algorithm |
required |
maximum_end_time_utc
|
Union[datetime, date]
|
The max end time |
required |
subscription_service
|
ISubscriptionDataConfigService
|
Instance which implements ISubscriptionDataConfigService interface |
required |
Returns:
| Type | Description |
|---|---|
Sequence[SubscriptionRequest]
|
All subscriptions required by this security. |
on_selection_changed
on_selection_changed(
selection: HashSet[Symbol] = None,
) -> None
Event invocator for the selection_changed event
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selection
|
HashSet[Symbol]
|
The current universe selection |
None
|
perform_selection
perform_selection(
utc_time: Union[datetime, date],
data: BaseDataCollection,
) -> Sequence[Symbol]
Performs universe selection using the data specified
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utc_time
|
Union[datetime, date]
|
The current utc time |
required |
data
|
BaseDataCollection
|
The symbols to remain in the universe |
required |
Returns:
| Type | Description |
|---|---|
Sequence[Symbol]
|
The data that passes the filter. |
prefilter_using
Creates a new universe that restricts the universe selection data to symbols that passed the first universe's selection criteria
NOTE: The second universe instance provided to this method should not be manually added to the algorithm. The first should still be manually (assuming no other changes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first
|
Universe
|
The universe providing the set of symbols used for filtered |
required |
Returns:
| Type | Description |
|---|---|
Universe
|
A new universe that can be added to the algorithm that represents invoking the second using the selections from the first as a filter. |