Lean  $LEAN_TAG$
QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated > Class Template Referenceabstract

Provides a base class for consolidators that emit data based on the passing of a period of time or after seeing a max count of data points. More...

Inheritance diagram for QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >:
[legend]

Public Member Functions

override void Update (T data)
 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. More...
 
override void Scan (DateTime currentLocalTime)
 Scans this consolidator to see if it should emit a bar due to time passing More...
 
- Public Member Functions inherited from QuantConnect.Data.Consolidators.DataConsolidator< T >
void Update (IBaseData data)
 Updates this consolidator with the specified data More...
 
abstract void Update (TInput data)
 Updates this consolidator with the specified data. This method is responsible for raising the DataConsolidated event More...
 
void Dispose ()
 Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. More...
 

Public Attributes

override Type OutputType => typeof(TConsolidated)
 Gets the type produced by this consolidator More...
 
override IBaseData WorkingData => _workingBar?.Clone()
 Gets a clone of the data being currently consolidated More...
 

Protected Member Functions

 PeriodCountConsolidatorBase (TimeSpan period)
 Creates a consolidator to produce a new TConsolidated instance representing the period More...
 
 PeriodCountConsolidatorBase (int maxCount)
 Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data More...
 
 PeriodCountConsolidatorBase (int maxCount, TimeSpan period)
 Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first More...
 
 PeriodCountConsolidatorBase (Func< DateTime, CalendarInfo > func)
 Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first More...
 
 PeriodCountConsolidatorBase (PyObject pyObject)
 Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first More...
 
virtual bool ShouldProcess (T data)
 Determines whether or not the specified data should be processed More...
 
abstract void AggregateBar (ref TConsolidated workingBar, T data)
 Aggregates the new 'data' into the 'workingBar'. The 'workingBar' will be null following the event firing More...
 
DateTime GetRoundedBarTime (DateTime time)
 Gets a rounded-down bar time. Called by AggregateBar in derived classes. More...
 
DateTime GetRoundedBarTime (IBaseData inputData)
 Gets a rounded-down bar start time. Called by AggregateBar in derived classes. More...
 
virtual void OnDataConsolidated (TConsolidated e)
 Event invocator for the DataConsolidated event More...
 
- Protected Member Functions inherited from QuantConnect.Data.Consolidators.DataConsolidator< T >
virtual void OnDataConsolidated (IBaseData consolidated)
 Event invocator for the DataConsolidated event. This should be invoked by derived classes when they have consolidated a new piece of data. More...
 

Protected Attributes

bool IsTimeBased => !_maxCount.HasValue
 Returns true if this consolidator is time-based, false otherwise More...
 
TimeSpan? Period => _period
 Gets the time period for this consolidator More...
 

Events

new EventHandler< TConsolidated > DataConsolidated
 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 TConsolidated instead of a BaseData instance More...
 
- Events inherited from QuantConnect.Data.Consolidators.DataConsolidator< T >
DataConsolidatedHandler DataConsolidated
 Event handler that fires when a new piece of data is produced More...
 

Additional Inherited Members

- Properties inherited from QuantConnect.Data.Consolidators.DataConsolidator< T >
IBaseData Consolidated [get]
 Gets the most recently consolidated piece of data. This will be null if this consolidator has not produced any data yet. More...
 
abstract IBaseData WorkingData [get]
 Gets a clone of the data being currently consolidated More...
 
Type InputType [get]
 Gets the type consumed by this consolidator More...
 
abstract Type OutputType [get]
 Gets the type produced by this consolidator More...
 

Detailed Description

Provides a base class for consolidators that emit data based on the passing of a period of time or after seeing a max count of data points.

Template Parameters
TThe input type of the consolidator
TConsolidatedThe output type of the consolidator
Type Constraints
T :IBaseData 
TConsolidated :BaseData 

Definition at line 30 of file PeriodCountConsolidatorBase.cs.

Constructor & Destructor Documentation

◆ PeriodCountConsolidatorBase() [1/5]

Creates a consolidator to produce a new TConsolidated instance representing the period

Parameters
periodThe minimum span of time before emitting a consolidated bar

Definition at line 61 of file PeriodCountConsolidatorBase.cs.

◆ PeriodCountConsolidatorBase() [2/5]

Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data

Parameters
maxCountThe number of pieces to accept before emiting a consolidated bar

Definition at line 71 of file PeriodCountConsolidatorBase.cs.

◆ PeriodCountConsolidatorBase() [3/5]

QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.PeriodCountConsolidatorBase ( int  maxCount,
TimeSpan  period 
)
protected

Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first

Parameters
maxCountThe number of pieces to accept before emiting a consolidated bar
periodThe minimum span of time before emitting a consolidated bar

Definition at line 82 of file PeriodCountConsolidatorBase.cs.

◆ PeriodCountConsolidatorBase() [4/5]

Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first

Parameters
funcFunc that defines the start time of a consolidated data

Definition at line 93 of file PeriodCountConsolidatorBase.cs.

◆ PeriodCountConsolidatorBase() [5/5]

Creates a consolidator to produce a new TConsolidated instance representing the last count pieces of data or the period, whichever comes first

Parameters
pyObjectPython object that defines either a function object that defines the start time of a consolidated data or a timespan

Definition at line 103 of file PeriodCountConsolidatorBase.cs.

Member Function Documentation

◆ Update()

override void QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.Update ( data)

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.

Exceptions
InvalidOperationExceptionThrown when multiple symbols are being consolidated.
Parameters
dataThe new data for the consolidator

Definition at line 133 of file PeriodCountConsolidatorBase.cs.

◆ Scan()

override void QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.Scan ( DateTime  currentLocalTime)
virtual

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

Parameters
currentLocalTimeThe current time in the local time zone (same as BaseData.Time)

Implements QuantConnect.Data.Consolidators.DataConsolidator< T >.

Definition at line 247 of file PeriodCountConsolidatorBase.cs.

◆ ShouldProcess()

virtual bool QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.ShouldProcess ( data)
protectedvirtual

Determines whether or not the specified data should be processed

Parameters
dataThe data to check
Returns
True if the consolidator should process this data, false otherwise
Here is the caller graph for this function:

◆ AggregateBar()

abstract void QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.AggregateBar ( ref TConsolidated  workingBar,
data 
)
protectedpure virtual

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

Parameters
workingBarThe bar we're building, null if the event was just fired and we're starting a new consolidated bar
dataThe new data
Here is the caller graph for this function:

◆ GetRoundedBarTime() [1/2]

DateTime QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.GetRoundedBarTime ( DateTime  time)
protected

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

Parameters
timeThe bar time to be rounded down
Returns
The rounded bar time

Definition at line 288 of file PeriodCountConsolidatorBase.cs.

Here is the caller graph for this function:

◆ GetRoundedBarTime() [2/2]

DateTime QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.GetRoundedBarTime ( IBaseData  inputData)
protected

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

Parameters
inputDataThe input data point
Returns
The rounded bar start time

Definition at line 307 of file PeriodCountConsolidatorBase.cs.

◆ OnDataConsolidated()

virtual void QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.OnDataConsolidated ( TConsolidated  e)
protectedvirtual

Event invocator for the DataConsolidated event

Parameters
eThe consolidated data

Definition at line 323 of file PeriodCountConsolidatorBase.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ OutputType

override Type QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.OutputType => typeof(TConsolidated)

Gets the type produced by this consolidator

Definition at line 111 of file PeriodCountConsolidatorBase.cs.

◆ WorkingData

override IBaseData QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.WorkingData => _workingBar?.Clone()

Gets a clone of the data being currently consolidated

Definition at line 116 of file PeriodCountConsolidatorBase.cs.

◆ IsTimeBased

bool QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.IsTimeBased => !_maxCount.HasValue
protected

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

Definition at line 260 of file PeriodCountConsolidatorBase.cs.

◆ Period

TimeSpan? QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.Period => _period
protected

Gets the time period for this consolidator

Definition at line 265 of file PeriodCountConsolidatorBase.cs.

Event Documentation

◆ DataConsolidated

new EventHandler<TConsolidated> QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase< T, TConsolidated >.DataConsolidated

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 TConsolidated instead of a BaseData instance

Definition at line 122 of file PeriodCountConsolidatorBase.cs.


The documentation for this class was generated from the following file: