Skip to content

ScheduledUniverseSelectionModel

QuantConnect.Algorithm.Framework.Selection.ScheduledUniverseSelectionModel

ScheduledUniverseSelectionModel(
    date_rule: IDateRule,
    time_rule: ITimeRule,
    selector: Any,
    settings: UniverseSettings = None,
)
ScheduledUniverseSelectionModel(
    time_zone: Any,
    date_rule: IDateRule,
    time_rule: ITimeRule,
    selector: Any,
    settings: UniverseSettings = None,
)
ScheduledUniverseSelectionModel(
    date_rule: IDateRule,
    time_rule: ITimeRule,
    selector: Callable[[datetime], List[Symbol]],
    settings: UniverseSettings = None,
)
ScheduledUniverseSelectionModel(
    time_zone: Any,
    date_rule: IDateRule,
    time_rule: ITimeRule,
    selector: Callable[[datetime], List[Symbol]],
    settings: UniverseSettings = None,
)

Bases: UniverseSelectionModel

Defines a universe selection model that invokes a selector function on a specific scheduled given by an IDateRule and an ITimeRule

Signature descriptions:

  • Initializes a new instance of the ScheduledUniverseSelectionModel class using the algorithm's time zone

  • Initializes a new instance of the ScheduledUniverseSelectionModel class

Parameters:

Name Type Description Default
date_rule IDateRule

Date rule defines what days the universe selection function will be invoked

required
time_rule ITimeRule

Time rule defines what times on each day selected by date rule the universe selection function will be invoked

required
selector Any | Callable[[datetime], List[Symbol]]

Selector function accepting the date time firing time and returning the universe selected symbols

required
settings UniverseSettings

Universe settings for subscriptions added via this universe, null will default to algorithm's universe settings

None
time_zone Optional[Any]

The time zone the date/time rules are in

None

instance

instance: Any

Gets the underlying python instance

This Property is protected.

PythonRuntimeChecker

Bases: Object

Set of helper methods to invoke Python methods with runtime checks for return values and out parameter's conversions.

invoke_method

invoke_method: PythonRuntimeChecker_InvokeMethod

invoke_method_and_enumerate

invoke_method_and_enumerate: (
    PythonRuntimeChecker_InvokeMethodAndEnumerate
)

invoke_method_and_get_dictionary

invoke_method_and_get_dictionary: (
    PythonRuntimeChecker_InvokeMethodAndGetDictionary
)

invoke_method_and_wrap_result

invoke_method_and_wrap_result: (
    PythonRuntimeChecker_InvokeMethodAndWrapResult
)

invoke_method_and_get_out_parameters

invoke_method_and_get_out_parameters: (
    PythonRuntimeChecker_InvokeMethodAndGetOutParameters
)

convert

convert: PythonRuntimeChecker_Convert

convert_and_dispose

convert_and_dispose: PythonRuntimeChecker_ConvertAndDispose

create_universes

create_universes(
    algorithm: QCAlgorithm,
) -> Sequence[Universe]

Creates the universes for this algorithm. Called once after IAlgorithm.initialize

Parameters:

Name Type Description Default
algorithm QCAlgorithm

The algorithm instance to create universes for

required

Returns:

Type Description
Sequence[Universe]

The universes to be used by the algorithm.

get_next_refresh_time_utc

get_next_refresh_time_utc() -> datetime

Gets the next time the framework should invoke the CreateUniverses method to refresh the set of universes.

equals

equals(
    other: BasePythonWrapper[
        QuantConnect_Python_BasePythonWrapper_TInterface
    ],
) -> bool
equals(obj: Any) -> bool

Signature descriptions:

  • Determines whether the specified instance wraps the same Python object reference as this instance, which would indicate that they are equal.

  • Determines whether the specified object is an instance of BasePythonWrapper{TInterface} and wraps the same Python object reference as this instance, which would indicate that they are equal.

Parameters:

Name Type Description Default
other Optional[BasePythonWrapper[QuantConnect_Python_BasePythonWrapper_TInterface]]

The other object to compare this with

None
obj Optional[Any]

The other object to compare this with

None

Returns:

Type Description
bool

True if both instances are equal, that is if both wrap the same Python object reference.

get_property

get_property(property_name: str) -> Any
get_property(
    property_name: str,
) -> QuantConnect_Python_BasePythonWrapper_GetProperty_T

Gets the Python instance property with the specified name

Parameters:

Name Type Description Default
property_name str

The name of the property

required

invoke_method

invoke_method(
    method_name: str, *args: Union[Object, Iterable[Object]]
) -> Any
invoke_method(
    method_name: str, *args: Union[Object, Iterable[Object]]
) -> QuantConnect_Python_BasePythonWrapper_InvokeMethod_T

Invokes the specified method with the specified arguments

Parameters:

Name Type Description Default
method_name str

The name of the method

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

Returns:

Type Description
Any | QuantConnect_Python_BasePythonWrapper_InvokeMethod_T

The returned valued converted to the given type.

invoke_method_and_enumerate

invoke_method_and_enumerate(
    method_name: str, *args: Union[Object, Iterable[Object]]
) -> Sequence[
    QuantConnect_Python_BasePythonWrapper_InvokeMethodAndEnumerate_T
]

Invokes the specified method with the specified arguments and iterates over the returned values

Parameters:

Name Type Description Default
method_name str

The name of the method

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

Returns:

Type Description
Sequence[QuantConnect_Python_BasePythonWrapper_InvokeMethodAndEnumerate_T]

The returned valued converted to the given type.

invoke_method_and_get_dictionary

invoke_method_and_get_dictionary(
    method_name: str, *args: Union[Object, Iterable[Object]]
) -> Dictionary[
    QuantConnect_Python_BasePythonWrapper_InvokeMethodAndGetDictionary_TKey,
    QuantConnect_Python_BasePythonWrapper_InvokeMethodAndGetDictionary_TValue,
]

Invokes the specified method with the specified arguments and iterates over the returned values

Parameters:

Name Type Description Default
method_name str

The name of the method

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

Returns:

Type Description
Dictionary[QuantConnect_Python_BasePythonWrapper_InvokeMethodAndGetDictionary_TKey, QuantConnect_Python_BasePythonWrapper_InvokeMethodAndGetDictionary_TValue]

The returned valued converted to the given type.

invoke_method_and_wrap_result

invoke_method_and_wrap_result(
    method_name: str,
    wrap_result: Callable[
        [Any],
        QuantConnect_Python_BasePythonWrapper_InvokeMethodAndWrapResult_T,
    ],
    *args: Union[Object, Iterable[Object]]
) -> QuantConnect_Python_BasePythonWrapper_InvokeMethodAndWrapResult_T

Invokes the specified method with the specified arguments and wraps the result by calling the given function if the result is not a C# object

Parameters:

Name Type Description Default
method_name str

The name of the method

required
wrap_result Callable[[Any], QuantConnect_Python_BasePythonWrapper_InvokeMethodAndWrapResult_T]

Method that wraps a Python object in the corresponding Python Wrapper

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

Returns:

Type Description
QuantConnect_Python_BasePythonWrapper_InvokeMethodAndWrapResult_T

The returned value wrapped using the given method if the result is not a C# object.

invoke_method_with_out_parameters

invoke_method_with_out_parameters(
    method_name: str,
    out_parameters_types: List[Type],
    out_parameters: Optional[List[Object]],
    *args: Union[Object, Iterable[Object]]
) -> Tuple[
    QuantConnect_Python_BasePythonWrapper_InvokeMethodWithOutParameters_T,
    List[Object],
]

Invokes the specified method with the specified arguments and out parameters

Parameters:

Name Type Description Default
method_name str

The name of the method

required
out_parameters_types List[Type]

The types of the out parameters

required
out_parameters Optional[List[Object]]

The out parameters values

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

Returns:

Type Description
Tuple[QuantConnect_Python_BasePythonWrapper_InvokeMethodWithOutParameters_T, List[Object]]

The returned valued converted to the given type.

set_python_instance

set_python_instance(instance: Any) -> None
set_python_instance(
    instance: Any, validate_interface: bool
) -> None

Signature descriptions:

  • Sets the python instance

  • Sets the python instance and sets the validate interface flag

Parameters:

Name Type Description Default
instance Any

The underlying python instance

required
validate_interface Optional[bool]

Whether to perform validations for interface implementation

None

try_invoke_python_override

try_invoke_python_override(
    method_name: str,
    result: Optional[
        QuantConnect_Python_BasePythonWrapper_TryInvokePythonOverride_T
    ],
    *args: Union[Object, Iterable[Object]]
) -> Tuple[
    bool,
    QuantConnect_Python_BasePythonWrapper_TryInvokePythonOverride_T,
]

Attempts to invoke the method if it has been overridden in Python.

Parameters:

Name Type Description Default
method_name str

The name of the method to call on the Python instance.

required
result Optional[QuantConnect_Python_BasePythonWrapper_TryInvokePythonOverride_T]

When this method returns, contains the method result if the call succeeded.

required
args Union[Object, Iterable[Object]]

The arguments to pass to the Python method.

()

Returns:

Type Description
Tuple[bool, QuantConnect_Python_BasePythonWrapper_TryInvokePythonOverride_T]

true if the Python method was successfully invoked, otherwise, false.

dispose

dispose() -> None

Dispose of this instance

get_event

get_event(name: str) -> Any

Gets the Python instance event with the specified name

Parameters:

Name Type Description Default
name str

The name of the event

required

get_hash_code

get_hash_code() -> int

Gets the hash code for the current instance

Returns:

Type Description
int

The hash code of the current instance.

get_method

get_method(
    method_name: str, python_only: bool = False
) -> Any

Gets the Python instances method with the specified name and caches it

Parameters:

Name Type Description Default
method_name str

The name of the method

required
python_only bool

Whether to only return python methods

False

Returns:

Type Description
Any

The matched method.

has_attr

has_attr(name: str) -> bool

Determines whether the Python instance has the specified attribute

Parameters:

Name Type Description Default
name str

The attribute name

required

Returns:

Type Description
bool

Whether the Python instance has the specified attribute.

invoke_void_method

invoke_void_method(
    method_name: str, *args: Union[Object, Iterable[Object]]
) -> None

Invokes the specified method with the specified arguments without returning a value

Parameters:

Name Type Description Default
method_name str

The name of the method

required
args Union[Object, Iterable[Object]]

The arguments to call the method with

()

set_property

set_property(property_name: str, value: Any) -> None

Sets the Python instance property with the specified name

Parameters:

Name Type Description Default
property_name str

The name of the property

required
value Any

The property value

required