@livefolio/sdk / Crypto24x7Calendar
Class: Crypto24x7Calendar
Defined in: calendars/crypto-24x7.ts:22
24/7 calendar where every day is a single session running midnight UTC to the next midnight UTC. Suitable for crypto strategies (BTC, ETH) and any always-on market.
isOpen(t)always returnstrue.next(t)returns midnight UTC of the day aftert.previous(t)returns midnight UTC of the day beforet.sessions(range)returns one Date per day in[range.from, range.to).schedule(range)returns full Sessions withopen/closeat midnight UTC.isEarlyClose(t)always returnsfalse.
Implements
Constructors
Constructor
new Crypto24x7Calendar():
Crypto24x7Calendar
Returns
Crypto24x7Calendar
Methods
isEarlyClose()
isEarlyClose(
_t):boolean
Defined in: calendars/crypto-24x7.ts:54
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 |
|---|---|
_t | Date |
Returns
boolean
Implementation of
isOpen()
isOpen(
_t):boolean
Defined in: calendars/crypto-24x7.ts:23
Returns true if t falls inside an open trading session for this exchange (i.e. between session open and session close, inclusive of open, exclusive of close).
Parameters
| Parameter | Type |
|---|---|
_t | Date |
Returns
boolean
Implementation of
next()
next(
t):Date
Defined in: calendars/crypto-24x7.ts:27
Returns the midnight-UTC Date of the next trading day strictly after t. Skips weekends, exchange holidays, and any days with no scheduled session.
Parameters
| Parameter | Type | Description |
|---|---|---|
t | Date | Reference date. If t itself is a trading day the result is the following trading day, not t. |
Returns
Date
Implementation of
previous()
previous(
t):Date
Defined in: calendars/crypto-24x7.ts:31
Returns the midnight-UTC Date of the most recent trading day strictly before t. Symmetric inverse of Calendar.next.
Parameters
| Parameter | Type | Description |
|---|---|---|
t | Date | Reference date. |
Returns
Date
Implementation of
schedule()
schedule(
range): readonlySession[]
Defined in: calendars/crypto-24x7.ts:46
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/crypto-24x7.ts:35
Returns the trading days (as midnight-UTC Dates) within the half-open interval [range.from, range.to), in ascending order.
Parameters
| Parameter | Type | Description |
|---|---|---|
range | DateRange | Half-open date range; range.from is inclusive, range.to is exclusive. |
Returns
readonly Date[]
Ascending array of trading-day Dates. Empty if no trading days fall in the range.
Example
import { NYSEExchangeCalendar } from '@livefolio/sdk';
const cal = new NYSEExchangeCalendar();
const days = cal.sessions({
from: new Date('2024-12-23'),
to: new Date('2025-01-02'),
});
// days.length === 5 (skips Christmas, Boxing Day is US-only partial, New Year's)