@tradejs/node 3.1.27 → 3.1.28-beta.252
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/dist/ai.js +1 -0
- package/dist/ai.mjs +1 -1
- package/dist/backtest.d.mts +3 -1
- package/dist/backtest.d.ts +3 -1
- package/dist/backtest.js +287 -39
- package/dist/backtest.mjs +30 -16
- package/dist/{chunk-NQO2MFP6.mjs → chunk-K2YQ3MQC.mjs} +58 -10
- package/dist/{chunk-FB5NUEOQ.mjs → chunk-OFVUEYUR.mjs} +4 -1
- package/dist/{chunk-IKRSNRP6.mjs → chunk-UITD6LG6.mjs} +83 -4
- package/dist/{chunk-XHNJ757K.mjs → chunk-VQSGH7YA.mjs} +341 -22
- package/dist/cli.js +2 -1
- package/dist/cli.mjs +1 -1
- package/dist/{registry-DHTLjQcr.d.mts → registry-3TsO1Ff1.d.mts} +2 -2
- package/dist/{registry-DHTLjQcr.d.ts → registry-3TsO1Ff1.d.ts} +2 -2
- package/dist/registry.d.mts +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +260 -23
- package/dist/registry.mjs +2 -2
- package/dist/runtimeDashboard.js +378 -37
- package/dist/runtimeDashboard.mjs +54 -8
- package/dist/runtimeStrategies.d.mts +4 -1
- package/dist/runtimeStrategies.d.ts +4 -1
- package/dist/runtimeStrategies.js +327 -34
- package/dist/runtimeStrategies.mjs +3 -3
- package/dist/runtimeTrades.d.mts +2 -1
- package/dist/runtimeTrades.d.ts +2 -1
- package/dist/runtimeTrades.js +4 -1
- package/dist/runtimeTrades.mjs +1 -1
- package/dist/strategies.d.mts +14 -2
- package/dist/strategies.d.ts +14 -2
- package/dist/strategies.js +417 -24
- package/dist/strategies.mjs +4 -2
- package/package.json +5 -5
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listRuntimeDeployments,
|
|
3
3
|
loadResolvedRuntimeStrategies
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-K2YQ3MQC.mjs";
|
|
5
5
|
import {
|
|
6
6
|
buildExchangeFallbackRuntimeTrades,
|
|
7
7
|
takeClosedPnlMatch
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OFVUEYUR.mjs";
|
|
9
9
|
import {
|
|
10
10
|
getConnectorCreatorByProvider
|
|
11
11
|
} from "./chunk-QVKUROR2.mjs";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-VQSGH7YA.mjs";
|
|
13
|
+
import "./chunk-UITD6LG6.mjs";
|
|
14
14
|
import "./chunk-LZDXRXIU.mjs";
|
|
15
15
|
import "./chunk-Y6FXYEAI.mjs";
|
|
16
16
|
|
|
@@ -249,6 +249,32 @@ var MIN_HOURS = 6;
|
|
|
249
249
|
var MAX_HOURS = 24 * 90;
|
|
250
250
|
var BYBIT_MAX_TIME_RANGE_MS = 7 * 24 * 60 * 60 * 1e3 - 1e3;
|
|
251
251
|
var EXCHANGE_REQUEST_TIMEOUT_MS = 15e3;
|
|
252
|
+
var groupRuntimeTradesByIdentity = (trades, identities) => {
|
|
253
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
254
|
+
for (const trade of trades) {
|
|
255
|
+
const matches = [...identities.entries()].filter(([, identity]) => {
|
|
256
|
+
if (trade.strategy !== identity.strategyName || String(trade.interval) !== String(identity.interval)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
if (trade.deploymentId && trade.deploymentId !== identity.deploymentId) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (trade.accountId && trade.accountId !== identity.accountId) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
if (trade.universe && trade.universe !== identity.universe) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
return true;
|
|
269
|
+
});
|
|
270
|
+
if (matches.length !== 1) continue;
|
|
271
|
+
const [runtimeKey] = matches[0];
|
|
272
|
+
const bucket = grouped.get(runtimeKey) ?? [];
|
|
273
|
+
bucket.push(trade);
|
|
274
|
+
grouped.set(runtimeKey, bucket);
|
|
275
|
+
}
|
|
276
|
+
return grouped;
|
|
277
|
+
};
|
|
252
278
|
var coerceHours = (value) => {
|
|
253
279
|
const parsed = Number(value ?? Number.NaN);
|
|
254
280
|
if (!Number.isFinite(parsed)) {
|
|
@@ -579,6 +605,7 @@ var loadRuntimeDashboard = async ({
|
|
|
579
605
|
const syncedTrades = [...unsyncedTrades, ...syncedConnectorTrades];
|
|
580
606
|
const fallbackTrades = [];
|
|
581
607
|
for (const {
|
|
608
|
+
connector,
|
|
582
609
|
strategyNames,
|
|
583
610
|
entryRows,
|
|
584
611
|
closedPnlRows,
|
|
@@ -591,7 +618,12 @@ var loadRuntimeDashboard = async ({
|
|
|
591
618
|
openPositions: openPositionsSnapshot.positions,
|
|
592
619
|
strategyNames,
|
|
593
620
|
existingTrades: [...syncedTrades, ...fallbackTrades],
|
|
594
|
-
endTime
|
|
621
|
+
endTime,
|
|
622
|
+
scope: {
|
|
623
|
+
accountId: connector.accountId,
|
|
624
|
+
deploymentId: connector.deploymentId,
|
|
625
|
+
universe: connector.universe
|
|
626
|
+
}
|
|
595
627
|
})
|
|
596
628
|
);
|
|
597
629
|
}
|
|
@@ -634,6 +666,9 @@ var loadRuntimeDashboard = async ({
|
|
|
634
666
|
});
|
|
635
667
|
identityByKey.set(runtimeKey, {
|
|
636
668
|
strategyName: resolvedStrategy.strategyName,
|
|
669
|
+
strategyModule: resolvedStrategy.strategyModule,
|
|
670
|
+
strategyPackage: resolvedStrategy.strategyPackage,
|
|
671
|
+
strategyPackageVersion: resolvedStrategy.strategyPackageVersion,
|
|
637
672
|
configId: strategyConfigId,
|
|
638
673
|
strategyRevision: resolvedStrategy.strategyRevision,
|
|
639
674
|
controlState: resolvedStrategy.controlState,
|
|
@@ -642,6 +677,8 @@ var loadRuntimeDashboard = async ({
|
|
|
642
677
|
accountId: deployment.accountId,
|
|
643
678
|
accountLabel: accountsById.get(deployment.accountId)?.label,
|
|
644
679
|
deploymentId: deployment.id,
|
|
680
|
+
deploymentLabel: deployment.label,
|
|
681
|
+
...resolvedStrategy.generation ? { generation: resolvedStrategy.generation } : {},
|
|
645
682
|
policyProfileId: strategyPolicyProfileId,
|
|
646
683
|
enabled: resolvedStrategy.controlState !== "entries_paused",
|
|
647
684
|
config: resolvedStrategy.strategyConfig,
|
|
@@ -650,12 +687,16 @@ var loadRuntimeDashboard = async ({
|
|
|
650
687
|
});
|
|
651
688
|
}
|
|
652
689
|
}
|
|
690
|
+
const tradesByRuntimeKey = groupRuntimeTradesByIdentity(
|
|
691
|
+
allTrades,
|
|
692
|
+
identityByKey
|
|
693
|
+
);
|
|
653
694
|
const strategies = await Promise.all(
|
|
654
695
|
[...identityByKey.entries()].map(async ([runtimeKey, identity]) => {
|
|
655
696
|
const { strategyName } = identity;
|
|
656
|
-
const strategyTrades =
|
|
657
|
-
(
|
|
658
|
-
)
|
|
697
|
+
const strategyTrades = (tradesByRuntimeKey.get(runtimeKey) ?? []).sort(
|
|
698
|
+
(left, right) => right.entryTimestamp - left.entryTimestamp
|
|
699
|
+
);
|
|
659
700
|
const orders = strategyTrades.sort((left, right) => {
|
|
660
701
|
const leftDate = left.exitTimestamp ?? left.entryTimestamp;
|
|
661
702
|
const rightDate = right.exitTimestamp ?? right.entryTimestamp;
|
|
@@ -670,14 +711,19 @@ var loadRuntimeDashboard = async ({
|
|
|
670
711
|
return {
|
|
671
712
|
runtimeKey,
|
|
672
713
|
strategyName,
|
|
714
|
+
strategyModule: identity.strategyModule,
|
|
715
|
+
strategyPackage: identity.strategyPackage,
|
|
716
|
+
strategyPackageVersion: identity.strategyPackageVersion,
|
|
673
717
|
configId: identity.configId,
|
|
674
718
|
strategyRevision: identity.strategyRevision,
|
|
719
|
+
...identity.generation ? { generation: identity.generation } : {},
|
|
675
720
|
controlState: identity.controlState,
|
|
676
721
|
interval: identity.interval,
|
|
677
722
|
universe: identity.universe,
|
|
678
723
|
accountId: identity.accountId,
|
|
679
724
|
accountLabel: identity.accountLabel,
|
|
680
725
|
deploymentId: identity.deploymentId,
|
|
726
|
+
deploymentLabel: identity.deploymentLabel,
|
|
681
727
|
...identity.selection ? { selection: identity.selection } : {},
|
|
682
728
|
policyProfileId: identity.policyProfileId,
|
|
683
729
|
connected: identity.connected,
|
|
@@ -8,6 +8,7 @@ interface RuntimePackageManifest {
|
|
|
8
8
|
}
|
|
9
9
|
interface ResolvedRuntimeStrategy {
|
|
10
10
|
strategyName: string;
|
|
11
|
+
strategyModule: string;
|
|
11
12
|
strategyRevision: string;
|
|
12
13
|
deploymentCompositionId: string;
|
|
13
14
|
generation?: string;
|
|
@@ -27,6 +28,7 @@ interface ResolvedRuntimeStrategy {
|
|
|
27
28
|
}
|
|
28
29
|
interface ResolvedStrategyComposition {
|
|
29
30
|
strategyName: string;
|
|
31
|
+
strategyModule: string;
|
|
30
32
|
strategyRevision: string;
|
|
31
33
|
generation?: string;
|
|
32
34
|
enabled: boolean;
|
|
@@ -93,9 +95,10 @@ declare const loadResolvedRuntimeStrategies: ({ userName, projectRoot, deploymen
|
|
|
93
95
|
accountId?: string;
|
|
94
96
|
interval?: Interval;
|
|
95
97
|
}) => Promise<ResolvedRuntimeStrategy[]>;
|
|
96
|
-
declare const getRuntimeStrategyPackageMetadata: ({ strategyName, projectRoot, }: {
|
|
98
|
+
declare const getRuntimeStrategyPackageMetadata: ({ strategyName, projectRoot, strategyModule, }: {
|
|
97
99
|
strategyName: string;
|
|
98
100
|
projectRoot: string;
|
|
101
|
+
strategyModule?: string;
|
|
99
102
|
}) => Promise<{
|
|
100
103
|
strategyPackage: string;
|
|
101
104
|
strategyPackageVersion: string;
|
|
@@ -8,6 +8,7 @@ interface RuntimePackageManifest {
|
|
|
8
8
|
}
|
|
9
9
|
interface ResolvedRuntimeStrategy {
|
|
10
10
|
strategyName: string;
|
|
11
|
+
strategyModule: string;
|
|
11
12
|
strategyRevision: string;
|
|
12
13
|
deploymentCompositionId: string;
|
|
13
14
|
generation?: string;
|
|
@@ -27,6 +28,7 @@ interface ResolvedRuntimeStrategy {
|
|
|
27
28
|
}
|
|
28
29
|
interface ResolvedStrategyComposition {
|
|
29
30
|
strategyName: string;
|
|
31
|
+
strategyModule: string;
|
|
30
32
|
strategyRevision: string;
|
|
31
33
|
generation?: string;
|
|
32
34
|
enabled: boolean;
|
|
@@ -93,9 +95,10 @@ declare const loadResolvedRuntimeStrategies: ({ userName, projectRoot, deploymen
|
|
|
93
95
|
accountId?: string;
|
|
94
96
|
interval?: Interval;
|
|
95
97
|
}) => Promise<ResolvedRuntimeStrategy[]>;
|
|
96
|
-
declare const getRuntimeStrategyPackageMetadata: ({ strategyName, projectRoot, }: {
|
|
98
|
+
declare const getRuntimeStrategyPackageMetadata: ({ strategyName, projectRoot, strategyModule, }: {
|
|
97
99
|
strategyName: string;
|
|
98
100
|
projectRoot: string;
|
|
101
|
+
strategyModule?: string;
|
|
99
102
|
}) => Promise<{
|
|
100
103
|
strategyPackage: string;
|
|
101
104
|
strategyPackageVersion: string;
|