Skip to content

SubscriptionUtils

QuantConnect.Lean.Engine.DataFeeds.SubscriptionUtils

Bases: Object

Utilities related to data Subscription

create

create(
    request: SubscriptionRequest,
    enumerator: IEnumerator[BaseData],
    daily_strict_end_time_enabled: bool,
) -> Subscription

Creates a new Subscription which will directly consume the provided enumerator

Parameters:

Name Type Description Default
request SubscriptionRequest

The subscription data request

required
enumerator IEnumerator[BaseData]

The data enumerator stack

required

Returns:

Type Description
Subscription

A new subscription instance ready to consume.

create_and_schedule_worker

create_and_schedule_worker(
    request: SubscriptionRequest,
    enumerator: IEnumerator[BaseData],
    factor_file_provider: IFactorFileProvider,
    enable_price_scale: bool,
    daily_strict_end_time_enabled: bool,
) -> Subscription

Setups a new Subscription which will consume a blocking EnqueueableEnumerator{T} that will be feed by a worker task

Parameters:

Name Type Description Default
request SubscriptionRequest

The subscription data request

required
enumerator IEnumerator[BaseData]

The data enumerator stack

required
factor_file_provider IFactorFileProvider

The factor file provider

required
enable_price_scale bool

Enables price factoring

required

Returns:

Type Description
Subscription

A new subscription instance ready to consume.

schedule_enumerator

schedule_enumerator(
    symbol: Union[Symbol, str, BaseContract, Security],
    enumerator: IEnumerator[BaseData],
) -> IEnumerator[BaseData]

Setups a worker task to enumerate the given enumerator, feeding a blocking EnqueueableEnumerator{T} which is returned. Useful for enumerators which perform blocking IO, like the live warmup enumerators performing history requests, so that they run concurrently on the workers instead of sequentially driven by the consuming thread, which will only block until the next data point of each enumerator is available

Parameters:

Name Type Description Default
symbol Union[Symbol, str, BaseContract, Security]

The symbol associated with this work

required
enumerator IEnumerator[BaseData]

The data enumerator stack to enumerate

required

Returns:

Type Description
IEnumerator[BaseData]

A blocking enumerator providing the data.