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, bool extendedMarketHours=false) |
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 126 of file SecurityExchangeHours.cs.
|
static |
Gets a SecurityExchangeHours instance that is always open
Definition at line 107 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 162 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, |
bool | extendedMarketHours = false |
||
) |
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 |
extendedMarketHours | True to consider days with extended market hours only as open |
Definition at line 212 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 235 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 276 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 329 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 |
This method will return an adjusted instance of LocalMarketHours for the specified date, that is, it will account for holidays, early closes, and late opens (e.g. if the security trades regularly on Mondays, but a specific Monday is a holiday, this method will return a LocalMarketHours that is closed all day). In order to get the regular schedule, use the MarketHours property.
Definition at line 447 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 576 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 592 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DayOfWeek, LocalMarketHours> QuantConnect.Securities.SecurityExchangeHours.MarketHours => _openHoursByDay |
Gets the market hours for this exchange
This returns the regular schedule for each day, without taking into account special cases such as holidays, early closes, or late opens. In order to get the actual market hours for a specific date, use GetMarketHours(DateTime)
Definition at line 79 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.EarlyCloses => _earlyCloses |
Gets the early closes for this exchange
Definition at line 84 of file SecurityExchangeHours.cs.
IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.LateOpens => _lateOpens |
Gets the late opens for this exchange
Definition at line 89 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 97 of file SecurityExchangeHours.cs.
|
get |
Checks whether the market is always open or not
Definition at line 102 of file SecurityExchangeHours.cs.