@gainsnetwork/sdk 1.8.5 → 1.8.7
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 +8 -1
- package/lib/markets/classification.d.ts +9 -0
- package/lib/markets/classification.js +41 -0
- package/lib/markets/commodities.js +1 -1
- package/lib/markets/forex.js +4 -2
- package/lib/markets/index.d.ts +1 -0
- package/lib/markets/index.js +1 -0
- package/lib/markets/indices.js +1 -1
- package/lib/markets/schedules/builders.d.ts +1 -1
- package/lib/markets/schedules/builders.js +83 -28
- package/lib/markets/schedules/checkers.js +2 -2
- package/lib/markets/schedules/holidays.js +20 -7
- package/lib/markets/stocks.js +1 -1
- package/lib/trade/fees/borrowingV2/fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/lib/contracts/types/generated/GFarmTradingStorageV5.d.ts +0 -1911
- package/lib/contracts/types/generated/GFarmTradingStorageV5.js +0 -2
- package/lib/contracts/types/generated/GNSBorrowingFees.d.ts +0 -1067
- package/lib/contracts/types/generated/GNSBorrowingFees.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6.d.ts +0 -533
- package/lib/contracts/types/generated/GNSNftRewardsV6.js +0 -2
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.d.ts +0 -613
- package/lib/contracts/types/generated/GNSNftRewardsV6_3_1.js +0 -2
- package/lib/contracts/types/generated/GNSTrading.d.ts +0 -758
- package/lib/contracts/types/generated/GNSTrading.js +0 -2
- package/lib/contracts/types/generated/GNSTradingCallbacks.d.ts +0 -875
- package/lib/contracts/types/generated/GNSTradingCallbacks.js +0 -2
- package/lib/contracts/types/generated/GNSTradingStorage.d.ts +0 -1387
- package/lib/contracts/types/generated/GNSTradingStorage.js +0 -2
- package/lib/contracts/types/generated/GTokenV6_3_2.d.ts +0 -1838
- package/lib/contracts/types/generated/GTokenV6_3_2.js +0 -2
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.d.ts +0 -83
- package/lib/contracts/types/generated/factories/GFarmTradingStorageV5__factory.js +0 -2691
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.d.ts +0 -124
- package/lib/contracts/types/generated/factories/GNSBorrowingFees__factory.js +0 -1784
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6_3_1__factory.js +0 -1116
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.d.ts +0 -100
- package/lib/contracts/types/generated/factories/GNSNftRewardsV6__factory.js +0 -1003
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.d.ts +0 -113
- package/lib/contracts/types/generated/factories/GNSTradingCallbacks__factory.js +0 -1428
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.d.ts +0 -96
- package/lib/contracts/types/generated/factories/GNSTradingStorage__factory.js +0 -2241
- package/lib/contracts/types/generated/factories/GNSTrading__factory.d.ts +0 -95
- package/lib/contracts/types/generated/factories/GNSTrading__factory.js +0 -1071
- package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.d.ts +0 -110
- package/lib/contracts/types/generated/factories/GTokenV6_3_2__factory.js +0 -2682
package/lib/constants.d.ts
CHANGED
|
@@ -483,6 +483,7 @@ export declare const stockSplits: {
|
|
|
483
483
|
split: number;
|
|
484
484
|
};
|
|
485
485
|
};
|
|
486
|
+
export declare const corePairIndices: Set<number>;
|
|
486
487
|
export declare const delistedPairIxs: Set<number>;
|
|
487
488
|
export declare const delistedGroupsIxs: Set<never>;
|
|
488
489
|
export declare const DEFAULT_PROTECTION_CLOSE_FACTOR = 1;
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_CUMULATIVE_FACTOR = exports.DEFAULT_PROTECTION_CLOSE_FACTOR = exports.delistedGroupsIxs = exports.delistedPairIxs = exports.stockSplits = exports.tickerChanges = exports.getAssetClassFromGroupIndex = exports.parentToSyntheticPairMap = exports.syntheticPairs = exports.pairs = void 0;
|
|
3
|
+
exports.DEFAULT_CUMULATIVE_FACTOR = exports.DEFAULT_PROTECTION_CLOSE_FACTOR = exports.delistedGroupsIxs = exports.delistedPairIxs = exports.corePairIndices = exports.stockSplits = exports.tickerChanges = exports.getAssetClassFromGroupIndex = exports.parentToSyntheticPairMap = exports.syntheticPairs = exports.pairs = void 0;
|
|
4
4
|
const CRYPTO = "crypto";
|
|
5
5
|
const FOREX = "forex";
|
|
6
6
|
const STOCKS = "stocks";
|
|
@@ -506,6 +506,13 @@ exports.stockSplits = {
|
|
|
506
506
|
"TSLA_1/USD": { date: "8/25/2022", split: 3 },
|
|
507
507
|
"NFLX_1/USD": { date: "11/17/2025", split: 10 },
|
|
508
508
|
};
|
|
509
|
+
exports.corePairIndices = new Set([
|
|
510
|
+
0, 1, 2, 3, 5, 7, 8, 11, 12, 13, 17, 18, 19, 20, 33, 35, 39, 40, 41, 44, 47,
|
|
511
|
+
49, 50, 57, 90, 91, 102, 103, 104, 105, 107, 109, 129, 134, 137, 138, 139,
|
|
512
|
+
140, 141, 142, 144, 145, 153, 155, 159, 168, 171, 188, 189, 190, 191, 193,
|
|
513
|
+
205, 215, 216, 217, 219, 223, 269, 299, 307, 320, 321, 328, 331, 332, 347,
|
|
514
|
+
358, 407, 413, 414, 418, 442,
|
|
515
|
+
]);
|
|
509
516
|
exports.delistedPairIxs = new Set([
|
|
510
517
|
4, 6, 12, 15, 24, 25, 27, 28, 30, 31, 36, 41, 52, 53, 54, 59, 60, 61, 63, 66,
|
|
511
518
|
67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 95, 96, 97, 98, 99, 101, 106,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const MARKET_TYPE: {
|
|
2
|
+
readonly CORE: "core";
|
|
3
|
+
readonly VOLATILE: "volatile";
|
|
4
|
+
readonly REGULAR: "regular";
|
|
5
|
+
};
|
|
6
|
+
export type MarketType = typeof MARKET_TYPE[keyof typeof MARKET_TYPE];
|
|
7
|
+
export declare const NO_FUTURES_CRYPTO_INDICES: Set<number>;
|
|
8
|
+
export declare function getMarketType(pairIndex: number): MarketType;
|
|
9
|
+
export declare function getMarketTypeByPairId(pairId: string): MarketType;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMarketTypeByPairId = exports.getMarketType = exports.NO_FUTURES_CRYPTO_INDICES = exports.MARKET_TYPE = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const CRYPTO = "crypto";
|
|
6
|
+
exports.MARKET_TYPE = {
|
|
7
|
+
CORE: "core",
|
|
8
|
+
VOLATILE: "volatile",
|
|
9
|
+
REGULAR: "regular",
|
|
10
|
+
};
|
|
11
|
+
exports.NO_FUTURES_CRYPTO_INDICES = new Set([
|
|
12
|
+
132, 195, 240, 300, 313, 314, 326, 327, 384, 385, 411, 445,
|
|
13
|
+
]);
|
|
14
|
+
const pairEntries = Object.entries(constants_1.pairs);
|
|
15
|
+
const pairIdToMarketType = new Map();
|
|
16
|
+
function getMarketType(pairIndex) {
|
|
17
|
+
if (constants_1.corePairIndices.has(pairIndex)) {
|
|
18
|
+
return exports.MARKET_TYPE.CORE;
|
|
19
|
+
}
|
|
20
|
+
const entry = pairEntries[pairIndex];
|
|
21
|
+
if (!entry) {
|
|
22
|
+
return exports.MARKET_TYPE.REGULAR;
|
|
23
|
+
}
|
|
24
|
+
const assetClass = entry[1];
|
|
25
|
+
if (assetClass !== CRYPTO) {
|
|
26
|
+
return exports.MARKET_TYPE.REGULAR;
|
|
27
|
+
}
|
|
28
|
+
if (exports.NO_FUTURES_CRYPTO_INDICES.has(pairIndex)) {
|
|
29
|
+
return exports.MARKET_TYPE.REGULAR;
|
|
30
|
+
}
|
|
31
|
+
return exports.MARKET_TYPE.VOLATILE;
|
|
32
|
+
}
|
|
33
|
+
exports.getMarketType = getMarketType;
|
|
34
|
+
// Build pairId lookup
|
|
35
|
+
for (let i = 0; i < pairEntries.length; i++) {
|
|
36
|
+
pairIdToMarketType.set(pairEntries[i][0], getMarketType(i));
|
|
37
|
+
}
|
|
38
|
+
function getMarketTypeByPairId(pairId) {
|
|
39
|
+
return pairIdToMarketType.get(pairId) ?? exports.MARKET_TYPE.REGULAR;
|
|
40
|
+
}
|
|
41
|
+
exports.getMarketTypeByPairId = getMarketTypeByPairId;
|
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isCommoditiesOpen = void 0;
|
|
4
4
|
// @ts-ignore-file
|
|
5
5
|
const schedules_1 = require("./schedules");
|
|
6
|
-
const isCommoditiesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)(
|
|
6
|
+
const isCommoditiesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)("commodities", dateToCheck);
|
|
7
7
|
exports.isCommoditiesOpen = isCommoditiesOpen;
|
package/lib/markets/forex.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isForexLowLiquidity = exports.isForexOpen = void 0;
|
|
4
4
|
const schedules_1 = require("./schedules");
|
|
5
|
-
const isForexOpen = (dateToCheck) => (0, schedules_1.isOpenAt)(
|
|
5
|
+
const isForexOpen = (dateToCheck) => (0, schedules_1.isOpenAt)("forex", dateToCheck);
|
|
6
6
|
exports.isForexOpen = isForexOpen;
|
|
7
|
-
const isForexLowLiquidity = (timestampToCheck, pair) => (0, schedules_1.isLowLiquidityAt)(
|
|
7
|
+
const isForexLowLiquidity = (timestampToCheck, pair) => (0, schedules_1.isLowLiquidityAt)("forex", new Date(timestampToCheck), pair?.groupIndex !== undefined
|
|
8
|
+
? { pairGroupIndex: +pair.groupIndex }
|
|
9
|
+
: undefined);
|
|
8
10
|
exports.isForexLowLiquidity = isForexLowLiquidity;
|
package/lib/markets/index.d.ts
CHANGED
package/lib/markets/index.js
CHANGED
package/lib/markets/indices.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isIndicesOpen = void 0;
|
|
4
4
|
const schedules_1 = require("./schedules");
|
|
5
|
-
const isIndicesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)(
|
|
5
|
+
const isIndicesOpen = (dateToCheck) => (0, schedules_1.isOpenAt)("indices", dateToCheck);
|
|
6
6
|
exports.isIndicesOpen = isIndicesOpen;
|
|
@@ -4,7 +4,7 @@ exports.buildCommoditiesWeeklySchedule = exports.buildIndicesWeeklySchedule = ex
|
|
|
4
4
|
const luxon_1 = require("luxon");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const holidays_1 = require("./holidays");
|
|
7
|
-
const ET = luxon_1.IANAZone.create(
|
|
7
|
+
const ET = luxon_1.IANAZone.create("America/New_York");
|
|
8
8
|
const emptyWeekly = () => ({
|
|
9
9
|
monday: [],
|
|
10
10
|
tuesday: [],
|
|
@@ -25,37 +25,75 @@ const buildForexWeeklySchedule = (currentDate = new Date(), opts) => {
|
|
|
25
25
|
const openHour = isInDST ? 16 : 17; // Monday open
|
|
26
26
|
const closeHour = isInDST ? 16 : 17; // Friday close
|
|
27
27
|
// Open windows (ET): Sun 16/17:00 -> 24:00, Mon-Thu 0-24, Fri 0 -> 16/17:00
|
|
28
|
-
add(open, types_1.WeekDay.Sunday, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
add(open, types_1.WeekDay.
|
|
33
|
-
|
|
28
|
+
add(open, types_1.WeekDay.Sunday, {
|
|
29
|
+
start: { hour: openHour, minute: 0 },
|
|
30
|
+
end: { hour: 24, minute: 0 },
|
|
31
|
+
});
|
|
32
|
+
add(open, types_1.WeekDay.Monday, {
|
|
33
|
+
start: { hour: 0, minute: 0 },
|
|
34
|
+
end: { hour: 24, minute: 0 },
|
|
35
|
+
});
|
|
36
|
+
add(open, types_1.WeekDay.Tuesday, {
|
|
37
|
+
start: { hour: 0, minute: 0 },
|
|
38
|
+
end: { hour: 24, minute: 0 },
|
|
39
|
+
});
|
|
40
|
+
add(open, types_1.WeekDay.Wednesday, {
|
|
41
|
+
start: { hour: 0, minute: 0 },
|
|
42
|
+
end: { hour: 24, minute: 0 },
|
|
43
|
+
});
|
|
44
|
+
add(open, types_1.WeekDay.Thursday, {
|
|
45
|
+
start: { hour: 0, minute: 0 },
|
|
46
|
+
end: { hour: 24, minute: 0 },
|
|
47
|
+
});
|
|
48
|
+
add(open, types_1.WeekDay.Friday, {
|
|
49
|
+
start: { hour: 0, minute: 0 },
|
|
50
|
+
end: { hour: closeHour, minute: 0 },
|
|
51
|
+
});
|
|
34
52
|
// Low-liquidity windows (ET)
|
|
35
53
|
const extendedGroups = [8, 9];
|
|
36
|
-
const useExtended = opts?.pairGroupIndex !== undefined &&
|
|
37
|
-
|
|
54
|
+
const useExtended = opts?.pairGroupIndex !== undefined &&
|
|
55
|
+
extendedGroups.includes(+opts.pairGroupIndex);
|
|
56
|
+
const llStartHour = isInDST ? (useExtended ? 14 : 15) : useExtended ? 15 : 16;
|
|
38
57
|
const llStartMinute = 45;
|
|
39
|
-
const llEndHour = isInDST ? (useExtended ? 21 : 19) :
|
|
58
|
+
const llEndHour = isInDST ? (useExtended ? 21 : 19) : useExtended ? 22 : 20;
|
|
40
59
|
const llEndMinute = 0;
|
|
41
|
-
for (const d of [
|
|
42
|
-
|
|
60
|
+
for (const d of [
|
|
61
|
+
types_1.WeekDay.Sunday,
|
|
62
|
+
types_1.WeekDay.Monday,
|
|
63
|
+
types_1.WeekDay.Tuesday,
|
|
64
|
+
types_1.WeekDay.Wednesday,
|
|
65
|
+
types_1.WeekDay.Thursday,
|
|
66
|
+
types_1.WeekDay.Friday,
|
|
67
|
+
]) {
|
|
68
|
+
add(lowLiq, d, {
|
|
69
|
+
start: { hour: llStartHour, minute: llStartMinute },
|
|
70
|
+
end: { hour: llEndHour, minute: llEndMinute },
|
|
71
|
+
});
|
|
43
72
|
}
|
|
44
|
-
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)(
|
|
73
|
+
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)("forex", currentDate);
|
|
45
74
|
const summary = isInDST
|
|
46
|
-
?
|
|
47
|
-
:
|
|
75
|
+
? "Sunday 4:00 pm - Friday 4:00 pm ET (Closed weekends & holidays)"
|
|
76
|
+
: "Sunday 5:00 pm - Friday 5:00 pm ET (Closed weekends & holidays)";
|
|
48
77
|
return { open, lowLiq, holidays, summary };
|
|
49
78
|
};
|
|
50
79
|
exports.buildForexWeeklySchedule = buildForexWeeklySchedule;
|
|
51
80
|
const buildStocksWeeklySchedule = (currentDate = new Date()) => {
|
|
52
81
|
const open = emptyWeekly();
|
|
53
82
|
const lowLiq = emptyWeekly();
|
|
54
|
-
for (const d of [
|
|
55
|
-
|
|
83
|
+
for (const d of [
|
|
84
|
+
types_1.WeekDay.Monday,
|
|
85
|
+
types_1.WeekDay.Tuesday,
|
|
86
|
+
types_1.WeekDay.Wednesday,
|
|
87
|
+
types_1.WeekDay.Thursday,
|
|
88
|
+
types_1.WeekDay.Friday,
|
|
89
|
+
]) {
|
|
90
|
+
add(open, d, {
|
|
91
|
+
start: { hour: 9, minute: 35 },
|
|
92
|
+
end: { hour: 16, minute: 0 },
|
|
93
|
+
});
|
|
56
94
|
}
|
|
57
|
-
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)(
|
|
58
|
-
const summary =
|
|
95
|
+
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)("stocks", currentDate);
|
|
96
|
+
const summary = "Monday - Friday: 9:35 am - 4:00 pm ET (Closed weekends & holidays)";
|
|
59
97
|
return { open, lowLiq, holidays, summary };
|
|
60
98
|
};
|
|
61
99
|
exports.buildStocksWeeklySchedule = buildStocksWeeklySchedule;
|
|
@@ -64,18 +102,35 @@ exports.buildIndicesWeeklySchedule = buildIndicesWeeklySchedule;
|
|
|
64
102
|
const buildCommoditiesWeeklySchedule = (currentDate = new Date()) => {
|
|
65
103
|
const open = emptyWeekly();
|
|
66
104
|
const lowLiq = emptyWeekly();
|
|
67
|
-
// Sunday: 18:
|
|
68
|
-
add(open, types_1.WeekDay.Sunday, {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
105
|
+
// Sunday: 18:10 -> 24:00
|
|
106
|
+
add(open, types_1.WeekDay.Sunday, {
|
|
107
|
+
start: { hour: 18, minute: 10 },
|
|
108
|
+
end: { hour: 24, minute: 0 },
|
|
109
|
+
});
|
|
110
|
+
// Mon-Thu: 0:00 -> 17:00 and 18:10 -> 24:00 (break represented by the gap)
|
|
111
|
+
for (const d of [
|
|
112
|
+
types_1.WeekDay.Monday,
|
|
113
|
+
types_1.WeekDay.Tuesday,
|
|
114
|
+
types_1.WeekDay.Wednesday,
|
|
115
|
+
types_1.WeekDay.Thursday,
|
|
116
|
+
]) {
|
|
117
|
+
add(open, d, {
|
|
118
|
+
start: { hour: 0, minute: 0 },
|
|
119
|
+
end: { hour: 17, minute: 0 },
|
|
120
|
+
});
|
|
121
|
+
add(open, d, {
|
|
122
|
+
start: { hour: 18, minute: 10 },
|
|
123
|
+
end: { hour: 24, minute: 0 },
|
|
124
|
+
});
|
|
73
125
|
}
|
|
74
126
|
// Friday: 0:00 -> 17:00
|
|
75
|
-
add(open, types_1.WeekDay.Friday, {
|
|
127
|
+
add(open, types_1.WeekDay.Friday, {
|
|
128
|
+
start: { hour: 0, minute: 0 },
|
|
129
|
+
end: { hour: 17, minute: 0 },
|
|
130
|
+
});
|
|
76
131
|
// Saturday: closed (no windows)
|
|
77
|
-
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)(
|
|
78
|
-
const summary = `Sunday 6:
|
|
132
|
+
const holidays = (0, holidays_1.getHolidaysInCurrentWeek)("commodities", currentDate);
|
|
133
|
+
const summary = `Sunday 6:10 pm - Friday 5:00 pm ET (Daily break: 5:00 pm - 6:10 pm ET)`;
|
|
79
134
|
return { open, lowLiq, holidays, summary };
|
|
80
135
|
};
|
|
81
136
|
exports.buildCommoditiesWeeklySchedule = buildCommoditiesWeeklySchedule;
|
|
@@ -23,7 +23,7 @@ const isOpenAt = (market, date, opts) => {
|
|
|
23
23
|
if (holiday) {
|
|
24
24
|
return inInAnyWindow(mm, holiday.openWindows);
|
|
25
25
|
}
|
|
26
|
-
return inInAnyWindow(mm,
|
|
26
|
+
return inInAnyWindow(mm, schedule.open[dayKey]);
|
|
27
27
|
};
|
|
28
28
|
exports.isOpenAt = isOpenAt;
|
|
29
29
|
const isLowLiquidityAt = (market, date, opts) => {
|
|
@@ -31,6 +31,6 @@ const isLowLiquidityAt = (market, date, opts) => {
|
|
|
31
31
|
const schedule = (0, index_1.getWeeklySchedule)(market, date, opts);
|
|
32
32
|
const dayKey = weekdayKey(dt.weekday);
|
|
33
33
|
const mm = dt.hour * 60 + dt.minute;
|
|
34
|
-
return inInAnyWindow(mm,
|
|
34
|
+
return inInAnyWindow(mm, schedule.lowLiq[dayKey]);
|
|
35
35
|
};
|
|
36
36
|
exports.isLowLiquidityAt = isLowLiquidityAt;
|
|
@@ -4,7 +4,18 @@ exports.getHolidaysInCurrentWeek = exports.getHolidays = void 0;
|
|
|
4
4
|
const luxon_1 = require("luxon");
|
|
5
5
|
const ET = luxon_1.IANAZone.create("America/New_York");
|
|
6
6
|
const full = (year, month, day, name) => ({ year, month, day, name, openWindows: [] });
|
|
7
|
-
const partial = (year, month, day, name, startH, startM, endH, endM) => ({
|
|
7
|
+
const partial = (year, month, day, name, startH, startM, endH, endM) => ({
|
|
8
|
+
year,
|
|
9
|
+
month,
|
|
10
|
+
day,
|
|
11
|
+
name,
|
|
12
|
+
openWindows: [
|
|
13
|
+
{
|
|
14
|
+
start: { hour: startH, minute: startM },
|
|
15
|
+
end: { hour: endH, minute: endM },
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
8
19
|
// Shared holidays
|
|
9
20
|
const HOLIDAYS = [
|
|
10
21
|
// 2025
|
|
@@ -41,8 +52,8 @@ const HOLIDAYS_OVERRIDES = {
|
|
|
41
52
|
name: "Martin Luther King Jr. Day",
|
|
42
53
|
openWindows: [
|
|
43
54
|
{ start: { hour: 0, minute: 0 }, end: { hour: 13, minute: 0 } },
|
|
44
|
-
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } }
|
|
45
|
-
]
|
|
55
|
+
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } },
|
|
56
|
+
],
|
|
46
57
|
},
|
|
47
58
|
partial(2025, 12, 24, "Christmas Eve", 0, 0, 12, 45),
|
|
48
59
|
partial(2025, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
@@ -54,8 +65,8 @@ const HOLIDAYS_OVERRIDES = {
|
|
|
54
65
|
name: "Presidents' Day",
|
|
55
66
|
openWindows: [
|
|
56
67
|
{ start: { hour: 0, minute: 0 }, end: { hour: 14, minute: 30 } },
|
|
57
|
-
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } }
|
|
58
|
-
]
|
|
68
|
+
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } },
|
|
69
|
+
],
|
|
59
70
|
},
|
|
60
71
|
],
|
|
61
72
|
forex: [
|
|
@@ -70,7 +81,7 @@ const getHolidaysForYear = (market, year) => {
|
|
|
70
81
|
return [...filteredHolidays, ...holidayOverrides].sort((a, b) => a.month === b.month ? a.day - b.day : a.month - b.month);
|
|
71
82
|
};
|
|
72
83
|
const getHolidays = (market, startDate, days) => {
|
|
73
|
-
const start = luxon_1.DateTime.fromJSDate(startDate).setZone(ET).startOf(
|
|
84
|
+
const start = luxon_1.DateTime.fromJSDate(startDate).setZone(ET).startOf("day");
|
|
74
85
|
const end = start.plus({ days });
|
|
75
86
|
const years = [];
|
|
76
87
|
for (let year = start.year; year <= end.year; year++) {
|
|
@@ -83,7 +94,9 @@ const getHolidays = (market, startDate, days) => {
|
|
|
83
94
|
};
|
|
84
95
|
exports.getHolidays = getHolidays;
|
|
85
96
|
const getHolidaysInCurrentWeek = (market, currentDate) => {
|
|
86
|
-
const weekStart = luxon_1.DateTime.fromJSDate(currentDate)
|
|
97
|
+
const weekStart = luxon_1.DateTime.fromJSDate(currentDate)
|
|
98
|
+
.setZone(ET)
|
|
99
|
+
.startOf("week");
|
|
87
100
|
return (0, exports.getHolidays)(market, weekStart.toJSDate(), 7);
|
|
88
101
|
};
|
|
89
102
|
exports.getHolidaysInCurrentWeek = getHolidaysInCurrentWeek;
|
package/lib/markets/stocks.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.getUSMarketsNow = exports.isStocksOpen = void 0;
|
|
|
7
7
|
const luxon_1 = require("luxon");
|
|
8
8
|
const schedules_1 = require("./schedules");
|
|
9
9
|
const STOCKS_MARKETS_TIME_ZONE_IANA = luxon_1.IANAZone.create("America/New_York");
|
|
10
|
-
const isStocksOpen = (dateToCheck) => (0, schedules_1.isOpenAt)(
|
|
10
|
+
const isStocksOpen = (dateToCheck) => (0, schedules_1.isOpenAt)("stocks", dateToCheck);
|
|
11
11
|
exports.isStocksOpen = isStocksOpen;
|
|
12
12
|
const getUSMarketsNow = () => {
|
|
13
13
|
return luxon_1.DateTime.now().setZone(STOCKS_MARKETS_TIME_ZONE_IANA);
|