@livefolio/sdk / ExchangeCalendar
Abstract Class: ExchangeCalendar
Defined in: calendars/exchange-calendar.ts:47
Abstract base class for exchange trading calendars. Implements the full Calendar interface by composing up to nine overridable hooks that subclasses provide. Concrete implementations ship for NYSEExchangeCalendar and LSEExchangeCalendar; additional exchanges can be added by extending this class.
Per-year caching: holiday sets and special-session maps are computed once per calendar year and stored in private Maps, so repeated calls to isOpen, next, or sessions within the same year are cheap.
Hook resolution order (adhoc beats rule, rule beats regular):
adhocHolidays()/specialClosesAdhoc()/specialOpensAdhoc()—YYYY-MM-DDstring sets/maps populated once at first access.regularHolidays()/specialCloses()/specialOpens()— year-derived rule arrays applied per year via the resolver helpers.regularOpen(date)/regularClose(date)/weekmask(date)— per-date fallbacks that subclasses override to encode era-varying session times and trading-day sets.
Extending: override only the hooks you need. All hooks have no-op / sensible defaults (Mon–Fri weekmask, 09:30–16:00 session) so a minimal subclass need only set name, tz, and regularHolidays().
Extended by
Implements
Constructors
Constructor
new ExchangeCalendar():
ExchangeCalendar
Returns
ExchangeCalendar
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
name | abstract | string | Short exchange name used as the registry key in getCalendar. | calendars/exchange-calendar.ts:49 |
tz | abstract | string | IANA timezone identifier, e.g. 'America/New_York' or 'Europe/London'. | calendars/exchange-calendar.ts:51 |
Methods
isEarlyClose()
isEarlyClose(
t):boolean
Defined in: calendars/exchange-calendar.ts:262
Returns true if the exchange closes early on the day containing t. Common examples: Black Friday (US), Christmas Eve, New Year's Eve.
Parameters
| Parameter | Type | Description |
|---|---|---|
t | Date | The instant or day to test. |
Returns
boolean
Implementation of
isOpen()
isOpen(
t):boolean
Defined in: calendars/exchange-calendar.ts:215
Returns true when t falls on a regular trading day (weekmask check, then holiday check).
Parameters
| Parameter | Type |
|---|---|
t | Date |
Returns
boolean
Implementation of
next()
next(
t):Date
Defined in: calendars/exchange-calendar.ts:225
Returns the first trading day strictly after t.
Parameters
| Parameter | Type |
|---|---|
t | Date |
Returns
Date
Implementation of
previous()
previous(
t):Date
Defined in: calendars/exchange-calendar.ts:232
Returns the first trading day strictly before t.
Parameters
| Parameter | Type |
|---|---|
t | Date |
Returns
Date
Implementation of
schedule()
schedule(
range): readonlySession[]
Defined in: calendars/exchange-calendar.ts:253
Returns full Session records (date, open instant, close instant) for every trading day in the half-open interval [range.from, range.to).
Parameters
| Parameter | Type | Description |
|---|---|---|
range | DateRange | Half-open date range. |
Returns
readonly Session[]
Ascending array of Session objects. Early-close days have a close earlier than the normal session close.
Implementation of
sessions()
sessions(
range): readonlyDate[]
Defined in: calendars/exchange-calendar.ts:242
Returns UTC midnight Date objects for every trading day in [range.from, range.to). The from bound is inclusive; to is exclusive.
Parameters
| Parameter | Type |
|---|---|
range | DateRange |
Returns
readonly Date[]