Consolidator Types

Calendar Consolidators

Introduction

Warning: file_get_contents(/tmp/docs/80eb5c5db3cc7f566cdd8343f6a804659594df34/Resources/consolidators/consolidator-info/calendar/intro.html): failed to open stream: No such file or directory in /tmp/docs/80eb5c5db3cc7f566cdd8343f6a804659594df34/03 Writing Algorithms/18 Consolidating Data/02 Consolidator Types/02 Calendar Consolidators/01 Introduction.php on line 2 Warning: Use of undefined constant DOCS_RESOURCE - assumed 'DOCS_RESOURCE' (this will throw an Error in a future version of PHP) in /tmp/docs/80eb5c5db3cc7f566cdd8343f6a804659594df34/03 Writing Algorithms/18 Consolidating Data/02 Consolidator Types/02 Calendar Consolidators/01 Introduction.php on line 3 Warning: include(DOCS_RESOURCE/consolidators/consolidator-info/calendar/class-definition.php): failed to open stream: No such file or directory in /tmp/docs/80eb5c5db3cc7f566cdd8343f6a804659594df34/03 Writing Algorithms/18 Consolidating Data/02 Consolidator Types/02 Calendar Consolidators/01 Introduction.php on line 3 Warning: include(): Failed opening 'DOCS_RESOURCE/consolidators/consolidator-info/calendar/class-definition.php' for inclusion (include_path='/var/www/beta/core/libraries/Google:/var/www/beta:.:/usr/share/php') in /tmp/docs/80eb5c5db3cc7f566cdd8343f6a804659594df34/03 Writing Algorithms/18 Consolidating Data/02 Consolidator Types/02 Calendar Consolidators/01 Introduction.php on line 3

Consolidate Trade Bars

ERROR: Class 'CalendarConsolidatorInfo' not found

File: 02 Consolidate Trade Bars.php line 11

Consolidate Quote Bars

ERROR: Class 'CalendarConsolidatorInfo' not found

File: 03 Consolidate Quote Bars.php line 10

Consolidate Trade Ticks

ERROR: Class 'CalendarConsolidatorInfo' not found

File: 04 Consolidate Trade Ticks.php line 11

Consolidate Quote Ticks

ERROR: Class 'CalendarConsolidatorInfo' not found

File: 05 Consolidate Quote Ticks.php line 10

Examples

The following method shows how to create a consolidation period that consolidates data into 20-minute TradeBar objects, starting at 9:30 AM:

public CalendarInfo ConsolidationPeriod(DateTime datetime)
{
    var period = TimeSpan.FromMinutes(20);
    var openTime = datetime.Date + new TimeSpan(9, 30, 0);
    var start = openTime + (int)((datetime - openTime) / period) * period;            
    return new CalendarInfo(start, period);
}
def consolidation_period(self, dt: datetime) -> CalendarInfo:
    period = timedelta(minutes=20)
    open_time = dt.replace(hour=9, minute=30, second=0, microsecond=0)
    start = open_time + ((dt - open_time) // period) * period
    return CalendarInfo(start, period)

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: