TickConsolidator
QuantConnect.Data.Consolidators.TickConsolidator
TickConsolidator(pyfuncobj: Any)
TickConsolidator(period: timedelta)
TickConsolidator(max_count: int)
TickConsolidator(max_count: int, period: timedelta)
TickConsolidator(func: Callable[[datetime], CalendarInfo])
Bases: TradeBarConsolidatorBase[Tick]
A data consolidator that can make bigger bars from ticks over a given time span or a count of pieces of data.
Signature descriptions:
-
Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data or the period, whichever comes first
-
Creates a consolidator to produce a new 'TradeBar' representing the period
-
Creates a consolidator to produce a new 'TradeBar' representing the last count pieces of data
-
Initializes a new instance of the TickQuoteBarConsolidator 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
|
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.
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
DEFAULT_WINDOW_SIZE
DEFAULT_WINDOW_SIZE: int
The default number of values to keep in the rolling window history
window
window: RollingWindow[QuantConnect_Indicators_WindowBase_T]
A rolling window keeping a history of values. The most recent value is at index 0. Uses lazy initialization to support Python subclasses that do not call base constructors.
current
current: QuantConnect_Indicators_WindowBase_T
Gets the most recent value. The protected setter adds the value to the rolling window.
previous
previous: QuantConnect_Indicators_WindowBase_T
Gets the previous value, or default if fewer than two values have been produced.
is_time_based
is_time_based: bool
Returns true if this consolidator is time-based, false otherwise
This Property is protected.
period
period: Optional[timedelta]
Gets the time period for this consolidator
This Property is protected.
aggregate_bar
should_process
should_process(data: Tick) -> bool
Determines whether or not the specified data should be processed
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tick
|
The data to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the consolidator should process this data, false otherwise. |
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 |
__getitem__
__getitem__(i: int) -> QuantConnect_Indicators_WindowBase_T
Indexes the history window, where index 0 is the most recent value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
int
|
The index |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Indicators_WindowBase_T
|
The ith most recent value. |
__iter__
__iter__() -> (
Iterator[QuantConnect_Indicators_WindowBase_T]
)
get_enumerator
get_enumerator() -> (
IEnumerator[QuantConnect_Indicators_WindowBase_T]
)
Returns an enumerator that iterates through the history window.
reset_window
reset_window() -> None
Resets the rolling window, clearing all stored values.
This Class is protected.
dispose
dispose() -> None
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
fire_data_consolidated
fire_data_consolidated(consolidated: IBaseData) -> None
Raises the strongly typed DataConsolidated event exposed by derived consolidators that produce a more specific bar type. Invoked after the rolling window is populated and before the shared event so every handler sees the same window. Consolidators whose output is a base data bar do not need to override this, the shared data_consolidated event already carries their bar.
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
consolidated
|
IBaseData
|
The newly consolidated data |
required |
on_data_consolidated
on_data_consolidated(
e: QuantConnect_Data_Consolidators_PeriodCountConsolidatorBase_TConsolidated,
) -> None
Event invocator for the data_consolidated event
This Class 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 Class is protected.