Lean  $LEAN_TAG$
QuantConnect.Scheduling.DateRules Class Reference

Helper class used to provide better syntax when defining date rules More...

Inheritance diagram for QuantConnect.Scheduling.DateRules:
[legend]

Public Member Functions

 DateRules (SecurityManager securities, DateTimeZone timeZone, MarketHoursDatabase marketHoursDatabase)
 Initializes a new instance of the DateRules helper class More...
 
void SetDefaultTimeZone (DateTimeZone timeZone)
 Sets the default time zone More...
 
IDateRule On (int year, int month, int day)
 Specifies an event should fire only on the specified day More...
 
IDateRule On (params DateTime[] dates)
 Specifies an event should fire only on the specified days More...
 
IDateRule Every (DayOfWeek day)
 Specifies an event should fire on each of the specified days of week More...
 
IDateRule Every (params DayOfWeek[] days)
 Specifies an event should fire on each of the specified days of week More...
 
IDateRule EveryDay ()
 Specifies an event should fire every day More...
 
IDateRule EveryDay (Symbol symbol, bool extendedMarketHours=false)
 Specifies an event should fire every day the symbol is trading More...
 
IDateRule YearStart (int daysOffset=0)
 Specifies an event should fire on the first of each year + offset More...
 
IDateRule YearStart (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the first tradable date + offset for the specified symbol of each year More...
 
IDateRule YearEnd (int daysOffset=0)
 Specifies an event should fire on the last of each year More...
 
IDateRule YearEnd (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the last tradable date - offset for the specified symbol of each year More...
 
IDateRule MonthStart (int daysOffset=0)
 Specifies an event should fire on the first of each month + offset More...
 
IDateRule MonthStart (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the first tradable date + offset for the specified symbol of each month More...
 
IDateRule MonthEnd (int daysOffset=0)
 Specifies an event should fire on the last of each month More...
 
IDateRule MonthEnd (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the last tradable date - offset for the specified symbol of each month More...
 
IDateRule WeekStart (int daysOffset=0)
 Specifies an event should fire on Monday + offset each week More...
 
IDateRule WeekStart (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the first tradable date + offset for the specified symbol each week More...
 
IDateRule WeekEnd (int daysOffset=0)
 Specifies an event should fire on Friday - offset More...
 
IDateRule WeekEnd (Symbol symbol, int daysOffset=0, bool extendedMarketHours=true)
 Specifies an event should fire on the last - offset tradable date for the specified symbol of each week More...
 
- Public Member Functions inherited from QuantConnect.Scheduling.BaseScheduleRules
 BaseScheduleRules (SecurityManager securities, DateTimeZone timeZone, MarketHoursDatabase marketHoursDatabase)
 Initializes a new instance of the TimeRules helper class More...
 

Public Attributes

IDateRule Today
 Specifies an event should only fire today in the algorithm's time zone using _securities.UtcTime instead of 'start' since ScheduleManager backs it up a day More...
 
IDateRule Tomorrow
 Specifies an event should only fire tomorrow in the algorithm's time zone using _securities.UtcTime instead of 'start' since ScheduleManager backs it up a day More...
 

Additional Inherited Members

- Protected Member Functions inherited from QuantConnect.Scheduling.BaseScheduleRules
SecurityExchangeHours GetSecurityExchangeHours (Symbol symbol)
 Helper method to fetch the security exchange hours More...
 
- Properties inherited from QuantConnect.Scheduling.BaseScheduleRules
DateTimeZone TimeZone [get, set]
 The algorithm's default time zone More...
 
SecurityManager Securities [get, set]
 The security manager More...
 
MarketHoursDatabase MarketHoursDatabase [get, set]
 The market hours database instance to use More...
 

Detailed Description

Helper class used to provide better syntax when defining date rules

Definition at line 29 of file DateRules.cs.

Constructor & Destructor Documentation

◆ DateRules()

QuantConnect.Scheduling.DateRules.DateRules ( SecurityManager  securities,
DateTimeZone  timeZone,
MarketHoursDatabase  marketHoursDatabase 
)

Initializes a new instance of the DateRules helper class

Parameters
securitiesThe security manager
timeZoneThe algorithm's default time zone
marketHoursDatabaseThe market hours database instance to use

Definition at line 37 of file DateRules.cs.

Member Function Documentation

◆ SetDefaultTimeZone()

void QuantConnect.Scheduling.DateRules.SetDefaultTimeZone ( DateTimeZone  timeZone)

Sets the default time zone

Parameters
timeZoneThe time zone to use for helper methods that can't resolve a time zone

Definition at line 46 of file DateRules.cs.

Here is the caller graph for this function:

◆ On() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.On ( int  year,
int  month,
int  day 
)

Specifies an event should fire only on the specified day

Parameters
yearThe year
monthThe month
dayThe day
Returns

Definition at line 58 of file DateRules.cs.

◆ On() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.On ( params DateTime[]  dates)

Specifies an event should fire only on the specified days

Parameters
datesThe dates the event should fire

Definition at line 69 of file DateRules.cs.

◆ Every() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.Every ( DayOfWeek  day)

Specifies an event should fire on each of the specified days of week

Parameters
dayThe day the event should fire
Returns
A date rule that fires on every specified day of week

◆ Every() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.Every ( params DayOfWeek[]  days)

Specifies an event should fire on each of the specified days of week

Parameters
daysThe days the event should fire
Returns
A date rule that fires on every specified day of week

Definition at line 106 of file DateRules.cs.

Here is the call graph for this function:

◆ EveryDay() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.EveryDay ( )

Specifies an event should fire every day

Returns
A date rule that fires every day

Definition at line 116 of file DateRules.cs.

Here is the call graph for this function:

◆ EveryDay() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.EveryDay ( Symbol  symbol,
bool  extendedMarketHours = false 
)

Specifies an event should fire every day the symbol is trading

Parameters
symbolThe symbol whose exchange is used to determine tradable dates
extendedMarketHoursTrue to include days with extended market hours only, like sunday for futures
Returns
A date rule that fires every day the specified symbol trades

Definition at line 127 of file DateRules.cs.

Here is the call graph for this function:

◆ YearStart() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.YearStart ( int  daysOffset = 0)

Specifies an event should fire on the first of each year + offset

Parameters
daysOffsetThe amount of days to offset the schedule by; must be between 0 and 365.
Returns
A date rule that fires on the first of each year + offset

Definition at line 138 of file DateRules.cs.

◆ YearStart() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.YearStart ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the first tradable date + offset for the specified symbol of each year

Parameters
symbolThe symbol whose exchange is used to determine the first tradable date of the year
daysOffsetThe amount of tradable days to offset the schedule by; must be between 0 and 365
extendedMarketHoursTrue to include days with extended market hours only, like sunday for futures
Returns
A date rule that fires on the first tradable date + offset for the specified security each year

Definition at line 151 of file DateRules.cs.

Here is the call graph for this function:

◆ YearEnd() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.YearEnd ( int  daysOffset = 0)

Specifies an event should fire on the last of each year

Parameters
daysOffsetThe amount of days to offset the schedule by; must be between 0 and 365
Returns
A date rule that fires on the last of each year - offset

Definition at line 174 of file DateRules.cs.

◆ YearEnd() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.YearEnd ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the last tradable date - offset for the specified symbol of each year

Parameters
symbolThe symbol whose exchange is used to determine the last tradable date of the year
daysOffsetThe amount of tradable days to offset the schedule by; must be between 0 and 365.
extendedMarketHoursTrue to include days with extended market hours only, like sunday for futures
Returns
A date rule that fires on the last tradable date - offset for the specified security each year

Definition at line 186 of file DateRules.cs.

Here is the call graph for this function:

◆ MonthStart() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.MonthStart ( int  daysOffset = 0)

Specifies an event should fire on the first of each month + offset

Parameters
daysOffsetThe amount of days to offset the schedule by; must be between 0 and 30.
Returns
A date rule that fires on the first of each month + offset

Definition at line 209 of file DateRules.cs.

◆ MonthStart() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.MonthStart ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the first tradable date + offset for the specified symbol of each month

Parameters
symbolThe symbol whose exchange is used to determine the first tradable date of the month
daysOffsetThe amount of tradable days to offset the schedule by; must be between 0 and 30
extendedMarketHoursTrue to include days with extended market hours only, like sunday for futures
Returns
A date rule that fires on the first tradable date + offset for the specified security each month

Definition at line 222 of file DateRules.cs.

Here is the call graph for this function:

◆ MonthEnd() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.MonthEnd ( int  daysOffset = 0)

Specifies an event should fire on the last of each month

Parameters
daysOffsetThe amount of days to offset the schedule by; must be between 0 and 30
Returns
A date rule that fires on the last of each month - offset

Definition at line 239 of file DateRules.cs.

◆ MonthEnd() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.MonthEnd ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the last tradable date - offset for the specified symbol of each month

Parameters
symbolThe symbol whose exchange is used to determine the last tradable date of the month
daysOffsetThe amount of tradable days to offset the schedule by; must be between 0 and 30.
extendedMarketHoursTrue to include days with extended market hours only, like sunday for futures
Returns
A date rule that fires on the last tradable date - offset for the specified security each month

Definition at line 251 of file DateRules.cs.

Here is the call graph for this function:

◆ WeekStart() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.WeekStart ( int  daysOffset = 0)

Specifies an event should fire on Monday + offset each week

Parameters
daysOffsetThe amount of days to offset monday by; must be between 0 and 6
Returns
A date rule that fires on Monday + offset each week

Definition at line 268 of file DateRules.cs.

◆ WeekStart() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.WeekStart ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the first tradable date + offset for the specified symbol each week

Parameters
symbolThe symbol whose exchange is used to determine the first tradeable date of the week
daysOffsetThe amount of tradable days to offset the first tradable day by
extendedMarketHoursTrue to include extended market hours, false otherwise
Returns
A date rule that fires on the first + offset tradable date for the specified security each week

Definition at line 289 of file DateRules.cs.

Here is the call graph for this function:

◆ WeekEnd() [1/2]

IDateRule QuantConnect.Scheduling.DateRules.WeekEnd ( int  daysOffset = 0)

Specifies an event should fire on Friday - offset

Parameters
daysOffsetThe amount of days to offset Friday by; must be between 0 and 6
Returns
A date rule that fires on Friday each week

Definition at line 312 of file DateRules.cs.

◆ WeekEnd() [2/2]

IDateRule QuantConnect.Scheduling.DateRules.WeekEnd ( Symbol  symbol,
int  daysOffset = 0,
bool  extendedMarketHours = true 
)

Specifies an event should fire on the last - offset tradable date for the specified symbol of each week

Parameters
symbolThe symbol whose exchange is used to determine the last tradable date of the week
daysOffsetThe amount of tradable days to offset the last tradable day by each week
extendedMarketHoursTrue to include extended market hours, false otherwise
Returns
A date rule that fires on the last - offset tradable date for the specified security each week

Definition at line 332 of file DateRules.cs.

Here is the call graph for this function:

Member Data Documentation

◆ Today

IDateRule QuantConnect.Scheduling.DateRules.Today
Initial value:
=> new FuncDateRule("TodayOnly",
(start, e) => {
return new[] { Securities.UtcTime.ConvertFromUtc(TimeZone).Date };
}
)

Specifies an event should only fire today in the algorithm's time zone using _securities.UtcTime instead of 'start' since ScheduleManager backs it up a day

Definition at line 80 of file DateRules.cs.

◆ Tomorrow

IDateRule QuantConnect.Scheduling.DateRules.Tomorrow
Initial value:
=> new FuncDateRule("TomorrowOnly",
(start, e) => new[] {Securities.UtcTime.ConvertFromUtc(TimeZone).Date.AddDays(1)}
)

Specifies an event should only fire tomorrow in the algorithm's time zone using _securities.UtcTime instead of 'start' since ScheduleManager backs it up a day

Definition at line 90 of file DateRules.cs.


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