@gainsnetwork/sdk 1.8.8-rc3 → 1.8.8
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.
|
@@ -18,60 +18,79 @@ const partial = (year, month, day, name, startH, startM, endH, endM) => ({
|
|
|
18
18
|
});
|
|
19
19
|
// Shared holidays
|
|
20
20
|
const HOLIDAYS = [
|
|
21
|
-
// 2025
|
|
22
|
-
full(2025, 5, 26, "Memorial Day"),
|
|
23
|
-
full(2025, 6, 19, "Juneteenth"),
|
|
24
|
-
partial(2025, 7, 3, "Day Before Independence Day", 9, 30, 13, 0),
|
|
25
|
-
full(2025, 7, 4, "Independence Day"),
|
|
26
|
-
full(2025, 9, 1, "Labor Day"),
|
|
27
|
-
full(2025, 11, 27, "Thanksgiving Day"),
|
|
28
|
-
partial(2025, 11, 28, "Black Friday", 9, 30, 13, 0),
|
|
29
|
-
full(2025, 12, 25, "Christmas Day"),
|
|
30
|
-
// 2026
|
|
31
|
-
full(2026, 1, 1, "New Year's Day"),
|
|
32
|
-
full(2026, 1, 19, "Martin Luther King Jr. Day"),
|
|
33
21
|
full(2026, 4, 3, "Good Friday"),
|
|
22
|
+
full(2026, 5, 25, "Memorial Day"),
|
|
23
|
+
full(2026, 6, 19, "Juneteenth"),
|
|
24
|
+
partial(2026, 7, 2, "Day Before Independence Day", 9, 30, 13, 0),
|
|
25
|
+
full(2026, 7, 3, "Independence Day"),
|
|
26
|
+
full(2026, 9, 7, "Labor Day"),
|
|
27
|
+
full(2026, 11, 26, "Thanksgiving Day"),
|
|
28
|
+
partial(2026, 11, 27, "Black Friday", 9, 30, 13, 0),
|
|
29
|
+
full(2026, 12, 25, "Christmas Day"),
|
|
30
|
+
// 2027
|
|
31
|
+
full(2027, 1, 1, "New Year's Day"),
|
|
32
|
+
full(2027, 1, 18, "Martin Luther King Jr. Day"),
|
|
33
|
+
full(2027, 3, 26, "Good Friday"),
|
|
34
|
+
full(2027, 5, 31, "Memorial Day"),
|
|
35
|
+
full(2027, 6, 18, "Juneteenth"),
|
|
36
|
+
full(2027, 7, 5, "Independence Day"),
|
|
37
|
+
full(2027, 9, 6, "Labor Day"),
|
|
38
|
+
full(2027, 11, 25, "Thanksgiving Day"),
|
|
39
|
+
partial(2027, 11, 26, "Black Friday", 9, 30, 13, 0),
|
|
40
|
+
full(2027, 12, 24, "Christmas Day"),
|
|
34
41
|
];
|
|
35
42
|
// Market-specific holiday overrides
|
|
36
43
|
const HOLIDAYS_OVERRIDES = {
|
|
37
44
|
stocks: [
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
// 2026
|
|
46
|
+
partial(2026, 12, 24, "Christmas Eve", 9, 30, 13, 0),
|
|
47
|
+
// 2027
|
|
48
|
+
full(2027, 2, 15, "Presidents' Day"),
|
|
40
49
|
],
|
|
41
50
|
indices: [
|
|
42
|
-
|
|
43
|
-
partial(
|
|
44
|
-
|
|
51
|
+
// 2026
|
|
52
|
+
partial(2026, 12, 24, "Christmas Eve", 9, 30, 12, 15),
|
|
53
|
+
partial(2026, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
54
|
+
// 2027
|
|
55
|
+
full(2027, 2, 15, "Presidents' Day"),
|
|
56
|
+
partial(2027, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
45
57
|
],
|
|
46
58
|
commodities: [
|
|
47
|
-
//
|
|
59
|
+
// 2026
|
|
60
|
+
partial(2026, 4, 2, "Maundy Thursday", 0, 0, 13, 0),
|
|
61
|
+
partial(2026, 12, 24, "Christmas Eve", 0, 0, 12, 45),
|
|
62
|
+
partial(2026, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
63
|
+
// 2027
|
|
64
|
+
// MLK Jr. Day: Open until 1 PM ET, closed 1-6 PM, reopens 6 PM
|
|
48
65
|
{
|
|
49
|
-
year:
|
|
66
|
+
year: 2027,
|
|
50
67
|
month: 1,
|
|
51
|
-
day:
|
|
68
|
+
day: 18,
|
|
52
69
|
name: "Martin Luther King Jr. Day",
|
|
53
70
|
openWindows: [
|
|
54
71
|
{ start: { hour: 0, minute: 0 }, end: { hour: 13, minute: 0 } },
|
|
55
72
|
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } },
|
|
56
73
|
],
|
|
57
74
|
},
|
|
58
|
-
|
|
59
|
-
partial(2025, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
60
|
-
// Presidents' Day: Open until 2:30 ET, closed from 2:30-6 PM ET, then reopens at 6 PM ET
|
|
75
|
+
// Presidents' Day: Open until 2:30 PM ET, closed 2:30-6 PM, reopens 6 PM
|
|
61
76
|
{
|
|
62
|
-
year:
|
|
77
|
+
year: 2027,
|
|
63
78
|
month: 2,
|
|
64
|
-
day:
|
|
79
|
+
day: 15,
|
|
65
80
|
name: "Presidents' Day",
|
|
66
81
|
openWindows: [
|
|
67
82
|
{ start: { hour: 0, minute: 0 }, end: { hour: 14, minute: 30 } },
|
|
68
83
|
{ start: { hour: 18, minute: 0 }, end: { hour: 24, minute: 0 } },
|
|
69
84
|
],
|
|
70
85
|
},
|
|
86
|
+
partial(2027, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
71
87
|
],
|
|
72
88
|
forex: [
|
|
73
|
-
|
|
74
|
-
partial(
|
|
89
|
+
// 2026
|
|
90
|
+
partial(2026, 12, 24, "Christmas Eve", 0, 0, 12, 45),
|
|
91
|
+
partial(2026, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
92
|
+
// 2027
|
|
93
|
+
partial(2027, 12, 31, "New Year's Eve", 0, 0, 16, 0),
|
|
75
94
|
],
|
|
76
95
|
};
|
|
77
96
|
const getHolidaysForYear = (market, year) => {
|
package/lib/trade/pnl/index.js
CHANGED
|
@@ -271,8 +271,11 @@ const getPriceForTargetPnlPercentage = (targetPnlPercent, trade, tradeInfo, cont
|
|
|
271
271
|
const totalHoldingFees = fees.fundingFeeCollateral +
|
|
272
272
|
fees.borrowingFeeCollateral +
|
|
273
273
|
fees.borrowingFeeCollateral_old;
|
|
274
|
+
const { totalRealizedPnlCollateral } = context.tradeData?.tradeFeesData
|
|
275
|
+
? (0, exports.getTradeRealizedPnlCollateral)(context.tradeData.tradeFeesData)
|
|
276
|
+
: { totalRealizedPnlCollateral: 0 };
|
|
274
277
|
const targetPnlInCollateral = (collateralAmount * targetPnlPercent) / 100;
|
|
275
|
-
let targetPnlGross = targetPnlInCollateral + totalHoldingFees;
|
|
278
|
+
let targetPnlGross = targetPnlInCollateral + totalHoldingFees - totalRealizedPnlCollateral;
|
|
276
279
|
if (netPnl) {
|
|
277
280
|
// Include closing fees
|
|
278
281
|
const closingFee = (0, trading_1.getTotalTradeFeesCollateral)(trade.collateralIndex, trade.user, trade.pairIndex, positionSizeCollateral, trade.isCounterTrade || false, {
|