|
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, IEnumerable< DateTime > bankHolidayDates=null) | |
| 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 | GetFirstDailyMarketOpen (DateTime localDateTime, bool extendedMarketHours) |
| Gets the local date time corresponding to the first market open to the specified previous date More... | |
| DateTime | GetPreviousMarketOpen (DateTime localDateTime, bool extendedMarketHours) |
| Gets the local date time corresponding to the previous market open to the specified time More... | |
| DateTime | GetPreviousMarketOpen (DateTime localDateTime, bool extendedMarketHours, bool firstOpen) |
| 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 | GetLastDailyMarketClose (DateTime localDateTime, bool extendedMarketHours) |
| Gets the local date time corresponding to the last market close following the specified date More... | |
| DateTime | GetNextMarketClose (DateTime localDateTime, bool extendedMarketHours) |
| Gets the local date time corresponding to the next market close following the specified time More... | |
| DateTime | GetNextMarketClose (DateTime localDateTime, bool extendedMarketHours, bool lastClose) |
| 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... | |
| HashSet< DateTime > | BankHolidays [get] |
| Gets the bank 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, | ||
| IEnumerable< DateTime > | bankHolidayDates = null |
||
| ) |
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 137 of file SecurityExchangeHours.cs.
|
static |
Gets a SecurityExchangeHours instance that is always open
Definition at line 118 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 175 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 188 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 225 of file SecurityExchangeHours.cs.
| DateTime QuantConnect.Securities.SecurityExchangeHours.GetFirstDailyMarketOpen | ( | DateTime | localDateTime, |
| bool | extendedMarketHours | ||
| ) |
Gets the local date time corresponding to the first market open to the specified previous date
| 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 248 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 259 of file SecurityExchangeHours.cs.
| DateTime QuantConnect.Securities.SecurityExchangeHours.GetPreviousMarketOpen | ( | DateTime | localDateTime, |
| bool | extendedMarketHours, | ||
| bool | firstOpen | ||
| ) |
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 270 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 321 of file SecurityExchangeHours.cs.
| DateTime QuantConnect.Securities.SecurityExchangeHours.GetLastDailyMarketClose | ( | DateTime | localDateTime, |
| bool | extendedMarketHours | ||
| ) |
Gets the local date time corresponding to the last market close following the specified date
| localDateTime | The time to begin searching for market close (non-inclusive) |
| extendedMarketHours | True to include extended market hours in the search |
Definition at line 374 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 385 of file SecurityExchangeHours.cs.
| DateTime QuantConnect.Securities.SecurityExchangeHours.GetNextMarketClose | ( | DateTime | localDateTime, |
| bool | extendedMarketHours, | ||
| bool | lastClose | ||
| ) |
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 |
| lastClose | True if the last available close of the date should be returned, else the first will be used |
Definition at line 397 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 515 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 644 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 660 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 90 of file SecurityExchangeHours.cs.
| IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.EarlyCloses => _earlyCloses |
Gets the early closes for this exchange
Definition at line 95 of file SecurityExchangeHours.cs.
| IReadOnlyDictionary<DateTime, TimeSpan> QuantConnect.Securities.SecurityExchangeHours.LateOpens => _lateOpens |
Gets the late opens for this exchange
Definition at line 100 of file SecurityExchangeHours.cs.
|
get |
Gets the time zone this exchange resides in
Definition at line 62 of file SecurityExchangeHours.cs.
|
get |
Gets the holidays for the exchange
Definition at line 68 of file SecurityExchangeHours.cs.
|
get |
Gets the bank holidays for the exchange
In some markets and assets, like CME futures, there are tradable dates (market open) which should not be considered for expiration rules due to banks being closed
Definition at line 78 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 108 of file SecurityExchangeHours.cs.
|
get |
Checks whether the market is always open or not
Definition at line 113 of file SecurityExchangeHours.cs.