@tradejs/cli 2.0.18 → 2.0.20
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 +14522 -15704
- package/dist/lib/aiExport.js +15 -1608
- package/dist/lib/aiPocketSearch.js +499 -67
- package/dist/lib/aiPocketSearchCli.js +113 -0
- package/dist/lib/aiTrainCharts.js +14 -1
- package/dist/lib/aiTrainMetrics.js +4 -1
- package/dist/lib/aiTrainResearch.js +88 -54
- package/dist/lib/binanceMarketContextBackfill.js +7 -6
- package/dist/lib/coinMarketCapContextBackfill.js +19 -18
- package/dist/lib/coreResearch.js +2738 -0
- package/dist/lib/derivativesContextBackfill.js +10 -9
- package/dist/lib/executionCalibration.js +6 -3
- package/dist/lib/hyperliquidWhaleBackfill.js +8 -8
- package/dist/lib/hyperliquidWhaleStream.js +4 -4
- package/dist/lib/marketContextPrepare.js +83 -1686
- package/dist/lib/runEnvironment.js +14 -1666
- package/dist/lib/runFormatting.js +1 -1607
- package/dist/lib/runtimeDebugEvidence.js +2 -48
- package/dist/lib/runtimeLineage.js +81 -48
- package/dist/lib/runtimeRedis.js +6 -57
- package/dist/lib/runtimeScorecard.js +153 -10
- package/dist/lib/runtimeStrategyBacktest.js +2 -48
- package/dist/lib/strategyGateFingerprint.js +80 -0
- package/dist/lib/strategyRelease.js +1365 -0
- package/dist/scripts/aiExport.js +17 -1610
- package/dist/scripts/aiPocketSearch.js +1070 -1770
- package/dist/scripts/aiTrain.js +108 -1688
- package/dist/scripts/backtest.js +120 -1760
- package/dist/scripts/binanceMarketIngest.js +5 -4
- package/dist/scripts/candlesMigrateProvider.js +6 -5186
- package/dist/scripts/cleanupMarketContext.js +4 -3
- package/dist/scripts/continuity.js +4 -3
- package/dist/scripts/coreResearch.js +2830 -0
- package/dist/scripts/derivativesIngest.js +6 -4
- package/dist/scripts/derivativesIngestCoinalyzeAll.js +5 -4
- package/dist/scripts/doctor.js +2 -5184
- package/dist/scripts/executionCalibration.js +6 -3
- package/dist/scripts/hyperliquidWhaleBackfill.js +8 -8
- package/dist/scripts/hyperliquidWhaleIngest.js +4 -4
- package/dist/scripts/hyperliquidWhalesUpdate.js +1 -1
- package/dist/scripts/migration.js +3 -3
- package/dist/scripts/mlExport.js +1 -1607
- package/dist/scripts/replay.js +239 -1855
- package/dist/scripts/replayRunner.js +239 -1855
- package/dist/scripts/replayRuntimeEvidence.js +29 -62
- package/dist/scripts/researchAuto.js +3 -49
- package/dist/scripts/results.js +1 -1607
- package/dist/scripts/runtimeEvidence.js +18 -56
- package/dist/scripts/runtimeParity.js +121 -1746
- package/dist/scripts/runtimeScorecard.js +883 -29
- package/dist/scripts/signals.js +1178 -2724
- package/dist/scripts/signalsDaemon.js +1183 -2696
- package/dist/scripts/signalsSummary.js +4 -26
- package/dist/scripts/strategyRelease.js +1469 -0
- package/dist/workers/testerWorker.js +2 -2
- package/package.json +13 -9
|
@@ -57,7 +57,8 @@ var import_progress = __toESM(require("progress"));
|
|
|
57
57
|
var import_async = require("@tradejs/core/async");
|
|
58
58
|
var import_constants = require("@tradejs/core/constants");
|
|
59
59
|
var import_indicators = require("@tradejs/core/indicators");
|
|
60
|
-
var
|
|
60
|
+
var import_derivatives = require("@tradejs/infra/timescale/derivatives");
|
|
61
|
+
var import_client = require("@tradejs/infra/timescale/client");
|
|
61
62
|
var import_userSettings = require("@tradejs/infra/userSettings");
|
|
62
63
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
63
64
|
var DAY_MS = 24 * HOUR_MS;
|
|
@@ -573,13 +574,13 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
573
574
|
if (!intervalWindows.length) {
|
|
574
575
|
return skippedBackfillResult();
|
|
575
576
|
}
|
|
576
|
-
await (0,
|
|
577
|
+
await (0, import_client.waitForDbReady)();
|
|
577
578
|
const edgesByInterval = /* @__PURE__ */ new Map();
|
|
578
579
|
await Promise.all(
|
|
579
580
|
intervalWindows.map(async ({ interval }) => {
|
|
580
581
|
edgesByInterval.set(
|
|
581
582
|
interval,
|
|
582
|
-
await (0,
|
|
583
|
+
await (0, import_derivatives.getDerivativesDataEdgesForSymbols)(symbols, interval)
|
|
583
584
|
);
|
|
584
585
|
})
|
|
585
586
|
);
|
|
@@ -596,14 +597,14 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
596
597
|
nowMs: coverageNowMs
|
|
597
598
|
});
|
|
598
599
|
const [coverageRows, liquidationCoverageRows] = await Promise.all([
|
|
599
|
-
(0,
|
|
600
|
+
(0, import_derivatives.getDerivativesBackfillCoverage)({
|
|
600
601
|
source: "coinalyze",
|
|
601
602
|
symbols,
|
|
602
603
|
interval: window.interval,
|
|
603
604
|
fromMs: window.fromMs,
|
|
604
605
|
toMs: window.toMs
|
|
605
606
|
}),
|
|
606
|
-
confirmedLiquidationWindow ? (0,
|
|
607
|
+
confirmedLiquidationWindow ? (0, import_derivatives.getDerivativesMetricCoverage)({
|
|
607
608
|
source: "coinalyze",
|
|
608
609
|
metric: "liquidation",
|
|
609
610
|
symbols,
|
|
@@ -774,7 +775,7 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
774
775
|
);
|
|
775
776
|
for (const window of intervalWindows) {
|
|
776
777
|
const { interval, intervalMs } = window;
|
|
777
|
-
const edgesBySymbol = edgesByInterval.get(interval) ?? await (0,
|
|
778
|
+
const edgesBySymbol = edgesByInterval.get(interval) ?? await (0, import_derivatives.getDerivativesDataEdgesForSymbols)(
|
|
778
779
|
matches.map((item) => item.symbol),
|
|
779
780
|
interval
|
|
780
781
|
);
|
|
@@ -897,7 +898,7 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
897
898
|
);
|
|
898
899
|
}
|
|
899
900
|
if (rows.length) {
|
|
900
|
-
await (0,
|
|
901
|
+
await (0, import_derivatives.upsertDerivatives)(rows);
|
|
901
902
|
totalRows += rows.length;
|
|
902
903
|
}
|
|
903
904
|
const confirmedLiquidationWindow = (0, import_indicators.resolveCoinalyzeConfirmedIntradayCoverage)({
|
|
@@ -925,7 +926,7 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
925
926
|
eventRowsCount
|
|
926
927
|
};
|
|
927
928
|
});
|
|
928
|
-
await (0,
|
|
929
|
+
await (0, import_derivatives.applyDerivativesMetricCoverage)(metricCoverageRows);
|
|
929
930
|
for (const coverageRow of metricCoverageRows) {
|
|
930
931
|
const symbol = coverageRow.symbol.toUpperCase();
|
|
931
932
|
const ranges = liquidationCoverageRangesBySymbol.get(symbol) ?? [];
|
|
@@ -957,7 +958,7 @@ var backfillDerivativesContext = async (params, enabled, mode) => {
|
|
|
957
958
|
rowsCount
|
|
958
959
|
};
|
|
959
960
|
});
|
|
960
|
-
await (0,
|
|
961
|
+
await (0, import_derivatives.upsertDerivativesBackfillCoverage)(coverageRows);
|
|
961
962
|
for (const coverageRow of coverageRows) {
|
|
962
963
|
const symbol = coverageRow.symbol.toUpperCase();
|
|
963
964
|
edgesBySymbol.set(
|
|
@@ -152,7 +152,8 @@ var extractRuntimeTradeRows = (runtimePayload) => {
|
|
|
152
152
|
const signal = asRecord(redisValues?.signal) ?? (signalId ? signalsById.get(signalId) ?? null : null) ?? (shapeKey ? signalsByShape.get(shapeKey) ?? null : null);
|
|
153
153
|
return {
|
|
154
154
|
trade,
|
|
155
|
-
signal
|
|
155
|
+
signal,
|
|
156
|
+
runtimeLineage: asRecord(trade.runtimeLineage) ?? null
|
|
156
157
|
};
|
|
157
158
|
}).filter((row) => row != null);
|
|
158
159
|
};
|
|
@@ -454,7 +455,8 @@ var buildSample = ({
|
|
|
454
455
|
direction: direction ?? match?.direction ?? null,
|
|
455
456
|
expectedPrice: match?.backtestPrice ?? null,
|
|
456
457
|
actualPrice: match?.runtimePrice ?? null
|
|
457
|
-
})
|
|
458
|
+
}),
|
|
459
|
+
runtimeLineage: row.runtimeLineage
|
|
458
460
|
};
|
|
459
461
|
};
|
|
460
462
|
var buildReplayOnlySample = (match) => ({
|
|
@@ -501,7 +503,8 @@ var buildReplayOnlySample = (match) => ({
|
|
|
501
503
|
direction: match.direction,
|
|
502
504
|
expectedPrice: match.backtestPrice,
|
|
503
505
|
actualPrice: match.runtimePrice
|
|
504
|
-
})
|
|
506
|
+
}),
|
|
507
|
+
runtimeLineage: null
|
|
505
508
|
});
|
|
506
509
|
var hasTelemetry = (sample) => sample.signalClosePrice != null || sample.arrivalMid != null || sample.orderSubmitTime != null || sample.fillAvgPrice != null || sample.fillTime != null || sample.fee != null;
|
|
507
510
|
var hasFullTelemetry = (sample) => sample.signalClosePrice != null && sample.arrivalMid != null && sample.orderSubmitTime != null && sample.orderAckTime != null && sample.fillAvgPrice != null && sample.fillTime != null;
|
|
@@ -35,7 +35,7 @@ __export(hyperliquidWhaleBackfill_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(hyperliquidWhaleBackfill_exports);
|
|
37
37
|
var import_progress = __toESM(require("progress"));
|
|
38
|
-
var
|
|
38
|
+
var import_hyperliquidWhales = require("@tradejs/infra/timescale/hyperliquidWhales");
|
|
39
39
|
var import_strategies = require("@tradejs/node/strategies");
|
|
40
40
|
|
|
41
41
|
// src/lib/hyperliquidWhaleData.ts
|
|
@@ -290,7 +290,7 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
290
290
|
};
|
|
291
291
|
const fromMs = Math.floor(params.startMs / HYPERLIQUID_WHALE_BUCKET_MS) * HYPERLIQUID_WHALE_BUCKET_MS;
|
|
292
292
|
const toMs = minuteCeil(params.endMs);
|
|
293
|
-
const cached = await (0,
|
|
293
|
+
const cached = await (0, import_hyperliquidWhales.hasHyperliquidWhaleBackfillCoverage)({
|
|
294
294
|
fromMs,
|
|
295
295
|
toMs,
|
|
296
296
|
...identity
|
|
@@ -339,7 +339,7 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
339
339
|
items: whales.addresses,
|
|
340
340
|
concurrency,
|
|
341
341
|
worker: async (address) => {
|
|
342
|
-
const previous = await (0,
|
|
342
|
+
const previous = await (0, import_hyperliquidWhales.getHyperliquidWhaleWalletCoverage)({
|
|
343
343
|
address,
|
|
344
344
|
fromMs,
|
|
345
345
|
toMs,
|
|
@@ -366,8 +366,8 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
366
366
|
identity
|
|
367
367
|
})
|
|
368
368
|
).filter((row) => row != null);
|
|
369
|
-
await (0,
|
|
370
|
-
await (0,
|
|
369
|
+
await (0, import_hyperliquidWhales.upsertHyperliquidWhaleTradeEvents)(addressEvents);
|
|
370
|
+
await (0, import_hyperliquidWhales.upsertHyperliquidWhaleWalletCoverage)({
|
|
371
371
|
address,
|
|
372
372
|
fromMs,
|
|
373
373
|
toMs,
|
|
@@ -385,7 +385,7 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
385
385
|
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
386
386
|
failures.push(normalizedError);
|
|
387
387
|
failedWallets += 1;
|
|
388
|
-
await (0,
|
|
388
|
+
await (0, import_hyperliquidWhales.upsertHyperliquidWhaleWalletCoverage)({
|
|
389
389
|
address,
|
|
390
390
|
fromMs,
|
|
391
391
|
toMs,
|
|
@@ -404,7 +404,7 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
404
404
|
);
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
|
-
const buckets = await (0,
|
|
407
|
+
const buckets = await (0, import_hyperliquidWhales.rebuildHyperliquidWhaleFlowRows)({
|
|
408
408
|
fromMs,
|
|
409
409
|
toMs,
|
|
410
410
|
...identity
|
|
@@ -420,7 +420,7 @@ var backfillHyperliquidWhaleContext = async (params) => {
|
|
|
420
420
|
}
|
|
421
421
|
);
|
|
422
422
|
let displayedCoverageBuckets = 0;
|
|
423
|
-
const coverageBuckets = await (0,
|
|
423
|
+
const coverageBuckets = await (0, import_hyperliquidWhales.rebuildHyperliquidWhaleCoverageRows)({
|
|
424
424
|
fromMs,
|
|
425
425
|
toMs,
|
|
426
426
|
expectedWhales: whales.addresses.length,
|
|
@@ -26,7 +26,7 @@ __export(hyperliquidWhaleStream_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(hyperliquidWhaleStream_exports);
|
|
28
28
|
var import_ws = require("ws");
|
|
29
|
-
var
|
|
29
|
+
var import_hyperliquidWhales = require("@tradejs/infra/timescale/hyperliquidWhales");
|
|
30
30
|
var import_strategies = require("@tradejs/node/strategies");
|
|
31
31
|
|
|
32
32
|
// src/lib/hyperliquidWhaleData.ts
|
|
@@ -194,7 +194,7 @@ var runHyperliquidWhaleStream = async (params) => {
|
|
|
194
194
|
const flush = () => {
|
|
195
195
|
if (!buffer.length) return writes;
|
|
196
196
|
const batch = buffer.splice(0, buffer.length);
|
|
197
|
-
writes = writes.then(() => (0,
|
|
197
|
+
writes = writes.then(() => (0, import_hyperliquidWhales.upsertHyperliquidWhaleTradeEvents)(batch));
|
|
198
198
|
return writes;
|
|
199
199
|
};
|
|
200
200
|
const recordStreamCoverage = (toMs) => {
|
|
@@ -213,7 +213,7 @@ var runHyperliquidWhaleStream = async (params) => {
|
|
|
213
213
|
})
|
|
214
214
|
);
|
|
215
215
|
streamCoverageToMs = toMs;
|
|
216
|
-
writes = writes.then(() => (0,
|
|
216
|
+
writes = writes.then(() => (0, import_hyperliquidWhales.upsertHyperliquidWhaleCoverageRows)(rows));
|
|
217
217
|
return writes;
|
|
218
218
|
};
|
|
219
219
|
const finalize = () => {
|
|
@@ -221,7 +221,7 @@ var runHyperliquidWhaleStream = async (params) => {
|
|
|
221
221
|
const fromMs = Math.max(0, toMs - REBUILD_LOOKBACK_MS);
|
|
222
222
|
recordStreamCoverage(toMs);
|
|
223
223
|
writes = writes.then(
|
|
224
|
-
() => (0,
|
|
224
|
+
() => (0, import_hyperliquidWhales.rebuildHyperliquidWhaleFlowRows)({
|
|
225
225
|
fromMs,
|
|
226
226
|
toMs,
|
|
227
227
|
deleteEventsBeforeMs: toMs - RAW_EVENT_RETENTION_MS,
|