@tradejs/cli 3.1.16 → 3.1.17-beta.231
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 +581 -839
- package/dist/lib/runtimeDebugEvidence.js +7 -20
- package/dist/lib/runtimeEvidenceArtifacts.js +165 -0
- package/dist/lib/runtimeEvidenceDeployment.js +84 -4
- package/dist/lib/runtimeEvidenceSync.js +171 -112
- package/dist/lib/runtimeLineage.js +28 -306
- package/dist/lib/runtimeRedis.js +1 -3
- package/dist/lib/runtimeScorecard.js +177 -135
- package/dist/lib/strategyRelease.js +1 -1
- package/dist/scripts/replay.js +165 -370
- package/dist/scripts/replayRunner.js +165 -370
- package/dist/scripts/replayRuntimeEvidence.js +5 -16
- package/dist/scripts/runtimeEvidence.js +319 -187
- package/dist/scripts/runtimeEvidenceSync.js +172 -106
- package/dist/scripts/runtimeParity.js +1 -3
- package/dist/scripts/runtimeScorecard.js +220 -167
- package/dist/scripts/signals.js +47 -316
- package/dist/scripts/signalsDaemon.js +47 -316
- package/dist/scripts/signalsSummary.js +3 -8
- package/package.json +7 -7
|
@@ -44,7 +44,7 @@ var import_chalk7 = __toESM(require("chalk"));
|
|
|
44
44
|
var import_connectors6 = require("@tradejs/node/connectors");
|
|
45
45
|
var import_cli2 = require("@tradejs/node/cli");
|
|
46
46
|
var import_async3 = require("@tradejs/core/async");
|
|
47
|
-
var
|
|
47
|
+
var import_strategies4 = require("@tradejs/core/strategies");
|
|
48
48
|
var import_constants3 = require("@tradejs/core/constants");
|
|
49
49
|
var import_time3 = require("@tradejs/core/time");
|
|
50
50
|
var import_logger4 = require("@tradejs/infra/logger");
|
|
@@ -2148,27 +2148,27 @@ var createCoinMarketCapFetchStats = () => ({
|
|
|
2148
2148
|
totalCredits: 0,
|
|
2149
2149
|
byPath: /* @__PURE__ */ new Map()
|
|
2150
2150
|
});
|
|
2151
|
-
var getCoinMarketCapPathLabel = (
|
|
2152
|
-
if (
|
|
2153
|
-
if (
|
|
2154
|
-
if (
|
|
2155
|
-
if (
|
|
2156
|
-
if (
|
|
2157
|
-
if (
|
|
2158
|
-
return
|
|
2159
|
-
};
|
|
2160
|
-
var recordCoinMarketCapFetchStats = (stats,
|
|
2151
|
+
var getCoinMarketCapPathLabel = (path) => {
|
|
2152
|
+
if (path.includes("global-metrics")) return "global";
|
|
2153
|
+
if (path.includes("cryptocurrency/quotes")) return "reference";
|
|
2154
|
+
if (path.includes("exchange/quotes")) return "exchangeLiquidity";
|
|
2155
|
+
if (path.includes("fear-and-greed")) return "fearGreed";
|
|
2156
|
+
if (path.includes("cmc100")) return "cmc100";
|
|
2157
|
+
if (path.includes("cmc20")) return "cmc20";
|
|
2158
|
+
return path;
|
|
2159
|
+
};
|
|
2160
|
+
var recordCoinMarketCapFetchStats = (stats, path, creditCount) => {
|
|
2161
2161
|
if (!stats) return;
|
|
2162
|
-
const existing = stats.byPath.get(
|
|
2162
|
+
const existing = stats.byPath.get(path) ?? { requests: 0, credits: 0 };
|
|
2163
2163
|
existing.requests += 1;
|
|
2164
2164
|
existing.credits += creditCount ?? 0;
|
|
2165
2165
|
stats.requests += 1;
|
|
2166
2166
|
stats.totalCredits += creditCount ?? 0;
|
|
2167
|
-
stats.byPath.set(
|
|
2167
|
+
stats.byPath.set(path, existing);
|
|
2168
2168
|
};
|
|
2169
2169
|
var formatCoinMarketCapFetchStats = (stats) => {
|
|
2170
2170
|
const byPath = [...stats.byPath.entries()].map(
|
|
2171
|
-
([
|
|
2171
|
+
([path, item]) => `${getCoinMarketCapPathLabel(path)}=${item.requests}req/${item.credits}cr`
|
|
2172
2172
|
).join(" ");
|
|
2173
2173
|
return `apiRequests=${stats.requests} apiCredits=${stats.totalCredits}${byPath ? ` ${byPath}` : ""}`;
|
|
2174
2174
|
};
|
|
@@ -3928,105 +3928,7 @@ var logStrategySkipStats = (runtimeStrategies, strategyStats) => {
|
|
|
3928
3928
|
var import_redis2 = require("@tradejs/infra/redis");
|
|
3929
3929
|
|
|
3930
3930
|
// src/lib/runtimeLineage.ts
|
|
3931
|
-
var import_node_child_process = require("child_process");
|
|
3932
|
-
var import_node_crypto2 = require("crypto");
|
|
3933
|
-
var import_promises2 = __toESM(require("fs/promises"));
|
|
3934
|
-
var import_node_path2 = __toESM(require("path"));
|
|
3935
|
-
var import_types = require("@tradejs/types");
|
|
3936
|
-
var import_strategies3 = require("@tradejs/node/strategies");
|
|
3937
|
-
var import_strategyReleaseEvidence = require("@tradejs/infra/strategyReleaseEvidence");
|
|
3938
|
-
|
|
3939
|
-
// src/lib/strategyGateFingerprint.ts
|
|
3940
3931
|
var import_node_crypto = require("crypto");
|
|
3941
|
-
var import_node_module = require("module");
|
|
3942
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
3943
|
-
var import_node_path = __toESM(require("path"));
|
|
3944
|
-
var toPackageToken = (strategyName) => strategyName.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3945
|
-
var getStrategyPackageName = (strategyName) => strategyName === "TrendLine" || strategyName === "ReverseTrendLine" ? "@tradejs/strategy-trend-line" : `@tradejs/strategy-${toPackageToken(strategyName)}`;
|
|
3946
|
-
var gateFingerprintSpecifiers = (strategyName) => [
|
|
3947
|
-
getStrategyPackageName(strategyName),
|
|
3948
|
-
"@tradejs/strategy-kit/ai-gate",
|
|
3949
|
-
"@tradejs/node/ai",
|
|
3950
|
-
"@tradejs/core/strategies"
|
|
3951
|
-
];
|
|
3952
|
-
var resolveStrategyGateFingerprint = async ({
|
|
3953
|
-
projectRoot,
|
|
3954
|
-
strategyName,
|
|
3955
|
-
gitSha
|
|
3956
|
-
}) => {
|
|
3957
|
-
const projectManifestPath = import_node_path.default.join(projectRoot, "package.json");
|
|
3958
|
-
const projectExists = await import_promises.default.access(projectManifestPath).then(() => true).catch(() => false);
|
|
3959
|
-
const requireFromProject = projectExists ? (0, import_node_module.createRequire)(projectManifestPath) : null;
|
|
3960
|
-
const candidates = requireFromProject ? await Promise.all(
|
|
3961
|
-
gateFingerprintSpecifiers(strategyName).map(async (specifier) => {
|
|
3962
|
-
let resolvedPath;
|
|
3963
|
-
try {
|
|
3964
|
-
resolvedPath = requireFromProject.resolve(specifier);
|
|
3965
|
-
} catch {
|
|
3966
|
-
return null;
|
|
3967
|
-
}
|
|
3968
|
-
const content = await import_promises.default.readFile(resolvedPath).catch(() => null);
|
|
3969
|
-
return content == null ? null : { specifier, content };
|
|
3970
|
-
})
|
|
3971
|
-
) : [];
|
|
3972
|
-
const sourceEntries = candidates.filter(
|
|
3973
|
-
(entry) => entry != null
|
|
3974
|
-
);
|
|
3975
|
-
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
3976
|
-
hash.update(strategyName);
|
|
3977
|
-
if (sourceEntries.length) {
|
|
3978
|
-
for (const entry of sourceEntries) {
|
|
3979
|
-
hash.update(entry.specifier);
|
|
3980
|
-
hash.update(entry.content);
|
|
3981
|
-
}
|
|
3982
|
-
} else {
|
|
3983
|
-
hash.update(gitSha ?? "unknown-git-sha");
|
|
3984
|
-
}
|
|
3985
|
-
return {
|
|
3986
|
-
gateFingerprint: hash.digest("hex").slice(0, 16),
|
|
3987
|
-
gateFingerprintFiles: sourceEntries.map((entry) => entry.specifier)
|
|
3988
|
-
};
|
|
3989
|
-
};
|
|
3990
|
-
|
|
3991
|
-
// src/lib/runtimeLineage.ts
|
|
3992
|
-
var RUNTIME_CONTEXT_ENV_KEYS = [
|
|
3993
|
-
"AI_MODE",
|
|
3994
|
-
"MIN_AI_QUALITY",
|
|
3995
|
-
"INTERVAL",
|
|
3996
|
-
"DERIVATIVES_CONTEXT_ENABLED",
|
|
3997
|
-
"DERIVATIVES_CONTEXT_TARGET_ENABLED",
|
|
3998
|
-
"DERIVATIVES_CONTEXT_LOOKBACK_HOURS",
|
|
3999
|
-
"DERIVATIVES_CONTEXT_EXTRA_REFERENCE_SYMBOLS",
|
|
4000
|
-
"DERIVATIVES_CONTEXT_EXCHANGE_PRIORITY",
|
|
4001
|
-
"COINMARKETCAP_CONTEXT_ENABLED",
|
|
4002
|
-
"COINMARKETCAP_CONTEXT_MAX_AGE_MS",
|
|
4003
|
-
"COINMARKETCAP_CONTEXT_EXCHANGE_LIQUIDITY_ENABLED",
|
|
4004
|
-
"COINMARKETCAP_CONTEXT_EXCHANGE_SLUGS",
|
|
4005
|
-
"COINMARKETCAP_CONTEXT_FEAR_GREED_ENABLED",
|
|
4006
|
-
"COINMARKETCAP_CONTEXT_HISTORICAL_ACCESS_MONTHS",
|
|
4007
|
-
"COINMARKETCAP_CONTEXT_BACKFILL_ENABLED",
|
|
4008
|
-
"COINMARKETCAP_CONTEXT_BACKFILL_MAX_DAYS",
|
|
4009
|
-
"COINMARKETCAP_CONTEXT_BACKFILL_WARMUP_DAYS",
|
|
4010
|
-
"HYPERLIQUID_WHALE_CONTEXT_ENABLED",
|
|
4011
|
-
"HYPERLIQUID_WHALE_BACKFILL_ENABLED",
|
|
4012
|
-
"HYPERLIQUID_WHALE_MIN_COVERAGE_PCT",
|
|
4013
|
-
"HYPERLIQUID_WHALE_CONCURRENCY",
|
|
4014
|
-
"HYPERLIQUID_WHALE_RATE_LIMIT_WEIGHT"
|
|
4015
|
-
];
|
|
4016
|
-
var RUNTIME_CONTEXT_DATA_MODEL = {
|
|
4017
|
-
derivativesSourceIntervals: "15m",
|
|
4018
|
-
derivativesDerivedIntervals: "1h",
|
|
4019
|
-
derivativesHourlyFallback: "stored-1h",
|
|
4020
|
-
derivativesDataModelVersion: 2,
|
|
4021
|
-
coinMarketCapAvailabilityModel: "closed-interval-all-daily",
|
|
4022
|
-
coinMarketCapDataModelVersion: 3,
|
|
4023
|
-
binanceBreadthUniverseModel: "fixed-versioned-top5-top10-top30-top50-top100",
|
|
4024
|
-
binanceBreadthDataModelVersion: 2,
|
|
4025
|
-
hyperliquidWhaleCanonicalInterval: "1m",
|
|
4026
|
-
hyperliquidWhaleGateMinNotionalUsd: 5e4,
|
|
4027
|
-
hyperliquidWhaleMinCoveragePct: 0.8,
|
|
4028
|
-
hyperliquidWhaleDataModelVersion: import_types.HYPERLIQUID_WHALE_DATA_MODEL_VERSION
|
|
4029
|
-
};
|
|
4030
3932
|
var normalizeForStableJson = (value) => {
|
|
4031
3933
|
if (Array.isArray(value)) {
|
|
4032
3934
|
return value.map(normalizeForStableJson);
|
|
@@ -4051,210 +3953,48 @@ var resolveRuntimeMaxLossValue = (config2) => {
|
|
|
4051
3953
|
);
|
|
4052
3954
|
return Number.isFinite(maxLossValue) ? maxLossValue : null;
|
|
4053
3955
|
};
|
|
4054
|
-
var fingerprintRuntimeValue = (value) => (0,
|
|
4055
|
-
var
|
|
4056
|
-
var gateFingerprintCache = /* @__PURE__ */ new Map();
|
|
4057
|
-
var binanceBreadthFingerprintCache = /* @__PURE__ */ new Map();
|
|
4058
|
-
var snapshotFingerprintCache = /* @__PURE__ */ new Map();
|
|
4059
|
-
var resolveGitLineage = (projectRoot) => {
|
|
4060
|
-
const cached = gitLineageCache.get(projectRoot);
|
|
4061
|
-
if (cached) {
|
|
4062
|
-
return cached;
|
|
4063
|
-
}
|
|
4064
|
-
const envSha = String(process.env.TRADEJS_GIT_SHA ?? "").trim();
|
|
4065
|
-
if (envSha && envSha !== "unknown") {
|
|
4066
|
-
const result = {
|
|
4067
|
-
gitSha: envSha,
|
|
4068
|
-
gitDirty: false
|
|
4069
|
-
};
|
|
4070
|
-
gitLineageCache.set(projectRoot, result);
|
|
4071
|
-
return result;
|
|
4072
|
-
}
|
|
4073
|
-
try {
|
|
4074
|
-
const gitSha = (0, import_node_child_process.execFileSync)("git", ["rev-parse", "HEAD"], {
|
|
4075
|
-
cwd: projectRoot,
|
|
4076
|
-
encoding: "utf8",
|
|
4077
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
4078
|
-
}).trim();
|
|
4079
|
-
const status = (0, import_node_child_process.execFileSync)(
|
|
4080
|
-
"git",
|
|
4081
|
-
["status", "--porcelain", "--untracked-files=normal"],
|
|
4082
|
-
{
|
|
4083
|
-
cwd: projectRoot,
|
|
4084
|
-
encoding: "utf8",
|
|
4085
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
4086
|
-
}
|
|
4087
|
-
).trim();
|
|
4088
|
-
const result = {
|
|
4089
|
-
gitSha: gitSha || null,
|
|
4090
|
-
gitDirty: status.length > 0
|
|
4091
|
-
};
|
|
4092
|
-
gitLineageCache.set(projectRoot, result);
|
|
4093
|
-
return result;
|
|
4094
|
-
} catch {
|
|
4095
|
-
const result = {
|
|
4096
|
-
gitSha: null,
|
|
4097
|
-
gitDirty: null
|
|
4098
|
-
};
|
|
4099
|
-
gitLineageCache.set(projectRoot, result);
|
|
4100
|
-
return result;
|
|
4101
|
-
}
|
|
4102
|
-
};
|
|
4103
|
-
var readOptionalFile = async (filePath) => {
|
|
4104
|
-
try {
|
|
4105
|
-
return await import_promises2.default.readFile(filePath);
|
|
4106
|
-
} catch {
|
|
4107
|
-
return null;
|
|
4108
|
-
}
|
|
4109
|
-
};
|
|
4110
|
-
var resolveBinanceBreadthFingerprint = async (projectRoot) => {
|
|
4111
|
-
if (binanceBreadthFingerprintCache.has(projectRoot)) {
|
|
4112
|
-
return binanceBreadthFingerprintCache.get(projectRoot) ?? null;
|
|
4113
|
-
}
|
|
4114
|
-
const content = await readOptionalFile(
|
|
4115
|
-
import_node_path2.default.join(
|
|
4116
|
-
projectRoot,
|
|
4117
|
-
"packages/node/src/config/binanceBreadthUniverses.json"
|
|
4118
|
-
)
|
|
4119
|
-
);
|
|
4120
|
-
let result = null;
|
|
4121
|
-
if (content) {
|
|
4122
|
-
try {
|
|
4123
|
-
const parsed = JSON.parse(content.toString("utf8"));
|
|
4124
|
-
result = typeof parsed.fingerprint === "string" && parsed.fingerprint.trim() ? parsed.fingerprint.trim() : null;
|
|
4125
|
-
} catch {
|
|
4126
|
-
result = null;
|
|
4127
|
-
}
|
|
4128
|
-
}
|
|
4129
|
-
binanceBreadthFingerprintCache.set(projectRoot, result);
|
|
4130
|
-
return result;
|
|
4131
|
-
};
|
|
4132
|
-
var resolveSnapshotFingerprint = async (projectRoot, relativePath) => {
|
|
4133
|
-
const cacheKey = `${projectRoot}:${relativePath}`;
|
|
4134
|
-
if (snapshotFingerprintCache.has(cacheKey)) {
|
|
4135
|
-
return snapshotFingerprintCache.get(cacheKey) ?? null;
|
|
4136
|
-
}
|
|
4137
|
-
const content = await readOptionalFile(import_node_path2.default.join(projectRoot, relativePath));
|
|
4138
|
-
let result = null;
|
|
4139
|
-
if (content) {
|
|
4140
|
-
try {
|
|
4141
|
-
const parsed = JSON.parse(content.toString("utf8"));
|
|
4142
|
-
result = typeof parsed.fingerprint === "string" && parsed.fingerprint.trim() ? parsed.fingerprint.trim() : null;
|
|
4143
|
-
} catch {
|
|
4144
|
-
result = null;
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
snapshotFingerprintCache.set(cacheKey, result);
|
|
4148
|
-
return result;
|
|
4149
|
-
};
|
|
4150
|
-
var resolveRuntimeGateFingerprint = async ({
|
|
4151
|
-
projectRoot,
|
|
4152
|
-
strategyName,
|
|
4153
|
-
gitSha
|
|
4154
|
-
}) => {
|
|
4155
|
-
const cacheKey = `${projectRoot}:${strategyName}:${gitSha ?? "unknown"}`;
|
|
4156
|
-
const cached = gateFingerprintCache.get(cacheKey);
|
|
4157
|
-
if (cached) return cached;
|
|
4158
|
-
const result = await resolveStrategyGateFingerprint({
|
|
4159
|
-
projectRoot,
|
|
4160
|
-
strategyName,
|
|
4161
|
-
gitSha
|
|
4162
|
-
});
|
|
4163
|
-
gateFingerprintCache.set(cacheKey, result);
|
|
4164
|
-
return result;
|
|
4165
|
-
};
|
|
4166
|
-
async function buildRuntimeLineage({
|
|
4167
|
-
projectRoot,
|
|
4168
|
-
strategyName,
|
|
4169
|
-
compositionId,
|
|
3956
|
+
var fingerprintRuntimeValue = (value) => (0, import_node_crypto.createHash)("sha256").update(JSON.stringify(normalizeForStableJson(value))).digest("hex").slice(0, 16);
|
|
3957
|
+
var buildRuntimeLineage = async ({
|
|
4170
3958
|
strategyRevision,
|
|
4171
3959
|
deploymentCompositionId,
|
|
4172
3960
|
strategyPackageVersion,
|
|
4173
3961
|
strategyDependencyVersions,
|
|
4174
3962
|
runtimePackageVersion,
|
|
4175
|
-
config: config2
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
})
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
([name, version]) => !name.startsWith("@tradejs/") || typeof version !== "string" || !version.trim()
|
|
4193
|
-
)) {
|
|
4194
|
-
throw new Error("Invalid strategy dependency versions");
|
|
4195
|
-
}
|
|
4196
|
-
return {
|
|
4197
|
-
schemaVersion: 3,
|
|
4198
|
-
strategyRevision,
|
|
4199
|
-
deploymentCompositionId,
|
|
4200
|
-
strategyPackageVersion,
|
|
4201
|
-
strategyDependencyVersions,
|
|
4202
|
-
runtimePackageVersion,
|
|
4203
|
-
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
4204
|
-
};
|
|
3963
|
+
config: config2
|
|
3964
|
+
}) => {
|
|
3965
|
+
if (!/^sr1:[a-f0-9]{16}$/.test(strategyRevision)) {
|
|
3966
|
+
throw new Error(`Invalid strategy revision: ${strategyRevision}`);
|
|
3967
|
+
}
|
|
3968
|
+
if (!/^dc1:[a-f0-9]{16}$/.test(deploymentCompositionId)) {
|
|
3969
|
+
throw new Error(
|
|
3970
|
+
`Invalid deployment composition id: ${deploymentCompositionId}`
|
|
3971
|
+
);
|
|
3972
|
+
}
|
|
3973
|
+
if (!strategyPackageVersion.trim() || !runtimePackageVersion.trim()) {
|
|
3974
|
+
throw new Error("Invalid revision package versions");
|
|
3975
|
+
}
|
|
3976
|
+
if (Object.keys(strategyDependencyVersions).length === 0 || Object.entries(strategyDependencyVersions).some(
|
|
3977
|
+
([name, version]) => !name.startsWith("@tradejs/") || typeof version !== "string" || !version.trim()
|
|
3978
|
+
)) {
|
|
3979
|
+
throw new Error("Invalid strategy dependency versions");
|
|
4205
3980
|
}
|
|
4206
|
-
const git = resolveGitLineage(projectRoot);
|
|
4207
|
-
const hyperliquidPerpUniverseFingerprint = typeof import_strategies3.getHyperliquidPerpUniverseSnapshot === "function" ? (0, import_strategies3.getHyperliquidPerpUniverseSnapshot)().fingerprint : await resolveSnapshotFingerprint(
|
|
4208
|
-
projectRoot,
|
|
4209
|
-
"packages/node/src/config/hyperliquidPerpUniverse.json"
|
|
4210
|
-
);
|
|
4211
|
-
const hyperliquidWhaleRegistryFingerprint = typeof import_strategies3.getHyperliquidWhaleRegistrySnapshot === "function" ? (0, import_strategies3.getHyperliquidWhaleRegistrySnapshot)().fingerprint : await resolveSnapshotFingerprint(
|
|
4212
|
-
projectRoot,
|
|
4213
|
-
"packages/node/src/config/hyperliquidWhales.json"
|
|
4214
|
-
);
|
|
4215
|
-
const context = {
|
|
4216
|
-
...Object.fromEntries(
|
|
4217
|
-
RUNTIME_CONTEXT_ENV_KEYS.map((key) => [key, env[key] ?? null])
|
|
4218
|
-
),
|
|
4219
|
-
...RUNTIME_CONTEXT_DATA_MODEL,
|
|
4220
|
-
binanceBreadthUniverseFingerprint: await resolveBinanceBreadthFingerprint(projectRoot),
|
|
4221
|
-
hyperliquidPerpUniverseFingerprint,
|
|
4222
|
-
hyperliquidWhaleRegistryFingerprint,
|
|
4223
|
-
...runContext
|
|
4224
|
-
};
|
|
4225
3981
|
return {
|
|
4226
|
-
schemaVersion:
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
gitSha: git.gitSha
|
|
4233
|
-
})).gateFingerprint,
|
|
4234
|
-
// Position risk is tracked separately so changing trade size does not
|
|
4235
|
-
// masquerade as a change to the core + gate decision logic.
|
|
4236
|
-
configFingerprint: (0, import_strategyReleaseEvidence.strategyLogicConfigFingerprint)(config2),
|
|
4237
|
-
contextFingerprint: fingerprintRuntimeValue(context),
|
|
3982
|
+
schemaVersion: 3,
|
|
3983
|
+
strategyRevision,
|
|
3984
|
+
deploymentCompositionId,
|
|
3985
|
+
strategyPackageVersion,
|
|
3986
|
+
strategyDependencyVersions,
|
|
3987
|
+
runtimePackageVersion,
|
|
4238
3988
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
4239
3989
|
};
|
|
4240
|
-
}
|
|
4241
|
-
var runtimeLineageKey = (lineage) =>
|
|
3990
|
+
};
|
|
3991
|
+
var runtimeLineageKey = (lineage) => [
|
|
4242
3992
|
"v3",
|
|
4243
3993
|
lineage.deploymentCompositionId,
|
|
4244
3994
|
lineage.strategyRevision,
|
|
4245
3995
|
lineage.strategyPackageVersion,
|
|
4246
|
-
`deps:${fingerprintRuntimeValue(
|
|
4247
|
-
lineage.strategyDependencyVersions
|
|
4248
|
-
).slice(0, 16)}`,
|
|
3996
|
+
`deps:${fingerprintRuntimeValue(lineage.strategyDependencyVersions).slice(0, 16)}`,
|
|
4249
3997
|
lineage.runtimePackageVersion
|
|
4250
|
-
].join(":") : [
|
|
4251
|
-
lineage.schemaVersion,
|
|
4252
|
-
lineage.compositionId ?? "unbound-composition",
|
|
4253
|
-
lineage.gitSha ?? "unknown",
|
|
4254
|
-
lineage.gitDirty == null ? "unknown" : lineage.gitDirty ? "dirty" : "clean",
|
|
4255
|
-
lineage.gateFingerprint,
|
|
4256
|
-
lineage.configFingerprint,
|
|
4257
|
-
lineage.contextFingerprint
|
|
4258
3998
|
].join(":");
|
|
4259
3999
|
|
|
4260
4000
|
// src/lib/signals/evaluations.ts
|
|
@@ -4802,7 +4542,7 @@ var createSignalsKlineFeed = async ({
|
|
|
4802
4542
|
};
|
|
4803
4543
|
|
|
4804
4544
|
// src/lib/signals/tickerEvaluator.ts
|
|
4805
|
-
var
|
|
4545
|
+
var import_strategies3 = require("@tradejs/node/strategies");
|
|
4806
4546
|
var import_logger3 = require("@tradejs/infra/logger");
|
|
4807
4547
|
|
|
4808
4548
|
// src/lib/runtimeModeConfig.ts
|
|
@@ -4826,7 +4566,6 @@ var buildRuntimeModeStrategyConfig = ({
|
|
|
4826
4566
|
var createSignalsTickerEvaluator = ({
|
|
4827
4567
|
userName,
|
|
4828
4568
|
makeOrders,
|
|
4829
|
-
projectRoot,
|
|
4830
4569
|
context
|
|
4831
4570
|
}) => async (symbol, instrument) => {
|
|
4832
4571
|
const {
|
|
@@ -4898,19 +4637,12 @@ var createSignalsTickerEvaluator = ({
|
|
|
4898
4637
|
makeOrders
|
|
4899
4638
|
});
|
|
4900
4639
|
const runtimeLineage = await buildRuntimeLineage({
|
|
4901
|
-
projectRoot,
|
|
4902
|
-
strategyName,
|
|
4903
4640
|
strategyRevision,
|
|
4904
4641
|
deploymentCompositionId,
|
|
4905
4642
|
strategyPackageVersion,
|
|
4906
4643
|
strategyDependencyVersions,
|
|
4907
4644
|
runtimePackageVersion,
|
|
4908
|
-
config: { strategyConfig }
|
|
4909
|
-
runContext: {
|
|
4910
|
-
connectorName: connectorName.toLowerCase(),
|
|
4911
|
-
interval: String(interval),
|
|
4912
|
-
universe
|
|
4913
|
-
}
|
|
4645
|
+
config: { strategyConfig }
|
|
4914
4646
|
});
|
|
4915
4647
|
const lifecycleKey = buildSignalsStrategyLifecycleKey({
|
|
4916
4648
|
connectorName,
|
|
@@ -5036,7 +4768,7 @@ var createSignalsTickerEvaluator = ({
|
|
|
5036
4768
|
if (signalRuntimeIdentity && !signal.signalId.endsWith(`:${signalRuntimeIdentity}`)) {
|
|
5037
4769
|
signal.signalId = `${signal.signalId}:${signalRuntimeIdentity}`;
|
|
5038
4770
|
}
|
|
5039
|
-
await (0,
|
|
4771
|
+
await (0, import_strategies3.enrichSignalWithBinanceMarketContext)({ signal, env: "CRON" });
|
|
5040
4772
|
if (signal.orderStatus === "skipped" && typeof signal.orderSkipReason === "string" && signal.orderSkipReason.trim()) {
|
|
5041
4773
|
recordStrategyReason(
|
|
5042
4774
|
strategyStats,
|
|
@@ -5198,7 +4930,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5198
4930
|
const createDefaultSignalsLifecycle = (runtimeInterval = interval) => createSignalsStrategyLifecycle({
|
|
5199
4931
|
intervalMs: Number(runtimeInterval) * 6e4,
|
|
5200
4932
|
maxLiveBars: resolveSignalsDaemonMaxLiveBars(runtimeInterval),
|
|
5201
|
-
releaseState:
|
|
4933
|
+
releaseState: import_strategies4.releaseStrategyReplayCache
|
|
5202
4934
|
});
|
|
5203
4935
|
const timeOperation2 = (label, operation) => timeOperation(
|
|
5204
4936
|
label,
|
|
@@ -5550,7 +5282,6 @@ var createSignalsRunner = (config2) => {
|
|
|
5550
5282
|
const evaluateTicker = createSignalsTickerEvaluator({
|
|
5551
5283
|
userName: config2.userName,
|
|
5552
5284
|
makeOrders: config2.makeOrders,
|
|
5553
|
-
projectRoot,
|
|
5554
5285
|
context: {
|
|
5555
5286
|
connectorName,
|
|
5556
5287
|
connector: marketConnector,
|
|
@@ -5604,7 +5335,7 @@ var createSignalsRunner = (config2) => {
|
|
|
5604
5335
|
new Map(
|
|
5605
5336
|
runtimeStrategies.map(({ strategyName, strategyConfig }) => [
|
|
5606
5337
|
strategyName,
|
|
5607
|
-
(0,
|
|
5338
|
+
(0, import_strategies4.mapAiRuntimeFromConfig)({
|
|
5608
5339
|
AI_ENABLED: strategyConfig.AI_ENABLED,
|
|
5609
5340
|
AI_MODE: strategyConfig.AI_MODE,
|
|
5610
5341
|
MIN_AI_QUALITY: strategyConfig.MIN_AI_QUALITY
|
|
@@ -73,9 +73,7 @@ var loadRuntimeTrades = async (userName, {
|
|
|
73
73
|
dedupedBucketTrades.set(trade.orderId, trade);
|
|
74
74
|
}
|
|
75
75
|
const windowedTrades = [...dedupedBucketTrades.values()].filter(filterByWindow).sort((left, right) => left.entryTimestamp - right.entryTimestamp);
|
|
76
|
-
|
|
77
|
-
return windowedTrades;
|
|
78
|
-
}
|
|
76
|
+
return windowedTrades;
|
|
79
77
|
}
|
|
80
78
|
const tradePrefix = import_redis.redisKeys.runtimeTrades(userName);
|
|
81
79
|
const bucketPrefix = import_redis.redisKeys.runtimeTradeBuckets(userName);
|
|
@@ -601,7 +599,6 @@ var buildRuntimeDebugReportPayload = async ({
|
|
|
601
599
|
signals,
|
|
602
600
|
evaluations,
|
|
603
601
|
trades,
|
|
604
|
-
strategyConfigs,
|
|
605
602
|
evaluationStatsBuckets,
|
|
606
603
|
lineageScopes
|
|
607
604
|
}) => {
|
|
@@ -731,8 +728,7 @@ var buildRuntimeDebugReportPayload = async ({
|
|
|
731
728
|
signals: signals.length,
|
|
732
729
|
evaluations: reportEvaluations.length,
|
|
733
730
|
evaluationStatsBuckets: evaluationStatsBuckets?.length ?? 0,
|
|
734
|
-
lineageScopes: lineageScopes?.length ?? 0
|
|
735
|
-
strategyConfigs: strategyConfigs?.length ?? 0
|
|
731
|
+
lineageScopes: lineageScopes?.length ?? 0
|
|
736
732
|
},
|
|
737
733
|
trades: debugTrades,
|
|
738
734
|
signals: signals.map((signal) => ({
|
|
@@ -755,8 +751,7 @@ var buildRuntimeDebugReportPayload = async ({
|
|
|
755
751
|
evaluation
|
|
756
752
|
})),
|
|
757
753
|
evaluationStatsBuckets: evaluationStatsBuckets ?? [],
|
|
758
|
-
lineageScopes: lineageScopes ?? []
|
|
759
|
-
strategyConfigs: strategyConfigs ?? []
|
|
754
|
+
lineageScopes: lineageScopes ?? []
|
|
760
755
|
};
|
|
761
756
|
};
|
|
762
757
|
var buildRuntimeDebugReportAttachment = async (params) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/cli",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.17-beta.231",
|
|
4
4
|
"description": "Official CLI for the TradeJS TypeScript framework: infra setup, backtests, signals, bots, and ML workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"tradejs": "dist/cli.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@tradejs/connectors": "^3.1.
|
|
40
|
-
"@tradejs/core": "^3.1.
|
|
41
|
-
"@tradejs/indicators": "^3.1.
|
|
42
|
-
"@tradejs/infra": "^3.1.
|
|
43
|
-
"@tradejs/node": "^3.1.
|
|
39
|
+
"@tradejs/connectors": "^3.1.17-beta.231",
|
|
40
|
+
"@tradejs/core": "^3.1.17-beta.231",
|
|
41
|
+
"@tradejs/indicators": "^3.1.17-beta.231",
|
|
42
|
+
"@tradejs/infra": "^3.1.17-beta.231",
|
|
43
|
+
"@tradejs/node": "^3.1.17-beta.231",
|
|
44
44
|
"@tradejs/strategy-kit": "3.0.3",
|
|
45
|
-
"@tradejs/types": "^3.1.
|
|
45
|
+
"@tradejs/types": "^3.1.17-beta.231",
|
|
46
46
|
"args": "^5.0.3",
|
|
47
47
|
"bcryptjs": "^2.4.3",
|
|
48
48
|
"chalk": "4.1.2",
|