@gainsnetwork/sdk 1.6.3-rc2 → 1.6.4-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -439,6 +439,7 @@ export declare const pairs: {
439
439
  "NAS100/USD": string;
440
440
  "USA30/USD": string;
441
441
  "NFLX_1/USD": string;
442
+ "STABLE/USD": string;
442
443
  };
443
444
  export declare const syntheticPairs: Set<string>;
444
445
  export declare const parentToSyntheticPairMap: Map<string, string>;
package/lib/constants.js CHANGED
@@ -447,6 +447,7 @@ exports.pairs = {
447
447
  "NAS100/USD": INDICES,
448
448
  "USA30/USD": INDICES,
449
449
  "NFLX_1/USD": STOCKS,
450
+ "STABLE/USD": STOCKS,
450
451
  };
451
452
  exports.syntheticPairs = new Set([
452
453
  "BTCDEGEN/USD",
@@ -496,13 +497,14 @@ exports.stockSplits = {
496
497
  };
497
498
  exports.delistedPairIxs = new Set([
498
499
  4, 6, 12, 15, 24, 25, 27, 28, 30, 31, 36, 41, 48, 51, 52, 53, 54, 56, 59, 60,
499
- 61, 63, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 95, 96, 97, 98,
500
- 99, 101, 106, 111, 113, 114, 116, 118, 120, 122, 123, 125, 127, 130, 147, 152,
501
- 160, 163, 170, 179, 182, 183, 186, 188, 189, 190, 198, 208, 209, 224, 225,
502
- 227, 229, 230, 231, 234, 238, 239, 241, 247, 250, 253, 254, 258, 261, 270,
503
- 272, 273, 275, 276, 278, 279, 280, 285, 290, 291, 292, 294, 296, 303, 305, 306,
504
- 311, 322, 323, 330, 333, 336, 337, 342, 343, 344, 347, 349, 350, 352, 354, 355,
505
- 357, 365, 366, 379, 380, 387, 395, 396, 400, 401, 408, 423, 427, 436, 437, 438,
500
+ 61, 63, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 95, 96, 97, 98, 99,
501
+ 101, 106, 111, 113, 114, 116, 118, 120, 122, 123, 125, 127, 130, 147, 152, 160,
502
+ 163, 170, 179, 182, 183, 186, 188, 189, 190, 198, 208, 209, 221, 224, 225, 227,
503
+ 229, 230, 231, 234, 238, 239, 241, 247, 250, 253, 254, 255, 258, 261, 268, 270,
504
+ 272, 273, 275, 276, 278, 279, 280, 281, 284, 285, 290, 291, 292, 294, 296, 303,
505
+ 305, 306, 311, 312, 322, 323, 330, 333, 335, 336, 337, 342, 343, 344, 346, 347,
506
+ 349, 350, 351, 352, 353, 354, 355, 357, 362, 365, 366, 372, 379, 380, 387, 395,
507
+ 396, 400, 401, 408, 423, 427, 428, 430, 435, 436, 437, 438, 440,
506
508
  ]);
507
509
  exports.delistedGroupsIxs = new Set([]);
508
510
  exports.DEFAULT_PROTECTION_CLOSE_FACTOR = 1;
@@ -593,4 +593,5 @@ const PAIR_INDEX_TO_DESCRIPTION = {
593
593
  [types_1.PairIndex.NAS100USD]: "NASDAQ 100 to US Dollar",
594
594
  [types_1.PairIndex.USA30USD]: "Down Jones 30 to US Dollar",
595
595
  [types_1.PairIndex.NFLXUSD2]: "Netflix to US Dollar",
596
+ [types_1.PairIndex.STABLEUSD]: "Stable to US Dollar",
596
597
  };
@@ -1,7 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isCommoditiesOpen = void 0;
4
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
6
  // @ts-ignore-file
5
- const schedules_1 = require("./schedules");
6
- const isCommoditiesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)('commodities', dateToCheck);
7
+ const luxon_1 = require("luxon");
8
+ const COMMODITIES_MARKETS_TIME_ZONE_IANA = luxon_1.IANAZone.create("America/New_York");
9
+ const isCommoditiesOpen = (dateToCheck) => {
10
+ const now = luxon_1.DateTime.fromJSDate(dateToCheck).setZone(COMMODITIES_MARKETS_TIME_ZONE_IANA);
11
+ const weekday = now.weekday;
12
+ const hour = now.hour;
13
+ const dayOfMonth = now.day;
14
+ const month = now.month;
15
+ const minute = now.minute;
16
+ const isClosed =
17
+ // Christmas 2023
18
+ (month === 12 && dayOfMonth >= 24) ||
19
+ // New Year's Eve 2023
20
+ (month === 1 && dayOfMonth >= 1 && dayOfMonth <= 2) ||
21
+ // Friday Closing: After 4:30 PM (Friday is closed for the whole day after 4:30 PM)
22
+ (weekday === 5 && (hour > 16 || (hour === 16 && minute >= 30))) ||
23
+ // Sunday Closing: before 7:30 PM (closed until Sunday 7:30 PM)
24
+ (weekday === 7 && (hour < 19 || (hour === 19 && minute < 30))) ||
25
+ // Saturday Closed
26
+ weekday === 6 ||
27
+ // Daily Closing: 4:30 PM to 6:30 PM (every day except Friday after 4:30 PM)
28
+ (hour === 16 && minute >= 30) || // 4:30 PM to 5:00 PM
29
+ hour === 17 || // 5:00 PM to 6:00 PM
30
+ (hour === 18 && minute <= 30); // 6:00 PM to 6:30 PM
31
+ return !isClosed;
32
+ };
7
33
  exports.isCommoditiesOpen = isCommoditiesOpen;
@@ -1,8 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isForexLowLiquidity = exports.isForexOpen = void 0;
4
- const schedules_1 = require("./schedules");
5
- const isForexOpen = (dateToCheck) => (0, schedules_1.isOpenAt)('forex', dateToCheck);
4
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
5
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
6
+ // @ts-ignore-file
7
+ const luxon_1 = require("luxon");
8
+ const FOREX_MARKETS_TIME_ZONE_IANA = luxon_1.IANAZone.create("America/New_York");
9
+ const isForexOpen = (dateToCheck) => {
10
+ const now = luxon_1.DateTime.fromJSDate(dateToCheck).setZone(FOREX_MARKETS_TIME_ZONE_IANA);
11
+ const weekday = now.weekday;
12
+ const hour = now.hour;
13
+ const dayOfMonth = now.day;
14
+ const month = now.month;
15
+ const isInDST = now.isInDST;
16
+ const isClosed =
17
+ // Christmas 2023
18
+ (month === 12 && dayOfMonth >= 25 && dayOfMonth <= 27) ||
19
+ // New Year's Eve 2023
20
+ (month === 1 && dayOfMonth >= 1 && dayOfMonth <= 2) ||
21
+ // Friday after 4PM (DST) and 5PM (non-DST)
22
+ (weekday === 5 && ((isInDST && hour >= 16) || hour >= 17)) ||
23
+ // Saturday
24
+ weekday === 6 ||
25
+ // Sunday before 4PM (DST) and 5PM (non-DST)
26
+ (weekday === 7 && ((isInDST && hour < 16) || hour < 17));
27
+ return !isClosed;
28
+ };
6
29
  exports.isForexOpen = isForexOpen;
7
- const isForexLowLiquidity = (timestampToCheck, pair) => (0, schedules_1.isLowLiquidityAt)('forex', new Date(timestampToCheck), pair?.groupIndex !== undefined ? { pairGroupIndex: +pair.groupIndex } : undefined);
30
+ const extendedLowLiqGroupIds = [8, 9];
31
+ const isForexLowLiquidity = (timestampToCheck, pair) => {
32
+ const now = luxon_1.DateTime.fromMillis(timestampToCheck).setZone(FOREX_MARKETS_TIME_ZONE_IANA);
33
+ const hour = now.hour;
34
+ const minute = now.minute;
35
+ const isInDST = now.isInDST;
36
+ const groupIndex = pair?.groupIndex;
37
+ if (groupIndex && extendedLowLiqGroupIds.includes(+groupIndex)) {
38
+ return ((isInDST &&
39
+ ((hour == 14 && minute >= 45) || (hour >= 15 && hour < 21))) ||
40
+ (!isInDST && ((hour == 15 && minute >= 45) || (hour >= 16 && hour < 22))));
41
+ }
42
+ return ((isInDST && ((hour == 15 && minute >= 45) || (hour >= 16 && hour < 19))) ||
43
+ (!isInDST && ((hour == 16 && minute >= 45) || (hour >= 17 && hour < 20))));
44
+ };
8
45
  exports.isForexLowLiquidity = isForexLowLiquidity;
@@ -3,7 +3,6 @@ export * from "./forex";
3
3
  export * from "./stocks";
4
4
  export * from "./indices";
5
5
  export * from "./commodities";
6
- export * from "./schedules";
7
6
  export * from "./oi";
8
7
  export * from "./collateral";
9
8
  export * from "./price";
@@ -19,7 +19,6 @@ __exportStar(require("./forex"), exports);
19
19
  __exportStar(require("./stocks"), exports);
20
20
  __exportStar(require("./indices"), exports);
21
21
  __exportStar(require("./commodities"), exports);
22
- __exportStar(require("./schedules"), exports);
23
22
  __exportStar(require("./oi"), exports);
24
23
  __exportStar(require("./collateral"), exports);
25
24
  __exportStar(require("./price"), exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isIndicesOpen = void 0;
4
- const schedules_1 = require("./schedules");
5
- const isIndicesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)('indices', dateToCheck);
4
+ const stocks_1 = require("./stocks");
5
+ const isIndicesOpen = (dateToCheck) => (0, stocks_1.isStocksOpen)(dateToCheck);
6
6
  exports.isIndicesOpen = isIndicesOpen;
@@ -5,9 +5,52 @@ exports.getUSMarketsNow = exports.isStocksOpen = void 0;
5
5
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
6
6
  // @ts-ignore-file
7
7
  const luxon_1 = require("luxon");
8
- const schedules_1 = require("./schedules");
9
8
  const STOCKS_MARKETS_TIME_ZONE_IANA = luxon_1.IANAZone.create("America/New_York");
10
- const isStocksOpen = (dateToCheck) => (0, schedules_1.isOpenAt)('stocks', dateToCheck);
9
+ const isStocksOpen = (dateToCheck) => {
10
+ const now = luxon_1.DateTime.fromJSDate(dateToCheck).setZone(STOCKS_MARKETS_TIME_ZONE_IANA);
11
+ const weekday = now.weekday;
12
+ const hour = now.hour;
13
+ const dayOfMonth = now.day;
14
+ const month = now.month;
15
+ const minute = now.minute;
16
+ const isClosed =
17
+ // New Year's Day 2026
18
+ (month === 1 && dayOfMonth === 1) ||
19
+ // Martin Luther King, Jr. Day 2026
20
+ (month === 1 && dayOfMonth === 19) ||
21
+ // Presidents' Day 2026
22
+ (month === 2 && dayOfMonth === 16) ||
23
+ // Good Friday 2026
24
+ (month === 4 && dayOfMonth === 3) ||
25
+ // Memorial Day 2025
26
+ (month === 5 && dayOfMonth === 26) ||
27
+ // Juneteenth National Independence Day 2025
28
+ (month === 6 && dayOfMonth === 19) ||
29
+ // Independence Day 2025
30
+ (month === 7 && dayOfMonth === 4) ||
31
+ // Labor Day 2025
32
+ (month === 9 && dayOfMonth === 1) ||
33
+ // Thanksgiving Day 2025
34
+ (month === 11 && dayOfMonth === 27) ||
35
+ // Black Friday 2025 (closes early at 1PM)
36
+ (month === 11 && dayOfMonth === 28 && hour >= 13) ||
37
+ // Christmas Eve 2025 (closes early at 1PM)
38
+ (month === 12 && dayOfMonth === 24 && hour >= 13) ||
39
+ // Christmas Day 2025
40
+ (month === 12 && dayOfMonth === 25) ||
41
+ // Day before Independence Day 2025 (closes early at 1PM)
42
+ (month === 7 && dayOfMonth === 3 && hour >= 13) ||
43
+ // Saturday
44
+ weekday === 6 ||
45
+ // Sunday
46
+ weekday === 7 ||
47
+ // Mo-Fr Daily Opening
48
+ hour < 9 ||
49
+ (hour === 9 && minute < 30) ||
50
+ // Mo-Fr Daily Closing
51
+ hour >= 16;
52
+ return !isClosed;
53
+ };
11
54
  exports.isStocksOpen = isStocksOpen;
12
55
  const getUSMarketsNow = () => {
13
56
  return luxon_1.DateTime.now().setZone(STOCKS_MARKETS_TIME_ZONE_IANA);
@@ -767,5 +767,6 @@ export declare enum PairIndex {
767
767
  SPX500USD = 436,
768
768
  NAS100USD = 437,
769
769
  USA30USD = 438,
770
- NFLXUSD2 = 439
770
+ NFLXUSD2 = 439,
771
+ STABLEUSD = 440
771
772
  }
@@ -469,4 +469,5 @@ var PairIndex;
469
469
  PairIndex[PairIndex["NAS100USD"] = 437] = "NAS100USD";
470
470
  PairIndex[PairIndex["USA30USD"] = 438] = "USA30USD";
471
471
  PairIndex[PairIndex["NFLXUSD2"] = 439] = "NFLXUSD2";
472
+ PairIndex[PairIndex["STABLEUSD"] = 440] = "STABLEUSD";
472
473
  })(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gainsnetwork/sdk",
3
- "version": "1.6.3-rc2",
3
+ "version": "1.6.4-rc1",
4
4
  "description": "Gains Network SDK",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -1,7 +0,0 @@
1
- import { Schedule } from './types';
2
- export declare const buildForexWeeklySchedule: (currentDate?: Date, opts?: {
3
- pairGroupIndex?: number;
4
- }) => Schedule;
5
- export declare const buildStocksWeeklySchedule: (currentDate?: Date) => Schedule;
6
- export declare const buildIndicesWeeklySchedule: (currentDate?: Date) => Schedule;
7
- export declare const buildCommoditiesWeeklySchedule: (currentDate?: Date) => Schedule;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildCommoditiesWeeklySchedule = exports.buildIndicesWeeklySchedule = exports.buildStocksWeeklySchedule = exports.buildForexWeeklySchedule = void 0;
4
- const luxon_1 = require("luxon");
5
- const types_1 = require("./types");
6
- const holidays_1 = require("./holidays");
7
- const ET = luxon_1.IANAZone.create('America/New_York');
8
- const emptyWeekly = () => ({
9
- monday: [],
10
- tuesday: [],
11
- wednesday: [],
12
- thursday: [],
13
- friday: [],
14
- saturday: [],
15
- sunday: [],
16
- });
17
- const add = (ws, day, win) => {
18
- ws[(0, types_1.weekDayToKey)(day)].push(win);
19
- };
20
- const buildForexWeeklySchedule = (currentDate = new Date(), opts) => {
21
- const dt = luxon_1.DateTime.fromJSDate(currentDate).setZone(ET);
22
- const isInDST = dt.isInDST;
23
- const open = emptyWeekly();
24
- const lowLiq = emptyWeekly();
25
- const openHour = isInDST ? 16 : 17; // Monday open
26
- const closeHour = isInDST ? 16 : 17; // Friday close
27
- // Open windows (ET): Mon 16/17:00 -> 24:00, Tue-Thu 0-24, Fri 0 -> 16/17:00
28
- add(open, types_1.WeekDay.Monday, { start: { hour: openHour, minute: 0 }, end: { hour: 24, minute: 0 } });
29
- add(open, types_1.WeekDay.Tuesday, { start: { hour: 0, minute: 0 }, end: { hour: 24, minute: 0 } });
30
- add(open, types_1.WeekDay.Wednesday, { start: { hour: 0, minute: 0 }, end: { hour: 24, minute: 0 } });
31
- add(open, types_1.WeekDay.Thursday, { start: { hour: 0, minute: 0 }, end: { hour: 24, minute: 0 } });
32
- add(open, types_1.WeekDay.Friday, { start: { hour: 0, minute: 0 }, end: { hour: closeHour, minute: 0 } });
33
- // Low-liquidity windows (ET)
34
- const extendedGroups = [8, 9];
35
- const useExtended = opts?.pairGroupIndex !== undefined && extendedGroups.includes(+opts.pairGroupIndex);
36
- const llStartHour = isInDST ? (useExtended ? 14 : 15) : (useExtended ? 15 : 16);
37
- const llStartMinute = 45;
38
- const llEndHour = isInDST ? (useExtended ? 21 : 19) : (useExtended ? 22 : 20);
39
- const llEndMinute = 0;
40
- for (const d of [types_1.WeekDay.Monday, types_1.WeekDay.Tuesday, types_1.WeekDay.Wednesday, types_1.WeekDay.Thursday, types_1.WeekDay.Friday]) {
41
- add(lowLiq, d, { start: { hour: llStartHour, minute: llStartMinute }, end: { hour: llEndHour, minute: llEndMinute } });
42
- }
43
- const summary = isInDST
44
- ? 'Monday 4:00 pm - Friday 4:00 pm ET (Closed weekends & holidays)'
45
- : 'Monday 5:00 pm - Friday 5:00 pm ET (Closed weekends & holidays)';
46
- return { open, lowLiq, summary };
47
- };
48
- exports.buildForexWeeklySchedule = buildForexWeeklySchedule;
49
- const buildStocksWeeklySchedule = (currentDate = new Date()) => {
50
- const open = emptyWeekly();
51
- const lowLiq = emptyWeekly();
52
- for (const d of [types_1.WeekDay.Monday, types_1.WeekDay.Tuesday, types_1.WeekDay.Wednesday, types_1.WeekDay.Thursday, types_1.WeekDay.Friday]) {
53
- add(open, d, { start: { hour: 9, minute: 30 }, end: { hour: 16, minute: 0 } });
54
- }
55
- const holidays = (0, holidays_1.getStocksHolidaysInWeek)(currentDate);
56
- const summary = 'Monday - Friday: 9:30 am - 4:00 pm ET (Closed weekends & holidays)';
57
- return { open, lowLiq, holidays, summary };
58
- };
59
- exports.buildStocksWeeklySchedule = buildStocksWeeklySchedule;
60
- const buildIndicesWeeklySchedule = (currentDate = new Date()) => (0, exports.buildStocksWeeklySchedule)(currentDate);
61
- exports.buildIndicesWeeklySchedule = buildIndicesWeeklySchedule;
62
- const buildCommoditiesWeeklySchedule = (currentDate = new Date()) => {
63
- const open = emptyWeekly();
64
- const lowLiq = emptyWeekly();
65
- // Sunday: 19:30 -> 24:00
66
- add(open, types_1.WeekDay.Sunday, { start: { hour: 19, minute: 30 }, end: { hour: 24, minute: 0 } });
67
- // Mon-Thu: 0:00 -> 16:30 and 18:30 -> 24:00 (break represented by the gap)
68
- for (const d of [types_1.WeekDay.Monday, types_1.WeekDay.Tuesday, types_1.WeekDay.Wednesday, types_1.WeekDay.Thursday]) {
69
- add(open, d, { start: { hour: 0, minute: 0 }, end: { hour: 16, minute: 30 } });
70
- add(open, d, { start: { hour: 18, minute: 30 }, end: { hour: 24, minute: 0 } });
71
- }
72
- // Friday: 0:00 -> 16:30
73
- add(open, types_1.WeekDay.Friday, { start: { hour: 0, minute: 0 }, end: { hour: 16, minute: 30 } });
74
- // Saturday: closed (no windows)
75
- const summary = 'Sunday 7:30 pm - Friday 4:30 pm ET (Daily break: 4:30 pm - 6:30 pm ET)';
76
- return { open, lowLiq, summary };
77
- };
78
- exports.buildCommoditiesWeeklySchedule = buildCommoditiesWeeklySchedule;
@@ -1,7 +0,0 @@
1
- import { TradFiMarket } from "./index";
2
- export declare const isOpenAt: (market: TradFiMarket, date: Date, opts?: {
3
- pairGroupIndex?: number;
4
- }) => boolean;
5
- export declare const isLowLiquidityAt: (market: TradFiMarket, date: Date, opts?: {
6
- pairGroupIndex?: number;
7
- }) => boolean;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLowLiquidityAt = exports.isOpenAt = void 0;
4
- const luxon_1 = require("luxon");
5
- const index_1 = require("./index");
6
- const types_1 = require("./types");
7
- const ET = luxon_1.IANAZone.create("America/New_York");
8
- const weekdayKey = (weekday) => (0, types_1.weekDayToKey)(weekday); // Luxon: Mon=1..Sun=7
9
- const inInAnyWindow = (mm, wins) => !!wins?.some(w => {
10
- const start = w.start.hour * 60 + w.start.minute;
11
- const end = w.end.hour === 24 && w.end.minute === 0
12
- ? 1440
13
- : w.end.hour * 60 + w.end.minute;
14
- return mm >= start && mm < end;
15
- });
16
- const isOpenAt = (market, date, opts) => {
17
- const dt = luxon_1.DateTime.fromJSDate(date).setZone(ET);
18
- const schedule = (0, index_1.getWeeklySchedule)(market, date, opts);
19
- const dayKey = weekdayKey(dt.weekday);
20
- const mm = dt.hour * 60 + dt.minute;
21
- // Holiday override: if this ET date has a holiday entry, use its openWindows
22
- const holiday = schedule.holidays?.find(x => x.month === dt.month && x.day === dt.day);
23
- if (holiday) {
24
- return inInAnyWindow(mm, holiday.openWindows);
25
- }
26
- return inInAnyWindow(mm, (schedule.open)[dayKey]);
27
- };
28
- exports.isOpenAt = isOpenAt;
29
- const isLowLiquidityAt = (market, date, opts) => {
30
- const dt = luxon_1.DateTime.fromJSDate(date).setZone(ET);
31
- const schedule = (0, index_1.getWeeklySchedule)(market, date, opts);
32
- const dayKey = weekdayKey(dt.weekday);
33
- const mm = dt.hour * 60 + dt.minute;
34
- return inInAnyWindow(mm, (schedule.lowLiq)[dayKey]);
35
- };
36
- exports.isLowLiquidityAt = isLowLiquidityAt;
@@ -1,2 +0,0 @@
1
- import { Holiday } from "./types";
2
- export declare function getStocksHolidaysInWeek(currentDate: Date): Holiday[];
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStocksHolidaysInWeek = void 0;
4
- const luxon_1 = require("luxon");
5
- const ET = luxon_1.IANAZone.create("America/New_York");
6
- // Holiday definitions per year (ET calendar). For full-day closure, openWindows: []
7
- const stocksFullDay = (month, day, name) => ({ month, day, name, openWindows: [] });
8
- const addWindows = (startH, startM, endH, endM) => ({ start: { hour: startH, minute: startM }, end: { hour: endH, minute: endM } });
9
- const HOLIDAYS_2025 = [
10
- stocksFullDay(5, 26, "Memorial Day"),
11
- stocksFullDay(6, 19, "Juneteenth"),
12
- stocksFullDay(7, 4, "Independence Day"),
13
- stocksFullDay(9, 1, "Labor Day"),
14
- stocksFullDay(11, 27, "Thanksgiving Day"),
15
- stocksFullDay(12, 25, "Christmas Day"),
16
- { month: 7, day: 3, name: "Day Before Independence Day", openWindows: [addWindows(9, 30, 13, 0)] },
17
- { month: 11, day: 28, name: "Black Friday", openWindows: [addWindows(9, 30, 13, 0)] },
18
- { month: 12, day: 24, name: "Christmas Eve", openWindows: [addWindows(9, 30, 13, 0)] },
19
- ];
20
- const HOLIDAYS_2026 = [
21
- stocksFullDay(1, 1, "New Year's Day"),
22
- stocksFullDay(1, 19, "Martin Luther King Jr. Day"),
23
- stocksFullDay(2, 16, "Presidents' Day"),
24
- stocksFullDay(4, 3, "Good Friday"),
25
- ];
26
- function getStocksHolidaysForYear(year) {
27
- if (year === 2025)
28
- return HOLIDAYS_2025;
29
- if (year === 2026)
30
- return HOLIDAYS_2026;
31
- return [];
32
- }
33
- function getStocksHolidaysInWeek(currentDate) {
34
- const dt = luxon_1.DateTime.fromJSDate(currentDate).setZone(ET);
35
- const weekStart = dt.startOf("week"); // Sunday 00:00 ET
36
- const weekEnd = weekStart.plus({ days: 7 }); // exclusive end
37
- const year = dt.year;
38
- const list = getStocksHolidaysForYear(year);
39
- return list.filter(h => {
40
- const d = luxon_1.DateTime.fromObject({ year, month: h.month, day: h.day }, { zone: ET });
41
- return d >= weekStart && d < weekEnd;
42
- });
43
- }
44
- exports.getStocksHolidaysInWeek = getStocksHolidaysInWeek;
@@ -1,8 +0,0 @@
1
- export * from "./types";
2
- export { buildForexWeeklySchedule, buildStocksWeeklySchedule, buildIndicesWeeklySchedule, buildCommoditiesWeeklySchedule, } from "./builders";
3
- export { isOpenAt, isLowLiquidityAt } from "./checkers";
4
- import { Schedule } from "./types";
5
- export type TradFiMarket = "forex" | "stocks" | "indices" | "commodities";
6
- export declare const getWeeklySchedule: (market: TradFiMarket, currentDate?: Date, opts?: {
7
- pairGroupIndex?: number;
8
- }) => Schedule;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getWeeklySchedule = exports.isLowLiquidityAt = exports.isOpenAt = exports.buildCommoditiesWeeklySchedule = exports.buildIndicesWeeklySchedule = exports.buildStocksWeeklySchedule = exports.buildForexWeeklySchedule = void 0;
18
- __exportStar(require("./types"), exports);
19
- var builders_1 = require("./builders");
20
- Object.defineProperty(exports, "buildForexWeeklySchedule", { enumerable: true, get: function () { return builders_1.buildForexWeeklySchedule; } });
21
- Object.defineProperty(exports, "buildStocksWeeklySchedule", { enumerable: true, get: function () { return builders_1.buildStocksWeeklySchedule; } });
22
- Object.defineProperty(exports, "buildIndicesWeeklySchedule", { enumerable: true, get: function () { return builders_1.buildIndicesWeeklySchedule; } });
23
- Object.defineProperty(exports, "buildCommoditiesWeeklySchedule", { enumerable: true, get: function () { return builders_1.buildCommoditiesWeeklySchedule; } });
24
- var checkers_1 = require("./checkers");
25
- Object.defineProperty(exports, "isOpenAt", { enumerable: true, get: function () { return checkers_1.isOpenAt; } });
26
- Object.defineProperty(exports, "isLowLiquidityAt", { enumerable: true, get: function () { return checkers_1.isLowLiquidityAt; } });
27
- const builders_2 = require("./builders");
28
- const getWeeklySchedule = (market, currentDate = new Date(), opts) => {
29
- switch (market) {
30
- case "forex":
31
- return (0, builders_2.buildForexWeeklySchedule)(currentDate, {
32
- pairGroupIndex: opts?.pairGroupIndex,
33
- });
34
- case "stocks":
35
- return (0, builders_2.buildStocksWeeklySchedule)(currentDate);
36
- case "indices":
37
- return (0, builders_2.buildIndicesWeeklySchedule)(currentDate);
38
- case "commodities":
39
- return (0, builders_2.buildCommoditiesWeeklySchedule)(currentDate);
40
- }
41
- };
42
- exports.getWeeklySchedule = getWeeklySchedule;
@@ -1,42 +0,0 @@
1
- import { IANAZone } from "luxon";
2
- export type HM = {
3
- hour: number;
4
- minute: number;
5
- };
6
- export type Window = {
7
- start: HM;
8
- end: HM;
9
- };
10
- export type WeeklySchedule = {
11
- monday: Window[];
12
- tuesday: Window[];
13
- wednesday: Window[];
14
- thursday: Window[];
15
- friday: Window[];
16
- saturday: Window[];
17
- sunday: Window[];
18
- };
19
- export declare enum WeekDay {
20
- Monday = 1,
21
- Tuesday = 2,
22
- Wednesday = 3,
23
- Thursday = 4,
24
- Friday = 5,
25
- Saturday = 6,
26
- Sunday = 7
27
- }
28
- export type WeekDayKey = keyof WeeklySchedule;
29
- export declare const weekDayToKey: (d: WeekDay) => WeekDayKey;
30
- export type Holiday = {
31
- month: number;
32
- day: number;
33
- name: string;
34
- openWindows: Window[];
35
- };
36
- export type Schedule = {
37
- holidays?: Holiday[];
38
- open: WeeklySchedule;
39
- lowLiq: WeeklySchedule;
40
- summary?: string;
41
- };
42
- export declare const ET_IANA: IANAZone;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ET_IANA = exports.weekDayToKey = exports.WeekDay = void 0;
4
- const luxon_1 = require("luxon");
5
- // Monday = 1 ... Sunday = 7 (matches Luxon DateTime.weekday)
6
- var WeekDay;
7
- (function (WeekDay) {
8
- WeekDay[WeekDay["Monday"] = 1] = "Monday";
9
- WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday";
10
- WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday";
11
- WeekDay[WeekDay["Thursday"] = 4] = "Thursday";
12
- WeekDay[WeekDay["Friday"] = 5] = "Friday";
13
- WeekDay[WeekDay["Saturday"] = 6] = "Saturday";
14
- WeekDay[WeekDay["Sunday"] = 7] = "Sunday";
15
- })(WeekDay = exports.WeekDay || (exports.WeekDay = {}));
16
- const weekDayToKey = (d) => {
17
- switch (d) {
18
- case WeekDay.Monday:
19
- return "monday";
20
- case WeekDay.Tuesday:
21
- return "tuesday";
22
- case WeekDay.Wednesday:
23
- return "wednesday";
24
- case WeekDay.Thursday:
25
- return "thursday";
26
- case WeekDay.Friday:
27
- return "friday";
28
- case WeekDay.Saturday:
29
- return "saturday";
30
- case WeekDay.Sunday:
31
- return "sunday";
32
- default:
33
- return "sunday";
34
- }
35
- };
36
- exports.weekDayToKey = weekDayToKey;
37
- exports.ET_IANA = luxon_1.IANAZone.create("America/New_York");