Skip to content

QuoteBarConsolidator

QuantConnect.Data.Consolidators.QuoteBarConsolidator

QuoteBarConsolidator(pyfuncobj: Any)
QuoteBarConsolidator(
    period: timedelta,
    start_time: Optional[timedelta] = None,
)
QuoteBarConsolidator(max_count: int)
QuoteBarConsolidator(max_count: int, period: timedelta)
QuoteBarConsolidator(
    func: Callable[[datetime], CalendarInfo],
)

Bases: PeriodCountConsolidatorBase[QuoteBar, QuoteBar]

Consolidates QuoteBars into larger QuoteBars

Signature descriptions:

  • Creates a consolidator to produce a new 'QuoteBar' representing the last count pieces of data or the period, whichever comes first

  • Initializes a new instance of the QuoteBarConsolidator class

Parameters:

Name Type Description Default
pyfuncobj Optional[Any]

Python function object that defines the start time of a consolidated data

None
period Optional[timedelta]

The minimum span of time before emitting a consolidated bar

None
start_time Optional[Optional[timedelta]]

Optionally the bar start time anchor to use

None
max_count Optional[int]

The number of pieces to accept before emitting a consolidated bar

None
func Optional[Callable[[datetime], CalendarInfo]]

Func that defines the start time of a consolidated data

None

consolidated

consolidated: IBaseData

Gets the most recently consolidated piece of data. This will be null if this consolidator has not produced any data yet.

working_data

working_data: IBaseData

Gets a clone of the data being currently consolidated

input_type

input_type: Type

Gets the type consumed by this consolidator

output_type

output_type: Type

Gets the type produced by this consolidator

data_consolidated

data_consolidated: _EventContainer[
    Callable[
        [
            Object,
            QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_TConsolidated,
        ],
        Any,
    ],
    Any,
]

Event handler that fires when a new piece of data is produced. We define this as a 'new' event so we can expose it as a t_consolidated instead of a BaseData instance

is_time_based

is_time_based: bool

Returns true if this consolidator is time-based, false otherwise

This codeEntityType is protected.

period

period: Optional[timedelta]

Gets the time period for this consolidator

This codeEntityType is protected.

aggregate_bar

aggregate_bar(
    working_bar: QuoteBar, data: QuoteBar
) -> None

Aggregates the new 'data' into the 'working_bar'. The 'working_bar' will be null following the event firing

This codeEntityType is protected.

Parameters:

Name Type Description Default
working_bar QuoteBar

The bar we're building, null if the event was just fired and we're starting a new consolidated bar

required
data QuoteBar

The new data

required

reset

reset() -> None

Resets the consolidator

scan

scan(current_local_time: Union[datetime, date]) -> None

Scans this consolidator to see if it should emit a bar due to time passing

Parameters:

Name Type Description Default
current_local_time Union[datetime, date]

The current time in the local time zone (same as BaseData.time)

required

update

update(
    data: QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_T,
) -> None

Updates this consolidator with the specified data. This method is responsible for raising the DataConsolidated event In time span mode, the bar range is closed on the left and open on the right: [T, T+TimeSpan). For example, if time span is 1 minute, we have [10:00, 10:01): so data at 10:01 is not included in the bar starting at 10:00.

Parameters:

Name Type Description Default
data QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_T

The new data for the consolidator

required

dispose

dispose() -> None

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

on_data_consolidated

on_data_consolidated(
    e: QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_TConsolidated,
) -> None

Event invocator for the data_consolidated event

This codeEntityType is protected.

Parameters:

Name Type Description Default
e QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_TConsolidated

The consolidated data

required

get_rounded_bar_time

get_rounded_bar_time(
    time: Union[datetime, date],
) -> datetime
get_rounded_bar_time(input_data: IBaseData) -> datetime

Signature descriptions:

  • Gets a rounded-down bar time. Called by AggregateBar in derived classes.

  • Gets a rounded-down bar start time. Called by AggregateBar in derived classes.

Parameters:

Name Type Description Default
time Optional[Union[datetime, date]]

The bar time to be rounded down

None
input_data Optional[IBaseData]

The input data point

None

Returns:

Type Description
datetime

Depends on the signature used. Case 1: [The rounded bar time.]; Case 2: [The rounded bar start time.]

reset_working_bar

reset_working_bar() -> None

Resets the working bar

This codeEntityType is protected.

should_process

should_process(
    data: QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_T,
) -> bool

Determines whether or not the specified data should be processed

This codeEntityType is protected.

Parameters:

Name Type Description Default
data QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_T

The data to check

required

Returns:

Type Description
bool

True if the consolidator should process this data, false otherwise.