@tradejs/cli 3.1.28-beta.258 → 3.1.29-beta.259

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.
@@ -1023,7 +1023,14 @@ var discoverRuntimeEvidenceCompositionSnapshots = async (evidenceRoot) => {
1023
1023
  };
1024
1024
 
1025
1025
  // src/lib/runtimeEvidenceCompositions.ts
1026
- var stableSnapshotIdentity = (deployment) => JSON.stringify({ ...deployment, tickers: void 0 });
1026
+ var stableSnapshotIdentity = (deployment) => JSON.stringify({
1027
+ ...deployment,
1028
+ tickers: void 0,
1029
+ strategies: deployment.strategies.map((strategy) => ({
1030
+ ...strategy,
1031
+ controlState: void 0
1032
+ }))
1033
+ });
1027
1034
  var producerIdentity = (producer) => JSON.stringify(producer);
1028
1035
  var loadRuntimeEvidenceCompositionSnapshots = async ({
1029
1036
  publishRoot,
@@ -4852,6 +4852,7 @@ var createSignalsTickerEvaluator = ({
4852
4852
  orderStatus: signal.orderStatus,
4853
4853
  orderSkipReason: signal.orderSkipReason,
4854
4854
  ...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {},
4855
+ ...signal.assessment ? { assessment: signal.assessment } : {},
4855
4856
  ...signal.allocatorDecision ? { allocatorDecision: signal.allocatorDecision } : {},
4856
4857
  ...signal.riskDecision ? { riskDecision: signal.riskDecision } : {},
4857
4858
  ...signal.ml ? { ml: signal.ml } : {}
@@ -4850,6 +4850,7 @@ var createSignalsTickerEvaluator = ({
4850
4850
  orderStatus: signal.orderStatus,
4851
4851
  orderSkipReason: signal.orderSkipReason,
4852
4852
  ...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {},
4853
+ ...signal.assessment ? { assessment: signal.assessment } : {},
4853
4854
  ...signal.allocatorDecision ? { allocatorDecision: signal.allocatorDecision } : {},
4854
4855
  ...signal.riskDecision ? { riskDecision: signal.riskDecision } : {},
4855
4856
  ...signal.ml ? { ml: signal.ml } : {}
@@ -838,11 +838,13 @@ var stripTelegramHtml = (value) => unescapeHtml(value.replace(/<\/?(?:b|code)>/g
838
838
  var buildSignalsSummaryAttachment = ({
839
839
  userName,
840
840
  endTime,
841
- content
841
+ content,
842
+ deploymentId
842
843
  }) => {
843
844
  const dayKey = formatSummaryIsoDayKey(endTime);
845
+ const scope = deploymentId ? `-${deploymentId}` : "";
844
846
  return {
845
- filename: `tradejs-signals-summary-${userName}-${dayKey}.txt`,
847
+ filename: `tradejs-signals-summary-${userName}${scope}-${dayKey}.txt`,
846
848
  content: stripTelegramHtml(content),
847
849
  caption: `Signals summary ${dayKey} ${SUMMARY_TIMEZONE_LABEL}`
848
850
  };
@@ -1003,6 +1005,7 @@ var mergeRuntimeSignalStats = (target, source) => {
1003
1005
  }
1004
1006
  };
1005
1007
  var buildSummaryPrelude = ({
1008
+ deploymentId,
1006
1009
  hours,
1007
1010
  startTime,
1008
1011
  endTime,
@@ -1016,6 +1019,7 @@ var buildSummaryPrelude = ({
1016
1019
  const windowPnlLabel = hours === 24 ? "24h Realized PnL" : `${hours}h Realized PnL`;
1017
1020
  return [
1018
1021
  `\u{1F4CB} <b>${escapeHtml(resolveSummaryTitle(hours))}</b>`,
1022
+ ...deploymentId ? [`Deployment: <b>${escapeHtml(deploymentId)}</b>`] : [],
1019
1023
  "",
1020
1024
  "\u{1F552} <b>Window</b>",
1021
1025
  `<b>${escapeHtml(formatMskDateTime(startTime))} - ${escapeHtml(formatMskDateTime(endTime))} ${SUMMARY_TIMEZONE_LABEL}</b>`,
@@ -1044,6 +1048,7 @@ var isRuntimeTradeClosedInWindow = (trade, startTime, endTime) => {
1044
1048
  return !isRuntimeTradeSyncFallbackClose(trade);
1045
1049
  };
1046
1050
  var buildSummaryMessages = ({
1051
+ deploymentId,
1047
1052
  hours,
1048
1053
  startTime,
1049
1054
  endTime,
@@ -1162,6 +1167,7 @@ var buildSummaryMessages = ({
1162
1167
  );
1163
1168
  const winRateText = formatWinRateText(closedWins, closedKnown);
1164
1169
  const prelude = buildSummaryPrelude({
1170
+ deploymentId,
1165
1171
  hours,
1166
1172
  startTime,
1167
1173
  endTime,
@@ -1328,15 +1334,6 @@ var signalsSummary = async () => {
1328
1334
  (signal) => signal.timestamp >= startTime && signal.timestamp < endTime
1329
1335
  );
1330
1336
  const windowDayKeys = new Set((0, import_time3.getRuntimeStorageDayKeys)(startTime, endTime));
1331
- const windowEvaluationStats = /* @__PURE__ */ new Map();
1332
- for (const entry of evaluationStatsBuckets) {
1333
- if (!windowDayKeys.has(entry.dayKey)) {
1334
- continue;
1335
- }
1336
- const stats = windowEvaluationStats.get(entry.strategy) ?? createRuntimeSignalStats();
1337
- mergeRuntimeSignalStats(stats, entry.stats);
1338
- windowEvaluationStats.set(entry.strategy, stats);
1339
- }
1340
1337
  const windowClosedTrades = syncedTrades.filter(
1341
1338
  (trade) => isRuntimeTradeClosedInWindow(trade, startTime, endTime)
1342
1339
  );
@@ -1344,76 +1341,109 @@ var signalsSummary = async () => {
1344
1341
  (trade) => trade.status === "active" && activeTradeOrderIds.has(trade.orderId) && typeof trade.entryTimestamp === "number" && Number.isFinite(trade.entryTimestamp) && trade.entryTimestamp < endTime
1345
1342
  );
1346
1343
  const windowTrades = [...windowClosedTrades, ...openSnapshotTrades];
1347
- const windowTradeSignalIds = new Set(
1348
- windowTrades.map((trade) => trade.signalId).filter((signalId) => typeof signalId === "string")
1349
- );
1350
- const debugSignals = windowSignals.filter(
1351
- (signal) => windowTradeSignalIds.has(signal.signalId)
1352
- );
1353
- const { signalsMessage, tradesMessage } = buildSummaryMessages({
1354
- hours,
1355
- startTime,
1356
- endTime,
1357
- configuredStrategyNames,
1358
- signals: windowSignals,
1359
- evaluationStatsByStrategy: windowEvaluationStats,
1360
- trades: windowTrades
1361
- });
1362
- const windowEvaluationsCount = [...windowEvaluationStats.values()].reduce(
1363
- (sum, stats) => sum + stats.evaluated,
1364
- 0
1365
- );
1366
- import_logger.logger.info(
1367
- "signals summary window=%sh signals=%s evaluations=%s trades=%s connectors=%s scopes=%s user=%s",
1368
- hours,
1369
- windowSignals.length,
1370
- windowEvaluationsCount,
1371
- windowClosedTrades.length,
1372
- connectorNames.join(",") || fallbackConnectorName,
1373
- scopesCount,
1374
- flags.user
1375
- );
1376
- const debugAttachment = shouldAttachDebugReport(flags.debugAttachment) ? await buildRuntimeDebugReportAttachment({
1377
- userName: flags.user,
1378
- startTime,
1379
- endTime,
1380
- signals: debugSignals,
1381
- evaluations: [],
1382
- trades: windowTrades
1383
- }) : null;
1384
- const signalsAttachment = buildSignalsSummaryAttachment({
1385
- userName: flags.user,
1386
- endTime,
1387
- content: signalsMessage
1388
- });
1389
- const tradesMessageWithAttachmentSummary = appendReportAttachmentSummary({
1390
- message: tradesMessage,
1391
- signalsFilename: signalsAttachment.filename,
1392
- filename: debugAttachment?.filename,
1393
- tradesCount: debugAttachment ? windowTrades.length : void 0,
1394
- signalsCount: debugAttachment ? debugAttachment.summary?.signals ?? debugSignals.length : void 0,
1395
- evaluationsCount: debugAttachment ? debugAttachment.summary?.evaluations ?? 0 : void 0
1396
- });
1397
- const attachments = [
1398
- signalsAttachment,
1399
- ...debugAttachment ? [debugAttachment] : []
1400
- ];
1401
- if (flags.printOnly) {
1402
- console.log(tradesMessageWithAttachmentSummary);
1403
- console.log("");
1404
- console.log(`Signals attachment: ${signalsAttachment.filename}`);
1405
- console.log(signalsAttachment.content);
1406
- if (debugAttachment) {
1344
+ const deploymentScopes = runtimeDeployments.filter((item) => item.enabled);
1345
+ const scopes = deploymentScopes.length ? deploymentScopes.map((deployment) => ({
1346
+ deploymentId: deployment.id,
1347
+ configuredStrategyNames: deployment.strategies.map(
1348
+ (strategy) => strategy.strategyName
1349
+ )
1350
+ })) : [{ deploymentId: void 0, configuredStrategyNames }];
1351
+ for (const scope of scopes) {
1352
+ const scopeSignals = windowSignals.filter(
1353
+ (signal) => signal.deploymentId === scope.deploymentId
1354
+ );
1355
+ const scopeTrades = windowTrades.filter(
1356
+ (trade) => trade.deploymentId === scope.deploymentId
1357
+ );
1358
+ const scopeEvaluationStats = /* @__PURE__ */ new Map();
1359
+ for (const entry of evaluationStatsBuckets) {
1360
+ if (!windowDayKeys.has(entry.dayKey) || entry.deploymentId !== scope.deploymentId) {
1361
+ continue;
1362
+ }
1363
+ const stats = scopeEvaluationStats.get(entry.strategy) ?? createRuntimeSignalStats();
1364
+ mergeRuntimeSignalStats(stats, entry.stats);
1365
+ scopeEvaluationStats.set(entry.strategy, stats);
1366
+ }
1367
+ const windowTradeSignalIds = new Set(
1368
+ scopeTrades.map((trade) => trade.signalId).filter((signalId) => typeof signalId === "string")
1369
+ );
1370
+ const debugSignals = scopeSignals.filter(
1371
+ (signal) => windowTradeSignalIds.has(signal.signalId)
1372
+ );
1373
+ const { signalsMessage, tradesMessage } = buildSummaryMessages({
1374
+ deploymentId: scope.deploymentId,
1375
+ hours,
1376
+ startTime,
1377
+ endTime,
1378
+ configuredStrategyNames: scope.configuredStrategyNames,
1379
+ signals: scopeSignals,
1380
+ evaluationStatsByStrategy: scopeEvaluationStats,
1381
+ trades: scopeTrades
1382
+ });
1383
+ const windowEvaluationsCount = [...scopeEvaluationStats.values()].reduce(
1384
+ (sum, stats) => sum + stats.evaluated,
1385
+ 0
1386
+ );
1387
+ import_logger.logger.info(
1388
+ "signals summary deployment=%s window=%sh signals=%s evaluations=%s trades=%s connectors=%s scopes=%s user=%s",
1389
+ scope.deploymentId ?? "legacy",
1390
+ hours,
1391
+ scopeSignals.length,
1392
+ windowEvaluationsCount,
1393
+ scopeTrades.filter((trade) => trade.status === "closed").length,
1394
+ connectorNames.join(",") || fallbackConnectorName,
1395
+ scopesCount,
1396
+ flags.user
1397
+ );
1398
+ const debugAttachment = shouldAttachDebugReport(flags.debugAttachment) ? await buildRuntimeDebugReportAttachment({
1399
+ userName: flags.user,
1400
+ startTime,
1401
+ endTime,
1402
+ signals: debugSignals,
1403
+ evaluations: [],
1404
+ trades: scopeTrades
1405
+ }) : null;
1406
+ if (debugAttachment && scope.deploymentId) {
1407
+ debugAttachment.filename = debugAttachment.filename.replace(
1408
+ /\.(json|txt)$/,
1409
+ `-${scope.deploymentId}.$1`
1410
+ );
1411
+ }
1412
+ const signalsAttachment = buildSignalsSummaryAttachment({
1413
+ userName: flags.user,
1414
+ endTime,
1415
+ content: signalsMessage,
1416
+ deploymentId: scope.deploymentId
1417
+ });
1418
+ const tradesMessageWithAttachmentSummary = appendReportAttachmentSummary({
1419
+ message: tradesMessage,
1420
+ signalsFilename: signalsAttachment.filename,
1421
+ filename: debugAttachment?.filename,
1422
+ tradesCount: debugAttachment ? scopeTrades.length : void 0,
1423
+ signalsCount: debugAttachment ? debugAttachment.summary?.signals ?? debugSignals.length : void 0,
1424
+ evaluationsCount: debugAttachment ? debugAttachment.summary?.evaluations ?? 0 : void 0
1425
+ });
1426
+ const attachments = [
1427
+ signalsAttachment,
1428
+ ...debugAttachment ? [debugAttachment] : []
1429
+ ];
1430
+ if (flags.printOnly) {
1431
+ console.log(tradesMessageWithAttachmentSummary);
1407
1432
  console.log("");
1408
- console.log(`Debug attachment: ${debugAttachment.filename}`);
1409
- console.log(debugAttachment.content);
1433
+ console.log(`Signals attachment: ${signalsAttachment.filename}`);
1434
+ console.log(signalsAttachment.content);
1435
+ if (debugAttachment) {
1436
+ console.log("");
1437
+ console.log(`Debug attachment: ${debugAttachment.filename}`);
1438
+ console.log(debugAttachment.content);
1439
+ }
1440
+ continue;
1410
1441
  }
1411
- return;
1442
+ await sendTelegramReport(tradesMessageWithAttachmentSummary, {
1443
+ userName: flags.user,
1444
+ attachments
1445
+ });
1412
1446
  }
1413
- await sendTelegramReport(tradesMessageWithAttachmentSummary, {
1414
- userName: flags.user,
1415
- attachments
1416
- });
1417
1447
  };
1418
1448
  var main = signalsSummary;
1419
1449
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/cli",
3
- "version": "3.1.28-beta.258",
3
+ "version": "3.1.29-beta.259",
4
4
  "description": "Official CLI for the TradeJS TypeScript framework: infra setup, backtests, signals, bots, and ML workflows.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -36,13 +36,13 @@
36
36
  "tradejs": "dist/cli.js"
37
37
  },
38
38
  "dependencies": {
39
- "@tradejs/connectors": "^3.1.28-beta.258",
40
- "@tradejs/core": "^3.1.28-beta.258",
41
- "@tradejs/indicators": "^3.1.28-beta.258",
42
- "@tradejs/infra": "^3.1.28-beta.258",
43
- "@tradejs/node": "^3.1.28-beta.258",
39
+ "@tradejs/connectors": "^3.1.29-beta.259",
40
+ "@tradejs/core": "^3.1.29-beta.259",
41
+ "@tradejs/indicators": "^3.1.29-beta.259",
42
+ "@tradejs/infra": "^3.1.29-beta.259",
43
+ "@tradejs/node": "^3.1.29-beta.259",
44
44
  "@tradejs/strategy-kit": "3.0.6",
45
- "@tradejs/types": "^3.1.28-beta.258",
45
+ "@tradejs/types": "^3.1.29-beta.259",
46
46
  "args": "^5.0.3",
47
47
  "bcryptjs": "^2.4.3",
48
48
  "chalk": "4.1.2",