Skip to content

@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 returns true.
  • next(t) returns midnight UTC of the day after t.
  • previous(t) returns midnight UTC of the day before t.
  • sessions(range) returns one Date per day in [range.from, range.to).
  • schedule(range) returns full Sessions with open/close at midnight UTC.
  • isEarlyClose(t) always returns false.

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

ParameterType
_tDate

Returns

boolean

Implementation of

Calendar.isEarlyClose


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

ParameterType
_tDate

Returns

boolean

Implementation of

Calendar.isOpen


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

ParameterTypeDescription
tDateReference date. If t itself is a trading day the result is the following trading day, not t.

Returns

Date

Implementation of

Calendar.next


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

ParameterTypeDescription
tDateReference date.

Returns

Date

Implementation of

Calendar.previous


schedule()

schedule(range): readonly Session[]

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

ParameterTypeDescription
rangeDateRangeHalf-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

Calendar.schedule


sessions()

sessions(range): readonly Date[]

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

ParameterTypeDescription
rangeDateRangeHalf-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

ts
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)

Implementation of

Calendar.sessions

Released under the MIT License.