Lean
$LEAN_TAG$
|
Base exchange class providing information and helper tools for reading the current exchange situation More...
Public Member Functions | |
SecurityExchange (SecurityExchangeHours exchangeHours) | |
Initializes a new instance of the SecurityExchange class using the specified exchange hours to determine open/close times More... | |
void | SetLocalDateTimeFrontierProvider (LocalTimeKeeper timeProvider) |
Set the current datetime in terms of the exchange's local time zone More... | |
bool | DateIsOpen (DateTime dateToCheck, bool extendedMarketHours=false) |
Check if the date is open. More... | |
bool | DateTimeIsOpen (DateTime dateTime) |
Check if this DateTime is open. More... | |
bool | IsOpenDuringBar (DateTime barStartTime, DateTime barEndTime, bool isExtendedMarketHours) |
Determines if the exchange was open at any time between start and stop More... | |
bool | IsClosingSoon (int minutesToClose) |
Determines if the exchange is going to close in the next provided minutes More... | |
void | SetMarketHours (IEnumerable< MarketHoursSegment > marketHoursSegments, params DayOfWeek[] days) |
Sets the regular market hours for the specified days If no days are specified then all days will be updated. More... | |
Public Attributes | |
DateTimeZone | TimeZone => Hours.TimeZone |
Gets the time zone for this exchange More... | |
virtual int | TradingDaysPerYear => 365 |
Number of trading days per year for this security. By default the market is open 365 days per year. More... | |
DateTime | LocalTime => _timeProvider.LocalTime |
Time from the most recent data More... | |
bool | ExchangeOpen => Hours.IsOpen(LocalTime, false) |
Boolean property for quickly testing if the exchange is open. More... | |
bool | ClosingSoon => IsClosingSoon(minutesToClose:10) |
Boolean property for quickly testing if the exchange is 10 minutes away from closing. More... | |
Properties | |
SecurityExchangeHours | Hours [get] |
Gets the SecurityExchangeHours for this exchange More... | |
Base exchange class providing information and helper tools for reading the current exchange situation
Definition at line 27 of file SecurityExchange.cs.
QuantConnect.Securities.SecurityExchange.SecurityExchange | ( | SecurityExchangeHours | exchangeHours | ) |
Initializes a new instance of the SecurityExchange class using the specified exchange hours to determine open/close times
exchangeHours | Contains the weekly exchange schedule plus holidays |
Definition at line 67 of file SecurityExchange.cs.
void QuantConnect.Securities.SecurityExchange.SetLocalDateTimeFrontierProvider | ( | LocalTimeKeeper | timeProvider | ) |
Set the current datetime in terms of the exchange's local time zone
timeProvider | Most recent data tick |
Definition at line 76 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.DateIsOpen | ( | DateTime | dateToCheck, |
bool | extendedMarketHours = false |
||
) |
Check if the date is open.
This is useful for first checking the date list, and then the market hours to save CPU cycles
dateToCheck | Date to check |
extendedMarketHours | True to consider days with extended market hours only as open |
Definition at line 88 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.DateTimeIsOpen | ( | DateTime | dateTime | ) |
Check if this DateTime is open.
dateTime | DateTime to check |
Definition at line 98 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.IsOpenDuringBar | ( | DateTime | barStartTime, |
DateTime | barEndTime, | ||
bool | isExtendedMarketHours | ||
) |
Determines if the exchange was open at any time between start and stop
Definition at line 106 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.IsClosingSoon | ( | int | minutesToClose | ) |
Determines if the exchange is going to close in the next provided minutes
minutesToClose | Minutes to close to check |
Definition at line 116 of file SecurityExchange.cs.
void QuantConnect.Securities.SecurityExchange.SetMarketHours | ( | IEnumerable< MarketHoursSegment > | marketHoursSegments, |
params DayOfWeek[] | days | ||
) |
Sets the regular market hours for the specified days If no days are specified then all days will be updated.
marketHoursSegments | Specifies each segment of the market hours, such as premarket/market/postmark |
days | The days of the week to set these times for |
Definition at line 127 of file SecurityExchange.cs.
DateTimeZone QuantConnect.Securities.SecurityExchange.TimeZone => Hours.TimeZone |
Gets the time zone for this exchange
Definition at line 39 of file SecurityExchange.cs.
virtual int QuantConnect.Securities.SecurityExchange.TradingDaysPerYear => 365 |
Number of trading days per year for this security. By default the market is open 365 days per year.
Used for performance statistics to calculate sharpe ratio accurately
Definition at line 45 of file SecurityExchange.cs.
DateTime QuantConnect.Securities.SecurityExchange.LocalTime => _timeProvider.LocalTime |
Time from the most recent data
Definition at line 50 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.ExchangeOpen => Hours.IsOpen(LocalTime, false) |
Boolean property for quickly testing if the exchange is open.
Definition at line 55 of file SecurityExchange.cs.
bool QuantConnect.Securities.SecurityExchange.ClosingSoon => IsClosingSoon(minutesToClose:10) |
Boolean property for quickly testing if the exchange is 10 minutes away from closing.
Definition at line 60 of file SecurityExchange.cs.
|
get |
Gets the SecurityExchangeHours for this exchange
Definition at line 34 of file SecurityExchange.cs.