@tradejs/cli 3.1.29-beta.296 → 3.1.29-beta.298

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 CHANGED
@@ -12367,6 +12367,18 @@ var init_binanceMarketContextBackfill = __esm({
12367
12367
  });
12368
12368
 
12369
12369
  // src/lib/derivativesContextBackfill.ts
12370
+ async function resolveCoinalyzeBackfillMarket(userName3, symbol) {
12371
+ const apiKey = await getCoinalyzeApiKey(userName3);
12372
+ if (!apiKey) throw new Error("Missing Coinalyze API key.");
12373
+ const markets = (await fetchCoinalyzeMarkets(apiKey)).filter(
12374
+ (market) => market.quote_asset?.toUpperCase() === "USDT" && market.is_perpetual
12375
+ );
12376
+ const priority = parseList(
12377
+ process.env.COINALYZE_EXCHANGE_PRIORITY || process.env.DERIVATIVES_CONTEXT_EXCHANGE_PRIORITY || "A,6,0"
12378
+ );
12379
+ const { matches: matches2 } = buildMatches([symbol], markets, priority);
12380
+ return { apiKey, marketSymbol: matches2[0]?.marketSymbol };
12381
+ }
12370
12382
  var import_chalk7, import_progress5, import_async, import_constants5, import_indicators, import_derivatives, import_client2, import_userSettings3, HOUR_MS, DAY_MS7, DEFAULT_LOOKBACK_HOURS, SOURCE_INTERVALS, coinalyzeIntervalMap, derivativesIntervalMs, lastRequestTs, asInt2, parseList, parseBooleanFlag, normalizeSymbols, isDerivativesTargetContextEnabled, resolveDerivativesContextBackfillSymbols, chunkArray, isBacktestDerivativesContextEnabled, isSignalsDerivativesContextEnabled, isDerivativesContextBackfillEnabled, shouldBackfillDerivativesContextForBacktest, shouldBackfillDerivativesContextForSignals, resolveDerivativesContextIntervals, resolveDerivativesContextLookbackMs, resolveDerivativesContextBackfillWindow, resolveDerivativesContextIntervalBackfillWindow, resolveDerivativesContextMissingFetchFromMs, resolveDerivativesContextFetchFromMs, resolveDerivativesContextRequiredFetchFromMs, countBackfillWindows, buildBackfillWindows, hasDerivativesWindowCoverage, resolveDerivativesContextMissingCoverageFetchFromMs, groupDerivativesContextMissingFetchRanges, getMissingClosedDerivativesSymbols, coverageKey, extendEdges, getCoinalyzeApiKey, getCoinalyzeBaseUrl, getRequestDelayMs, getRequestTimeoutMs, networkErrorCodes, getNestedErrorValue, getCoinalyzeErrorCause, isRetryableCoinalyzeFetchError, formatCoinalyzeRequestError, fetchJsonWithRateLimit, fetchCoinalyzeMarkets, selectBestMarket, buildMatches, normalizeMetricPoint, toSeriesMap, fetchMetricBatch, skippedBackfillResult2, backfillDerivativesContext, backfillDerivativesContextForBacktest, backfillDerivativesContextForSignals;
12371
12383
  var init_derivativesContextBackfill = __esm({
12372
12384
  "src/lib/derivativesContextBackfill.ts"() {
@@ -14107,11 +14119,27 @@ var init_coinMarketCapContextBackfill = __esm({
14107
14119
  toMs
14108
14120
  })
14109
14121
  );
14110
- const globalDailyReady = globalDailyCached || globalDailyBackfillCovered;
14111
- const referencesDailyReady = referencesDailyCached || referencesDailyBackfillCovered;
14112
- const exchangeLiquidityReady = exchangeLiquidityCached || !exchangeLiquidityEnabled || exchangeLiquidityBackfillCovered;
14113
- const fearGreedReady = fearGreedCached || !fearGreedEnabled || fearGreedBackfillCovered;
14114
- const indexesReady = indexesCached || indexesBackfillCovered;
14122
+ const ready = (dataset, existing) => params.repairDataset ? params.repairDataset !== dataset : existing;
14123
+ const globalDailyReady = ready(
14124
+ "cmc-global-1d",
14125
+ globalDailyCached || globalDailyBackfillCovered
14126
+ );
14127
+ const referencesDailyReady = ready(
14128
+ "cmc-reference_asset-1d",
14129
+ referencesDailyCached || referencesDailyBackfillCovered
14130
+ );
14131
+ const exchangeLiquidityReady = ready(
14132
+ "cmc-exchange_liquidity-1d",
14133
+ exchangeLiquidityCached || !exchangeLiquidityEnabled || exchangeLiquidityBackfillCovered
14134
+ );
14135
+ const fearGreedReady = ready(
14136
+ "cmc-fear_greed-1d",
14137
+ fearGreedCached || !fearGreedEnabled || fearGreedBackfillCovered
14138
+ );
14139
+ const indexesReady = ready(
14140
+ "cmc-index-1d",
14141
+ indexesCached || indexesBackfillCovered
14142
+ );
14115
14143
  let globalStatus = resolveBackfillStatus({
14116
14144
  cached: globalDailyCached,
14117
14145
  covered: globalDailyBackfillCovered
@@ -26024,6 +26052,184 @@ var init_cleanTests = __esm({
26024
26052
  }
26025
26053
  });
26026
26054
 
26055
+ // src/scripts/coverageBackfill.ts
26056
+ var coverageBackfill_exports = {};
26057
+ __export(coverageBackfill_exports, {
26058
+ main: () => main17
26059
+ });
26060
+ async function fetchTarget(userName3, request, target, loaded) {
26061
+ const { dataset, end } = target;
26062
+ const { series, day } = request;
26063
+ const endMs = end - 1;
26064
+ const interval4 = dataset.interval;
26065
+ const missing = (time2) => time2 >= day && time2 < end && !loaded.has(time2);
26066
+ if (dataset.provider === "CoinMarketCap") {
26067
+ await backfillCoinMarketCapContext({
26068
+ userName: userName3,
26069
+ startMs: day,
26070
+ preloadStartMs: day,
26071
+ endMs: end,
26072
+ repairDataset: dataset.id
26073
+ });
26074
+ return;
26075
+ }
26076
+ if (dataset.provider === "Coinalyze") {
26077
+ if (interval4 !== "15m" && interval4 !== "1h") return;
26078
+ const { apiKey, marketSymbol } = await resolveCoinalyzeBackfillMarket(
26079
+ userName3,
26080
+ series
26081
+ );
26082
+ if (!marketSymbol) return;
26083
+ const { derivativesRows = [] } = await import_connectors11.marketDataProviders.coinalyze.fetchWindow({
26084
+ symbol: series,
26085
+ marketSymbol,
26086
+ apiKey,
26087
+ interval: interval4,
26088
+ fromMs: day,
26089
+ toMs: endMs
26090
+ });
26091
+ await (0, import_derivatives2.upsertDerivatives)(
26092
+ derivativesRows.filter(({ ts }) => missing(ts.getTime())).flatMap((row) => {
26093
+ const { symbol, ts, interval: interval5, source } = row;
26094
+ if (dataset.id.startsWith("coinalyze-open-interest-")) {
26095
+ return row.openInterest == null ? [] : [
26096
+ {
26097
+ symbol,
26098
+ ts,
26099
+ interval: interval5,
26100
+ source,
26101
+ openInterest: row.openInterest
26102
+ }
26103
+ ];
26104
+ }
26105
+ if (dataset.id.startsWith("coinalyze-funding-")) {
26106
+ return row.fundingRate == null ? [] : [
26107
+ {
26108
+ symbol,
26109
+ ts,
26110
+ interval: interval5,
26111
+ source,
26112
+ fundingRate: row.fundingRate
26113
+ }
26114
+ ];
26115
+ }
26116
+ const { liqLong, liqShort, liqTotal } = row;
26117
+ return liqLong == null && liqShort == null && liqTotal == null ? [] : [{ symbol, ts, interval: interval5, source, liqLong, liqShort, liqTotal }];
26118
+ })
26119
+ );
26120
+ return;
26121
+ }
26122
+ if (dataset.id === "binance-coinbase-spread-15m") {
26123
+ const { spreadRows = [] } = await import_connectors11.marketDataProviders.binance_coinbase_spread.fetchWindow({
26124
+ symbol: series,
26125
+ interval: "15m",
26126
+ fromMs: day,
26127
+ toMs: endMs
26128
+ });
26129
+ await (0, import_spread.upsertSpreadRows)(
26130
+ spreadRows.filter(({ ts }) => missing(ts.getTime()))
26131
+ );
26132
+ return;
26133
+ }
26134
+ const provider = dataset.provider === "Bybit" ? "bybit" : "binance";
26135
+ const connector = await import_connectors11.connectors[provider === "bybit" ? import_connectors11.ConnectorNames.ByBit : import_connectors11.ConnectorNames.Binance]({ userName: userName3 });
26136
+ const connectorInterval = interval4 === "5m" ? "5" : interval4 === "1h" ? "60" : "15";
26137
+ const fetchCandles = async (symbol, start) => {
26138
+ const candles = await connector.kline({
26139
+ symbol,
26140
+ interval: connectorInterval,
26141
+ start,
26142
+ end: endMs,
26143
+ silent: true
26144
+ });
26145
+ return candles.filter(
26146
+ ({ timestamp }) => timestamp >= start && timestamp < end
26147
+ );
26148
+ };
26149
+ if (dataset.id.includes("-candles-")) {
26150
+ const candles = (await fetchCandles(series, day)).filter(
26151
+ ({ timestamp }) => missing(timestamp)
26152
+ );
26153
+ await (0, import_candles3.upsertCandles)(
26154
+ (0, import_candles3.toRows)(provider, series, Number(connectorInterval), candles)
26155
+ );
26156
+ return;
26157
+ }
26158
+ if (interval4 === "1d") return;
26159
+ if (dataset.id.startsWith("binance-trade-flow-")) {
26160
+ await (0, import_marketContext5.upsertMarketTradeFlowRows)(
26161
+ buildKlineTradeFlowRows({
26162
+ symbol: series,
26163
+ interval: interval4,
26164
+ candles: (await fetchCandles(series, day)).filter(
26165
+ ({ timestamp }) => missing(timestamp)
26166
+ )
26167
+ })
26168
+ );
26169
+ return;
26170
+ }
26171
+ const universe = (0, import_strategies11.getBinanceBreadthUniverses)().find(
26172
+ (item) => item.universe === series
26173
+ );
26174
+ if (!universe)
26175
+ throw new Error("The historical Binance basket is unavailable.");
26176
+ const candlesBySymbol = {};
26177
+ const warmup = day - 2 * DAY_MS11;
26178
+ for (let offset = 0; offset < universe.symbols.length; offset += 4) {
26179
+ const entries = await Promise.all(
26180
+ universe.symbols.slice(offset, offset + 4).map(
26181
+ async (symbol) => [symbol, await fetchCandles(symbol, warmup)]
26182
+ )
26183
+ );
26184
+ Object.assign(candlesBySymbol, Object.fromEntries(entries));
26185
+ }
26186
+ const rows = buildMarketBreadthRows({
26187
+ universe: series,
26188
+ interval: interval4,
26189
+ candlesBySymbol,
26190
+ btcCandles: candlesBySymbol.BTCUSDT ?? await fetchCandles("BTCUSDT", warmup)
26191
+ });
26192
+ await (0, import_marketContext5.upsertMarketBreadthRows)(rows.filter(({ ts }) => missing(ts.getTime())));
26193
+ }
26194
+ async function main17() {
26195
+ const [userName3, dataset, series, day] = process.argv.slice(2);
26196
+ const request = { dataset, series, day: Number(day) };
26197
+ const target = (0, import_dataCoverage.resolveDataBackfill)(request);
26198
+ if (!target || !userName3)
26199
+ throw new Error(
26200
+ "Expected user, dataset, series and UTC day in milliseconds."
26201
+ );
26202
+ await (0, import_client5.waitForDbReady)();
26203
+ const before = await (0, import_dataCoverage.readDataBackfillSlots)(request, target.end);
26204
+ if (before.loaded.size < before.expected)
26205
+ await fetchTarget(userName3, request, target, before.loaded);
26206
+ const after = await (0, import_dataCoverage.readDataBackfillSlots)(request, target.end);
26207
+ const result = {
26208
+ loaded: after.loaded.size,
26209
+ added: Math.max(0, after.loaded.size - before.loaded.size),
26210
+ missing: Math.max(0, after.expected - after.loaded.size)
26211
+ };
26212
+ console.log(`TRADEJS_DATA_BACKFILL ${JSON.stringify(result)}`);
26213
+ }
26214
+ var import_connectors11, import_candles3, import_client5, import_dataCoverage, import_derivatives2, import_marketContext5, import_spread, import_strategies11, DAY_MS11;
26215
+ var init_coverageBackfill = __esm({
26216
+ "src/scripts/coverageBackfill.ts"() {
26217
+ "use strict";
26218
+ import_connectors11 = require("@tradejs/connectors");
26219
+ import_candles3 = require("@tradejs/infra/timescale/candles");
26220
+ import_client5 = require("@tradejs/infra/timescale/client");
26221
+ import_dataCoverage = require("@tradejs/infra/timescale/dataCoverage");
26222
+ import_derivatives2 = require("@tradejs/infra/timescale/derivatives");
26223
+ import_marketContext5 = require("@tradejs/infra/timescale/marketContext");
26224
+ import_spread = require("@tradejs/infra/timescale/spread");
26225
+ import_strategies11 = require("@tradejs/node/strategies");
26226
+ init_binanceMarketData();
26227
+ init_coinMarketCapContextBackfill();
26228
+ init_derivativesContextBackfill();
26229
+ DAY_MS11 = 864e5;
26230
+ }
26231
+ });
26232
+
26027
26233
  // src/lib/continuity.ts
26028
26234
  var import_types6, parseContinuityUniverse, resolveContinuityUniverses, findRepairableContinuityGap;
26029
26235
  var init_continuity = __esm({
@@ -26062,22 +26268,22 @@ var init_continuity = __esm({
26062
26268
  // src/scripts/continuity.ts
26063
26269
  var continuity_exports = {};
26064
26270
  __export(continuity_exports, {
26065
- main: () => main17
26271
+ main: () => main18
26066
26272
  });
26067
- var import_args14, import_progress9, import_chalk26, import_connectors11, import_cli9, import_constants17, import_time10, import_logger4, import_candles3, import_client5, flags12, interval2, intervalKey, projectRoot5, parseProviders, runContinuity, main17;
26273
+ var import_args14, import_progress9, import_chalk26, import_connectors12, import_cli9, import_constants17, import_time10, import_logger4, import_candles4, import_client6, flags12, interval2, intervalKey, projectRoot5, parseProviders, runContinuity, main18;
26068
26274
  var init_continuity2 = __esm({
26069
26275
  "src/scripts/continuity.ts"() {
26070
26276
  "use strict";
26071
26277
  import_args14 = __toESM(require("args"));
26072
26278
  import_progress9 = __toESM(require("progress"));
26073
26279
  import_chalk26 = __toESM(require("chalk"));
26074
- import_connectors11 = require("@tradejs/node/connectors");
26280
+ import_connectors12 = require("@tradejs/node/connectors");
26075
26281
  import_cli9 = require("@tradejs/node/cli");
26076
26282
  import_constants17 = require("@tradejs/core/constants");
26077
26283
  import_time10 = require("@tradejs/core/time");
26078
26284
  import_logger4 = require("@tradejs/infra/logger");
26079
- import_candles3 = require("@tradejs/infra/timescale/candles");
26080
- import_client5 = require("@tradejs/infra/timescale/client");
26285
+ import_candles4 = require("@tradejs/infra/timescale/candles");
26286
+ import_client6 = require("@tradejs/infra/timescale/client");
26081
26287
  init_continuity();
26082
26288
  import_args14.default.option(["t", "tickers"], "Selected tickers");
26083
26289
  import_args14.default.option(["f", "timeframe"], "Timeframe", 15);
@@ -26093,7 +26299,7 @@ var init_continuity2 = __esm({
26093
26299
  intervalKey = flags12.timeframe.toString();
26094
26300
  projectRoot5 = String(process.env.PROJECT_CWD || process.cwd()).trim() || process.cwd();
26095
26301
  parseProviders = async (value) => {
26096
- const allProviders = await (0, import_connectors11.getAvailableConnectorProviders)(projectRoot5);
26302
+ const allProviders = await (0, import_connectors12.getAvailableConnectorProviders)(projectRoot5);
26097
26303
  const raw = String(value || "").trim().toLowerCase();
26098
26304
  if (!raw || raw === "all") {
26099
26305
  return allProviders;
@@ -26161,7 +26367,7 @@ var init_continuity2 = __esm({
26161
26367
  (0, import_time10.formatUnix)(gap.ts),
26162
26368
  gap.diffSeconds
26163
26369
  );
26164
- await (0, import_candles3.deleteCandles)(provider, symbol, interval2);
26370
+ await (0, import_candles4.deleteCandles)(provider, symbol, interval2);
26165
26371
  const reloaded = await connector.kline({
26166
26372
  symbol,
26167
26373
  interval: intervalKey,
@@ -26186,12 +26392,12 @@ var init_continuity2 = __esm({
26186
26392
  )
26187
26393
  );
26188
26394
  };
26189
- main17 = async () => {
26395
+ main18 = async () => {
26190
26396
  if (!Number.isFinite(interval2) || interval2 <= 0) {
26191
26397
  import_logger4.logger.error("Invalid timeframe: %s", flags12.timeframe);
26192
26398
  process.exit(1);
26193
26399
  }
26194
- await (0, import_client5.waitForDbReady)();
26400
+ await (0, import_client6.waitForDbReady)();
26195
26401
  const reloadStart = (0, import_time10.getTimestamp)(import_constants17.PRELOAD_DAYS);
26196
26402
  const reloadEnd = (0, import_time10.getTimestamp)();
26197
26403
  let requestedUniverse;
@@ -26204,7 +26410,7 @@ var init_continuity2 = __esm({
26204
26410
  const providerIds = await parseProviders(flags12.provider);
26205
26411
  const providers = await Promise.all(
26206
26412
  providerIds.map(async (providerId) => {
26207
- const connectorName = await (0, import_connectors11.getConnectorNameByProvider)(
26413
+ const connectorName = await (0, import_connectors12.getConnectorNameByProvider)(
26208
26414
  providerId,
26209
26415
  projectRoot5
26210
26416
  );
@@ -26215,7 +26421,7 @@ var init_continuity2 = __esm({
26215
26421
  );
26216
26422
  return null;
26217
26423
  }
26218
- const creator = await (0, import_connectors11.getConnectorCreatorByName)(
26424
+ const creator = await (0, import_connectors12.getConnectorCreatorByName)(
26219
26425
  connectorName,
26220
26426
  projectRoot5
26221
26427
  );
@@ -26277,9 +26483,9 @@ var init_continuity2 = __esm({
26277
26483
  // src/scripts/derivativesIngest.ts
26278
26484
  var derivativesIngest_exports = {};
26279
26485
  __export(derivativesIngest_exports, {
26280
- main: () => main18
26486
+ main: () => main19
26281
26487
  });
26282
- var import_config4, import_args15, import_chalk27, import_indicators3, import_client6, import_derivatives2, import_spread, import_userSettings5, import_connectors12, flags13, asInt5, main18;
26488
+ var import_config4, import_args15, import_chalk27, import_indicators3, import_client7, import_derivatives3, import_spread2, import_userSettings5, import_connectors13, flags13, asInt5, main19;
26283
26489
  var init_derivativesIngest = __esm({
26284
26490
  "src/scripts/derivativesIngest.ts"() {
26285
26491
  "use strict";
@@ -26287,11 +26493,11 @@ var init_derivativesIngest = __esm({
26287
26493
  import_args15 = __toESM(require("args"));
26288
26494
  import_chalk27 = __toESM(require("chalk"));
26289
26495
  import_indicators3 = require("@tradejs/core/indicators");
26290
- import_client6 = require("@tradejs/infra/timescale/client");
26291
- import_derivatives2 = require("@tradejs/infra/timescale/derivatives");
26292
- import_spread = require("@tradejs/infra/timescale/spread");
26496
+ import_client7 = require("@tradejs/infra/timescale/client");
26497
+ import_derivatives3 = require("@tradejs/infra/timescale/derivatives");
26498
+ import_spread2 = require("@tradejs/infra/timescale/spread");
26293
26499
  import_userSettings5 = require("@tradejs/infra/userSettings");
26294
- import_connectors12 = require("@tradejs/connectors");
26500
+ import_connectors13 = require("@tradejs/connectors");
26295
26501
  import_args15.default.example(
26296
26502
  "yarn ts-node ./src/scripts/derivativesIngest --provider coinalyze --symbols BTCUSDT,ETHUSDT --intervals 15m --days 120",
26297
26503
  "Ingest market features (derivatives/spread) into Timescale by provider"
@@ -26311,9 +26517,9 @@ var init_derivativesIngest = __esm({
26311
26517
  const parsed = Number.parseInt(String(value ?? ""), 10);
26312
26518
  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
26313
26519
  };
26314
- main18 = async () => {
26520
+ main19 = async () => {
26315
26521
  const providerName = String(flags13.provider || "coinalyze").trim().toLowerCase();
26316
- const provider = import_connectors12.marketDataProviders[providerName];
26522
+ const provider = import_connectors13.marketDataProviders[providerName];
26317
26523
  if (!provider) {
26318
26524
  throw new Error(`Unsupported provider: ${providerName}`);
26319
26525
  }
@@ -26327,7 +26533,7 @@ var init_derivativesIngest = __esm({
26327
26533
  const coinalyzeApiKey = providerName === "coinalyze" ? (await (0, import_userSettings5.getUserSettings)(userName3)).COINALYZE_API_KEY : void 0;
26328
26534
  if (!symbols.length) throw new Error("No symbols provided");
26329
26535
  if (!intervals.length) throw new Error("No intervals provided");
26330
- await (0, import_client6.waitForDbReady)();
26536
+ await (0, import_client7.waitForDbReady)();
26331
26537
  const now2 = Date.now();
26332
26538
  const fromMs = now2 - days * 24 * 60 * 60 * 1e3;
26333
26539
  let totalDerivativesRows = 0;
@@ -26356,12 +26562,12 @@ var init_derivativesIngest = __esm({
26356
26562
  });
26357
26563
  const derivativesRows = window.derivativesRows ?? [];
26358
26564
  if (derivativesRows.length) {
26359
- await (0, import_derivatives2.upsertDerivatives)(derivativesRows);
26565
+ await (0, import_derivatives3.upsertDerivatives)(derivativesRows);
26360
26566
  totalDerivativesRows += derivativesRows.length;
26361
26567
  }
26362
26568
  const spreadRows = window.spreadRows ?? [];
26363
26569
  if (spreadRows.length) {
26364
- await (0, import_spread.upsertSpreadRows)(spreadRows);
26570
+ await (0, import_spread2.upsertSpreadRows)(spreadRows);
26365
26571
  totalSpreadRows += spreadRows.length;
26366
26572
  }
26367
26573
  cursor = toMs + 1;
@@ -26381,9 +26587,9 @@ var init_derivativesIngest = __esm({
26381
26587
  // src/scripts/derivativesIngestCoinalyzeAll.ts
26382
26588
  var derivativesIngestCoinalyzeAll_exports = {};
26383
26589
  __export(derivativesIngestCoinalyzeAll_exports, {
26384
- main: () => main19
26590
+ main: () => main20
26385
26591
  });
26386
- var import_config5, import_args16, import_chalk28, import_progress10, import_lodash2, import_connectors13, import_indicators4, import_async4, import_userSettings6, import_cli10, import_derivatives3, import_client7, coinalyzeIntervalMap2, flags14, asInt6, parseList2, coinalyzeBaseUrl, coinalyzeMaxRetries, lastRequestTs3, fetchJsonWithRateLimit2, fetchCoinalyzeMarkets2, selectBestMarket2, buildMatches2, normalizeMetricPoint2, toSeriesMap2, fetchMetricBatch2, main19;
26592
+ var import_config5, import_args16, import_chalk28, import_progress10, import_lodash2, import_connectors14, import_indicators4, import_async4, import_userSettings6, import_cli10, import_derivatives4, import_client8, coinalyzeIntervalMap2, flags14, asInt6, parseList2, coinalyzeBaseUrl, coinalyzeMaxRetries, lastRequestTs3, fetchJsonWithRateLimit2, fetchCoinalyzeMarkets2, selectBestMarket2, buildMatches2, normalizeMetricPoint2, toSeriesMap2, fetchMetricBatch2, main20;
26387
26593
  var init_derivativesIngestCoinalyzeAll = __esm({
26388
26594
  "src/scripts/derivativesIngestCoinalyzeAll.ts"() {
26389
26595
  "use strict";
@@ -26392,13 +26598,13 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26392
26598
  import_chalk28 = __toESM(require("chalk"));
26393
26599
  import_progress10 = __toESM(require("progress"));
26394
26600
  import_lodash2 = __toESM(require("lodash"));
26395
- import_connectors13 = require("@tradejs/connectors");
26601
+ import_connectors14 = require("@tradejs/connectors");
26396
26602
  import_indicators4 = require("@tradejs/core/indicators");
26397
26603
  import_async4 = require("@tradejs/core/async");
26398
26604
  import_userSettings6 = require("@tradejs/infra/userSettings");
26399
26605
  import_cli10 = require("@tradejs/node/cli");
26400
- import_derivatives3 = require("@tradejs/infra/timescale/derivatives");
26401
- import_client7 = require("@tradejs/infra/timescale/client");
26606
+ import_derivatives4 = require("@tradejs/infra/timescale/derivatives");
26607
+ import_client8 = require("@tradejs/infra/timescale/client");
26402
26608
  coinalyzeIntervalMap2 = {
26403
26609
  "15m": "15min",
26404
26610
  "1h": "1hour"
@@ -26592,7 +26798,7 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26592
26798
  const raw = await fetchJsonWithRateLimit2(url.toString(), apiKey);
26593
26799
  return toSeriesMap2(raw, metric);
26594
26800
  };
26595
- main19 = async () => {
26801
+ main20 = async () => {
26596
26802
  const userName3 = String(flags14.user || "root").trim() || "root";
26597
26803
  const intervals = (0, import_indicators4.normalizeDerivativesIntervals)(
26598
26804
  flags14.intervals
@@ -26610,7 +26816,7 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26610
26816
  `Missing COINALYZE_API_KEY in user settings for user ${userName3}`
26611
26817
  );
26612
26818
  }
26613
- const connectorFactory = import_connectors13.connectors[import_connectors13.ConnectorNames.ByBit];
26819
+ const connectorFactory = import_connectors14.connectors[import_connectors14.ConnectorNames.ByBit];
26614
26820
  const bybit = await connectorFactory({
26615
26821
  userName: userName3
26616
26822
  });
@@ -26662,7 +26868,7 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26662
26868
  );
26663
26869
  return;
26664
26870
  }
26665
- await (0, import_client7.waitForDbReady)();
26871
+ await (0, import_client8.waitForDbReady)();
26666
26872
  const now2 = Date.now();
26667
26873
  const fromMs = now2 - days * 24 * 60 * 60 * 1e3;
26668
26874
  const symbolBatches = import_lodash2.default.chunk(matches2, symbolBatchSize);
@@ -26730,7 +26936,7 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26730
26936
  return (0, import_indicators4.coinalyzePointsToRows)(points, interval4, "coinalyze");
26731
26937
  });
26732
26938
  if (rows.length) {
26733
- await (0, import_derivatives3.upsertDerivatives)(rows);
26939
+ await (0, import_derivatives4.upsertDerivatives)(rows);
26734
26940
  totalRows += rows.length;
26735
26941
  }
26736
26942
  const confirmedLiquidationWindow = (0, import_indicators4.resolveCoinalyzeConfirmedIntradayCoverage)({
@@ -26740,7 +26946,7 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26740
26946
  nowMs: now2
26741
26947
  });
26742
26948
  if (confirmedLiquidationWindow) {
26743
- await (0, import_derivatives3.applyDerivativesMetricCoverage)(
26949
+ await (0, import_derivatives4.applyDerivativesMetricCoverage)(
26744
26950
  batch.map((item) => {
26745
26951
  const marketSymbol = item.marketSymbol.toUpperCase();
26746
26952
  const eventRowsCount = (liqMap.get(marketSymbol) ?? []).filter(
@@ -26799,9 +27005,9 @@ var init_derivativesIngestCoinalyzeAll = __esm({
26799
27005
  // src/scripts/doctor.ts
26800
27006
  var doctor_exports = {};
26801
27007
  __export(doctor_exports, {
26802
- main: () => main20
27008
+ main: () => main21
26803
27009
  });
26804
- var import_config6, import_args17, import_chalk29, import_ioredis, import_pg2, import_node_net, okLabel, failLabel, infoLabel, toPort, parseAddress, checkRedis, checkPostgres, checkMlGrpc, flags15, main20;
27010
+ var import_config6, import_args17, import_chalk29, import_ioredis, import_pg2, import_node_net, okLabel, failLabel, infoLabel, toPort, parseAddress, checkRedis, checkPostgres, checkMlGrpc, flags15, main21;
26805
27011
  var init_doctor = __esm({
26806
27012
  "src/scripts/doctor.ts"() {
26807
27013
  "use strict";
@@ -26926,7 +27132,7 @@ var init_doctor = __esm({
26926
27132
  };
26927
27133
  import_args17.default.option("require-ml", "Treat ML gRPC connectivity as required", false).option("skip-ml", "Skip ML gRPC check", false);
26928
27134
  flags15 = import_args17.default.parse(process.argv);
26929
- main20 = async () => {
27135
+ main21 = async () => {
26930
27136
  const checks = [];
26931
27137
  checks.push(await checkRedis());
26932
27138
  checks.push(await checkPostgres());
@@ -27664,9 +27870,9 @@ var init_executionCalibration = __esm({
27664
27870
  var executionCalibration_exports = {};
27665
27871
  __export(executionCalibration_exports, {
27666
27872
  executionCalibration: () => executionCalibration,
27667
- main: () => main21
27873
+ main: () => main22
27668
27874
  });
27669
- var import_promises21, import_node_path17, import_args18, import_chalk30, flags16, projectRoot6, readJsonFile, resolveInputPath, executionCalibration, main21;
27875
+ var import_promises21, import_node_path17, import_args18, import_chalk30, flags16, projectRoot6, readJsonFile, resolveInputPath, executionCalibration, main22;
27670
27876
  var init_executionCalibration2 = __esm({
27671
27877
  "src/scripts/executionCalibration.ts"() {
27672
27878
  "use strict";
@@ -27741,7 +27947,7 @@ var init_executionCalibration2 = __esm({
27741
27947
  )
27742
27948
  );
27743
27949
  };
27744
- main21 = executionCalibration;
27950
+ main22 = executionCalibration;
27745
27951
  }
27746
27952
  });
27747
27953
 
@@ -27859,15 +28065,15 @@ volumes:
27859
28065
  // src/scripts/infraDown.ts
27860
28066
  var infraDown_exports = {};
27861
28067
  __export(infraDown_exports, {
27862
- main: () => main22
28068
+ main: () => main23
27863
28069
  });
27864
- var import_chalk32, main22;
28070
+ var import_chalk32, main23;
27865
28071
  var init_infraDown = __esm({
27866
28072
  "src/scripts/infraDown.ts"() {
27867
28073
  "use strict";
27868
28074
  import_chalk32 = __toESM(require("chalk"));
27869
28075
  init_infraCommon();
27870
- main22 = async () => {
28076
+ main23 = async () => {
27871
28077
  const composePath = requireDevComposeFile();
27872
28078
  console.log(import_chalk32.default.cyan("Stopping dev infra (timescale, redis)..."));
27873
28079
  runDockerCompose(composePath, ["stop", "timescale", "redis"]);
@@ -27879,15 +28085,15 @@ var init_infraDown = __esm({
27879
28085
  // src/scripts/infraInit.ts
27880
28086
  var infraInit_exports = {};
27881
28087
  __export(infraInit_exports, {
27882
- main: () => main23
28088
+ main: () => main24
27883
28089
  });
27884
- var import_chalk33, main23;
28090
+ var import_chalk33, main24;
27885
28091
  var init_infraInit = __esm({
27886
28092
  "src/scripts/infraInit.ts"() {
27887
28093
  "use strict";
27888
28094
  import_chalk33 = __toESM(require("chalk"));
27889
28095
  init_infraCommon();
27890
- main23 = async () => {
28096
+ main24 = async () => {
27891
28097
  initDevComposeFile();
27892
28098
  console.log(import_chalk33.default.green("Dev infra files are initialized."));
27893
28099
  };
@@ -27897,15 +28103,15 @@ var init_infraInit = __esm({
27897
28103
  // src/scripts/infraUp.ts
27898
28104
  var infraUp_exports = {};
27899
28105
  __export(infraUp_exports, {
27900
- main: () => main24
28106
+ main: () => main25
27901
28107
  });
27902
- var import_chalk34, main24;
28108
+ var import_chalk34, main25;
27903
28109
  var init_infraUp = __esm({
27904
28110
  "src/scripts/infraUp.ts"() {
27905
28111
  "use strict";
27906
28112
  import_chalk34 = __toESM(require("chalk"));
27907
28113
  init_infraCommon();
27908
- main24 = async () => {
28114
+ main25 = async () => {
27909
28115
  const composePath = requireDevComposeFile();
27910
28116
  console.log(import_chalk34.default.cyan("Starting dev infra (timescale, redis)..."));
27911
28117
  runDockerCompose(composePath, [
@@ -27925,27 +28131,27 @@ var init_infraUp = __esm({
27925
28131
  // src/scripts/cleanupMarketContext.ts
27926
28132
  var cleanupMarketContext_exports = {};
27927
28133
  __export(cleanupMarketContext_exports, {
27928
- main: () => main25
28134
+ main: () => main26
27929
28135
  });
27930
- var import_config7, import_args19, import_chalk35, import_client8, import_marketContext5, flags17, main25;
28136
+ var import_config7, import_args19, import_chalk35, import_client9, import_marketContext6, flags17, main26;
27931
28137
  var init_cleanupMarketContext = __esm({
27932
28138
  "src/scripts/cleanupMarketContext.ts"() {
27933
28139
  "use strict";
27934
28140
  import_config7 = require("dotenv/config");
27935
28141
  import_args19 = __toESM(require("args"));
27936
28142
  import_chalk35 = __toESM(require("chalk"));
27937
- import_client8 = require("@tradejs/infra/timescale/client");
27938
- import_marketContext5 = require("@tradejs/infra/timescale/marketContext");
28143
+ import_client9 = require("@tradejs/infra/timescale/client");
28144
+ import_marketContext6 = require("@tradejs/infra/timescale/marketContext");
27939
28145
  import_args19.default.example(
27940
28146
  "yarn cli maintenance:cleanup-market-context --apply",
27941
28147
  "Remove deprecated snapshot-only market context data from Timescale"
27942
28148
  );
27943
28149
  import_args19.default.option(["a", "apply"], "Apply destructive cleanup; default is dry-run");
27944
28150
  flags17 = import_args19.default.parse(process.argv);
27945
- main25 = async () => {
28151
+ main26 = async () => {
27946
28152
  const apply = Boolean(flags17.apply);
27947
- await (0, import_client8.waitForDbReady)();
27948
- const items = await (0, import_marketContext5.cleanupDeprecatedMarketContext)({ apply });
28153
+ await (0, import_client9.waitForDbReady)();
28154
+ const items = await (0, import_marketContext6.cleanupDeprecatedMarketContext)({ apply });
27949
28155
  if (!items.length) {
27950
28156
  console.log(import_chalk35.default.green("No deprecated market context data found."));
27951
28157
  return;
@@ -27968,9 +28174,9 @@ var init_cleanupMarketContext = __esm({
27968
28174
  // src/scripts/migration.ts
27969
28175
  var migration_exports = {};
27970
28176
  __export(migration_exports, {
27971
- main: () => main26
28177
+ main: () => main27
27972
28178
  });
27973
- var import_progress11, import_chalk36, import_logger5, import_files, import_candles4, DIR, re, BATCH, projectRoot7, migrateFile, main26;
28179
+ var import_progress11, import_chalk36, import_logger5, import_files, import_candles5, DIR, re, BATCH, projectRoot7, migrateFile, main27;
27974
28180
  var init_migration = __esm({
27975
28181
  "src/scripts/migration.ts"() {
27976
28182
  "use strict";
@@ -27978,7 +28184,7 @@ var init_migration = __esm({
27978
28184
  import_chalk36 = __toESM(require("chalk"));
27979
28185
  import_logger5 = require("@tradejs/infra/logger");
27980
28186
  import_files = require("@tradejs/infra/files");
27981
- import_candles4 = require("@tradejs/infra/timescale/candles");
28187
+ import_candles5 = require("@tradejs/infra/timescale/candles");
27982
28188
  DIR = "data/history";
27983
28189
  re = /^(.+?)_(\d+)\.json$/;
27984
28190
  BATCH = 2e3;
@@ -27994,12 +28200,12 @@ var init_migration = __esm({
27994
28200
  [],
27995
28201
  projectRoot7
27996
28202
  );
27997
- const rows = (0, import_candles4.toRows)("bybit", symbol, interval4, data);
28203
+ const rows = (0, import_candles5.toRows)("bybit", symbol, interval4, data);
27998
28204
  for (let i = 0; i < rows.length; i += BATCH) {
27999
- await (0, import_candles4.upsertCandles)(rows.slice(i, i + BATCH));
28205
+ await (0, import_candles5.upsertCandles)(rows.slice(i, i + BATCH));
28000
28206
  }
28001
28207
  };
28002
- main26 = async () => {
28208
+ main27 = async () => {
28003
28209
  const files = await (0, import_files.getFiles)(DIR, projectRoot7);
28004
28210
  const bar = new import_progress11.default(
28005
28211
  ":current/:total [:bar][:percent] :eta(s) :file",
@@ -28205,14 +28411,14 @@ var init_marketWsGateway = __esm({
28205
28411
  // src/scripts/marketWs.ts
28206
28412
  var marketWs_exports = {};
28207
28413
  __export(marketWs_exports, {
28208
- main: () => main27
28414
+ main: () => main28
28209
28415
  });
28210
- var main27;
28416
+ var main28;
28211
28417
  var init_marketWs = __esm({
28212
28418
  "src/scripts/marketWs.ts"() {
28213
28419
  "use strict";
28214
28420
  init_marketWsGateway();
28215
- main27 = async () => {
28421
+ main28 = async () => {
28216
28422
  const gateway = await startMarketWsGateway();
28217
28423
  const abortController = new AbortController();
28218
28424
  const stop = () => abortController.abort();
@@ -28326,9 +28532,9 @@ const timer = setInterval(() => {
28326
28532
  // src/scripts/mcpWorker.ts
28327
28533
  var mcpWorker_exports = {};
28328
28534
  __export(mcpWorker_exports, {
28329
- main: () => main28
28535
+ main: () => main29
28330
28536
  });
28331
- var import_node_child_process4, import_node_crypto15, import_promises23, import_redis16, import_mcp, pause, leaseKey, LEASE_SECONDS, JOB_TIMEOUT_MS, main28;
28537
+ var import_node_child_process4, import_node_crypto15, import_promises23, import_redis16, import_mcp, pause, leaseKey, LEASE_SECONDS, JOB_TIMEOUT_MS, main29;
28332
28538
  var init_mcpWorker = __esm({
28333
28539
  "src/scripts/mcpWorker.ts"() {
28334
28540
  "use strict";
@@ -28342,7 +28548,7 @@ var init_mcpWorker = __esm({
28342
28548
  leaseKey = "worker:lease";
28343
28549
  LEASE_SECONDS = 15;
28344
28550
  JOB_TIMEOUT_MS = 60 * 60 * 1e3;
28345
- main28 = async (options = {}) => {
28551
+ main29 = async (options = {}) => {
28346
28552
  const owner = (0, import_node_crypto15.randomUUID)();
28347
28553
  if (!await import_redis16.mcpStorage.put(leaseKey, owner, LEASE_SECONDS, true))
28348
28554
  throw new Error("Another MCP worker owns this storage");
@@ -28672,9 +28878,9 @@ var init_mcpWorker = __esm({
28672
28878
  // src/scripts/hyperliquidWhaleBackfill.ts
28673
28879
  var hyperliquidWhaleBackfill_exports = {};
28674
28880
  __export(hyperliquidWhaleBackfill_exports, {
28675
- main: () => main29
28881
+ main: () => main30
28676
28882
  });
28677
- var import_args20, flags18, parseTime, main29;
28883
+ var import_args20, flags18, parseTime, main30;
28678
28884
  var init_hyperliquidWhaleBackfill2 = __esm({
28679
28885
  "src/scripts/hyperliquidWhaleBackfill.ts"() {
28680
28886
  "use strict";
@@ -28694,7 +28900,7 @@ var init_hyperliquidWhaleBackfill2 = __esm({
28694
28900
  if (!Number.isFinite(parsed)) throw new Error(`Invalid timestamp: ${value}`);
28695
28901
  return parsed;
28696
28902
  };
28697
- main29 = async () => {
28903
+ main30 = async () => {
28698
28904
  const toMs = parseTime(flags18.to, Date.now());
28699
28905
  const days = Number(flags18.days);
28700
28906
  const lookbackMs = (Number.isFinite(days) && days > 0 ? days : 1) * 864e5;
@@ -28712,13 +28918,13 @@ var init_hyperliquidWhaleBackfill2 = __esm({
28712
28918
  });
28713
28919
 
28714
28920
  // src/lib/hyperliquidWhaleStream.ts
28715
- var import_ws2, import_hyperliquidWhales2, import_strategies11, DEFAULT_WS_URL, EVENT_BATCH_SIZE, FLUSH_INTERVAL_MS, FINALIZE_INTERVAL_MS, FINALIZE_LAG_MS, REBUILD_LOOKBACK_MS, RAW_EVENT_RETENTION_MS, sleep5, parseHyperliquidUserFillsMessage, runHyperliquidWhaleStream;
28921
+ var import_ws2, import_hyperliquidWhales2, import_strategies12, DEFAULT_WS_URL, EVENT_BATCH_SIZE, FLUSH_INTERVAL_MS, FINALIZE_INTERVAL_MS, FINALIZE_LAG_MS, REBUILD_LOOKBACK_MS, RAW_EVENT_RETENTION_MS, sleep5, parseHyperliquidUserFillsMessage, runHyperliquidWhaleStream;
28716
28922
  var init_hyperliquidWhaleStream = __esm({
28717
28923
  "src/lib/hyperliquidWhaleStream.ts"() {
28718
28924
  "use strict";
28719
28925
  import_ws2 = require("ws");
28720
28926
  import_hyperliquidWhales2 = require("@tradejs/infra/timescale/hyperliquidWhales");
28721
- import_strategies11 = require("@tradejs/node/strategies");
28927
+ import_strategies12 = require("@tradejs/node/strategies");
28722
28928
  init_hyperliquidWhaleData();
28723
28929
  DEFAULT_WS_URL = "wss://api.hyperliquid.xyz/ws";
28724
28930
  EVENT_BATCH_SIZE = 500;
@@ -28759,8 +28965,8 @@ var init_hyperliquidWhaleStream = __esm({
28759
28965
  }
28760
28966
  };
28761
28967
  runHyperliquidWhaleStream = async (params) => {
28762
- const universe = (0, import_strategies11.getHyperliquidPerpUniverseSnapshot)();
28763
- const whales = (0, import_strategies11.getHyperliquidWhaleRegistrySnapshot)();
28968
+ const universe = (0, import_strategies12.getHyperliquidPerpUniverseSnapshot)();
28969
+ const whales = (0, import_strategies12.getHyperliquidWhaleRegistrySnapshot)();
28764
28970
  const trackedSymbols = new Set(universe.symbols);
28765
28971
  const identity = {
28766
28972
  universeFingerprint: universe.fingerprint,
@@ -28903,14 +29109,14 @@ var init_hyperliquidWhaleStream = __esm({
28903
29109
  // src/scripts/hyperliquidWhaleIngest.ts
28904
29110
  var hyperliquidWhaleIngest_exports = {};
28905
29111
  __export(hyperliquidWhaleIngest_exports, {
28906
- main: () => main30
29112
+ main: () => main31
28907
29113
  });
28908
- var main30;
29114
+ var main31;
28909
29115
  var init_hyperliquidWhaleIngest = __esm({
28910
29116
  "src/scripts/hyperliquidWhaleIngest.ts"() {
28911
29117
  "use strict";
28912
29118
  init_hyperliquidWhaleStream();
28913
- main30 = async () => {
29119
+ main31 = async () => {
28914
29120
  const controller = new AbortController();
28915
29121
  const stop = () => controller.abort();
28916
29122
  process.once("SIGINT", stop);
@@ -29022,21 +29228,21 @@ var init_hyperliquidWhaleSelection = __esm({
29022
29228
  // src/scripts/hyperliquidWhalesUpdate.ts
29023
29229
  var hyperliquidWhalesUpdate_exports = {};
29024
29230
  __export(hyperliquidWhalesUpdate_exports, {
29025
- main: () => main31
29231
+ main: () => main32
29026
29232
  });
29027
- var import_config8, import_args21, import_node_crypto16, import_strategies12, LEADERBOARD_URL, DAY_MS11, CANDIDATE_LIMIT, flags19, fingerprint, runConcurrent2, main31;
29233
+ var import_config8, import_args21, import_node_crypto16, import_strategies13, LEADERBOARD_URL, DAY_MS12, CANDIDATE_LIMIT, flags19, fingerprint, runConcurrent2, main32;
29028
29234
  var init_hyperliquidWhalesUpdate = __esm({
29029
29235
  "src/scripts/hyperliquidWhalesUpdate.ts"() {
29030
29236
  "use strict";
29031
29237
  import_config8 = require("dotenv/config");
29032
29238
  import_args21 = __toESM(require("args"));
29033
29239
  import_node_crypto16 = require("crypto");
29034
- import_strategies12 = require("@tradejs/node/strategies");
29240
+ import_strategies13 = require("@tradejs/node/strategies");
29035
29241
  init_hyperliquidWhaleBackfill();
29036
29242
  init_hyperliquidRateLimiter();
29037
29243
  init_hyperliquidWhaleSelection();
29038
29244
  LEADERBOARD_URL = "https://stats-data.hyperliquid.xyz/Mainnet/leaderboard";
29039
- DAY_MS11 = 864e5;
29245
+ DAY_MS12 = 864e5;
29040
29246
  CANDIDATE_LIMIT = 400;
29041
29247
  import_args21.default.option(
29042
29248
  ["t", "to"],
@@ -29058,11 +29264,11 @@ var init_hyperliquidWhalesUpdate = __esm({
29058
29264
  })
29059
29265
  );
29060
29266
  };
29061
- main31 = async () => {
29267
+ main32 = async () => {
29062
29268
  const explicitTo = flags19.to == null ? Number.NaN : Date.parse(String(flags19.to));
29063
- const calibrationToMs = Number.isFinite(explicitTo) ? explicitTo : Math.floor(Date.now() / DAY_MS11) * DAY_MS11;
29269
+ const calibrationToMs = Number.isFinite(explicitTo) ? explicitTo : Math.floor(Date.now() / DAY_MS12) * DAY_MS12;
29064
29270
  const calibrationDays = Math.max(1, Number(flags19.days) || 7);
29065
- const calibrationFromMs = calibrationToMs - calibrationDays * DAY_MS11;
29271
+ const calibrationFromMs = calibrationToMs - calibrationDays * DAY_MS12;
29066
29272
  const response = await fetch(LEADERBOARD_URL);
29067
29273
  if (!response.ok) {
29068
29274
  throw new Error(`Hyperliquid leaderboard ${response.status}`);
@@ -29084,7 +29290,7 @@ var init_hyperliquidWhalesUpdate = __esm({
29084
29290
  ).sort(
29085
29291
  (left, right) => left.turnoverToEquity - right.turnoverToEquity || right.accountValueUsd - left.accountValueUsd || left.address.localeCompare(right.address)
29086
29292
  ).slice(0, CANDIDATE_LIMIT);
29087
- const top30Symbols = new Set((0, import_strategies12.getHyperliquidPerpUniverseSnapshot)().symbols);
29293
+ const top30Symbols = new Set((0, import_strategies13.getHyperliquidPerpUniverseSnapshot)().symbols);
29088
29294
  const limiter = new HyperliquidInfoRateLimiter();
29089
29295
  const metrics = [];
29090
29296
  let completed = 0;
@@ -29151,9 +29357,9 @@ var init_hyperliquidWhalesUpdate = __esm({
29151
29357
  // src/scripts/mlExport.ts
29152
29358
  var mlExport_exports = {};
29153
29359
  __export(mlExport_exports, {
29154
- main: () => main32
29360
+ main: () => main33
29155
29361
  });
29156
- var import_args22, import_chalk37, import_promises24, import_path8, import_ml, flags20, resolveRunScopedMlChunks, main32;
29362
+ var import_args22, import_chalk37, import_promises24, import_path8, import_ml, flags20, resolveRunScopedMlChunks, main33;
29157
29363
  var init_mlExport = __esm({
29158
29364
  "src/scripts/mlExport.ts"() {
29159
29365
  "use strict";
@@ -29208,7 +29414,7 @@ var init_mlExport = __esm({
29208
29414
  completedAttemptKeys: buildCompletedBacktestDatasetAttemptKeys(completed)
29209
29415
  };
29210
29416
  };
29211
- main32 = async () => {
29417
+ main33 = async () => {
29212
29418
  const outDir = String(flags20.outDir || "data/ml/export");
29213
29419
  await import_promises24.default.mkdir(outDir, { recursive: true });
29214
29420
  const strategyName = await resolveExportStrategy({
@@ -29274,9 +29480,9 @@ var init_mlExport = __esm({
29274
29480
  // src/scripts/mlInspect.ts
29275
29481
  var mlInspect_exports = {};
29276
29482
  __export(mlInspect_exports, {
29277
- main: () => main33
29483
+ main: () => main34
29278
29484
  });
29279
- var import_args23, import_chalk38, import_promises25, import_fs3, import_path9, import_readline2, import_child_process2, flags21, toMode, toInspectTool, selectInspectTool, asPositiveInt, readRowsHead, readRowsTail, readRowsSample, quantileSorted, mean2, std, findLatestDataset, buildNumericStats, formatNumber5, runQuickInspect, runYDataInspect, main33;
29485
+ var import_args23, import_chalk38, import_promises25, import_fs3, import_path9, import_readline2, import_child_process2, flags21, toMode, toInspectTool, selectInspectTool, asPositiveInt, readRowsHead, readRowsTail, readRowsSample, quantileSorted, mean2, std, findLatestDataset, buildNumericStats, formatNumber5, runQuickInspect, runYDataInspect, main34;
29280
29486
  var init_mlInspect = __esm({
29281
29487
  "src/scripts/mlInspect.ts"() {
29282
29488
  "use strict";
@@ -29768,7 +29974,7 @@ var init_mlInspect = __esm({
29768
29974
  }
29769
29975
  console.log(import_chalk38.default.green(`Profile report saved: ${reportPath}`));
29770
29976
  };
29771
- main33 = async () => {
29977
+ main34 = async () => {
29772
29978
  const dir = String(flags21.dir || "data/ml/export");
29773
29979
  const rowsToInspect = asPositiveInt(flags21.rows, 1e4);
29774
29980
  const mode = toMode(flags21.mode);
@@ -29810,9 +30016,9 @@ var init_mlInspect = __esm({
29810
30016
  // src/scripts/mlTrainLatestSelect.ts
29811
30017
  var mlTrainLatestSelect_exports = {};
29812
30018
  __export(mlTrainLatestSelect_exports, {
29813
- main: () => main34
30019
+ main: () => main35
29814
30020
  });
29815
- var import_path10, import_promises26, import_fs4, import_crypto2, import_child_process3, import_events, import_readline3, import_args24, import_chalk39, import_ml2, toFileToken6, asBool, asInt7, asNonNegativeInt, formatBytes, getMlContainerMemUsage, MODEL_TYPES, STRATEGIES, flags22, parseStrategy, parseModelType, selectModelType, listDatasetFiles, concatFiles, pipeNormalized, DAY_MS12, SPLIT_PROGRESS_EVERY, parseTimestampMs, scanMaxLabeledTimestampMs, scanMaxTrainTimestampMs, hashFileNameSha1, prepareTrainWindowFiles, main34;
30021
+ var import_path10, import_promises26, import_fs4, import_crypto2, import_child_process3, import_events, import_readline3, import_args24, import_chalk39, import_ml2, toFileToken6, asBool, asInt7, asNonNegativeInt, formatBytes, getMlContainerMemUsage, MODEL_TYPES, STRATEGIES, flags22, parseStrategy, parseModelType, selectModelType, listDatasetFiles, concatFiles, pipeNormalized, DAY_MS13, SPLIT_PROGRESS_EVERY, parseTimestampMs, scanMaxLabeledTimestampMs, scanMaxTrainTimestampMs, hashFileNameSha1, prepareTrainWindowFiles, main35;
29816
30022
  var init_mlTrainLatestSelect = __esm({
29817
30023
  "src/scripts/mlTrainLatestSelect.ts"() {
29818
30024
  "use strict";
@@ -30003,7 +30209,7 @@ var init_mlTrainLatestSelect = __esm({
30003
30209
  }
30004
30210
  };
30005
30211
  };
30006
- DAY_MS12 = 24 * 60 * 60 * 1e3;
30212
+ DAY_MS13 = 24 * 60 * 60 * 1e3;
30007
30213
  SPLIT_PROGRESS_EVERY = 2e5;
30008
30214
  parseTimestampMs = (value) => {
30009
30215
  const numeric = Number(value);
@@ -30220,7 +30426,7 @@ var init_mlTrainLatestSelect = __esm({
30220
30426
  }
30221
30427
  console.log("[split] phase 1/3: scanning max labeled timestamp...");
30222
30428
  const maxLabeledTs = await scanMaxLabeledTimestampMs(inputPath);
30223
- const holdoutCutoffMs = maxLabeledTs - testDays * DAY_MS12;
30429
+ const holdoutCutoffMs = maxLabeledTs - testDays * DAY_MS13;
30224
30430
  console.log("[split] phase 2/3: scanning max train timestamp...");
30225
30431
  const maxTrainTs = await scanMaxTrainTimestampMs(inputPath, holdoutCutoffMs);
30226
30432
  const {
@@ -30533,7 +30739,7 @@ var init_mlTrainLatestSelect = __esm({
30533
30739
  }
30534
30740
  };
30535
30741
  };
30536
- main34 = async () => {
30742
+ main35 = async () => {
30537
30743
  const selectedFromCli = parseStrategy(flags22.strategy);
30538
30744
  const selected = selectedFromCli ?? await selectStrategy();
30539
30745
  const envModelType = (process.env.ML_MODEL_TYPE ?? "random_forest").trim().toLowerCase();
@@ -30797,7 +31003,7 @@ __export(researchAuto_exports, {
30797
31003
  isProcessAlive: () => isProcessAlive,
30798
31004
  listMergedFiles: () => listMergedFiles3,
30799
31005
  listRuntimeStrategyNames: () => listRuntimeStrategyNames,
30800
- main: () => main35,
31006
+ main: () => main36,
30801
31007
  parseJsonOutput: () => parseJsonOutput,
30802
31008
  releaseResearchAutoLock: () => releaseResearchAutoLock,
30803
31009
  resolveHeapMbFromEnv: () => resolveHeapMbFromEnv,
@@ -30807,7 +31013,7 @@ __export(researchAuto_exports, {
30807
31013
  toStrategyConfigGrid: () => toStrategyConfigGrid2,
30808
31014
  trimTextTail: () => trimTextTail2
30809
31015
  });
30810
- var import_args25, import_chalk40, import_node_child_process5, import_promises27, import_node_os2, import_node_path20, import_constants19, import_ai8, import_logger7, import_redis17, import_registry4, flags23, projectRoot8, dotenvPath, getResearchAutoLockPath, readResearchAutoLock, isProcessAlive, acquireResearchAutoLock, releaseResearchAutoLock, resolvePositiveInteger, resolveHeapMbFromEnv, buildNodeOptions, RESEARCH_AUTO_PARENT_HEAP_MB, RESEARCH_AUTO_BACKTEST_PARENT_HEAP_MB, RESEARCH_AUTO_AI_TRAIN_PARENT_HEAP_MB, RESEARCH_AUTO_AGENT_PARENT_HEAP_MB, trimTextTail2, escapeHtml3, createEmptySteps, saveRun, listMergedFiles3, getBacktestResultsPrefix, listRuntimeStrategyNames, toStrategyConfigGrid2, formatMskDateTime, buildTelegramReport, runCliCommand, resolveTarget, parseJsonOutput, logResearch, executeNonBlockingStep, main35;
31016
+ var import_args25, import_chalk40, import_node_child_process5, import_promises27, import_node_os2, import_node_path20, import_constants19, import_ai8, import_logger7, import_redis17, import_registry4, flags23, projectRoot8, dotenvPath, getResearchAutoLockPath, readResearchAutoLock, isProcessAlive, acquireResearchAutoLock, releaseResearchAutoLock, resolvePositiveInteger, resolveHeapMbFromEnv, buildNodeOptions, RESEARCH_AUTO_PARENT_HEAP_MB, RESEARCH_AUTO_BACKTEST_PARENT_HEAP_MB, RESEARCH_AUTO_AI_TRAIN_PARENT_HEAP_MB, RESEARCH_AUTO_AGENT_PARENT_HEAP_MB, trimTextTail2, escapeHtml3, createEmptySteps, saveRun, listMergedFiles3, getBacktestResultsPrefix, listRuntimeStrategyNames, toStrategyConfigGrid2, formatMskDateTime, buildTelegramReport, runCliCommand, resolveTarget, parseJsonOutput, logResearch, executeNonBlockingStep, main36;
30811
31017
  var init_researchAuto = __esm({
30812
31018
  "src/scripts/researchAuto.ts"() {
30813
31019
  "use strict";
@@ -31332,7 +31538,7 @@ var init_researchAuto = __esm({
31332
31538
  );
31333
31539
  return result;
31334
31540
  };
31335
- main35 = async () => {
31541
+ main36 = async () => {
31336
31542
  resolveRequiredResearchRoots({ projectRoot: projectRoot8 });
31337
31543
  const userName3 = String(flags23.user || "root").trim() || "root";
31338
31544
  const connector = String(flags23.connector || "bybit").trim() || "bybit";
@@ -33503,9 +33709,9 @@ var init_orchestrator = __esm({
33503
33709
  // src/scripts/coreResearch.ts
33504
33710
  var coreResearch_exports = {};
33505
33711
  __export(coreResearch_exports, {
33506
- main: () => main36
33712
+ main: () => main37
33507
33713
  });
33508
- var import_promises30, import_node_path24, import_chalk41, valueAfter, required, parseTimestamp, readSymbols, printUsage, main36;
33714
+ var import_promises30, import_node_path24, import_chalk41, valueAfter, required, parseTimestamp, readSymbols, printUsage, main37;
33509
33715
  var init_coreResearch = __esm({
33510
33716
  "src/scripts/coreResearch.ts"() {
33511
33717
  "use strict";
@@ -33554,7 +33760,7 @@ var init_coreResearch = __esm({
33554
33760
 
33555
33761
  The run command executes only variants with an explicit command[] in the preregistered spec. Variants with files[] are analyzed without starting a backtest.`);
33556
33762
  };
33557
- main36 = async () => {
33763
+ main37 = async () => {
33558
33764
  const roots = resolveResearchRoots();
33559
33765
  process.chdir(roots.projectRoot);
33560
33766
  const argv2 = process.argv.slice(2);
@@ -35197,11 +35403,11 @@ print(json.dumps(sorted(opened)))
35197
35403
  });
35198
35404
 
35199
35405
  // src/lib/strategyRelease/evidenceRetention.ts
35200
- var DAY_MS13, isResearchRetired, planStrategyEvidenceRetention;
35406
+ var DAY_MS14, isResearchRetired, planStrategyEvidenceRetention;
35201
35407
  var init_evidenceRetention = __esm({
35202
35408
  "src/lib/strategyRelease/evidenceRetention.ts"() {
35203
35409
  "use strict";
35204
- DAY_MS13 = 864e5;
35410
+ DAY_MS14 = 864e5;
35205
35411
  isResearchRetired = (research) => research?.status === "retired" && research.retirement?.policy === "discard-unrecoverable-without-rerun" && Boolean(research.retirement.reason.trim()) && Boolean(research.retirement.missingEvidence.length) && research.retirement.missingEvidence.every((item) => Boolean(item.trim()));
35206
35412
  planStrategyEvidenceRetention = ({
35207
35413
  now: now2,
@@ -35233,7 +35439,7 @@ var init_evidenceRetention = __esm({
35233
35439
  const completedResearch = Boolean(
35234
35440
  terminalResearch && research?.researchId === entry.researchId && /^[a-f0-9]{64}$/.test(entry.sha256 ?? "")
35235
35441
  );
35236
- if (isResearch && !completedResearch || days == null || !entry.verified || !entry.aggregated && !(isResearch && retired) || !isResearch && now2 - entry.createdAt <= days * DAY_MS13) {
35442
+ if (isResearch && !completedResearch || days == null || !entry.verified || !entry.aggregated && !(isResearch && retired) || !isResearch && now2 - entry.createdAt <= days * DAY_MS14) {
35237
35443
  keep.push(entry);
35238
35444
  } else {
35239
35445
  remove.push(entry);
@@ -36402,7 +36608,7 @@ ${conclusion.nextAction} Current-snapshot universe; no deployment authorization.
36402
36608
  });
36403
36609
 
36404
36610
  // src/lib/strategyResearch/native.ts
36405
- var import_promises35, import_node_fs9, import_node_path30, import_node_os4, import_node_readline4, import_node_child_process8, import_node_module3, import_redis18, import_ai9, import_backtest7, import_registry5, import_connectors14, import_data9, import_coreResearch2, import_jev6, validateResearchJevTraining, nativeConfig, runResearchCommand, createNativeStrategyResearchBackend;
36611
+ var import_promises35, import_node_fs9, import_node_path30, import_node_os4, import_node_readline4, import_node_child_process8, import_node_module3, import_redis18, import_ai9, import_backtest7, import_registry5, import_connectors15, import_data9, import_coreResearch2, import_jev6, validateResearchJevTraining, nativeConfig, runResearchCommand, createNativeStrategyResearchBackend;
36406
36612
  var init_native = __esm({
36407
36613
  "src/lib/strategyResearch/native.ts"() {
36408
36614
  "use strict";
@@ -36417,7 +36623,7 @@ var init_native = __esm({
36417
36623
  import_ai9 = require("@tradejs/node/ai");
36418
36624
  import_backtest7 = require("@tradejs/node/backtest");
36419
36625
  import_registry5 = require("@tradejs/node/registry");
36420
- import_connectors14 = require("@tradejs/node/connectors");
36626
+ import_connectors15 = require("@tradejs/node/connectors");
36421
36627
  init_dataset2();
36422
36628
  init_reconciliation();
36423
36629
  init_metrics();
@@ -36578,7 +36784,7 @@ var init_native = __esm({
36578
36784
  let connector;
36579
36785
  const getConnector = async (spec) => {
36580
36786
  if (connector) return connector;
36581
- const creator = await (0, import_connectors14.getConnectorCreatorByName)(
36787
+ const creator = await (0, import_connectors15.getConnectorCreatorByName)(
36582
36788
  spec.core.execution.connector,
36583
36789
  projectRoot18
36584
36790
  );
@@ -37313,9 +37519,9 @@ var init_strategyResearch = __esm({
37313
37519
  // src/scripts/strategyResearch.ts
37314
37520
  var strategyResearch_exports = {};
37315
37521
  __export(strategyResearch_exports, {
37316
- main: () => main37
37522
+ main: () => main38
37317
37523
  });
37318
- var import_promises36, import_node_path31, import_redis19, usage, main37;
37524
+ var import_promises36, import_node_path31, import_redis19, usage, main38;
37319
37525
  var init_strategyResearch2 = __esm({
37320
37526
  "src/scripts/strategyResearch.ts"() {
37321
37527
  "use strict";
@@ -37340,7 +37546,7 @@ frozen rules, actual gated entries, non-fast and delayed-entry confirmation.
37340
37546
  Resume with the same run command. No notifications, publication or live orders.
37341
37547
  Revalidate keeps the frozen rule and evaluates a new period without fitting.
37342
37548
  `;
37343
- main37 = async () => {
37549
+ main38 = async () => {
37344
37550
  const argv2 = process.argv.slice(2);
37345
37551
  const command = argv2.shift();
37346
37552
  if (!command || command === "--help") {
@@ -37551,16 +37757,16 @@ Revalidate keeps the frozen rule and evaluates a new period without fitting.
37551
37757
  // src/scripts/results.ts
37552
37758
  var results_exports = {};
37553
37759
  __export(results_exports, {
37554
- main: () => main38,
37760
+ main: () => main39,
37555
37761
  results: () => results
37556
37762
  });
37557
- var import_args26, import_chalk42, import_connectors15, import_cli11, import_redis20, ListIt4, flags24, MIN_PROFIT, MIN_WIN_RATE, MIN_ORDERS_PER_MONTH, createListIt4, formatPercent4, getMonthlyReturn, toStrategyResultEntry, toStrategyResults, getTestConfigs, buildBestResults, getSavedProfitsBySymbol, getCoverageRow, results, main38;
37763
+ var import_args26, import_chalk42, import_connectors16, import_cli11, import_redis20, ListIt4, flags24, MIN_PROFIT, MIN_WIN_RATE, MIN_ORDERS_PER_MONTH, createListIt4, formatPercent4, getMonthlyReturn, toStrategyResultEntry, toStrategyResults, getTestConfigs, buildBestResults, getSavedProfitsBySymbol, getCoverageRow, results, main39;
37558
37764
  var init_results = __esm({
37559
37765
  "src/scripts/results.ts"() {
37560
37766
  "use strict";
37561
37767
  import_args26 = __toESM(require("args"));
37562
37768
  import_chalk42 = __toESM(require("chalk"));
37563
- import_connectors15 = require("@tradejs/connectors");
37769
+ import_connectors16 = require("@tradejs/connectors");
37564
37770
  import_cli11 = require("@tradejs/node/cli");
37565
37771
  import_redis20 = require("@tradejs/infra/redis");
37566
37772
  ListIt4 = require("list-it");
@@ -37701,7 +37907,7 @@ var init_results = __esm({
37701
37907
  goodMissing += 1;
37702
37908
  }
37703
37909
  }
37704
- const byBitConnector = await import_connectors15.connectors.ByBit({
37910
+ const byBitConnector = await import_connectors16.connectors.ByBit({
37705
37911
  userName: userName3
37706
37912
  });
37707
37913
  const tickers = await (0, import_cli11.getTickers)(byBitConnector);
@@ -37850,7 +38056,7 @@ var init_results = __esm({
37850
38056
  }
37851
38057
  process.exit();
37852
38058
  };
37853
- main38 = results;
38059
+ main39 = results;
37854
38060
  }
37855
38061
  });
37856
38062
 
@@ -38143,11 +38349,11 @@ var init_runtimeDebugEvidence = __esm({
38143
38349
  // src/scripts/replayRuntimeEvidence.ts
38144
38350
  var replayRuntimeEvidence_exports = {};
38145
38351
  __export(replayRuntimeEvidence_exports, {
38146
- main: () => main39,
38352
+ main: () => main40,
38147
38353
  replayRuntimeEvidence: () => replayRuntimeEvidence,
38148
38354
  summarizeReplayComparison: () => summarizeReplayComparison
38149
38355
  });
38150
- var import_promises37, import_node_path32, import_args27, import_chalk43, import_redis22, toEpochMs2, resolveWindow, parseStrategyFilter, asRecord5, asArray2, sum, groupCount, compactMatched, resolveItemStrategy, summarizeReplayComparison, loadReplayResult, getReplayStrategies, loadRuntimePayload, replayRuntimeEvidence, main39;
38356
+ var import_promises37, import_node_path32, import_args27, import_chalk43, import_redis22, toEpochMs2, resolveWindow, parseStrategyFilter, asRecord5, asArray2, sum, groupCount, compactMatched, resolveItemStrategy, summarizeReplayComparison, loadReplayResult, getReplayStrategies, loadRuntimePayload, replayRuntimeEvidence, main40;
38151
38357
  var init_replayRuntimeEvidence = __esm({
38152
38358
  "src/scripts/replayRuntimeEvidence.ts"() {
38153
38359
  "use strict";
@@ -38246,6 +38452,8 @@ var init_replayRuntimeEvidence = __esm({
38246
38452
  timestampDiffMs: item.timestampDiffMs ?? null,
38247
38453
  backtestPrice: backtest2.price ?? null,
38248
38454
  runtimePrice: runtime.price ?? null,
38455
+ backtestQty: backtest2.qty ?? null,
38456
+ runtimeQty: runtime.qty ?? null,
38249
38457
  backtestExitPrice: backtest2.exitPrice ?? null,
38250
38458
  runtimeExitPrice: runtime.exitPrice ?? null,
38251
38459
  expectedPnl: pnl.expectedPnl ?? null,
@@ -38256,7 +38464,8 @@ var init_replayRuntimeEvidence = __esm({
38256
38464
  totalSlippageCost: slippage.totalCost ?? null,
38257
38465
  orderId: runtime.orderId ?? backtest2.orderId ?? null,
38258
38466
  orderLinkId: runtime.orderLinkId ?? null,
38259
- signalId: backtest2.signalId ?? null
38467
+ signalId: backtest2.signalId ?? null,
38468
+ runtimeSignalId: runtime.signalId ?? null
38260
38469
  };
38261
38470
  };
38262
38471
  resolveItemStrategy = (item) => asRecord5(item.backtest).strategy ?? asRecord5(item.runtime).inferredStrategy ?? item.strategy ?? item.inferredStrategy ?? null;
@@ -38524,7 +38733,7 @@ var init_replayRuntimeEvidence = __esm({
38524
38733
  )
38525
38734
  );
38526
38735
  };
38527
- main39 = replayRuntimeEvidence;
38736
+ main40 = replayRuntimeEvidence;
38528
38737
  }
38529
38738
  });
38530
38739
 
@@ -38832,10 +39041,10 @@ var init_runtimeFeedbackReplay = __esm({
38832
39041
  // src/scripts/runtimeFeedbackReplay.ts
38833
39042
  var runtimeFeedbackReplay_exports = {};
38834
39043
  __export(runtimeFeedbackReplay_exports, {
38835
- main: () => main40,
39044
+ main: () => main41,
38836
39045
  runtimeFeedbackReplay: () => runtimeFeedbackReplay
38837
39046
  });
38838
- var import_node_path34, import_args28, import_chalk44, flags25, projectRoot9, runtimeFeedbackReplay, main40;
39047
+ var import_node_path34, import_args28, import_chalk44, flags25, projectRoot9, runtimeFeedbackReplay, main41;
38839
39048
  var init_runtimeFeedbackReplay2 = __esm({
38840
39049
  "src/scripts/runtimeFeedbackReplay.ts"() {
38841
39050
  "use strict";
@@ -38879,7 +39088,7 @@ var init_runtimeFeedbackReplay2 = __esm({
38879
39088
  )
38880
39089
  );
38881
39090
  };
38882
- main40 = runtimeFeedbackReplay;
39091
+ main41 = runtimeFeedbackReplay;
38883
39092
  }
38884
39093
  });
38885
39094
 
@@ -39017,10 +39226,10 @@ var init_runtimeFeedbackNotification = __esm({
39017
39226
  // src/scripts/runtimeFeedbackNotify.ts
39018
39227
  var runtimeFeedbackNotify_exports = {};
39019
39228
  __export(runtimeFeedbackNotify_exports, {
39020
- main: () => main41,
39229
+ main: () => main42,
39021
39230
  runtimeFeedbackNotify: () => runtimeFeedbackNotify
39022
39231
  });
39023
- var import_node_path35, import_args29, import_chalk45, flags26, projectRoot10, runtimeFeedbackNotify, main41;
39232
+ var import_node_path35, import_args29, import_chalk45, flags26, projectRoot10, runtimeFeedbackNotify, main42;
39024
39233
  var init_runtimeFeedbackNotify = __esm({
39025
39234
  "src/scripts/runtimeFeedbackNotify.ts"() {
39026
39235
  "use strict";
@@ -39051,7 +39260,7 @@ var init_runtimeFeedbackNotify = __esm({
39051
39260
  )
39052
39261
  );
39053
39262
  };
39054
- main41 = runtimeFeedbackNotify;
39263
+ main42 = runtimeFeedbackNotify;
39055
39264
  }
39056
39265
  });
39057
39266
 
@@ -40143,9 +40352,9 @@ var init_runtimeFeedbackProcess = __esm({
40143
40352
  // src/scripts/runtimeFeedbackProcess.ts
40144
40353
  var runtimeFeedbackProcess_exports = {};
40145
40354
  __export(runtimeFeedbackProcess_exports, {
40146
- main: () => main42
40355
+ main: () => main43
40147
40356
  });
40148
- var import_args30, import_node_path38, flags27, main42;
40357
+ var import_args30, import_node_path38, flags27, main43;
40149
40358
  var init_runtimeFeedbackProcess2 = __esm({
40150
40359
  "src/scripts/runtimeFeedbackProcess.ts"() {
40151
40360
  "use strict";
@@ -40166,7 +40375,7 @@ var init_runtimeFeedbackProcess2 = __esm({
40166
40375
  "data/runtime-evidence/artifacts/production"
40167
40376
  );
40168
40377
  flags27 = import_args30.default.parse(process.argv);
40169
- main42 = async () => {
40378
+ main43 = async () => {
40170
40379
  if (!flags27.runtimeDir || !flags27.replayDir)
40171
40380
  throw new Error("Provide --runtimeDir and --replayDir");
40172
40381
  const root = process.env.PROJECT_CWD || process.cwd();
@@ -40279,10 +40488,10 @@ var init_runtimeFeedbackSync = __esm({
40279
40488
  // src/scripts/runtimeFeedbackSync.ts
40280
40489
  var runtimeFeedbackSync_exports = {};
40281
40490
  __export(runtimeFeedbackSync_exports, {
40282
- main: () => main43,
40491
+ main: () => main44,
40283
40492
  runtimeFeedbackSync: () => runtimeFeedbackSync
40284
40493
  });
40285
- var import_node_path40, import_args31, import_chalk46, flags28, projectRoot11, runtimeFeedbackSync, main43;
40494
+ var import_node_path40, import_args31, import_chalk46, flags28, projectRoot11, runtimeFeedbackSync, main44;
40286
40495
  var init_runtimeFeedbackSync2 = __esm({
40287
40496
  "src/scripts/runtimeFeedbackSync.ts"() {
40288
40497
  "use strict";
@@ -40341,7 +40550,7 @@ var init_runtimeFeedbackSync2 = __esm({
40341
40550
  )
40342
40551
  );
40343
40552
  };
40344
- main43 = runtimeFeedbackSync;
40553
+ main44 = runtimeFeedbackSync;
40345
40554
  }
40346
40555
  });
40347
40556
 
@@ -40748,10 +40957,10 @@ var init_runtimeEvidenceCompositions = __esm({
40748
40957
  // src/scripts/runtimeEvidence.ts
40749
40958
  var runtimeEvidence_exports = {};
40750
40959
  __export(runtimeEvidence_exports, {
40751
- main: () => main44,
40960
+ main: () => main45,
40752
40961
  runtimeEvidence: () => runtimeEvidence
40753
40962
  });
40754
- var import_promises43, import_node_path42, import_args32, import_chalk47, flags29, projectRoot12, toEpochMs3, resolveWindow2, parseStrategyFilter2, runtimeEvidence, main44;
40963
+ var import_promises43, import_node_path42, import_args32, import_chalk47, flags29, projectRoot12, toEpochMs3, resolveWindow2, parseStrategyFilter2, runtimeEvidence, main45;
40755
40964
  var init_runtimeEvidence = __esm({
40756
40965
  "src/scripts/runtimeEvidence.ts"() {
40757
40966
  "use strict";
@@ -40980,17 +41189,17 @@ var init_runtimeEvidence = __esm({
40980
41189
  )
40981
41190
  );
40982
41191
  };
40983
- main44 = runtimeEvidence;
41192
+ main45 = runtimeEvidence;
40984
41193
  }
40985
41194
  });
40986
41195
 
40987
41196
  // src/scripts/runtimeEvidenceSync.ts
40988
41197
  var runtimeEvidenceSync_exports = {};
40989
41198
  __export(runtimeEvidenceSync_exports, {
40990
- main: () => main45,
41199
+ main: () => main46,
40991
41200
  runtimeEvidenceSync: () => runtimeEvidenceSync
40992
41201
  });
40993
- var import_node_path43, import_args33, import_chalk48, flags30, projectRoot13, runtimeEvidenceSync, main45;
41202
+ var import_node_path43, import_args33, import_chalk48, flags30, projectRoot13, runtimeEvidenceSync, main46;
40994
41203
  var init_runtimeEvidenceSync2 = __esm({
40995
41204
  "src/scripts/runtimeEvidenceSync.ts"() {
40996
41205
  "use strict";
@@ -41054,7 +41263,7 @@ var init_runtimeEvidenceSync2 = __esm({
41054
41263
  )
41055
41264
  );
41056
41265
  };
41057
- main45 = runtimeEvidenceSync;
41266
+ main46 = runtimeEvidenceSync;
41058
41267
  }
41059
41268
  });
41060
41269
 
@@ -41171,11 +41380,11 @@ var init_liveDiagnosis = __esm({
41171
41380
  function assert2(condition, message) {
41172
41381
  if (!condition) throw new Error(`Invalid strategy release: ${message}`);
41173
41382
  }
41174
- var DAY_MS14, realizedDrawdown, lowerBoundExitTimestamp, percentile2, buildStrategyMonitoringProfile;
41383
+ var DAY_MS15, realizedDrawdown, lowerBoundExitTimestamp, percentile2, buildStrategyMonitoringProfile;
41175
41384
  var init_monitoringProfile = __esm({
41176
41385
  "src/lib/strategyRelease/monitoringProfile.ts"() {
41177
41386
  "use strict";
41178
- DAY_MS14 = 864e5;
41387
+ DAY_MS15 = 864e5;
41179
41388
  realizedDrawdown = (trades, startIndex = 0, endIndex = trades.length) => {
41180
41389
  let equity = 0;
41181
41390
  let peak = 0;
@@ -41228,13 +41437,13 @@ var init_monitoringProfile = __esm({
41228
41437
  Number.isInteger(windowDays) && windowDays > 0,
41229
41438
  "monitoring profile days must be positive integers"
41230
41439
  );
41231
- const duration = windowDays * DAY_MS14;
41440
+ const duration = windowDays * DAY_MS15;
41232
41441
  assert2(
41233
41442
  endTime - startTime >= duration,
41234
41443
  `${windowDays}d monitoring window exceeds historical coverage`
41235
41444
  );
41236
41445
  const drawdowns = [];
41237
- for (let windowStart = startTime; windowStart + duration <= endTime; windowStart += DAY_MS14) {
41446
+ for (let windowStart = startTime; windowStart + duration <= endTime; windowStart += DAY_MS15) {
41238
41447
  const windowEnd = windowStart + duration;
41239
41448
  drawdowns.push(
41240
41449
  realizedDrawdown(
@@ -42483,10 +42692,10 @@ var init_strategyRelease = __esm({
42483
42692
  // src/scripts/runtimeScorecard.ts
42484
42693
  var runtimeScorecard_exports = {};
42485
42694
  __export(runtimeScorecard_exports, {
42486
- main: () => main46,
42695
+ main: () => main47,
42487
42696
  runtimeScorecard: () => runtimeScorecard
42488
42697
  });
42489
- var import_promises45, import_node_crypto24, import_node_path45, import_args34, import_chalk49, flags31, projectRoot14, resolveOptionalPath, readJson2, assertReportType, sha256File2, loadHistoryArtifacts, runtimeScorecard, main46;
42698
+ var import_promises45, import_node_crypto24, import_node_path45, import_args34, import_chalk49, flags31, projectRoot14, resolveOptionalPath, readJson2, assertReportType, sha256File2, loadHistoryArtifacts, runtimeScorecard, main47;
42490
42699
  var init_runtimeScorecard2 = __esm({
42491
42700
  "src/scripts/runtimeScorecard.ts"() {
42492
42701
  "use strict";
@@ -42738,7 +42947,7 @@ var init_runtimeScorecard2 = __esm({
42738
42947
  )
42739
42948
  );
42740
42949
  };
42741
- main46 = runtimeScorecard;
42950
+ main47 = runtimeScorecard;
42742
42951
  }
42743
42952
  });
42744
42953
 
@@ -42746,10 +42955,10 @@ var init_runtimeScorecard2 = __esm({
42746
42955
  var runtimeControl_exports = {};
42747
42956
  __export(runtimeControl_exports, {
42748
42957
  RUNTIME_CONTROL_ACTIONS: () => RUNTIME_CONTROL_ACTIONS,
42749
- main: () => main47,
42958
+ main: () => main48,
42750
42959
  runtimeControl: () => runtimeControl
42751
42960
  });
42752
- var import_config9, import_runtimeControls, import_runtimeStrategies5, argv, RUNTIME_CONTROL_ACTIONS, action, option, required2, projectRoot15, userName2, verify, inspect, updateControlState, runtimeControl, main47;
42961
+ var import_config9, import_runtimeControls, import_runtimeStrategies5, argv, RUNTIME_CONTROL_ACTIONS, action, option, required2, projectRoot15, userName2, verify, inspect, updateControlState, runtimeControl, main48;
42753
42962
  var init_runtimeControl = __esm({
42754
42963
  "src/scripts/runtimeControl.ts"() {
42755
42964
  "use strict";
@@ -42897,17 +43106,17 @@ var init_runtimeControl = __esm({
42897
43106
  `Usage: tradejs runtime-control ${RUNTIME_CONTROL_ACTIONS.join("|")}`
42898
43107
  );
42899
43108
  };
42900
- main47 = runtimeControl;
43109
+ main48 = runtimeControl;
42901
43110
  }
42902
43111
  });
42903
43112
 
42904
43113
  // src/scripts/strategyRelease.ts
42905
43114
  var strategyRelease_exports = {};
42906
43115
  __export(strategyRelease_exports, {
42907
- main: () => main48,
43116
+ main: () => main49,
42908
43117
  runStrategyReleaseCommand: () => runStrategyReleaseCommand
42909
43118
  });
42910
- var import_promises46, import_node_fs10, import_node_readline5, import_node_path46, import_chalk50, valueAfter2, required3, writeJsonAtomic3, runStrategyReleaseCommand, printUsage2, main48;
43119
+ var import_promises46, import_node_fs10, import_node_readline5, import_node_path46, import_chalk50, valueAfter2, required3, writeJsonAtomic3, runStrategyReleaseCommand, printUsage2, main49;
42911
43120
  var init_strategyRelease2 = __esm({
42912
43121
  "src/scripts/strategyRelease.ts"() {
42913
43122
  "use strict";
@@ -43074,7 +43283,7 @@ var init_strategyRelease2 = __esm({
43074
43283
  yarn strategy:release profile --input <trades.jsonl> --variant <id> --startTime <ms> --endTime <ms> [--days 7,30,90] [--out <profile.json>]
43075
43284
  yarn strategy:release diagnose --input <diagnosis-input.json> [--out output/diagnosis.json]
43076
43285
  yarn strategy:release retention --input <inventory.json> [--apply]`);
43077
- main48 = async () => {
43286
+ main49 = async () => {
43078
43287
  const argv2 = process.argv.slice(2);
43079
43288
  const command = argv2[0];
43080
43289
  if (!command || ![
@@ -43113,10 +43322,10 @@ __export(serverHealth_exports, {
43113
43322
  buildServerHealthDiagnostics: () => buildServerHealthDiagnostics,
43114
43323
  collectServerHealthSnapshot: () => collectServerHealthSnapshot,
43115
43324
  evaluateServerHealth: () => evaluateServerHealth,
43116
- main: () => main49,
43325
+ main: () => main50,
43117
43326
  resolveServerHealthThresholds: () => resolveServerHealthThresholds
43118
43327
  });
43119
- var import_config10, import_node_child_process12, import_node_os5, import_node_fs11, import_args35, import_redis23, DEFAULT_STATE, DEFAULT_THRESHOLDS, escapeHtml6, formatPctValue, formatLoadPerCore, formatGiB, formatDuration2, readDiskUsage, parseMeminfoBytes, readMemorySnapshot, runDiagnosticCommand, runDiagnosticCommands, collectServerHealthSnapshot, buildHumanSummaryLines, evaluateServerHealth, shouldRecover, buildAlertMessage, buildRecoveryMessage, buildServerHealthDiagnostics, getStateKey, toFiniteNumber3, resolveServerHealthThresholds, main49;
43328
+ var import_config10, import_node_child_process12, import_node_os5, import_node_fs11, import_args35, import_redis23, DEFAULT_STATE, DEFAULT_THRESHOLDS, escapeHtml6, formatPctValue, formatLoadPerCore, formatGiB, formatDuration2, readDiskUsage, parseMeminfoBytes, readMemorySnapshot, runDiagnosticCommand, runDiagnosticCommands, collectServerHealthSnapshot, buildHumanSummaryLines, evaluateServerHealth, shouldRecover, buildAlertMessage, buildRecoveryMessage, buildServerHealthDiagnostics, getStateKey, toFiniteNumber3, resolveServerHealthThresholds, main50;
43120
43329
  var init_serverHealth = __esm({
43121
43330
  "src/scripts/serverHealth.ts"() {
43122
43331
  "use strict";
@@ -43529,7 +43738,7 @@ var init_serverHealth = __esm({
43529
43738
  "Recovery threshold for disk used percent",
43530
43739
  String(DEFAULT_THRESHOLDS.diskRecoverPct)
43531
43740
  );
43532
- main49 = async () => {
43741
+ main50 = async () => {
43533
43742
  const flags36 = import_args35.default.parse(process.argv);
43534
43743
  const thresholds = resolveServerHealthThresholds(flags36);
43535
43744
  const diskPath = String(flags36.diskPath || "/");
@@ -44921,10 +45130,10 @@ var init_reporting = __esm({
44921
45130
  var runtimeParity_exports = {};
44922
45131
  __export(runtimeParity_exports, {
44923
45132
  buildRuntimeParityMessage: () => buildRuntimeParityMessage,
44924
- main: () => main50,
45133
+ main: () => main51,
44925
45134
  runtimeParity: () => runtimeParity
44926
45135
  });
44927
- var import_config11, import_node_crypto25, import_args36, import_chalk52, import_constants20, import_time13, import_logger8, import_redis24, import_cli12, import_backtest8, import_connectors16, flags32, interval3, projectRoot16, DEFAULT_LOOKBACK_DAYS, DETAIL_LIMIT2, DEFAULT_REPLAY_ENV, resolveParityConnectorName, createConnector, buildReplayAiAnalyses, formatReplayEnvSummary, buildReplayConfig, warmReplayHistory, runtimeParity, main50;
45136
+ var import_config11, import_node_crypto25, import_args36, import_chalk52, import_constants20, import_time13, import_logger8, import_redis24, import_cli12, import_backtest8, import_connectors17, flags32, interval3, projectRoot16, DEFAULT_LOOKBACK_DAYS, DETAIL_LIMIT2, DEFAULT_REPLAY_ENV, resolveParityConnectorName, createConnector, buildReplayAiAnalyses, formatReplayEnvSummary, buildReplayConfig, warmReplayHistory, runtimeParity, main51;
44928
45137
  var init_runtimeParity2 = __esm({
44929
45138
  "src/scripts/runtimeParity.ts"() {
44930
45139
  "use strict";
@@ -44938,7 +45147,7 @@ var init_runtimeParity2 = __esm({
44938
45147
  import_redis24 = require("@tradejs/infra/redis");
44939
45148
  import_cli12 = require("@tradejs/node/cli");
44940
45149
  import_backtest8 = require("@tradejs/node/backtest");
44941
- import_connectors16 = require("@tradejs/node/connectors");
45150
+ import_connectors17 = require("@tradejs/node/connectors");
44942
45151
  init_runtimeParity();
44943
45152
  init_cliArgs();
44944
45153
  init_runtimeRedis();
@@ -45008,22 +45217,22 @@ var init_runtimeParity2 = __esm({
45008
45217
  DETAIL_LIMIT2 = 10;
45009
45218
  DEFAULT_REPLAY_ENV = flags32.runtimeGates ? "PARITY" : "BACKTEST";
45010
45219
  resolveParityConnectorName = async (value) => {
45011
- const connectorName = await (0, import_connectors16.resolveConnectorName)(value, projectRoot16);
45220
+ const connectorName = await (0, import_connectors17.resolveConnectorName)(value, projectRoot16);
45012
45221
  if (connectorName) {
45013
45222
  return connectorName;
45014
45223
  }
45015
45224
  import_logger8.logger.warn(
45016
45225
  'Unknown connector "%s". Fallback to %s.',
45017
45226
  String(value || "").trim() || String(value),
45018
- import_connectors16.DEFAULT_CONNECTOR_NAME
45227
+ import_connectors17.DEFAULT_CONNECTOR_NAME
45019
45228
  );
45020
- return import_connectors16.DEFAULT_CONNECTOR_NAME;
45229
+ return import_connectors17.DEFAULT_CONNECTOR_NAME;
45021
45230
  };
45022
45231
  createConnector = async ({
45023
45232
  userName: userName3,
45024
45233
  connectorName
45025
45234
  }) => {
45026
- const connectorFactory = await (0, import_connectors16.getConnectorCreatorByName)(
45235
+ const connectorFactory = await (0, import_connectors17.getConnectorCreatorByName)(
45027
45236
  connectorName,
45028
45237
  projectRoot16
45029
45238
  );
@@ -45463,7 +45672,7 @@ var init_runtimeParity2 = __esm({
45463
45672
  (0, import_backtest8.resetTestingKlineCache)(projectRoot16);
45464
45673
  }
45465
45674
  };
45466
- main50 = runtimeParity;
45675
+ main51 = runtimeParity;
45467
45676
  }
45468
45677
  });
45469
45678
 
@@ -45975,13 +46184,13 @@ var init_daemon = __esm({
45975
46184
  });
45976
46185
 
45977
46186
  // src/lib/signals/klineFeed.ts
45978
- var import_connectors17, import_logger10, import_candles5, FLUSH_DELAY_MS, normalizeSymbols2, createSignalsKlineFeed;
46187
+ var import_connectors18, import_logger10, import_candles6, FLUSH_DELAY_MS, normalizeSymbols2, createSignalsKlineFeed;
45979
46188
  var init_klineFeed = __esm({
45980
46189
  "src/lib/signals/klineFeed.ts"() {
45981
46190
  "use strict";
45982
- import_connectors17 = require("@tradejs/connectors");
46191
+ import_connectors18 = require("@tradejs/connectors");
45983
46192
  import_logger10 = require("@tradejs/infra/logger");
45984
- import_candles5 = require("@tradejs/infra/timescale/candles");
46193
+ import_candles6 = require("@tradejs/infra/timescale/candles");
45985
46194
  init_klineEvents();
45986
46195
  FLUSH_DELAY_MS = 100;
45987
46196
  normalizeSymbols2 = (symbols) => [...new Set(symbols.map((symbol) => symbol.trim().toUpperCase()))].filter(
@@ -45994,13 +46203,13 @@ var init_klineFeed = __esm({
45994
46203
  publish = publishMarketKlineEvent,
45995
46204
  persist = async (rows) => {
45996
46205
  const intervalMinutes = Number(interval4);
45997
- await (0, import_candles5.upsertCandles)(
46206
+ await (0, import_candles6.upsertCandles)(
45998
46207
  rows.flatMap(
45999
- ({ symbol, candle }) => (0, import_candles5.toRows)("bybit", symbol, intervalMinutes, [candle])
46208
+ ({ symbol, candle }) => (0, import_candles6.toRows)("bybit", symbol, intervalMinutes, [candle])
46000
46209
  )
46001
46210
  );
46002
46211
  },
46003
- streamFactory = import_connectors17.createBybitKlineStream
46212
+ streamFactory = import_connectors18.createBybitKlineStream
46004
46213
  }) => {
46005
46214
  const pending = /* @__PURE__ */ new Map();
46006
46215
  const lastClosedTimestamp = /* @__PURE__ */ new Map();
@@ -46106,11 +46315,11 @@ var init_klineFeed = __esm({
46106
46315
  });
46107
46316
 
46108
46317
  // src/lib/signals/tickerEvaluator.ts
46109
- var import_strategies13, import_logger11, createSignalsTickerEvaluator;
46318
+ var import_strategies14, import_logger11, createSignalsTickerEvaluator;
46110
46319
  var init_tickerEvaluator = __esm({
46111
46320
  "src/lib/signals/tickerEvaluator.ts"() {
46112
46321
  "use strict";
46113
- import_strategies13 = require("@tradejs/node/strategies");
46322
+ import_strategies14 = require("@tradejs/node/strategies");
46114
46323
  import_logger11 = require("@tradejs/infra/logger");
46115
46324
  init_windows();
46116
46325
  init_runtimeLineage();
@@ -46327,7 +46536,7 @@ var init_tickerEvaluator = __esm({
46327
46536
  if (signalRuntimeIdentity && !signal.signalId.endsWith(`:${signalRuntimeIdentity}`)) {
46328
46537
  signal.signalId = `${signal.signalId}:${signalRuntimeIdentity}`;
46329
46538
  }
46330
- await (0, import_strategies13.enrichSignalWithBinanceMarketContext)({ signal, env: "CRON" });
46539
+ await (0, import_strategies14.enrichSignalWithBinanceMarketContext)({ signal, env: "CRON" });
46331
46540
  if (signal.orderStatus === "skipped" && typeof signal.orderSkipReason === "string" && signal.orderSkipReason.trim()) {
46332
46541
  recordStrategyReason(
46333
46542
  strategyStats,
@@ -46523,16 +46732,16 @@ var init_configuredScopes = __esm({
46523
46732
  });
46524
46733
 
46525
46734
  // src/lib/signals/runner.ts
46526
- var import_progress12, import_chalk54, import_connectors18, import_cli13, import_async5, import_strategies14, import_constants21, import_time14, import_logger12, import_runtimeDeploymentEvents, import_runtimeHeartbeats, import_runtimeStrategies7, SLOW_SIGNALS_WARNING_MS, formatDuration3, resolvePositiveInteger2, resolveNonNegativeInteger, createSignalsRunner;
46735
+ var import_progress12, import_chalk54, import_connectors19, import_cli13, import_async5, import_strategies15, import_constants21, import_time14, import_logger12, import_runtimeDeploymentEvents, import_runtimeHeartbeats, import_runtimeStrategies7, SLOW_SIGNALS_WARNING_MS, formatDuration3, resolvePositiveInteger2, resolveNonNegativeInteger, createSignalsRunner;
46527
46736
  var init_runner = __esm({
46528
46737
  "src/lib/signals/runner.ts"() {
46529
46738
  "use strict";
46530
46739
  import_progress12 = __toESM(require("progress"));
46531
46740
  import_chalk54 = __toESM(require("chalk"));
46532
- import_connectors18 = require("@tradejs/node/connectors");
46741
+ import_connectors19 = require("@tradejs/node/connectors");
46533
46742
  import_cli13 = require("@tradejs/node/cli");
46534
46743
  import_async5 = require("@tradejs/core/async");
46535
- import_strategies14 = require("@tradejs/core/strategies");
46744
+ import_strategies15 = require("@tradejs/core/strategies");
46536
46745
  import_constants21 = require("@tradejs/core/constants");
46537
46746
  import_time14 = require("@tradejs/core/time");
46538
46747
  import_logger12 = require("@tradejs/infra/logger");
@@ -46605,7 +46814,7 @@ var init_runner = __esm({
46605
46814
  const createDefaultSignalsLifecycle = (runtimeInterval = interval4) => createSignalsStrategyLifecycle({
46606
46815
  intervalMs: Number(runtimeInterval) * 6e4,
46607
46816
  maxLiveBars: resolveSignalsDaemonMaxLiveBars(runtimeInterval),
46608
- releaseState: import_strategies14.releaseStrategyReplayCache
46817
+ releaseState: import_strategies15.releaseStrategyReplayCache
46609
46818
  });
46610
46819
  const timeOperation3 = (label, operation) => timeOperation(
46611
46820
  label,
@@ -46620,7 +46829,7 @@ var init_runner = __esm({
46620
46829
  `Found signals: <b>${params.found}</b>`
46621
46830
  ].join("\n");
46622
46831
  const resolveSignalsConnectorName = async (value) => {
46623
- const connectorName = await (0, import_connectors18.resolveConnectorName)(value, projectRoot18);
46832
+ const connectorName = await (0, import_connectors19.resolveConnectorName)(value, projectRoot18);
46624
46833
  if (!connectorName) {
46625
46834
  throw new Error(
46626
46835
  `Unknown runtime connector: ${String(value || "").trim() || String(value)}`
@@ -46648,7 +46857,7 @@ var init_runner = __esm({
46648
46857
  );
46649
46858
  const universe = scope.universe ?? config2.universe;
46650
46859
  const requestedAccountId = deployment?.accountId ?? scope.accountId ?? config2.accountId;
46651
- const connectorFactory = await (0, import_connectors18.getConnectorCreatorByName)(
46860
+ const connectorFactory = await (0, import_connectors19.getConnectorCreatorByName)(
46652
46861
  connectorName,
46653
46862
  projectRoot18
46654
46863
  );
@@ -46666,7 +46875,7 @@ var init_runner = __esm({
46666
46875
  marketConnector,
46667
46876
  userName: config2.userName,
46668
46877
  projectRoot: projectRoot18,
46669
- shouldUseDedicatedReferences: universe === "crypto" && connectorName.toLowerCase() === import_connectors18.DEFAULT_CONNECTOR_NAME.toLowerCase(),
46878
+ shouldUseDedicatedReferences: universe === "crypto" && connectorName.toLowerCase() === import_connectors19.DEFAULT_CONNECTOR_NAME.toLowerCase(),
46670
46879
  warn: (message) => import_logger12.logger.warn(message)
46671
46880
  });
46672
46881
  return {
@@ -47024,7 +47233,7 @@ var init_runner = __esm({
47024
47233
  new Map(
47025
47234
  runtimeStrategies.map(({ strategyName, strategyConfig }) => [
47026
47235
  strategyName,
47027
- (0, import_strategies14.mapAiRuntimeFromConfig)({
47236
+ (0, import_strategies15.mapAiRuntimeFromConfig)({
47028
47237
  AI_ENABLED: strategyConfig.AI_ENABLED,
47029
47238
  AI_MODE: strategyConfig.AI_MODE,
47030
47239
  MIN_AI_QUALITY: strategyConfig.MIN_AI_QUALITY
@@ -47336,12 +47545,12 @@ var init_runner = __esm({
47336
47545
  var signals_exports = {};
47337
47546
  __export(signals_exports, {
47338
47547
  createSignalsSession: () => createSignalsSession,
47339
- main: () => main51,
47548
+ main: () => main52,
47340
47549
  signals: () => signals,
47341
47550
  signalsConfiguredScopesOnce: () => signalsConfiguredScopesOnce,
47342
47551
  signalsDaemon: () => signalsDaemon
47343
47552
  });
47344
- var import_config12, import_args37, flags33, config, runner, createSignalsSession, signals, signalsConfiguredScopesOnce, signalsDaemon, main51;
47553
+ var import_config12, import_args37, flags33, config, runner, createSignalsSession, signals, signalsConfiguredScopesOnce, signalsDaemon, main52;
47345
47554
  var init_signals = __esm({
47346
47555
  "src/scripts/signals.ts"() {
47347
47556
  "use strict";
@@ -47413,31 +47622,31 @@ var init_signals = __esm({
47413
47622
  signals = runner.runCycle;
47414
47623
  signalsConfiguredScopesOnce = runner.runConfiguredScopesOnce;
47415
47624
  signalsDaemon = runner.runDaemon;
47416
- main51 = () => config.watch ? signalsDaemon() : signalsConfiguredScopesOnce();
47625
+ main52 = () => config.watch ? signalsDaemon() : signalsConfiguredScopesOnce();
47417
47626
  }
47418
47627
  });
47419
47628
 
47420
47629
  // src/scripts/signalsDaemon.ts
47421
47630
  var signalsDaemon_exports = {};
47422
47631
  __export(signalsDaemon_exports, {
47423
- main: () => main52
47632
+ main: () => main53
47424
47633
  });
47425
- var main52;
47634
+ var main53;
47426
47635
  var init_signalsDaemon = __esm({
47427
47636
  "src/scripts/signalsDaemon.ts"() {
47428
47637
  "use strict";
47429
47638
  init_signals();
47430
- main52 = signalsDaemon;
47639
+ main53 = signalsDaemon;
47431
47640
  }
47432
47641
  });
47433
47642
 
47434
47643
  // src/scripts/signalsSummary.ts
47435
47644
  var signalsSummary_exports = {};
47436
47645
  __export(signalsSummary_exports, {
47437
- main: () => main53,
47646
+ main: () => main54,
47438
47647
  signalsSummary: () => signalsSummary
47439
47648
  });
47440
- var import_config13, import_userSettings8, import_args38, import_logger13, import_connectors19, import_runtimeStrategies9, flags34, projectRoot17, SUMMARY_TIMEZONE2, SUMMARY_TIMEZONE_LABEL2, escapeHtml8, formatMskDateTime4, formatSigned3, formatPnlMoneyText, formatWinRateText, resolveSummaryTitle, normalizeStatus, shouldAttachDebugReport, getSummaryDateParts, formatSummaryIsoDayKey, unescapeHtml, stripTelegramHtml, buildSignalsSummaryAttachment, appendReportAttachmentSummary, resolveSummaryConnectorName, groupRuntimeTradesByConnectorScope, syncRuntimeTradeScopes, createRuntimeSignalStats, mergeRuntimeSignalStats, buildSummaryPrelude, resolveTradeStatusEmoji, isTimestampInWindow, isRuntimeTradeClosedInWindow, buildSummaryMessages, signalsSummary, main53;
47649
+ var import_config13, import_userSettings8, import_args38, import_logger13, import_connectors20, import_runtimeStrategies9, flags34, projectRoot17, SUMMARY_TIMEZONE2, SUMMARY_TIMEZONE_LABEL2, escapeHtml8, formatMskDateTime4, formatSigned3, formatPnlMoneyText, formatWinRateText, resolveSummaryTitle, normalizeStatus, shouldAttachDebugReport, getSummaryDateParts, formatSummaryIsoDayKey, unescapeHtml, stripTelegramHtml, buildSignalsSummaryAttachment, appendReportAttachmentSummary, resolveSummaryConnectorName, groupRuntimeTradesByConnectorScope, syncRuntimeTradeScopes, createRuntimeSignalStats, mergeRuntimeSignalStats, buildSummaryPrelude, resolveTradeStatusEmoji, isTimestampInWindow, isRuntimeTradeClosedInWindow, buildSummaryMessages, signalsSummary, main54;
47441
47650
  var init_signalsSummary = __esm({
47442
47651
  "src/scripts/signalsSummary.ts"() {
47443
47652
  "use strict";
@@ -47445,7 +47654,7 @@ var init_signalsSummary = __esm({
47445
47654
  import_userSettings8 = require("@tradejs/infra/userSettings");
47446
47655
  import_args38 = __toESM(require("args"));
47447
47656
  import_logger13 = require("@tradejs/infra/logger");
47448
- import_connectors19 = require("@tradejs/node/connectors");
47657
+ import_connectors20 = require("@tradejs/node/connectors");
47449
47658
  init_runtimeRedis();
47450
47659
  init_runtimeTradeSync();
47451
47660
  init_telegramReports();
@@ -47556,16 +47765,16 @@ var init_signalsSummary = __esm({
47556
47765
  return lines.join("\n");
47557
47766
  };
47558
47767
  resolveSummaryConnectorName = async (value) => {
47559
- const connectorName = await (0, import_connectors19.resolveConnectorName)(value, projectRoot17);
47768
+ const connectorName = await (0, import_connectors20.resolveConnectorName)(value, projectRoot17);
47560
47769
  if (connectorName) {
47561
47770
  return connectorName;
47562
47771
  }
47563
47772
  import_logger13.logger.warn(
47564
47773
  'Unknown connector "%s". Fallback to %s.',
47565
47774
  String(value || "").trim() || String(value),
47566
- import_connectors19.DEFAULT_CONNECTOR_NAME
47775
+ import_connectors20.DEFAULT_CONNECTOR_NAME
47567
47776
  );
47568
- return import_connectors19.DEFAULT_CONNECTOR_NAME;
47777
+ return import_connectors20.DEFAULT_CONNECTOR_NAME;
47569
47778
  };
47570
47779
  groupRuntimeTradesByConnectorScope = ({
47571
47780
  trades,
@@ -47619,7 +47828,7 @@ var init_signalsSummary = __esm({
47619
47828
  const connectorName = await resolveSummaryConnectorName(
47620
47829
  scope.connectorName
47621
47830
  );
47622
- const connectorFactory = await (0, import_connectors19.getConnectorCreatorByName)(
47831
+ const connectorFactory = await (0, import_connectors20.getConnectorCreatorByName)(
47623
47832
  connectorName,
47624
47833
  projectRoot17
47625
47834
  );
@@ -48124,16 +48333,16 @@ none`
48124
48333
  });
48125
48334
  }
48126
48335
  };
48127
- main53 = signalsSummary;
48336
+ main54 = signalsSummary;
48128
48337
  }
48129
48338
  });
48130
48339
 
48131
48340
  // src/scripts/test-ml.ts
48132
48341
  var test_ml_exports = {};
48133
48342
  __export(test_ml_exports, {
48134
- main: () => main54
48343
+ main: () => main55
48135
48344
  });
48136
- var import_config14, import_constants22, import_ml3, import_registry6, now, INTERVAL_MIN, CANDLES, makeSeries, makeCandles, buildTrendline, main54;
48345
+ var import_config14, import_constants22, import_ml3, import_registry6, now, INTERVAL_MIN, CANDLES, makeSeries, makeCandles, buildTrendline, main55;
48137
48346
  var init_test_ml = __esm({
48138
48347
  "src/scripts/test-ml.ts"() {
48139
48348
  "use strict";
@@ -48183,7 +48392,7 @@ var init_test_ml = __esm({
48183
48392
  { timestamp: entryTs - 2 * INTERVAL_MIN * 6e4, value: price * 0.995 }
48184
48393
  ]
48185
48394
  });
48186
- main54 = async () => {
48395
+ main55 = async () => {
48187
48396
  const defaultConfig = await (0, import_registry6.getStrategyDefaults)("TrendLine", process.cwd());
48188
48397
  if (!defaultConfig) {
48189
48398
  throw new Error(
@@ -48276,20 +48485,20 @@ var init_test_ml = __esm({
48276
48485
  // src/scripts/test.ts
48277
48486
  var test_exports = {};
48278
48487
  __export(test_exports, {
48279
- main: () => main55
48488
+ main: () => main56
48280
48489
  });
48281
- var import_config15, import_connectors20, getPositions, main55;
48490
+ var import_config15, import_connectors21, getPositions, main56;
48282
48491
  var init_test = __esm({
48283
48492
  "src/scripts/test.ts"() {
48284
48493
  "use strict";
48285
48494
  import_config15 = require("dotenv/config");
48286
- import_connectors20 = require("@tradejs/connectors");
48495
+ import_connectors21 = require("@tradejs/connectors");
48287
48496
  getPositions = async (connector) => {
48288
48497
  const res = await connector.getPositions();
48289
48498
  console.log("res", res);
48290
48499
  };
48291
- main55 = async () => {
48292
- const byBitConnector = await import_connectors20.connectors.ByBit({
48500
+ main56 = async () => {
48501
+ const byBitConnector = await import_connectors21.connectors.ByBit({
48293
48502
  userName: "root"
48294
48503
  });
48295
48504
  await getPositions(byBitConnector);
@@ -48300,9 +48509,9 @@ var init_test = __esm({
48300
48509
  // src/scripts/user-add.ts
48301
48510
  var user_add_exports = {};
48302
48511
  __export(user_add_exports, {
48303
- main: () => main56
48512
+ main: () => main57
48304
48513
  });
48305
- var import_args39, import_chalk55, import_bcryptjs, import_redis26, flags35, main56;
48514
+ var import_args39, import_chalk55, import_bcryptjs, import_redis26, flags35, main57;
48306
48515
  var init_user_add = __esm({
48307
48516
  "src/scripts/user-add.ts"() {
48308
48517
  "use strict";
@@ -48314,7 +48523,7 @@ var init_user_add = __esm({
48314
48523
  import_args39.default.option(["u", "user"], "Username", "");
48315
48524
  import_args39.default.option(["p", "password"], "Password (plain text)", "");
48316
48525
  flags35 = import_args39.default.parse(process.argv);
48317
- main56 = async () => {
48526
+ main57 = async () => {
48318
48527
  const userName3 = String(flags35.user || "").trim();
48319
48528
  const password = String(flags35.password || "");
48320
48529
  if (!userName3 || !password) {
@@ -48342,14 +48551,14 @@ var init_user_add = __esm({
48342
48551
  var cli_exports = {};
48343
48552
  __export(cli_exports, {
48344
48553
  cleanupCliResources: () => cleanupCliResources,
48345
- main: () => main57,
48554
+ main: () => main58,
48346
48555
  printUsage: () => printUsage3,
48347
48556
  runLoadedModule: () => runLoadedModule
48348
48557
  });
48349
48558
  module.exports = __toCommonJS(cli_exports);
48350
48559
  var import_config16 = require("dotenv/config");
48351
48560
  var import_redis27 = require("@tradejs/infra/redis");
48352
- var import_client9 = require("@tradejs/infra/timescale/client");
48561
+ var import_client10 = require("@tradejs/infra/timescale/client");
48353
48562
  var scriptLoaders = {
48354
48563
  "research-visuals": () => Promise.resolve().then(() => (init_researchVisuals2(), researchVisuals_exports)),
48355
48564
  "agent-run": () => Promise.resolve().then(() => (init_agentRun(), agentRun_exports)),
@@ -48367,6 +48576,7 @@ var scriptLoaders = {
48367
48576
  "clean-dir": () => Promise.resolve().then(() => (init_cleanDir(), cleanDir_exports)),
48368
48577
  "clean-redis": () => Promise.resolve().then(() => (init_cleanRedis(), cleanRedis_exports)),
48369
48578
  "clean-tests": () => Promise.resolve().then(() => (init_cleanTests(), cleanTests_exports)),
48579
+ "coverage:backfill": () => Promise.resolve().then(() => (init_coverageBackfill(), coverageBackfill_exports)),
48370
48580
  continuity: () => Promise.resolve().then(() => (init_continuity2(), continuity_exports)),
48371
48581
  "derivatives:ingest": () => Promise.resolve().then(() => (init_derivativesIngest(), derivativesIngest_exports)),
48372
48582
  "derivatives:ingest:coinalyze:all": () => Promise.resolve().then(() => (init_derivativesIngestCoinalyzeAll(), derivativesIngestCoinalyzeAll_exports)),
@@ -48423,9 +48633,9 @@ var runLoadedModule = async (loaded) => {
48423
48633
  }
48424
48634
  };
48425
48635
  var cleanupCliResources = async () => {
48426
- await Promise.allSettled([(0, import_redis27.closeRedisConnection)(), (0, import_client9.closeTimescalePool)()]);
48636
+ await Promise.allSettled([(0, import_redis27.closeRedisConnection)(), (0, import_client10.closeTimescalePool)()]);
48427
48637
  };
48428
- var main57 = async () => {
48638
+ var main58 = async () => {
48429
48639
  const [, scriptPath, command = "", ...args40] = process.argv;
48430
48640
  const loader = scriptLoaders[command];
48431
48641
  if (!loader) {
@@ -48456,7 +48666,7 @@ var main57 = async () => {
48456
48666
  }
48457
48667
  };
48458
48668
  if (require.main === module) {
48459
- main57().catch((error) => {
48669
+ main58().catch((error) => {
48460
48670
  console.error(error);
48461
48671
  process.exit(1);
48462
48672
  });