Lean
$LEAN_TAG$
|
Represents the schedule of a security exchange. This includes daily regular and extended market hours as well as holidays, early closes and late opens. More...
Public Member Functions | |
SecurityExchangeHours (DateTimeZone timeZone, IEnumerable< DateTime > holidayDates, Dictionary< DayOfWeek, LocalMarketHours > marketHoursForEachDayOfWeek, IReadOnlyDictionary< DateTime, TimeSpan > earlyCloses, IReadOnlyDictionary< DateTime, TimeSpan > lateOpens) | |
Initializes a new instance of the SecurityExchangeHours class More... | |
bool | IsOpen (DateTime localDateTime, bool extendedMarketHours) |
Determines if the exchange is open at the specified local date time. More... | |
bool | IsOpen (DateTime startLocalDateTime, DateTime endLocalDateTime, bool extendedMarketHours) |
Determines if the exchange is open at any point in time over the specified interval. More... | |
bool | IsDateOpen (DateTime localDateTime) |
Determines if the exchange will be open on the date specified by the local date time More... | |
DateTime | GetPreviousMarketOpen (DateTime localDateTime, bool extendedMarketHours) |
Gets the local date time corresponding to the previous market open to the specified time More... | |
DateTime | GetNextMarketOpen (DateTime localDateTime, bool extendedMarketHours) |
Gets the local date time corresponding to the next market open following the specified time More... | |
DateTime | GetNextMarketClose (DateTime localDateTime, bool extendedMarketHours) |
Gets the local date time corresponding to the next market close following the specified time More... | |
LocalMarketHours | GetMarketHours (DateTime localDateTime) |
Helper to access the market hours field based on the day of week More... | |
DateTime | GetPreviousTradingDay (DateTime localDate) |
Gets the previous trading day More... | |
DateTime | GetNextTradingDay (DateTime date) |
Gets the next trading day More... | |
Static Public Member Functions | |
static SecurityExchangeHours | AlwaysOpen (DateTimeZone timeZone) |
Gets a SecurityExchangeHours instance that is always open More... | |
Public Attributes | |
IReadOnlyDictionary< DayOfWeek, LocalMarketHours > | MarketHours => _openHoursByDay |
Gets the market hours for this exchange More... | |
IReadOnlyDictionary< DateTime, TimeSpan > | EarlyCloses => _earlyCloses |
Gets the early closes for this exchange More... | |
IReadOnlyDictionary< DateTime, TimeSpan > | LateOpens => _lateOpens |
Gets the late opens for this exchange More... | |
Properties | |
DateTimeZone | TimeZone [get] |
Gets the time zone this exchange resides in More... | |
HashSet< DateTime > | Holidays [get] |
Gets the holidays for the exchange More... | |
TimeSpan | RegularMarketDuration [get] |
Gets the most common tradable time during the market week. For a normal US equity trading day this is 6.5 hours. This does NOT account for extended market hours and only considers MarketHoursState.Market More... | |
bool | IsMarketAlwaysOpen [get] |
Checks whether the market is always open or not More... | |
Represents the schedule of a security exchange. This includes daily regular and extended market hours as well as holidays, early closes and late opens.
This type assumes that IsOpen will be called with increasingly future times, that is, the calls should never back track in time. This assumption is required to prevent time zone conversions on every call.
Definition at line 33 of file SecurityExchangeHours.cs.
QuantConnect.Securities.SecurityExchangeHours.SecurityExchangeHours | ( | DateTimeZone | timeZone, |
IEnumerable< DateTime > | holidayDates, | ||
Dictionary< DayOfWeek, LocalMarketHours > | marketHoursForEachDayOfWeek, | ||
IReadOnlyDictionary< DateTime, TimeSpan > | earlyCloses, | ||
IReadOnlyDictionary< DateTime, TimeSpan > | lateOpens | ||
) |
Initializes a new instance of the SecurityExchangeHours class
timeZone | The time zone the dates and hours are represented in |
holidayDates | The dates this exchange is closed for holiday |
marketHoursForEachDayOfWeek | The exchange's schedule for each day of the week |
earlyCloses | The dates this exchange has an early close |
lateOpens | The dates this exchange has a late open |
Definition at line 121 of file SecurityExchangeHours.cs.
|
static |
Gets a SecurityExchangeHours instance that is always open
Definition at line 102 of file SecurityExchangeHours.cs.
bool QuantConnect.Securities.SecurityExchangeHours.IsOpen | ( | DateTime | localDateTime, |
bool | extendedMarketHours | ||
) |
Determines if the exchange is open at the specified local date time.
localDateTime | The time to check represented as a local time |
extendedMarketHours | True to use the extended market hours, false for just regular market hours |
Definition at line 157 of file SecurityExchangeHours.cs.
bool QuantConnect.Securities.SecurityExchangeHours.IsOpen | ( | DateTime | startLocalDateTime, |
DateTime | endLocalDateTime, | ||
bool | extendedMarketHours | ||
) |
Determines if the exchange is open at any point in time over the specified interval.
startLocalDateTime | The start of the interval in local time |
endLocalDateTime | The end of the interval in local time |
extendedMarketHours | True to use the extended market hours, false for just regular market hours |
Definition at line 175 of file SecurityExchangeHours.cs.
bool QuantConnect.Securities.SecurityExchangeHours.IsDateOpen | ( | DateTime | localDateTime | ) |
Determines if the exchange will be open on the date specified by the local date time
localDateTime | The date time to check if the day is open |
Definition at line 211 of file SecurityExchangeHours.cs.
DateTime QuantConnect.Securities.SecurityExchangeHours.GetPreviousMarketOpen | ( | DateTime | localDateTime, |
bool | extendedMarketHours | ||
) |
Gets the local date time corresponding to the previous market open to the specified time
localDateTime | The time to begin searching for the last market open (non-inclusive) |
extendedMarketHours | True to include extended market hours in the search |
Definition at line 230 of file SecurityExchangeHours.cs.
DateTime QuantConnect.Securities.SecurityExchangeHours.GetNextMarketOpen | ( | DateTime | localDateTime, |
bool | extendedMarketHours | ||
) |
Gets the local date time corresponding to the next market open following the specified time
localDateTime | The time to begin searching for market open (non-inclusive) |
extendedMarketHours | True to include extended market hours in the search |
Definition at line 271 of file SecurityExchangeHours.cs.
DateTime QuantConnect.Securities.SecurityExchangeHours.GetNextMarketClose | ( | DateTime | localDateTime, |
bool | extendedMarketHours | ||
) |
Gets the local date time corresponding to the next market close following the specified time
localDateTime | The time to begin searching for market close (non-inclusive) |
extendedMarketHours | True to include extended market hours in the search |
Definition at line 324 of file SecurityExchangeHours.cs.
LocalMarketHours QuantConnect.Securities.SecurityExchangeHours.GetMarketHours | ( | DateTime | localDateTime | ) |
Helper to access the market hours field based on the day of week
localDateTime | The local date time to retrieve market hours for |
Definition at line 436 of file SecurityExchangeHours.cs.
DateTime QuantConnect.Securities.SecurityExchangeHours.GetPreviousTradingDay | ( | DateTime | localDate | ) |
Gets the previous trading day
localDate | The date to start searching at in this exchange's time zones |
Definition at line 551 of file SecurityExchangeHours.cs.
DateTime QuantConnect.Securities.SecurityExchangeHours.GetNextTradingDay | ( | DateTime | date | ) |
Gets the next trading day
date | The date to start searching at |
Definition at line 567 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DayOfWeek, LocalMarketHours> QuantConnect.Securities.SecurityExchangeHours.MarketHours => _openHoursByDay |
Gets the market hours for this exchange
Definition at line 74 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.EarlyCloses => _earlyCloses |
Gets the early closes for this exchange
Definition at line 79 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.LateOpens => _lateOpens |
Gets the late opens for this exchange
Definition at line 84 of file SecurityExchangeHours.cs.
|
get |
Gets the time zone this exchange resides in
Definition at line 61 of file SecurityExchangeHours.cs.
|
get |
Gets the holidays for the exchange
Definition at line 67 of file SecurityExchangeHours.cs.
|
get |
Gets the most common tradable time during the market week. For a normal US equity trading day this is 6.5 hours. This does NOT account for extended market hours and only considers MarketHoursState.Market
Definition at line 92 of file SecurityExchangeHours.cs.
|
get |
Checks whether the market is always open or not
Definition at line 97 of file SecurityExchangeHours.cs.