@tradejs/core 3.1.16-beta.230 → 3.1.17-beta.231
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/runtimeTrades.d.mts +2 -21
- package/dist/runtimeTrades.d.ts +2 -21
- package/dist/runtimeTrades.js +1 -58
- package/dist/runtimeTrades.mjs +1 -56
- package/package.json +2 -2
package/dist/runtimeTrades.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeTradeRecord, SimpleOrderLogData, TestStat, RuntimeStrategyTradeSummary, RuntimeStrategyTradeView,
|
|
1
|
+
import { RuntimeTradeRecord, SimpleOrderLogData, TestStat, RuntimeStrategyTradeSummary, RuntimeStrategyTradeView, RuntimeLineage, MarketUniverse } from '@tradejs/types';
|
|
2
2
|
|
|
3
3
|
declare const resolveStrategyNameByOrderLinkId: ({ orderLinkId, strategyNames, }: {
|
|
4
4
|
orderLinkId: string | null | undefined;
|
|
@@ -27,11 +27,6 @@ interface RuntimeStrategyLineageScope {
|
|
|
27
27
|
firstTimestamp: number;
|
|
28
28
|
lastTimestamp: number;
|
|
29
29
|
}
|
|
30
|
-
interface RuntimeStrategyAiGateChange {
|
|
31
|
-
timestamp: number;
|
|
32
|
-
previousFingerprint: string;
|
|
33
|
-
fingerprint: string;
|
|
34
|
-
}
|
|
35
30
|
interface RuntimeStrategyMaxLossValueChange {
|
|
36
31
|
timestamp: number;
|
|
37
32
|
previousValue: number;
|
|
@@ -42,12 +37,6 @@ interface RuntimeStrategyMaxLossValueTimeline {
|
|
|
42
37
|
initialValue: number | null;
|
|
43
38
|
changes: RuntimeStrategyMaxLossValueChange[];
|
|
44
39
|
}
|
|
45
|
-
interface RuntimeStrategyAccountScope {
|
|
46
|
-
strategyName: string;
|
|
47
|
-
configId: string;
|
|
48
|
-
universe: MarketUniverse;
|
|
49
|
-
accountId?: string;
|
|
50
|
-
}
|
|
51
40
|
declare const buildRuntimeStrategyIdentityKey: ({ strategyName, configId, universe, accountId, deploymentId, policyProfileId, }: {
|
|
52
41
|
strategyName: string;
|
|
53
42
|
configId?: string;
|
|
@@ -56,7 +45,6 @@ declare const buildRuntimeStrategyIdentityKey: ({ strategyName, configId, univer
|
|
|
56
45
|
deploymentId?: string;
|
|
57
46
|
policyProfileId?: string;
|
|
58
47
|
}) => string;
|
|
59
|
-
declare const assignLegacyRuntimeTradeAccountScopes: (trades: RuntimeTradeRecord[], scopes: RuntimeStrategyAccountScope[]) => RuntimeTradeRecord[];
|
|
60
48
|
declare const getRuntimeStrategyAiGateObservedFrom: ({ scopes, strategyName, configId, endTime, }: {
|
|
61
49
|
scopes: RuntimeStrategyLineageScope[];
|
|
62
50
|
strategyName: string;
|
|
@@ -71,12 +59,5 @@ declare const buildRuntimeStrategyMaxLossValueTimeline: ({ scopes, strategyName,
|
|
|
71
59
|
endTime: number;
|
|
72
60
|
}) => RuntimeStrategyMaxLossValueTimeline;
|
|
73
61
|
declare const isRuntimeStrategyLineageScope: (value: unknown) => value is RuntimeStrategyLineageScope;
|
|
74
|
-
declare const buildRuntimeStrategyAiGateChanges: ({ scopes, strategyName, configId, startTime, endTime, }: {
|
|
75
|
-
scopes: RuntimeStrategyLineageScope[];
|
|
76
|
-
strategyName: string;
|
|
77
|
-
configId?: string;
|
|
78
|
-
startTime: number;
|
|
79
|
-
endTime: number;
|
|
80
|
-
}) => RuntimeStrategyAiGateChange[];
|
|
81
62
|
|
|
82
|
-
export { type
|
|
63
|
+
export { type RuntimeStrategyLineageScope, type RuntimeStrategyMaxLossValueChange, type RuntimeStrategyMaxLossValueTimeline, buildRuntimeStrategyAnalytics, buildRuntimeStrategyIdentityKey, buildRuntimeStrategyMaxLossValueTimeline, getRuntimeStrategyAiGateObservedFrom, isRuntimeStrategyLineageScope, isRuntimeTradeRecord, resolveStrategyNameByOrderLinkId, selectTradesForWindow, toRuntimeTradeView };
|
package/dist/runtimeTrades.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeTradeRecord, SimpleOrderLogData, TestStat, RuntimeStrategyTradeSummary, RuntimeStrategyTradeView,
|
|
1
|
+
import { RuntimeTradeRecord, SimpleOrderLogData, TestStat, RuntimeStrategyTradeSummary, RuntimeStrategyTradeView, RuntimeLineage, MarketUniverse } from '@tradejs/types';
|
|
2
2
|
|
|
3
3
|
declare const resolveStrategyNameByOrderLinkId: ({ orderLinkId, strategyNames, }: {
|
|
4
4
|
orderLinkId: string | null | undefined;
|
|
@@ -27,11 +27,6 @@ interface RuntimeStrategyLineageScope {
|
|
|
27
27
|
firstTimestamp: number;
|
|
28
28
|
lastTimestamp: number;
|
|
29
29
|
}
|
|
30
|
-
interface RuntimeStrategyAiGateChange {
|
|
31
|
-
timestamp: number;
|
|
32
|
-
previousFingerprint: string;
|
|
33
|
-
fingerprint: string;
|
|
34
|
-
}
|
|
35
30
|
interface RuntimeStrategyMaxLossValueChange {
|
|
36
31
|
timestamp: number;
|
|
37
32
|
previousValue: number;
|
|
@@ -42,12 +37,6 @@ interface RuntimeStrategyMaxLossValueTimeline {
|
|
|
42
37
|
initialValue: number | null;
|
|
43
38
|
changes: RuntimeStrategyMaxLossValueChange[];
|
|
44
39
|
}
|
|
45
|
-
interface RuntimeStrategyAccountScope {
|
|
46
|
-
strategyName: string;
|
|
47
|
-
configId: string;
|
|
48
|
-
universe: MarketUniverse;
|
|
49
|
-
accountId?: string;
|
|
50
|
-
}
|
|
51
40
|
declare const buildRuntimeStrategyIdentityKey: ({ strategyName, configId, universe, accountId, deploymentId, policyProfileId, }: {
|
|
52
41
|
strategyName: string;
|
|
53
42
|
configId?: string;
|
|
@@ -56,7 +45,6 @@ declare const buildRuntimeStrategyIdentityKey: ({ strategyName, configId, univer
|
|
|
56
45
|
deploymentId?: string;
|
|
57
46
|
policyProfileId?: string;
|
|
58
47
|
}) => string;
|
|
59
|
-
declare const assignLegacyRuntimeTradeAccountScopes: (trades: RuntimeTradeRecord[], scopes: RuntimeStrategyAccountScope[]) => RuntimeTradeRecord[];
|
|
60
48
|
declare const getRuntimeStrategyAiGateObservedFrom: ({ scopes, strategyName, configId, endTime, }: {
|
|
61
49
|
scopes: RuntimeStrategyLineageScope[];
|
|
62
50
|
strategyName: string;
|
|
@@ -71,12 +59,5 @@ declare const buildRuntimeStrategyMaxLossValueTimeline: ({ scopes, strategyName,
|
|
|
71
59
|
endTime: number;
|
|
72
60
|
}) => RuntimeStrategyMaxLossValueTimeline;
|
|
73
61
|
declare const isRuntimeStrategyLineageScope: (value: unknown) => value is RuntimeStrategyLineageScope;
|
|
74
|
-
declare const buildRuntimeStrategyAiGateChanges: ({ scopes, strategyName, configId, startTime, endTime, }: {
|
|
75
|
-
scopes: RuntimeStrategyLineageScope[];
|
|
76
|
-
strategyName: string;
|
|
77
|
-
configId?: string;
|
|
78
|
-
startTime: number;
|
|
79
|
-
endTime: number;
|
|
80
|
-
}) => RuntimeStrategyAiGateChange[];
|
|
81
62
|
|
|
82
|
-
export { type
|
|
63
|
+
export { type RuntimeStrategyLineageScope, type RuntimeStrategyMaxLossValueChange, type RuntimeStrategyMaxLossValueTimeline, buildRuntimeStrategyAnalytics, buildRuntimeStrategyIdentityKey, buildRuntimeStrategyMaxLossValueTimeline, getRuntimeStrategyAiGateObservedFrom, isRuntimeStrategyLineageScope, isRuntimeTradeRecord, resolveStrategyNameByOrderLinkId, selectTradesForWindow, toRuntimeTradeView };
|
package/dist/runtimeTrades.js
CHANGED
|
@@ -30,8 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/runtimeTrades.ts
|
|
31
31
|
var runtimeTrades_exports = {};
|
|
32
32
|
__export(runtimeTrades_exports, {
|
|
33
|
-
assignLegacyRuntimeTradeAccountScopes: () => assignLegacyRuntimeTradeAccountScopes,
|
|
34
|
-
buildRuntimeStrategyAiGateChanges: () => buildRuntimeStrategyAiGateChanges,
|
|
35
33
|
buildRuntimeStrategyAnalytics: () => buildRuntimeStrategyAnalytics,
|
|
36
34
|
buildRuntimeStrategyIdentityKey: () => buildRuntimeStrategyIdentityKey,
|
|
37
35
|
buildRuntimeStrategyMaxLossValueTimeline: () => buildRuntimeStrategyMaxLossValueTimeline,
|
|
@@ -440,15 +438,6 @@ var buildRuntimeStrategyIdentityKey = ({
|
|
|
440
438
|
deploymentId ?? "default",
|
|
441
439
|
policyProfileId ?? "default"
|
|
442
440
|
].join(":");
|
|
443
|
-
var assignLegacyRuntimeTradeAccountScopes = (trades, scopes) => trades.map((trade) => {
|
|
444
|
-
if (trade.accountId || trade.deploymentId) return trade;
|
|
445
|
-
const matchingAccountIds = new Set(
|
|
446
|
-
scopes.filter(
|
|
447
|
-
(scope) => scope.strategyName === trade.strategy && scope.configId === (trade.runtimeConfigId ?? "config") && scope.universe === (trade.universe ?? "crypto")
|
|
448
|
-
).map((scope) => scope.accountId).filter((accountId) => Boolean(accountId))
|
|
449
|
-
);
|
|
450
|
-
return matchingAccountIds.size === 1 ? { ...trade, accountId: [...matchingAccountIds][0] } : trade;
|
|
451
|
-
});
|
|
452
441
|
var getRuntimeStrategyAiGateObservedFrom = ({
|
|
453
442
|
scopes,
|
|
454
443
|
strategyName,
|
|
@@ -516,56 +505,10 @@ var isRuntimeStrategyLineageScope = (value) => {
|
|
|
516
505
|
if (!value || typeof value !== "object") return false;
|
|
517
506
|
const record = value;
|
|
518
507
|
const lineage = record.lineage;
|
|
519
|
-
return typeof record.strategy === "string" && typeof record.symbol === "string" && typeof record.firstTimestamp === "number" && Number.isFinite(record.firstTimestamp) && typeof record.lastTimestamp === "number" && Number.isFinite(record.lastTimestamp) && lineage != null && lineage.schemaVersion ===
|
|
520
|
-
};
|
|
521
|
-
var buildRuntimeStrategyAiGateChanges = ({
|
|
522
|
-
scopes,
|
|
523
|
-
strategyName,
|
|
524
|
-
configId,
|
|
525
|
-
startTime,
|
|
526
|
-
endTime
|
|
527
|
-
}) => {
|
|
528
|
-
const normalizedConfigId = configId ?? "config";
|
|
529
|
-
const observationsByTimestamp = /* @__PURE__ */ new Map();
|
|
530
|
-
for (const scope of scopes) {
|
|
531
|
-
if (scope.strategy !== strategyName || (scope.runtimeConfigId ?? "config") !== normalizedConfigId || scope.firstTimestamp > endTime) {
|
|
532
|
-
continue;
|
|
533
|
-
}
|
|
534
|
-
if (scope.lineage.schemaVersion !== 1) continue;
|
|
535
|
-
const fingerprint = scope.lineage.gateFingerprint.trim();
|
|
536
|
-
const existing = observationsByTimestamp.get(scope.firstTimestamp);
|
|
537
|
-
if (!existing || scope.lastTimestamp > existing.lastTimestamp || scope.lastTimestamp === existing.lastTimestamp && fingerprint > existing.fingerprint) {
|
|
538
|
-
observationsByTimestamp.set(scope.firstTimestamp, {
|
|
539
|
-
fingerprint,
|
|
540
|
-
lastTimestamp: scope.lastTimestamp
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const changes = [];
|
|
545
|
-
let currentFingerprint = null;
|
|
546
|
-
for (const [timestamp, observation] of [
|
|
547
|
-
...observationsByTimestamp.entries()
|
|
548
|
-
].sort(([left], [right]) => left - right)) {
|
|
549
|
-
if (currentFingerprint == null) {
|
|
550
|
-
currentFingerprint = observation.fingerprint;
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
if (observation.fingerprint === currentFingerprint) continue;
|
|
554
|
-
if (timestamp >= startTime) {
|
|
555
|
-
changes.push({
|
|
556
|
-
timestamp,
|
|
557
|
-
previousFingerprint: currentFingerprint,
|
|
558
|
-
fingerprint: observation.fingerprint
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
currentFingerprint = observation.fingerprint;
|
|
562
|
-
}
|
|
563
|
-
return changes;
|
|
508
|
+
return typeof record.strategy === "string" && typeof record.symbol === "string" && typeof record.firstTimestamp === "number" && Number.isFinite(record.firstTimestamp) && typeof record.lastTimestamp === "number" && Number.isFinite(record.lastTimestamp) && lineage != null && lineage.schemaVersion === 3 && typeof lineage.strategyRevision === "string" && /^sr1:[a-f0-9]{16}$/.test(lineage.strategyRevision) && typeof lineage.deploymentCompositionId === "string" && /^dc1:[a-f0-9]{16}$/.test(lineage.deploymentCompositionId) && typeof lineage.strategyPackageVersion === "string" && lineage.strategyPackageVersion.trim().length > 0 && typeof lineage.runtimePackageVersion === "string" && lineage.runtimePackageVersion.trim().length > 0 && lineage.strategyDependencyVersions != null && typeof lineage.strategyDependencyVersions === "object";
|
|
564
509
|
};
|
|
565
510
|
// Annotate the CommonJS export names for ESM import in node:
|
|
566
511
|
0 && (module.exports = {
|
|
567
|
-
assignLegacyRuntimeTradeAccountScopes,
|
|
568
|
-
buildRuntimeStrategyAiGateChanges,
|
|
569
512
|
buildRuntimeStrategyAnalytics,
|
|
570
513
|
buildRuntimeStrategyIdentityKey,
|
|
571
514
|
buildRuntimeStrategyMaxLossValueTimeline,
|
package/dist/runtimeTrades.mjs
CHANGED
|
@@ -342,15 +342,6 @@ var buildRuntimeStrategyIdentityKey = ({
|
|
|
342
342
|
deploymentId ?? "default",
|
|
343
343
|
policyProfileId ?? "default"
|
|
344
344
|
].join(":");
|
|
345
|
-
var assignLegacyRuntimeTradeAccountScopes = (trades, scopes) => trades.map((trade) => {
|
|
346
|
-
if (trade.accountId || trade.deploymentId) return trade;
|
|
347
|
-
const matchingAccountIds = new Set(
|
|
348
|
-
scopes.filter(
|
|
349
|
-
(scope) => scope.strategyName === trade.strategy && scope.configId === (trade.runtimeConfigId ?? "config") && scope.universe === (trade.universe ?? "crypto")
|
|
350
|
-
).map((scope) => scope.accountId).filter((accountId) => Boolean(accountId))
|
|
351
|
-
);
|
|
352
|
-
return matchingAccountIds.size === 1 ? { ...trade, accountId: [...matchingAccountIds][0] } : trade;
|
|
353
|
-
});
|
|
354
345
|
var getRuntimeStrategyAiGateObservedFrom = ({
|
|
355
346
|
scopes,
|
|
356
347
|
strategyName,
|
|
@@ -418,55 +409,9 @@ var isRuntimeStrategyLineageScope = (value) => {
|
|
|
418
409
|
if (!value || typeof value !== "object") return false;
|
|
419
410
|
const record = value;
|
|
420
411
|
const lineage = record.lineage;
|
|
421
|
-
return typeof record.strategy === "string" && typeof record.symbol === "string" && typeof record.firstTimestamp === "number" && Number.isFinite(record.firstTimestamp) && typeof record.lastTimestamp === "number" && Number.isFinite(record.lastTimestamp) && lineage != null && lineage.schemaVersion ===
|
|
422
|
-
};
|
|
423
|
-
var buildRuntimeStrategyAiGateChanges = ({
|
|
424
|
-
scopes,
|
|
425
|
-
strategyName,
|
|
426
|
-
configId,
|
|
427
|
-
startTime,
|
|
428
|
-
endTime
|
|
429
|
-
}) => {
|
|
430
|
-
const normalizedConfigId = configId ?? "config";
|
|
431
|
-
const observationsByTimestamp = /* @__PURE__ */ new Map();
|
|
432
|
-
for (const scope of scopes) {
|
|
433
|
-
if (scope.strategy !== strategyName || (scope.runtimeConfigId ?? "config") !== normalizedConfigId || scope.firstTimestamp > endTime) {
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
if (scope.lineage.schemaVersion !== 1) continue;
|
|
437
|
-
const fingerprint = scope.lineage.gateFingerprint.trim();
|
|
438
|
-
const existing = observationsByTimestamp.get(scope.firstTimestamp);
|
|
439
|
-
if (!existing || scope.lastTimestamp > existing.lastTimestamp || scope.lastTimestamp === existing.lastTimestamp && fingerprint > existing.fingerprint) {
|
|
440
|
-
observationsByTimestamp.set(scope.firstTimestamp, {
|
|
441
|
-
fingerprint,
|
|
442
|
-
lastTimestamp: scope.lastTimestamp
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
const changes = [];
|
|
447
|
-
let currentFingerprint = null;
|
|
448
|
-
for (const [timestamp, observation] of [
|
|
449
|
-
...observationsByTimestamp.entries()
|
|
450
|
-
].sort(([left], [right]) => left - right)) {
|
|
451
|
-
if (currentFingerprint == null) {
|
|
452
|
-
currentFingerprint = observation.fingerprint;
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
if (observation.fingerprint === currentFingerprint) continue;
|
|
456
|
-
if (timestamp >= startTime) {
|
|
457
|
-
changes.push({
|
|
458
|
-
timestamp,
|
|
459
|
-
previousFingerprint: currentFingerprint,
|
|
460
|
-
fingerprint: observation.fingerprint
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
currentFingerprint = observation.fingerprint;
|
|
464
|
-
}
|
|
465
|
-
return changes;
|
|
412
|
+
return typeof record.strategy === "string" && typeof record.symbol === "string" && typeof record.firstTimestamp === "number" && Number.isFinite(record.firstTimestamp) && typeof record.lastTimestamp === "number" && Number.isFinite(record.lastTimestamp) && lineage != null && lineage.schemaVersion === 3 && typeof lineage.strategyRevision === "string" && /^sr1:[a-f0-9]{16}$/.test(lineage.strategyRevision) && typeof lineage.deploymentCompositionId === "string" && /^dc1:[a-f0-9]{16}$/.test(lineage.deploymentCompositionId) && typeof lineage.strategyPackageVersion === "string" && lineage.strategyPackageVersion.trim().length > 0 && typeof lineage.runtimePackageVersion === "string" && lineage.runtimePackageVersion.trim().length > 0 && lineage.strategyDependencyVersions != null && typeof lineage.strategyDependencyVersions === "object";
|
|
466
413
|
};
|
|
467
414
|
export {
|
|
468
|
-
assignLegacyRuntimeTradeAccountScopes,
|
|
469
|
-
buildRuntimeStrategyAiGateChanges,
|
|
470
415
|
buildRuntimeStrategyAnalytics,
|
|
471
416
|
buildRuntimeStrategyIdentityKey,
|
|
472
417
|
buildRuntimeStrategyMaxLossValueTimeline,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/core",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.17-beta.231",
|
|
4
4
|
"description": "MIT-licensed browser-safe API for TradeJS config, strategy authoring, figures, and shared helpers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"@tradejs/types": "^3.1.
|
|
135
|
+
"@tradejs/types": "^3.1.17-beta.231",
|
|
136
136
|
"date-fns": "^3.6.0",
|
|
137
137
|
"fast-technical-indicators": "^1.1.4",
|
|
138
138
|
"klinecharts": "10.0.0-alpha9",
|