@tradejs/cli 3.1.29-beta.290 → 3.1.29-beta.292

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.
@@ -827,7 +827,9 @@ var BASE_CONTEXT_FEATURE_SECTIONS = [
827
827
  "relative",
828
828
  "derivatives",
829
829
  "mtf",
830
- "gateFeatures"
830
+ "gateFeatures",
831
+ "tickerProfile",
832
+ "portfolioContext"
831
833
  ];
832
834
  var asRecord = (value) => typeof value === "object" && value != null && !Array.isArray(value) ? value : null;
833
835
  var collectStrategyGateFeatures = (baseContext) => {
@@ -844,6 +846,7 @@ var pickBaseContextFeatureSections = (baseContext) => Object.fromEntries(
844
846
  );
845
847
  var buildAiTrainEvaluationFeatureSnapshot = ({
846
848
  additionalIndicators,
849
+ featureSnapshot,
847
850
  mode
848
851
  }) => {
849
852
  if (mode === "none") {
@@ -853,12 +856,14 @@ var buildAiTrainEvaluationFeatureSnapshot = ({
853
856
  const baseContext = asRecord(additional?.baseContext);
854
857
  if (!baseContext) {
855
858
  return {
856
- baseContextAvailable: false
859
+ baseContextAvailable: false,
860
+ ...featureSnapshot ? { featureSnapshot } : {}
857
861
  };
858
862
  }
859
863
  const strategyGateFeatures = collectStrategyGateFeatures(baseContext);
860
864
  const snapshot = {
861
865
  baseContextAvailable: true,
866
+ ...featureSnapshot ? { featureSnapshot } : {},
862
867
  gateFeatures: baseContext.gateFeatures ?? null,
863
868
  ...strategyGateFeatures ? { strategyGateFeatures } : {}
864
869
  };
@@ -1059,6 +1064,8 @@ var RESEARCH_CONTEXT_ENV_KEYS = [
1059
1064
  "INTERVAL",
1060
1065
  "DERIVATIVES_CONTEXT_ENABLED",
1061
1066
  "DERIVATIVES_CONTEXT_TARGET_ENABLED",
1067
+ "TICKER_PROFILES_PROVIDER",
1068
+ "TICKER_PROFILES_UNIVERSE",
1062
1069
  "DERIVATIVES_CONTEXT_LOOKBACK_HOURS",
1063
1070
  "DERIVATIVES_CONTEXT_EXTRA_REFERENCE_SYMBOLS",
1064
1071
  "DERIVATIVES_CONTEXT_EXCHANGE_PRIORITY",
@@ -1093,13 +1100,15 @@ var writeAiTrainResearchSnapshot = async ({
1093
1100
  }) => {
1094
1101
  const resolvedPath = import_node_path2.default.resolve(outputPath);
1095
1102
  await import_promises2.default.mkdir(import_node_path2.default.dirname(resolvedPath), { recursive: true });
1096
- await import_promises2.default.writeFile(
1097
- resolvedPath,
1098
- `${JSON.stringify(result, null, 2)}
1099
- `,
1100
- "utf8"
1101
- );
1102
- return resolvedPath;
1103
+ const bytes = `${JSON.stringify(result)}
1104
+ `;
1105
+ await import_promises2.default.writeFile(resolvedPath, bytes, "utf8");
1106
+ return {
1107
+ schema: "tradejs-research-report-receipt/v1",
1108
+ path: resolvedPath,
1109
+ bytes: Buffer.byteLength(bytes),
1110
+ sha256: (0, import_node_crypto2.createHash)("sha256").update(bytes).digest("hex")
1111
+ };
1103
1112
  };
1104
1113
  var normalizeForStableJson = (value) => {
1105
1114
  if (Array.isArray(value)) {
@@ -1416,6 +1425,7 @@ var extractSignalFromAiDatasetRow = (row) => {
1416
1425
  const { payload } = row;
1417
1426
  return {
1418
1427
  ...payload.signal,
1428
+ aiFeatureReplay: { snapshot: payload.featureSnapshot ?? null },
1419
1429
  strategy: payload.signal.strategy,
1420
1430
  figures: payload.figures ?? {},
1421
1431
  indicators: payload.indicators ?? {},
@@ -1474,7 +1484,11 @@ import_args.default.option(
1474
1484
  "Save compact AI approval chart data for the strategies UI",
1475
1485
  false
1476
1486
  );
1477
- import_args.default.option(["j", "json"], "Print structured JSON summary", false);
1487
+ import_args.default.option(
1488
+ ["j", "json"],
1489
+ "Print full JSON without --output; otherwise print its receipt",
1490
+ false
1491
+ );
1478
1492
  import_args.default.option(
1479
1493
  ["O", "output"],
1480
1494
  "Write the structured JSON summary to a file and suppress table output",
@@ -1938,6 +1952,7 @@ var main = async () => {
1938
1952
  const isCorrect = aiApproved === profitableTrade;
1939
1953
  const features = buildAiTrainEvaluationFeatureSnapshot({
1940
1954
  additionalIndicators: payload.additionalIndicators,
1955
+ featureSnapshot: payload.featureSnapshot,
1941
1956
  mode: dumpFeatureMode
1942
1957
  });
1943
1958
  evaluations.push({
@@ -2182,14 +2197,11 @@ var main = async () => {
2182
2197
  ttlMs: import_constants.TTL_1M
2183
2198
  });
2184
2199
  }
2185
- if (jsonOutputPath) {
2186
- await writeAiTrainResearchSnapshot({
2187
- outputPath: jsonOutputPath,
2188
- result
2189
- });
2190
- }
2200
+ const reportReceipt = jsonOutputPath ? await writeAiTrainResearchSnapshot({ outputPath: jsonOutputPath, result }) : null;
2191
2201
  if (jsonOutput) {
2192
- if (printJsonOutput) {
2202
+ if (reportReceipt) {
2203
+ console.log(JSON.stringify(reportReceipt));
2204
+ } else if (printJsonOutput) {
2193
2205
  console.log(JSON.stringify(result));
2194
2206
  }
2195
2207
  process.exit(failed === selectedRows ? 1 : 0);