@tradejs/cli 3.1.8-beta.207 → 3.1.8-beta.212
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/cli.js +245 -471
- package/dist/lib/runtimeLineage.js +6 -6
- package/dist/lib/runtimeSignalsStorage.js +1 -1
- package/dist/lib/strategyRelease.js +6 -5
- package/dist/scripts/backtest.js +6 -2
- package/dist/scripts/replay.js +11 -11
- package/dist/scripts/replayRunner.js +11 -11
- package/dist/scripts/runtimeControl.js +177 -0
- package/dist/scripts/runtimeEvidence.js +1 -1
- package/dist/scripts/signals.js +50 -45
- package/dist/scripts/signalsDaemon.js +50 -45
- package/dist/scripts/signalsSummary.js +2 -2
- package/dist/scripts/strategyRelease.js +6 -5
- package/package.json +8 -8
- package/dist/scripts/runtimeConfig.js +0 -427
package/dist/scripts/signals.js
CHANGED
|
@@ -50,7 +50,8 @@ var import_strategies5 = require("@tradejs/core/strategies");
|
|
|
50
50
|
var import_constants3 = require("@tradejs/core/constants");
|
|
51
51
|
var import_time2 = require("@tradejs/core/time");
|
|
52
52
|
var import_logger4 = require("@tradejs/infra/logger");
|
|
53
|
-
var
|
|
53
|
+
var import_runtimeHeartbeats = require("@tradejs/infra/runtimeHeartbeats");
|
|
54
|
+
var import_runtimeStrategies2 = require("@tradejs/node/runtimeStrategies");
|
|
54
55
|
|
|
55
56
|
// src/lib/marketData/windows.ts
|
|
56
57
|
var import_indicators = require("@tradejs/core/indicators");
|
|
@@ -3772,7 +3773,7 @@ var toRuntimeSignalBucketRef = (signal) => ({
|
|
|
3772
3773
|
strategy: signal.strategy,
|
|
3773
3774
|
timestamp: signal.timestamp,
|
|
3774
3775
|
...signal.runtimeConfigId && signal.runtimeConfigId !== "config" ? { runtimeConfigId: signal.runtimeConfigId } : {},
|
|
3775
|
-
...signal.
|
|
3776
|
+
...signal.runtimeVersion ? { runtimeVersion: signal.runtimeVersion } : {}
|
|
3776
3777
|
});
|
|
3777
3778
|
var shouldStoreRuntimeSignalDiagnostics = (signal) => signal.orderStatus === "completed" || signal.orderStatus === "failed";
|
|
3778
3779
|
var toStoredRuntimeSignal = (signal) => {
|
|
@@ -4136,20 +4137,20 @@ async function buildRuntimeLineage({
|
|
|
4136
4137
|
projectRoot,
|
|
4137
4138
|
strategyName,
|
|
4138
4139
|
compositionId,
|
|
4139
|
-
|
|
4140
|
+
version,
|
|
4140
4141
|
strategyPackageVersion,
|
|
4141
4142
|
runtimePackageVersion,
|
|
4142
4143
|
config: config2,
|
|
4143
4144
|
runContext,
|
|
4144
4145
|
env = process.env
|
|
4145
4146
|
}) {
|
|
4146
|
-
if (
|
|
4147
|
-
if (!Number.isSafeInteger(
|
|
4148
|
-
throw new Error(`Invalid runtime
|
|
4147
|
+
if (version != null) {
|
|
4148
|
+
if (!Number.isSafeInteger(version) || version <= 0) {
|
|
4149
|
+
throw new Error(`Invalid runtime strategy version: ${version}`);
|
|
4149
4150
|
}
|
|
4150
4151
|
return {
|
|
4151
4152
|
schemaVersion: 2,
|
|
4152
|
-
|
|
4153
|
+
version,
|
|
4153
4154
|
strategyPackageVersion,
|
|
4154
4155
|
runtimePackageVersion,
|
|
4155
4156
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
@@ -4190,7 +4191,7 @@ async function buildRuntimeLineage({
|
|
|
4190
4191
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
4191
4192
|
};
|
|
4192
4193
|
}
|
|
4193
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
4194
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
4194
4195
|
lineage.schemaVersion,
|
|
4195
4196
|
lineage.compositionId ?? "unbound-composition",
|
|
4196
4197
|
lineage.gitSha ?? "unknown",
|
|
@@ -4209,12 +4210,12 @@ var buildRuntimeSignalEvaluationId = ({
|
|
|
4209
4210
|
symbol,
|
|
4210
4211
|
timestamp,
|
|
4211
4212
|
runtimeConfigId,
|
|
4212
|
-
|
|
4213
|
-
}) =>
|
|
4213
|
+
runtimeVersion
|
|
4214
|
+
}) => runtimeVersion ? [strategyName, `v${runtimeVersion}`, symbol, timestamp].join(":") : runtimeConfigId && runtimeConfigId !== "config" ? [strategyName, runtimeConfigId, symbol, timestamp].join(":") : [strategyName, symbol, timestamp].join(":");
|
|
4214
4215
|
var buildLineageField = (scope) => [
|
|
4215
4216
|
scope.strategy,
|
|
4216
4217
|
scope.runtimeConfigId ?? "config",
|
|
4217
|
-
scope.
|
|
4218
|
+
scope.runtimeVersion ? `v${scope.runtimeVersion}` : "legacy",
|
|
4218
4219
|
scope.symbol,
|
|
4219
4220
|
runtimeLineageKey(scope.lineage)
|
|
4220
4221
|
].join(":");
|
|
@@ -4254,7 +4255,7 @@ var flushRuntimeSignalEvaluations = async (evaluations) => {
|
|
|
4254
4255
|
const lineageField = buildLineageField({
|
|
4255
4256
|
strategy: evaluation.strategy,
|
|
4256
4257
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
4257
|
-
|
|
4258
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
4258
4259
|
symbol: evaluation.symbol,
|
|
4259
4260
|
lineage: evaluation.runtimeLineage
|
|
4260
4261
|
});
|
|
@@ -4264,7 +4265,7 @@ var flushRuntimeSignalEvaluations = async (evaluations) => {
|
|
|
4264
4265
|
strategy: evaluation.strategy,
|
|
4265
4266
|
symbol: evaluation.symbol,
|
|
4266
4267
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
4267
|
-
|
|
4268
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
4268
4269
|
lineage: evaluation.runtimeLineage,
|
|
4269
4270
|
firstTimestamp: Math.min(
|
|
4270
4271
|
existing?.firstTimestamp ?? evaluation.timestamp,
|
|
@@ -4803,7 +4804,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4803
4804
|
for (const runtimeStrategy of runtimeStrategies) {
|
|
4804
4805
|
const {
|
|
4805
4806
|
strategyName,
|
|
4806
|
-
|
|
4807
|
+
version,
|
|
4807
4808
|
controlState,
|
|
4808
4809
|
strategyPackageVersion,
|
|
4809
4810
|
runtimePackageVersion,
|
|
@@ -4811,7 +4812,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4811
4812
|
sourceStrategyConfig,
|
|
4812
4813
|
strategyConfig
|
|
4813
4814
|
} = runtimeStrategy;
|
|
4814
|
-
const runtimeIdentity = `v${
|
|
4815
|
+
const runtimeIdentity = `v${version}`;
|
|
4815
4816
|
const runtimeConfig = buildRuntimeModeStrategyConfig({
|
|
4816
4817
|
strategyConfig,
|
|
4817
4818
|
env: "CRON",
|
|
@@ -4821,7 +4822,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4821
4822
|
const runtimeLineage = await buildRuntimeLineage({
|
|
4822
4823
|
projectRoot,
|
|
4823
4824
|
strategyName,
|
|
4824
|
-
|
|
4825
|
+
version,
|
|
4825
4826
|
strategyPackageVersion,
|
|
4826
4827
|
runtimePackageVersion,
|
|
4827
4828
|
config: { strategyConfig },
|
|
@@ -4864,7 +4865,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4864
4865
|
userName,
|
|
4865
4866
|
connectorName,
|
|
4866
4867
|
runtimeConfigId: runtimeIdentity,
|
|
4867
|
-
|
|
4868
|
+
runtimeVersion: version,
|
|
4868
4869
|
entriesPaused: controlState === "entries_paused",
|
|
4869
4870
|
runtimeLineage,
|
|
4870
4871
|
runtimeConfigSnapshot: {
|
|
@@ -4919,12 +4920,12 @@ var createSignalsTickerEvaluator = ({
|
|
|
4919
4920
|
symbol,
|
|
4920
4921
|
timestamp: lastCandle.timestamp,
|
|
4921
4922
|
runtimeConfigId: runtimeIdentity,
|
|
4922
|
-
|
|
4923
|
+
runtimeVersion: version
|
|
4923
4924
|
}),
|
|
4924
4925
|
userName,
|
|
4925
4926
|
strategy: strategyName,
|
|
4926
4927
|
runtimeConfigId: runtimeIdentity,
|
|
4927
|
-
|
|
4928
|
+
runtimeVersion: version,
|
|
4928
4929
|
runtimeLineage,
|
|
4929
4930
|
symbol,
|
|
4930
4931
|
interval,
|
|
@@ -4942,10 +4943,10 @@ var createSignalsTickerEvaluator = ({
|
|
|
4942
4943
|
}
|
|
4943
4944
|
if (stats) stats.signals += 1;
|
|
4944
4945
|
signal.runtimeConfigId = runtimeIdentity;
|
|
4945
|
-
signal.
|
|
4946
|
+
signal.runtimeVersion = version;
|
|
4946
4947
|
signal.runtimeLineage = runtimeLineage;
|
|
4947
|
-
if (
|
|
4948
|
-
signal.signalId = `${signal.signalId}:v${
|
|
4948
|
+
if (version && !signal.signalId.endsWith(`:v${version}`)) {
|
|
4949
|
+
signal.signalId = `${signal.signalId}:v${version}`;
|
|
4949
4950
|
}
|
|
4950
4951
|
await (0, import_strategies4.enrichSignalWithBinanceMarketContext)({ signal, env: "CRON" });
|
|
4951
4952
|
if (signal.orderStatus === "skipped" && typeof signal.orderSkipReason === "string" && signal.orderSkipReason.trim()) {
|
|
@@ -4964,12 +4965,12 @@ var createSignalsTickerEvaluator = ({
|
|
|
4964
4965
|
symbol,
|
|
4965
4966
|
timestamp: lastCandle.timestamp,
|
|
4966
4967
|
runtimeConfigId: runtimeIdentity,
|
|
4967
|
-
|
|
4968
|
+
runtimeVersion: version
|
|
4968
4969
|
}),
|
|
4969
4970
|
userName,
|
|
4970
4971
|
strategy: strategyName,
|
|
4971
4972
|
runtimeConfigId: runtimeIdentity,
|
|
4972
|
-
|
|
4973
|
+
runtimeVersion: version,
|
|
4973
4974
|
runtimeLineage,
|
|
4974
4975
|
symbol,
|
|
4975
4976
|
interval,
|
|
@@ -4996,7 +4997,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4996
4997
|
|
|
4997
4998
|
// src/lib/signals/configuredScopes.ts
|
|
4998
4999
|
var sorted = (values) => values ? [...values].sort() : [];
|
|
4999
|
-
var formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}@v${strategy.
|
|
5000
|
+
var formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}@v${strategy.version}[${strategy.controlState}]`;
|
|
5000
5001
|
var buildConfiguredSignalsScopes = ({
|
|
5001
5002
|
connectorName,
|
|
5002
5003
|
deployment,
|
|
@@ -5101,13 +5102,14 @@ var createSignalsRunner = (config2) => {
|
|
|
5101
5102
|
return connectorName;
|
|
5102
5103
|
};
|
|
5103
5104
|
const createSignalsSession2 = async (lifecycle, scope = {}) => {
|
|
5104
|
-
const deployment = config2.deploymentId ? await (0,
|
|
5105
|
+
const deployment = config2.deploymentId ? await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5106
|
+
userName: config2.userName,
|
|
5107
|
+
projectRoot,
|
|
5108
|
+
deploymentId: config2.deploymentId
|
|
5109
|
+
}) : null;
|
|
5105
5110
|
if (config2.deploymentId && !deployment) {
|
|
5106
5111
|
throw new Error(`Runtime deployment not found: ${config2.deploymentId}`);
|
|
5107
5112
|
}
|
|
5108
|
-
if (deployment && !deployment.enabled) {
|
|
5109
|
-
throw new Error(`Runtime deployment is disabled: ${deployment.id}`);
|
|
5110
|
-
}
|
|
5111
5113
|
const requestedRuntimeInterval = scope.interval ?? interval;
|
|
5112
5114
|
const runtimeInterval = requestedRuntimeInterval;
|
|
5113
5115
|
const runtimeIntervalMs = Number(runtimeInterval) * 6e4;
|
|
@@ -5328,7 +5330,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5328
5330
|
const runtimeStrategies = await (0, import_runtimeStrategies.loadResolvedRuntimeStrategies)({
|
|
5329
5331
|
userName: config2.userName,
|
|
5330
5332
|
projectRoot,
|
|
5331
|
-
deployment,
|
|
5333
|
+
deploymentId: deployment?.id ?? "",
|
|
5332
5334
|
universe,
|
|
5333
5335
|
accountId,
|
|
5334
5336
|
interval: interval2
|
|
@@ -5345,7 +5347,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5345
5347
|
new Set(
|
|
5346
5348
|
tickers.flatMap(
|
|
5347
5349
|
(symbol) => runtimeStrategies.map(
|
|
5348
|
-
({ strategyName,
|
|
5350
|
+
({ strategyName, version }) => buildSignalsStrategyLifecycleKey({
|
|
5349
5351
|
connectorName,
|
|
5350
5352
|
universe: sessionUniverse,
|
|
5351
5353
|
accountId,
|
|
@@ -5353,7 +5355,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5353
5355
|
symbol,
|
|
5354
5356
|
interval: interval2,
|
|
5355
5357
|
strategyName,
|
|
5356
|
-
configId: `v${
|
|
5358
|
+
configId: `v${version}`
|
|
5357
5359
|
})
|
|
5358
5360
|
)
|
|
5359
5361
|
)
|
|
@@ -5484,7 +5486,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5484
5486
|
}
|
|
5485
5487
|
const durationMs = Date.now() - startedAt;
|
|
5486
5488
|
if (activeSession?.deployment) {
|
|
5487
|
-
await (0,
|
|
5489
|
+
await (0, import_runtimeHeartbeats.saveRuntimeDeploymentHeartbeat)(config2.userName, {
|
|
5488
5490
|
deploymentId: activeSession.deployment.id,
|
|
5489
5491
|
status: getSignalsHeartbeatStatus({
|
|
5490
5492
|
cycleStatus: status,
|
|
@@ -5542,7 +5544,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5542
5544
|
const configuredStrategies = await (0, import_runtimeStrategies.loadResolvedRuntimeStrategies)({
|
|
5543
5545
|
userName: config2.userName,
|
|
5544
5546
|
projectRoot,
|
|
5545
|
-
deployment
|
|
5547
|
+
deploymentId: deployment.id
|
|
5546
5548
|
});
|
|
5547
5549
|
const connectorName = await resolveSignalsConnectorName(
|
|
5548
5550
|
deployment.connectorName
|
|
@@ -5562,10 +5564,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5562
5564
|
if (!config2.deploymentId) {
|
|
5563
5565
|
throw new Error("Runtime deployment id is required");
|
|
5564
5566
|
}
|
|
5565
|
-
const configuredDeployment = await (0,
|
|
5566
|
-
config2.userName,
|
|
5567
|
-
|
|
5568
|
-
|
|
5567
|
+
const configuredDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5568
|
+
userName: config2.userName,
|
|
5569
|
+
projectRoot,
|
|
5570
|
+
deploymentId: config2.deploymentId
|
|
5571
|
+
});
|
|
5569
5572
|
if (!configuredDeployment) {
|
|
5570
5573
|
throw new Error(`Runtime deployment not found: ${config2.deploymentId}`);
|
|
5571
5574
|
}
|
|
@@ -5595,10 +5598,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5595
5598
|
throw new Error("Runtime deployment id is required");
|
|
5596
5599
|
}
|
|
5597
5600
|
const deploymentId = config2.deploymentId;
|
|
5598
|
-
const initialDeployment = await (0,
|
|
5599
|
-
config2.userName,
|
|
5601
|
+
const initialDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5602
|
+
userName: config2.userName,
|
|
5603
|
+
projectRoot,
|
|
5600
5604
|
deploymentId
|
|
5601
|
-
);
|
|
5605
|
+
});
|
|
5602
5606
|
if (!initialDeployment) {
|
|
5603
5607
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
5604
5608
|
}
|
|
@@ -5619,10 +5623,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5619
5623
|
settleDelayMs: resolveNonNegativeInteger(config2.settleDelayMs, 5e3),
|
|
5620
5624
|
signal: abortController.signal,
|
|
5621
5625
|
runCycle: async () => {
|
|
5622
|
-
const currentDeployment = await (0,
|
|
5623
|
-
config2.userName,
|
|
5626
|
+
const currentDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5627
|
+
userName: config2.userName,
|
|
5628
|
+
projectRoot,
|
|
5624
5629
|
deploymentId
|
|
5625
|
-
);
|
|
5630
|
+
});
|
|
5626
5631
|
if (!currentDeployment) {
|
|
5627
5632
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
5628
5633
|
}
|
|
@@ -5702,7 +5707,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5702
5707
|
await session.klineFeed?.close();
|
|
5703
5708
|
session.lifecycle.clear();
|
|
5704
5709
|
if (session.deployment) {
|
|
5705
|
-
await (0,
|
|
5710
|
+
await (0, import_runtimeHeartbeats.saveRuntimeDeploymentHeartbeat)(config2.userName, {
|
|
5706
5711
|
deploymentId: session.deployment.id,
|
|
5707
5712
|
status: "stopped",
|
|
5708
5713
|
pid: process.pid,
|
|
@@ -48,7 +48,8 @@ var import_strategies5 = require("@tradejs/core/strategies");
|
|
|
48
48
|
var import_constants3 = require("@tradejs/core/constants");
|
|
49
49
|
var import_time2 = require("@tradejs/core/time");
|
|
50
50
|
var import_logger4 = require("@tradejs/infra/logger");
|
|
51
|
-
var
|
|
51
|
+
var import_runtimeHeartbeats = require("@tradejs/infra/runtimeHeartbeats");
|
|
52
|
+
var import_runtimeStrategies2 = require("@tradejs/node/runtimeStrategies");
|
|
52
53
|
|
|
53
54
|
// src/lib/marketData/windows.ts
|
|
54
55
|
var import_indicators = require("@tradejs/core/indicators");
|
|
@@ -3770,7 +3771,7 @@ var toRuntimeSignalBucketRef = (signal) => ({
|
|
|
3770
3771
|
strategy: signal.strategy,
|
|
3771
3772
|
timestamp: signal.timestamp,
|
|
3772
3773
|
...signal.runtimeConfigId && signal.runtimeConfigId !== "config" ? { runtimeConfigId: signal.runtimeConfigId } : {},
|
|
3773
|
-
...signal.
|
|
3774
|
+
...signal.runtimeVersion ? { runtimeVersion: signal.runtimeVersion } : {}
|
|
3774
3775
|
});
|
|
3775
3776
|
var shouldStoreRuntimeSignalDiagnostics = (signal) => signal.orderStatus === "completed" || signal.orderStatus === "failed";
|
|
3776
3777
|
var toStoredRuntimeSignal = (signal) => {
|
|
@@ -4134,20 +4135,20 @@ async function buildRuntimeLineage({
|
|
|
4134
4135
|
projectRoot,
|
|
4135
4136
|
strategyName,
|
|
4136
4137
|
compositionId,
|
|
4137
|
-
|
|
4138
|
+
version,
|
|
4138
4139
|
strategyPackageVersion,
|
|
4139
4140
|
runtimePackageVersion,
|
|
4140
4141
|
config: config2,
|
|
4141
4142
|
runContext,
|
|
4142
4143
|
env = process.env
|
|
4143
4144
|
}) {
|
|
4144
|
-
if (
|
|
4145
|
-
if (!Number.isSafeInteger(
|
|
4146
|
-
throw new Error(`Invalid runtime
|
|
4145
|
+
if (version != null) {
|
|
4146
|
+
if (!Number.isSafeInteger(version) || version <= 0) {
|
|
4147
|
+
throw new Error(`Invalid runtime strategy version: ${version}`);
|
|
4147
4148
|
}
|
|
4148
4149
|
return {
|
|
4149
4150
|
schemaVersion: 2,
|
|
4150
|
-
|
|
4151
|
+
version,
|
|
4151
4152
|
strategyPackageVersion,
|
|
4152
4153
|
runtimePackageVersion,
|
|
4153
4154
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
@@ -4188,7 +4189,7 @@ async function buildRuntimeLineage({
|
|
|
4188
4189
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
4189
4190
|
};
|
|
4190
4191
|
}
|
|
4191
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
4192
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
4192
4193
|
lineage.schemaVersion,
|
|
4193
4194
|
lineage.compositionId ?? "unbound-composition",
|
|
4194
4195
|
lineage.gitSha ?? "unknown",
|
|
@@ -4207,12 +4208,12 @@ var buildRuntimeSignalEvaluationId = ({
|
|
|
4207
4208
|
symbol,
|
|
4208
4209
|
timestamp,
|
|
4209
4210
|
runtimeConfigId,
|
|
4210
|
-
|
|
4211
|
-
}) =>
|
|
4211
|
+
runtimeVersion
|
|
4212
|
+
}) => runtimeVersion ? [strategyName, `v${runtimeVersion}`, symbol, timestamp].join(":") : runtimeConfigId && runtimeConfigId !== "config" ? [strategyName, runtimeConfigId, symbol, timestamp].join(":") : [strategyName, symbol, timestamp].join(":");
|
|
4212
4213
|
var buildLineageField = (scope) => [
|
|
4213
4214
|
scope.strategy,
|
|
4214
4215
|
scope.runtimeConfigId ?? "config",
|
|
4215
|
-
scope.
|
|
4216
|
+
scope.runtimeVersion ? `v${scope.runtimeVersion}` : "legacy",
|
|
4216
4217
|
scope.symbol,
|
|
4217
4218
|
runtimeLineageKey(scope.lineage)
|
|
4218
4219
|
].join(":");
|
|
@@ -4252,7 +4253,7 @@ var flushRuntimeSignalEvaluations = async (evaluations) => {
|
|
|
4252
4253
|
const lineageField = buildLineageField({
|
|
4253
4254
|
strategy: evaluation.strategy,
|
|
4254
4255
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
4255
|
-
|
|
4256
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
4256
4257
|
symbol: evaluation.symbol,
|
|
4257
4258
|
lineage: evaluation.runtimeLineage
|
|
4258
4259
|
});
|
|
@@ -4262,7 +4263,7 @@ var flushRuntimeSignalEvaluations = async (evaluations) => {
|
|
|
4262
4263
|
strategy: evaluation.strategy,
|
|
4263
4264
|
symbol: evaluation.symbol,
|
|
4264
4265
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
4265
|
-
|
|
4266
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
4266
4267
|
lineage: evaluation.runtimeLineage,
|
|
4267
4268
|
firstTimestamp: Math.min(
|
|
4268
4269
|
existing?.firstTimestamp ?? evaluation.timestamp,
|
|
@@ -4801,7 +4802,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4801
4802
|
for (const runtimeStrategy of runtimeStrategies) {
|
|
4802
4803
|
const {
|
|
4803
4804
|
strategyName,
|
|
4804
|
-
|
|
4805
|
+
version,
|
|
4805
4806
|
controlState,
|
|
4806
4807
|
strategyPackageVersion,
|
|
4807
4808
|
runtimePackageVersion,
|
|
@@ -4809,7 +4810,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4809
4810
|
sourceStrategyConfig,
|
|
4810
4811
|
strategyConfig
|
|
4811
4812
|
} = runtimeStrategy;
|
|
4812
|
-
const runtimeIdentity = `v${
|
|
4813
|
+
const runtimeIdentity = `v${version}`;
|
|
4813
4814
|
const runtimeConfig = buildRuntimeModeStrategyConfig({
|
|
4814
4815
|
strategyConfig,
|
|
4815
4816
|
env: "CRON",
|
|
@@ -4819,7 +4820,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4819
4820
|
const runtimeLineage = await buildRuntimeLineage({
|
|
4820
4821
|
projectRoot,
|
|
4821
4822
|
strategyName,
|
|
4822
|
-
|
|
4823
|
+
version,
|
|
4823
4824
|
strategyPackageVersion,
|
|
4824
4825
|
runtimePackageVersion,
|
|
4825
4826
|
config: { strategyConfig },
|
|
@@ -4862,7 +4863,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4862
4863
|
userName,
|
|
4863
4864
|
connectorName,
|
|
4864
4865
|
runtimeConfigId: runtimeIdentity,
|
|
4865
|
-
|
|
4866
|
+
runtimeVersion: version,
|
|
4866
4867
|
entriesPaused: controlState === "entries_paused",
|
|
4867
4868
|
runtimeLineage,
|
|
4868
4869
|
runtimeConfigSnapshot: {
|
|
@@ -4917,12 +4918,12 @@ var createSignalsTickerEvaluator = ({
|
|
|
4917
4918
|
symbol,
|
|
4918
4919
|
timestamp: lastCandle.timestamp,
|
|
4919
4920
|
runtimeConfigId: runtimeIdentity,
|
|
4920
|
-
|
|
4921
|
+
runtimeVersion: version
|
|
4921
4922
|
}),
|
|
4922
4923
|
userName,
|
|
4923
4924
|
strategy: strategyName,
|
|
4924
4925
|
runtimeConfigId: runtimeIdentity,
|
|
4925
|
-
|
|
4926
|
+
runtimeVersion: version,
|
|
4926
4927
|
runtimeLineage,
|
|
4927
4928
|
symbol,
|
|
4928
4929
|
interval,
|
|
@@ -4940,10 +4941,10 @@ var createSignalsTickerEvaluator = ({
|
|
|
4940
4941
|
}
|
|
4941
4942
|
if (stats) stats.signals += 1;
|
|
4942
4943
|
signal.runtimeConfigId = runtimeIdentity;
|
|
4943
|
-
signal.
|
|
4944
|
+
signal.runtimeVersion = version;
|
|
4944
4945
|
signal.runtimeLineage = runtimeLineage;
|
|
4945
|
-
if (
|
|
4946
|
-
signal.signalId = `${signal.signalId}:v${
|
|
4946
|
+
if (version && !signal.signalId.endsWith(`:v${version}`)) {
|
|
4947
|
+
signal.signalId = `${signal.signalId}:v${version}`;
|
|
4947
4948
|
}
|
|
4948
4949
|
await (0, import_strategies4.enrichSignalWithBinanceMarketContext)({ signal, env: "CRON" });
|
|
4949
4950
|
if (signal.orderStatus === "skipped" && typeof signal.orderSkipReason === "string" && signal.orderSkipReason.trim()) {
|
|
@@ -4962,12 +4963,12 @@ var createSignalsTickerEvaluator = ({
|
|
|
4962
4963
|
symbol,
|
|
4963
4964
|
timestamp: lastCandle.timestamp,
|
|
4964
4965
|
runtimeConfigId: runtimeIdentity,
|
|
4965
|
-
|
|
4966
|
+
runtimeVersion: version
|
|
4966
4967
|
}),
|
|
4967
4968
|
userName,
|
|
4968
4969
|
strategy: strategyName,
|
|
4969
4970
|
runtimeConfigId: runtimeIdentity,
|
|
4970
|
-
|
|
4971
|
+
runtimeVersion: version,
|
|
4971
4972
|
runtimeLineage,
|
|
4972
4973
|
symbol,
|
|
4973
4974
|
interval,
|
|
@@ -4994,7 +4995,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
4994
4995
|
|
|
4995
4996
|
// src/lib/signals/configuredScopes.ts
|
|
4996
4997
|
var sorted = (values) => values ? [...values].sort() : [];
|
|
4997
|
-
var formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}@v${strategy.
|
|
4998
|
+
var formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}@v${strategy.version}[${strategy.controlState}]`;
|
|
4998
4999
|
var buildConfiguredSignalsScopes = ({
|
|
4999
5000
|
connectorName,
|
|
5000
5001
|
deployment,
|
|
@@ -5099,13 +5100,14 @@ var createSignalsRunner = (config2) => {
|
|
|
5099
5100
|
return connectorName;
|
|
5100
5101
|
};
|
|
5101
5102
|
const createSignalsSession2 = async (lifecycle, scope = {}) => {
|
|
5102
|
-
const deployment = config2.deploymentId ? await (0,
|
|
5103
|
+
const deployment = config2.deploymentId ? await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5104
|
+
userName: config2.userName,
|
|
5105
|
+
projectRoot,
|
|
5106
|
+
deploymentId: config2.deploymentId
|
|
5107
|
+
}) : null;
|
|
5103
5108
|
if (config2.deploymentId && !deployment) {
|
|
5104
5109
|
throw new Error(`Runtime deployment not found: ${config2.deploymentId}`);
|
|
5105
5110
|
}
|
|
5106
|
-
if (deployment && !deployment.enabled) {
|
|
5107
|
-
throw new Error(`Runtime deployment is disabled: ${deployment.id}`);
|
|
5108
|
-
}
|
|
5109
5111
|
const requestedRuntimeInterval = scope.interval ?? interval;
|
|
5110
5112
|
const runtimeInterval = requestedRuntimeInterval;
|
|
5111
5113
|
const runtimeIntervalMs = Number(runtimeInterval) * 6e4;
|
|
@@ -5326,7 +5328,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5326
5328
|
const runtimeStrategies = await (0, import_runtimeStrategies.loadResolvedRuntimeStrategies)({
|
|
5327
5329
|
userName: config2.userName,
|
|
5328
5330
|
projectRoot,
|
|
5329
|
-
deployment,
|
|
5331
|
+
deploymentId: deployment?.id ?? "",
|
|
5330
5332
|
universe,
|
|
5331
5333
|
accountId,
|
|
5332
5334
|
interval: interval2
|
|
@@ -5343,7 +5345,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5343
5345
|
new Set(
|
|
5344
5346
|
tickers.flatMap(
|
|
5345
5347
|
(symbol) => runtimeStrategies.map(
|
|
5346
|
-
({ strategyName,
|
|
5348
|
+
({ strategyName, version }) => buildSignalsStrategyLifecycleKey({
|
|
5347
5349
|
connectorName,
|
|
5348
5350
|
universe: sessionUniverse,
|
|
5349
5351
|
accountId,
|
|
@@ -5351,7 +5353,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5351
5353
|
symbol,
|
|
5352
5354
|
interval: interval2,
|
|
5353
5355
|
strategyName,
|
|
5354
|
-
configId: `v${
|
|
5356
|
+
configId: `v${version}`
|
|
5355
5357
|
})
|
|
5356
5358
|
)
|
|
5357
5359
|
)
|
|
@@ -5482,7 +5484,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5482
5484
|
}
|
|
5483
5485
|
const durationMs = Date.now() - startedAt;
|
|
5484
5486
|
if (activeSession?.deployment) {
|
|
5485
|
-
await (0,
|
|
5487
|
+
await (0, import_runtimeHeartbeats.saveRuntimeDeploymentHeartbeat)(config2.userName, {
|
|
5486
5488
|
deploymentId: activeSession.deployment.id,
|
|
5487
5489
|
status: getSignalsHeartbeatStatus({
|
|
5488
5490
|
cycleStatus: status,
|
|
@@ -5540,7 +5542,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5540
5542
|
const configuredStrategies = await (0, import_runtimeStrategies.loadResolvedRuntimeStrategies)({
|
|
5541
5543
|
userName: config2.userName,
|
|
5542
5544
|
projectRoot,
|
|
5543
|
-
deployment
|
|
5545
|
+
deploymentId: deployment.id
|
|
5544
5546
|
});
|
|
5545
5547
|
const connectorName = await resolveSignalsConnectorName(
|
|
5546
5548
|
deployment.connectorName
|
|
@@ -5560,10 +5562,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5560
5562
|
if (!config2.deploymentId) {
|
|
5561
5563
|
throw new Error("Runtime deployment id is required");
|
|
5562
5564
|
}
|
|
5563
|
-
const configuredDeployment = await (0,
|
|
5564
|
-
config2.userName,
|
|
5565
|
-
|
|
5566
|
-
|
|
5565
|
+
const configuredDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5566
|
+
userName: config2.userName,
|
|
5567
|
+
projectRoot,
|
|
5568
|
+
deploymentId: config2.deploymentId
|
|
5569
|
+
});
|
|
5567
5570
|
if (!configuredDeployment) {
|
|
5568
5571
|
throw new Error(`Runtime deployment not found: ${config2.deploymentId}`);
|
|
5569
5572
|
}
|
|
@@ -5593,10 +5596,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5593
5596
|
throw new Error("Runtime deployment id is required");
|
|
5594
5597
|
}
|
|
5595
5598
|
const deploymentId = config2.deploymentId;
|
|
5596
|
-
const initialDeployment = await (0,
|
|
5597
|
-
config2.userName,
|
|
5599
|
+
const initialDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5600
|
+
userName: config2.userName,
|
|
5601
|
+
projectRoot,
|
|
5598
5602
|
deploymentId
|
|
5599
|
-
);
|
|
5603
|
+
});
|
|
5600
5604
|
if (!initialDeployment) {
|
|
5601
5605
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
5602
5606
|
}
|
|
@@ -5617,10 +5621,11 @@ var createSignalsRunner = (config2) => {
|
|
|
5617
5621
|
settleDelayMs: resolveNonNegativeInteger(config2.settleDelayMs, 5e3),
|
|
5618
5622
|
signal: abortController.signal,
|
|
5619
5623
|
runCycle: async () => {
|
|
5620
|
-
const currentDeployment = await (0,
|
|
5621
|
-
config2.userName,
|
|
5624
|
+
const currentDeployment = await (0, import_runtimeStrategies2.getRuntimeDeployment)({
|
|
5625
|
+
userName: config2.userName,
|
|
5626
|
+
projectRoot,
|
|
5622
5627
|
deploymentId
|
|
5623
|
-
);
|
|
5628
|
+
});
|
|
5624
5629
|
if (!currentDeployment) {
|
|
5625
5630
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
5626
5631
|
}
|
|
@@ -5700,7 +5705,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5700
5705
|
await session.klineFeed?.close();
|
|
5701
5706
|
session.lifecycle.clear();
|
|
5702
5707
|
if (session.deployment) {
|
|
5703
|
-
await (0,
|
|
5708
|
+
await (0, import_runtimeHeartbeats.saveRuntimeDeploymentHeartbeat)(config2.userName, {
|
|
5704
5709
|
deploymentId: session.deployment.id,
|
|
5705
5710
|
status: "stopped",
|
|
5706
5711
|
pid: process.pid,
|
|
@@ -768,7 +768,7 @@ var buildRuntimeDebugReportAttachment = async (params) => {
|
|
|
768
768
|
};
|
|
769
769
|
|
|
770
770
|
// src/scripts/signalsSummary.ts
|
|
771
|
-
var
|
|
771
|
+
var import_runtimeStrategies = require("@tradejs/node/runtimeStrategies");
|
|
772
772
|
import_args.default.option(["u", "user"], "Use user config", "root");
|
|
773
773
|
import_args.default.option(
|
|
774
774
|
"connector",
|
|
@@ -1306,7 +1306,7 @@ var signalsSummary = async () => {
|
|
|
1306
1306
|
loadRuntimeSignals(flags.user, { startTime, endTime }),
|
|
1307
1307
|
loadRuntimeSignalEvaluationStatsBuckets(flags.user),
|
|
1308
1308
|
loadRuntimeTrades(flags.user),
|
|
1309
|
-
(0,
|
|
1309
|
+
(0, import_runtimeStrategies.listRuntimeDeployments)({ userName: flags.user, projectRoot })
|
|
1310
1310
|
]);
|
|
1311
1311
|
const {
|
|
1312
1312
|
trades: syncedTrades,
|
|
@@ -250,8 +250,8 @@ var verifyFullPeriodChartArtifact = async (input) => {
|
|
|
250
250
|
return false;
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
|
-
var hasExactRuntimeTarget = (target) => Boolean(
|
|
254
|
-
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.
|
|
253
|
+
var hasExactRuntimeTarget = (target, strategyName) => Boolean(
|
|
254
|
+
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.strategyName.trim() === strategyName.trim() && Number.isSafeInteger(target.version) && target.version > 0
|
|
255
255
|
);
|
|
256
256
|
var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
257
257
|
const blockers = [];
|
|
@@ -336,13 +336,14 @@ var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
|
336
336
|
targetDirection: input.recentFailure?.direction ?? null,
|
|
337
337
|
maxLossValue: 1,
|
|
338
338
|
requiresRuntimeBinding: !hasExactRuntimeTarget(
|
|
339
|
-
input.forwardTest.runtimeTarget
|
|
339
|
+
input.forwardTest.runtimeTarget,
|
|
340
|
+
input.strategy
|
|
340
341
|
),
|
|
341
342
|
blockers: ["FORWARD_NOT_AUTHORIZED"],
|
|
342
343
|
summary: "The candidate is ready for a separately authorized micro-forward test at MAX_LOSS_VALUE=1."
|
|
343
344
|
};
|
|
344
345
|
}
|
|
345
|
-
if (!hasExactRuntimeTarget(input.forwardTest.runtimeTarget)) {
|
|
346
|
+
if (!hasExactRuntimeTarget(input.forwardTest.runtimeTarget, input.strategy)) {
|
|
346
347
|
return {
|
|
347
348
|
strategy: input.strategy,
|
|
348
349
|
action: "MICRO_FORWARD_READY",
|
|
@@ -351,7 +352,7 @@ var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
|
351
352
|
maxLossValue: 1,
|
|
352
353
|
requiresRuntimeBinding: true,
|
|
353
354
|
blockers: [],
|
|
354
|
-
summary: "The portable micro-forward handoff is ready.
|
|
355
|
+
summary: "The portable micro-forward handoff is ready. Commit its deployment, account binding, complete config, and explicit strategy version in TradeJS-Project."
|
|
355
356
|
};
|
|
356
357
|
}
|
|
357
358
|
return {
|