Lean  $LEAN_TAG$
QuantConnect.Scheduling.TimeRules Class Reference

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

Public Member Functions

 TimeRules (SecurityManager securities, DateTimeZone timeZone)
 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 AfterMarketOpen (Symbol symbol, double minutesAfterOpen=0, bool extendedMarketOpen=false)
 Specifies an event should fire at market open +- minutesAfterOpen More...
 
ITimeRule BeforeMarketClose (Symbol symbol, double minutesBeforeClose=0, bool extendedMarketClose=false)
 Specifies an event should fire at the market close +- minutesBeforeClose 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...
 

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 
)

Initializes a new instance of the TimeRules helper class

Parameters
securitiesThe security manager
timeZoneThe algorithm's default time zone

Definition at line 40 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 50 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 84 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 96 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 108 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 121 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 132 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 149 of file TimeRules.cs.

◆ 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 167 of file TimeRules.cs.

◆ 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 194 of file TimeRules.cs.

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 58 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 72 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 77 of file TimeRules.cs.


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