@gainsnetwork/sdk 1.6.7 → 1.6.8-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.
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/contracts/utils/pairs.js +1 -0
- package/lib/markets/schedules/builders.js +11 -13
- package/lib/markets/schedules/checkers.js +1 -1
- package/lib/markets/schedules/holidays.d.ts +1 -3
- package/lib/markets/schedules/holidays.js +39 -58
- package/lib/markets/schedules/index.d.ts +0 -1
- package/lib/markets/schedules/index.js +1 -4
- package/lib/markets/schedules/types.d.ts +0 -1
- package/lib/trade/types.d.ts +2 -1
- package/lib/trade/types.js +1 -0
- package/package.json +1 -1
package/lib/constants.d.ts
CHANGED
|
@@ -440,6 +440,7 @@ export declare const pairs: {
|
|
|
440
440
|
"USA30/USD": string;
|
|
441
441
|
"NFLX_1/USD": string;
|
|
442
442
|
"STABLE/USD": string;
|
|
443
|
+
"VOOI/USD": string;
|
|
443
444
|
};
|
|
444
445
|
export declare const syntheticPairs: Set<string>;
|
|
445
446
|
export declare const parentToSyntheticPairMap: Map<string, string>;
|
package/lib/constants.js
CHANGED
|
@@ -448,6 +448,7 @@ exports.pairs = {
|
|
|
448
448
|
"USA30/USD": INDICES,
|
|
449
449
|
"NFLX_1/USD": STOCKS,
|
|
450
450
|
"STABLE/USD": CRYPTO,
|
|
451
|
+
"VOOI/USD": CRYPTO,
|
|
451
452
|
};
|
|
452
453
|
exports.syntheticPairs = new Set([
|
|
453
454
|
"BTCDEGEN/USD",
|
|
@@ -504,7 +505,7 @@ exports.delistedPairIxs = new Set([
|
|
|
504
505
|
272, 273, 275, 276, 278, 279, 280, 281, 284, 285, 290, 291, 292, 294, 296, 303,
|
|
505
506
|
305, 306, 311, 312, 322, 323, 330, 333, 335, 336, 337, 342, 343, 344, 346, 347,
|
|
506
507
|
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,
|
|
508
|
+
396, 400, 401, 408, 423, 427, 428, 430, 435, 436, 437, 438, 441,
|
|
508
509
|
]);
|
|
509
510
|
exports.delistedGroupsIxs = new Set([]);
|
|
510
511
|
exports.DEFAULT_PROTECTION_CLOSE_FACTOR = 1;
|
|
@@ -594,4 +594,5 @@ const PAIR_INDEX_TO_DESCRIPTION = {
|
|
|
594
594
|
[types_1.PairIndex.USA30USD]: "Down Jones 30 to US Dollar",
|
|
595
595
|
[types_1.PairIndex.NFLXUSD2]: "Netflix to US Dollar",
|
|
596
596
|
[types_1.PairIndex.STABLEUSD]: "Stable to US Dollar",
|
|
597
|
+
[types_1.PairIndex.VOOIUSD]: "VOOI to US Dollar",
|
|
597
598
|
};
|
|
@@ -40,11 +40,10 @@ const buildForexWeeklySchedule = (currentDate = new Date(), opts) => {
|
|
|
40
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
41
|
add(lowLiq, d, { start: { hour: llStartHour, minute: llStartMinute }, end: { hour: llEndHour, minute: llEndMinute } });
|
|
42
42
|
}
|
|
43
|
-
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)('forex', currentDate);
|
|
44
43
|
const summary = isInDST
|
|
45
44
|
? 'Monday 4:00 pm - Friday 4:00 pm ET (Closed weekends & holidays)'
|
|
46
45
|
: 'Monday 5:00 pm - Friday 5:00 pm ET (Closed weekends & holidays)';
|
|
47
|
-
return { open, lowLiq,
|
|
46
|
+
return { open, lowLiq, summary };
|
|
48
47
|
};
|
|
49
48
|
exports.buildForexWeeklySchedule = buildForexWeeklySchedule;
|
|
50
49
|
const buildStocksWeeklySchedule = (currentDate = new Date()) => {
|
|
@@ -53,7 +52,7 @@ const buildStocksWeeklySchedule = (currentDate = new Date()) => {
|
|
|
53
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]) {
|
|
54
53
|
add(open, d, { start: { hour: 9, minute: 30 }, end: { hour: 16, minute: 0 } });
|
|
55
54
|
}
|
|
56
|
-
const holidays = (0, holidays_1.
|
|
55
|
+
const holidays = (0, holidays_1.getStocksHolidaysInWeek)(currentDate);
|
|
57
56
|
const summary = 'Monday - Friday: 9:30 am - 4:00 pm ET (Closed weekends & holidays)';
|
|
58
57
|
return { open, lowLiq, holidays, summary };
|
|
59
58
|
};
|
|
@@ -63,18 +62,17 @@ exports.buildIndicesWeeklySchedule = buildIndicesWeeklySchedule;
|
|
|
63
62
|
const buildCommoditiesWeeklySchedule = (currentDate = new Date()) => {
|
|
64
63
|
const open = emptyWeekly();
|
|
65
64
|
const lowLiq = emptyWeekly();
|
|
66
|
-
// Sunday:
|
|
67
|
-
add(open, types_1.WeekDay.Sunday, { start: { hour:
|
|
68
|
-
// Mon-Thu: 0:00 ->
|
|
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)
|
|
69
68
|
for (const d of [types_1.WeekDay.Monday, types_1.WeekDay.Tuesday, types_1.WeekDay.Wednesday, types_1.WeekDay.Thursday]) {
|
|
70
|
-
add(open, d, { start: { hour: 0, minute: 0 }, end: { hour:
|
|
71
|
-
add(open, d, { start: { hour: 18, minute:
|
|
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 } });
|
|
72
71
|
}
|
|
73
|
-
// Friday: 0:00 ->
|
|
74
|
-
add(open, types_1.WeekDay.Friday, { start: { hour: 0, minute: 0 }, end: { hour:
|
|
72
|
+
// Friday: 0:00 -> 16:30
|
|
73
|
+
add(open, types_1.WeekDay.Friday, { start: { hour: 0, minute: 0 }, end: { hour: 16, minute: 30 } });
|
|
75
74
|
// Saturday: closed (no windows)
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
return { open, lowLiq, holidays, summary };
|
|
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 };
|
|
79
77
|
};
|
|
80
78
|
exports.buildCommoditiesWeeklySchedule = buildCommoditiesWeeklySchedule;
|
|
@@ -19,7 +19,7 @@ const isOpenAt = (market, date, opts) => {
|
|
|
19
19
|
const dayKey = weekdayKey(dt.weekday);
|
|
20
20
|
const mm = dt.hour * 60 + dt.minute;
|
|
21
21
|
// Holiday override: if this ET date has a holiday entry, use its openWindows
|
|
22
|
-
const holiday = schedule.holidays?.find(x => x.
|
|
22
|
+
const holiday = schedule.holidays?.find(x => x.month === dt.month && x.day === dt.day);
|
|
23
23
|
if (holiday) {
|
|
24
24
|
return inInAnyWindow(mm, holiday.openWindows);
|
|
25
25
|
}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import { Holiday } from "./types";
|
|
2
|
-
|
|
3
|
-
export declare const getHolidays: (market: TradFiMarket, startDate: Date, days: number) => Holiday[];
|
|
4
|
-
export declare const getHolidaysInCurrentWeek: (market: TradFiMarket, currentDate: Date) => Holiday[];
|
|
2
|
+
export declare function getStocksHolidaysInWeek(currentDate: Date): Holiday[];
|
|
@@ -1,63 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getStocksHolidaysInWeek = void 0;
|
|
4
4
|
const luxon_1 = require("luxon");
|
|
5
5
|
const ET = luxon_1.IANAZone.create("America/New_York");
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// 2026
|
|
20
|
-
full(2026, 1, 1, "New Year's Day"),
|
|
21
|
-
full(2026, 1, 19, "Martin Luther King Jr. Day"),
|
|
22
|
-
full(2026, 2, 16, "Presidents' Day"),
|
|
23
|
-
full(2026, 4, 3, "Good Friday"),
|
|
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)] },
|
|
24
19
|
];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
for (let year = start.year; year <= end.year; year++) {
|
|
51
|
-
years.push(year);
|
|
52
|
-
}
|
|
53
|
-
return years.flatMap(year => getHolidaysForYear(market, year).filter(h => {
|
|
54
|
-
const d = luxon_1.DateTime.fromObject({ year: h.year, month: h.month, day: h.day }, { zone: ET });
|
|
55
|
-
return d >= start && d < end;
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
exports.getHolidays = getHolidays;
|
|
59
|
-
const getHolidaysInCurrentWeek = (market, currentDate) => {
|
|
60
|
-
const weekStart = luxon_1.DateTime.fromJSDate(currentDate).setZone(ET).startOf("week");
|
|
61
|
-
return (0, exports.getHolidays)(market, weekStart.toJSDate(), 7);
|
|
62
|
-
};
|
|
63
|
-
exports.getHolidaysInCurrentWeek = getHolidaysInCurrentWeek;
|
|
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,7 +1,6 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export { buildForexWeeklySchedule, buildStocksWeeklySchedule, buildIndicesWeeklySchedule, buildCommoditiesWeeklySchedule, } from "./builders";
|
|
3
3
|
export { isOpenAt, isLowLiquidityAt } from "./checkers";
|
|
4
|
-
export { getHolidays, getHolidaysInCurrentWeek } from "./holidays";
|
|
5
4
|
import { Schedule } from "./types";
|
|
6
5
|
export type TradFiMarket = "forex" | "stocks" | "indices" | "commodities";
|
|
7
6
|
export declare const getWeeklySchedule: (market: TradFiMarket, currentDate?: Date, opts?: {
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getWeeklySchedule = exports.
|
|
17
|
+
exports.getWeeklySchedule = exports.isLowLiquidityAt = exports.isOpenAt = exports.buildCommoditiesWeeklySchedule = exports.buildIndicesWeeklySchedule = exports.buildStocksWeeklySchedule = exports.buildForexWeeklySchedule = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
var builders_1 = require("./builders");
|
|
20
20
|
Object.defineProperty(exports, "buildForexWeeklySchedule", { enumerable: true, get: function () { return builders_1.buildForexWeeklySchedule; } });
|
|
@@ -24,9 +24,6 @@ Object.defineProperty(exports, "buildCommoditiesWeeklySchedule", { enumerable: t
|
|
|
24
24
|
var checkers_1 = require("./checkers");
|
|
25
25
|
Object.defineProperty(exports, "isOpenAt", { enumerable: true, get: function () { return checkers_1.isOpenAt; } });
|
|
26
26
|
Object.defineProperty(exports, "isLowLiquidityAt", { enumerable: true, get: function () { return checkers_1.isLowLiquidityAt; } });
|
|
27
|
-
var holidays_1 = require("./holidays");
|
|
28
|
-
Object.defineProperty(exports, "getHolidays", { enumerable: true, get: function () { return holidays_1.getHolidays; } });
|
|
29
|
-
Object.defineProperty(exports, "getHolidaysInCurrentWeek", { enumerable: true, get: function () { return holidays_1.getHolidaysInCurrentWeek; } });
|
|
30
27
|
const builders_2 = require("./builders");
|
|
31
28
|
const getWeeklySchedule = (market, currentDate = new Date(), opts) => {
|
|
32
29
|
switch (market) {
|
package/lib/trade/types.d.ts
CHANGED
package/lib/trade/types.js
CHANGED
|
@@ -470,4 +470,5 @@ var PairIndex;
|
|
|
470
470
|
PairIndex[PairIndex["USA30USD"] = 438] = "USA30USD";
|
|
471
471
|
PairIndex[PairIndex["NFLXUSD2"] = 439] = "NFLXUSD2";
|
|
472
472
|
PairIndex[PairIndex["STABLEUSD"] = 440] = "STABLEUSD";
|
|
473
|
+
PairIndex[PairIndex["VOOIUSD"] = 441] = "VOOIUSD";
|
|
473
474
|
})(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
|