Lean  $LEAN_TAG$
QuantConnect.Scheduling.TimeRules Class Reference

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

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

Public Member Functions

 TimeRules (SecurityManager securities, DateTimeZone timeZone, MarketHoursDatabase marketHoursDatabase)
 Initializes a new instance of the TimeRules helper class More...
 
void SetDefaultTimeZone (DateTimeZone timeZone)
 Sets the default time zone More...
 
ITimeRule At (TimeSpan timeOfDay)
 Specifies an event should fire at the specified time of day in the algorithm's time zone More...
 
ITimeRule At (int hour, int minute, int second=0)
 Specifies an event should fire at the specified time of day in the algorithm's time zone More...
 
ITimeRule At (int hour, int minute, DateTimeZone timeZone)
 Specifies an event should fire at the specified time of day in the specified time zone More...
 
ITimeRule At (int hour, int minute, int second, DateTimeZone timeZone)
 Specifies an event should fire at the specified time of day in the specified time zone More...
 
ITimeRule At (TimeSpan timeOfDay, DateTimeZone timeZone)
 Specifies an event should fire at the specified time of day in the specified time zone More...
 
ITimeRule Every (TimeSpan interval)
 Specifies an event should fire periodically on the requested interval More...
 
ITimeRule BeforeMarketOpen (Symbol symbol, double minutesBeforeOpen=0, bool extendedMarketOpen=false)
 Specifies an event should fire at market open +- minutesBeforeOpen More...
 
ITimeRule AfterMarketOpen (Symbol symbol, double minutesAfterOpen=0, bool extendedMarketOpen=false)
 Specifies an event should fire at market open +- minutesAfterOpen More...
 
ITimeRule AfterMarketClose (Symbol symbol, double minutesAfterClose=0, bool extendedMarketClose=false)
 Specifies an event should fire at the market close +- minutesAfterClose More...
 
ITimeRule BeforeMarketClose (Symbol symbol, double minutesBeforeClose=0, bool extendedMarketClose=false)
 Specifies an event should fire at the market close +- minutesBeforeClose 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

ITimeRule Now
 Specifies an event should fire at the current time More...
 
ITimeRule Midnight => new FuncTimeRule("Midnight", dates => dates.Select(date => date.ConvertToUtc(TimeZone)))
 Convenience property for running a scheduled event at midnight in the algorithm time zone More...
 
ITimeRule Noon => new FuncTimeRule("Noon", dates => dates.Select(date => date.ConvertToUtc(TimeZone).AddHours(12)))
 Convenience property for running a scheduled event at noon in the algorithm time zone 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 time rules

Definition at line 29 of file TimeRules.cs.

Constructor & Destructor Documentation

◆ TimeRules()

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

Initializes a new instance of the TimeRules 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 TimeRules.cs.

Member Function Documentation

◆ SetDefaultTimeZone()

void QuantConnect.Scheduling.TimeRules.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 TimeRules.cs.

Here is the caller graph for this function:

◆ At() [1/5]

ITimeRule QuantConnect.Scheduling.TimeRules.At ( TimeSpan  timeOfDay)

Specifies an event should fire at the specified time of day in the algorithm's time zone

Parameters
timeOfDayThe time of day in the algorithm's time zone the event should fire
Returns
A time rule that fires at the specified time in the algorithm's time zone

Definition at line 80 of file TimeRules.cs.

Here is the caller graph for this function:

◆ At() [2/5]

ITimeRule QuantConnect.Scheduling.TimeRules.At ( int  hour,
int  minute,
int  second = 0 
)

Specifies an event should fire at the specified time of day in the algorithm's time zone

Parameters
hourThe hour
minuteThe minute
secondThe second
Returns
A time rule that fires at the specified time in the algorithm's time zone

Definition at line 92 of file TimeRules.cs.

Here is the call graph for this function:

◆ At() [3/5]

ITimeRule QuantConnect.Scheduling.TimeRules.At ( int  hour,
int  minute,
DateTimeZone  timeZone 
)

Specifies an event should fire at the specified time of day in the specified time zone

Parameters
hourThe hour
minuteThe minute
timeZoneThe time zone the event time is represented in
Returns
A time rule that fires at the specified time in the algorithm's time zone

Definition at line 104 of file TimeRules.cs.

Here is the call graph for this function:

◆ At() [4/5]

ITimeRule QuantConnect.Scheduling.TimeRules.At ( int  hour,
int  minute,
int  second,
DateTimeZone  timeZone 
)

Specifies an event should fire at the specified time of day in the specified time zone

Parameters
hourThe hour
minuteThe minute
secondThe second
timeZoneThe time zone the event time is represented in
Returns
A time rule that fires at the specified time in the algorithm's time zone

Definition at line 117 of file TimeRules.cs.

Here is the call graph for this function:

◆ At() [5/5]

ITimeRule QuantConnect.Scheduling.TimeRules.At ( TimeSpan  timeOfDay,
DateTimeZone  timeZone 
)

Specifies an event should fire at the specified time of day in the specified time zone

Parameters
timeOfDayThe time of day in the algorithm's time zone the event should fire
timeZoneThe time zone the date time is expressed in
Returns
A time rule that fires at the specified time in the algorithm's time zone

Definition at line 128 of file TimeRules.cs.

◆ Every()

ITimeRule QuantConnect.Scheduling.TimeRules.Every ( TimeSpan  interval)

Specifies an event should fire periodically on the requested interval

Parameters
intervalThe frequency with which the event should fire, can not be zero or less
Returns
A time rule that fires after each interval passes

Definition at line 145 of file TimeRules.cs.

◆ BeforeMarketOpen()

ITimeRule QuantConnect.Scheduling.TimeRules.BeforeMarketOpen ( Symbol  symbol,
double  minutesBeforeOpen = 0,
bool  extendedMarketOpen = false 
)

Specifies an event should fire at market open +- minutesBeforeOpen

Parameters
symbolThe symbol whose market open we want an event for
minutesBeforeOpenThe minutes before market open that the event should fire
extendedMarketOpenTrue to use extended market open, false to use regular market open
Returns
A time rule that fires the specified number of minutes before the symbol's market open

Definition at line 163 of file TimeRules.cs.

Here is the call graph for this function:

◆ AfterMarketOpen()

ITimeRule QuantConnect.Scheduling.TimeRules.AfterMarketOpen ( Symbol  symbol,
double  minutesAfterOpen = 0,
bool  extendedMarketOpen = false 
)

Specifies an event should fire at market open +- minutesAfterOpen

Parameters
symbolThe symbol whose market open we want an event for
minutesAfterOpenThe minutes after market open that the event should fire
extendedMarketOpenTrue to use extended market open, false to use regular market open
Returns
A time rule that fires the specified number of minutes after the symbol's market open

Definition at line 175 of file TimeRules.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AfterMarketClose()

ITimeRule QuantConnect.Scheduling.TimeRules.AfterMarketClose ( Symbol  symbol,
double  minutesAfterClose = 0,
bool  extendedMarketClose = false 
)

Specifies an event should fire at the market close +- minutesAfterClose

Parameters
symbolThe symbol whose market close we want an event for
minutesAfterCloseThe time after market close that the event should fire
extendedMarketCloseTrue to use extended market close, false to use regular market close
Returns
A time rule that fires the specified number of minutes after the symbol's market close

Definition at line 202 of file TimeRules.cs.

Here is the call graph for this function:

◆ BeforeMarketClose()

ITimeRule QuantConnect.Scheduling.TimeRules.BeforeMarketClose ( Symbol  symbol,
double  minutesBeforeClose = 0,
bool  extendedMarketClose = false 
)

Specifies an event should fire at the market close +- minutesBeforeClose

Parameters
symbolThe symbol whose market close we want an event for
minutesBeforeCloseThe time before market close that the event should fire
extendedMarketCloseTrue to use extended market close, false to use regular market close
Returns
A time rule that fires the specified number of minutes before the symbol's market close

Definition at line 214 of file TimeRules.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Now

ITimeRule QuantConnect.Scheduling.TimeRules.Now
Initial value:
=> new FuncTimeRule("Now", dates => {
return dates.Select(date =>
{
return Securities.UtcTime;
});
})

Specifies an event should fire at the current time

Definition at line 54 of file TimeRules.cs.

◆ Midnight

ITimeRule QuantConnect.Scheduling.TimeRules.Midnight => new FuncTimeRule("Midnight", dates => dates.Select(date => date.ConvertToUtc(TimeZone)))

Convenience property for running a scheduled event at midnight in the algorithm time zone

Definition at line 68 of file TimeRules.cs.

◆ Noon

ITimeRule QuantConnect.Scheduling.TimeRules.Noon => new FuncTimeRule("Noon", dates => dates.Select(date => date.ConvertToUtc(TimeZone).AddHours(12)))

Convenience property for running a scheduled event at noon in the algorithm time zone

Definition at line 73 of file TimeRules.cs.


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