create-tradejs 3.1.29 → 3.1.30-beta.313
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.
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { createReadStream, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { createInterface } from 'node:readline';
|
|
7
|
+
import { createGunzip, gunzipSync } from 'node:zlib';
|
|
8
|
+
|
|
9
|
+
const step = 15 * 60_000;
|
|
10
|
+
const day = 96 * step;
|
|
11
|
+
const readJson = (file) => JSON.parse(readFileSync(file, 'utf8'));
|
|
12
|
+
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
13
|
+
const keyOf = (strategy, symbol) => JSON.stringify([strategy, symbol]);
|
|
14
|
+
|
|
15
|
+
async function readCandles(file, symbols, intervalMs = step) {
|
|
16
|
+
const series = new Map(symbols.map((symbol) => [symbol, []]));
|
|
17
|
+
const stream = createReadStream(file).pipe(createGunzip());
|
|
18
|
+
for await (const line of createInterface({
|
|
19
|
+
input: stream,
|
|
20
|
+
crlfDelay: Infinity,
|
|
21
|
+
})) {
|
|
22
|
+
const [symbol, ...values] = line.split(',');
|
|
23
|
+
const [
|
|
24
|
+
timestamp,
|
|
25
|
+
open,
|
|
26
|
+
high,
|
|
27
|
+
low,
|
|
28
|
+
close,
|
|
29
|
+
volume,
|
|
30
|
+
turnover,
|
|
31
|
+
buyBase,
|
|
32
|
+
buyQuote,
|
|
33
|
+
sellBase,
|
|
34
|
+
sellQuote,
|
|
35
|
+
] = values.map((value) => (value === '' ? undefined : Number(value)));
|
|
36
|
+
const bars = series.get(symbol);
|
|
37
|
+
assert.ok(bars, `Unexpected symbol ${symbol}`);
|
|
38
|
+
assert.ok(
|
|
39
|
+
[timestamp, open, high, low, close, volume, turnover].every(
|
|
40
|
+
Number.isFinite,
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
if (bars.length)
|
|
44
|
+
assert.equal(timestamp, bars.at(-1).timestamp + intervalMs, symbol);
|
|
45
|
+
bars.push({
|
|
46
|
+
timestamp,
|
|
47
|
+
open,
|
|
48
|
+
high,
|
|
49
|
+
low,
|
|
50
|
+
close,
|
|
51
|
+
volume,
|
|
52
|
+
turnover,
|
|
53
|
+
takerBuyBaseVolume: buyBase,
|
|
54
|
+
takerBuyQuoteVolume: buyQuote,
|
|
55
|
+
takerSellBaseVolume: sellBase,
|
|
56
|
+
takerSellQuoteVolume: sellQuote,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const reference = series.get('BTCUSDT');
|
|
60
|
+
assert.ok(reference?.length);
|
|
61
|
+
for (const [symbol, bars] of series) {
|
|
62
|
+
assert.equal(bars.length, reference.length, symbol);
|
|
63
|
+
assert.equal(bars[0].timestamp, reference[0].timestamp, symbol);
|
|
64
|
+
}
|
|
65
|
+
return series;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function loadFunding(directory, symbol, start, end) {
|
|
69
|
+
const file = path.join(directory, `${symbol}.json.gz`);
|
|
70
|
+
const raw = readFileSync(file);
|
|
71
|
+
const payload = JSON.parse(gunzipSync(raw));
|
|
72
|
+
assert.equal(payload.symbol, symbol);
|
|
73
|
+
const points = payload.rates.map(([timestamp, rate]) => ({
|
|
74
|
+
symbol,
|
|
75
|
+
timestamp,
|
|
76
|
+
rate: Number(rate),
|
|
77
|
+
}));
|
|
78
|
+
const maxInterval = 8 * 3_600_000;
|
|
79
|
+
for (let i = 0; i < points.length; i++) {
|
|
80
|
+
const point = points[i];
|
|
81
|
+
assert.ok(
|
|
82
|
+
Number.isFinite(point.rate) && Number.isSafeInteger(point.timestamp),
|
|
83
|
+
symbol,
|
|
84
|
+
);
|
|
85
|
+
if (i > 0) {
|
|
86
|
+
const previous = points[i - 1].timestamp;
|
|
87
|
+
assert.ok(point.timestamp > previous, symbol);
|
|
88
|
+
if (point.timestamp > start && previous < end) {
|
|
89
|
+
assert.ok(
|
|
90
|
+
point.timestamp - previous <= maxInterval,
|
|
91
|
+
`Funding gap for ${symbol} at ${point.timestamp}`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
assert.ok(points[0].timestamp <= start + maxInterval, symbol);
|
|
97
|
+
assert.ok(points.at(-1).timestamp >= end - maxInterval, symbol);
|
|
98
|
+
return {
|
|
99
|
+
rates: points.filter(
|
|
100
|
+
({ timestamp }) => timestamp >= start && timestamp < end,
|
|
101
|
+
),
|
|
102
|
+
hash: sha(raw),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function modelFeatures(offer, priority, series, index) {
|
|
107
|
+
const { strategy, symbol, direction, stop, target } = offer;
|
|
108
|
+
const bars = series.get(symbol);
|
|
109
|
+
const btc = series.get('BTCUSDT');
|
|
110
|
+
const bar = bars[index];
|
|
111
|
+
const side = direction === 'LONG' ? 1 : -1;
|
|
112
|
+
const ret = (data, barsAgo) =>
|
|
113
|
+
Math.log(data[index].close / data[index - barsAgo].close);
|
|
114
|
+
const stopDistance = Math.abs(bar.close - stop) / bar.close;
|
|
115
|
+
const targetDistance = Math.abs(bar.close - target) / bar.close;
|
|
116
|
+
const recentVolume =
|
|
117
|
+
bars
|
|
118
|
+
.slice(index - 16, index)
|
|
119
|
+
.reduce((sum, item) => sum + item.turnover, 0) / 16;
|
|
120
|
+
return [
|
|
121
|
+
...priority.map((name) => Number(name === strategy)),
|
|
122
|
+
side,
|
|
123
|
+
...priority.map((name) => (name === strategy ? side : 0)),
|
|
124
|
+
Math.log1p(100 * stopDistance),
|
|
125
|
+
Math.log1p(100 * targetDistance),
|
|
126
|
+
side * ret(btc, 16),
|
|
127
|
+
side * ret(btc, 96),
|
|
128
|
+
side * (ret(bars, 16) - ret(btc, 16)),
|
|
129
|
+
side * (ret(bars, 96) - ret(btc, 96)),
|
|
130
|
+
(bar.high - bar.low) / bar.close,
|
|
131
|
+
Math.log1p(bar.turnover / Math.max(1, recentVolume)),
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function fitRidge(rows, penalty) {
|
|
136
|
+
assert.ok(rows.length > 0, 'No closed training trades');
|
|
137
|
+
const width = rows[0].x.length;
|
|
138
|
+
const weightsByTime = new Map();
|
|
139
|
+
for (const row of rows)
|
|
140
|
+
weightsByTime.set(row.time, (weightsByTime.get(row.time) ?? 0) + 1);
|
|
141
|
+
const weight = (row) => 1 / weightsByTime.get(row.time);
|
|
142
|
+
const totalWeight = weightsByTime.size;
|
|
143
|
+
const mean = Array.from(
|
|
144
|
+
{ length: width },
|
|
145
|
+
(_, i) =>
|
|
146
|
+
rows.reduce((sum, row) => sum + weight(row) * row.x[i], 0) / totalWeight,
|
|
147
|
+
);
|
|
148
|
+
const scale = mean.map(
|
|
149
|
+
(m, i) =>
|
|
150
|
+
Math.sqrt(
|
|
151
|
+
rows.reduce((sum, row) => sum + weight(row) * (row.x[i] - m) ** 2, 0) /
|
|
152
|
+
totalWeight,
|
|
153
|
+
) || 1,
|
|
154
|
+
);
|
|
155
|
+
const design = (x) => [
|
|
156
|
+
1,
|
|
157
|
+
...x.map((value, i) => (value - mean[i]) / scale[i]),
|
|
158
|
+
];
|
|
159
|
+
const system = Array.from({ length: width + 1 }, (_, row) =>
|
|
160
|
+
Array.from({ length: width + 2 }, (_, col) =>
|
|
161
|
+
row === col && row !== 0 ? penalty : 0,
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
const features = design(row.x);
|
|
166
|
+
const w = weight(row);
|
|
167
|
+
for (let i = 0; i < features.length; i++) {
|
|
168
|
+
for (let j = 0; j < features.length; j++)
|
|
169
|
+
system[i][j] += w * features[i] * features[j];
|
|
170
|
+
system[i][features.length] += w * features[i] * row.y;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// The positive ridge penalty makes the weighted normal matrix positive definite.
|
|
174
|
+
for (let i = 0; i < system.length; i++) {
|
|
175
|
+
const divisor = system[i][i];
|
|
176
|
+
assert.ok(divisor > 0);
|
|
177
|
+
system[i] = system[i].map((value) => value / divisor);
|
|
178
|
+
for (let j = 0; j < system.length; j++) {
|
|
179
|
+
if (i === j) continue;
|
|
180
|
+
const factor = system[j][i];
|
|
181
|
+
system[j] = system[j].map(
|
|
182
|
+
(value, col) => value - factor * system[i][col],
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const coefficients = system.map((row) => row.at(-1));
|
|
187
|
+
return {
|
|
188
|
+
mean,
|
|
189
|
+
scale,
|
|
190
|
+
coefficients,
|
|
191
|
+
rows: rows.length,
|
|
192
|
+
timestamps: totalWeight,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function predict(model, x) {
|
|
197
|
+
return x.reduce(
|
|
198
|
+
(score, value, i) =>
|
|
199
|
+
score +
|
|
200
|
+
(model.coefficients[i + 1] * (value - model.mean[i])) / model.scale[i],
|
|
201
|
+
model.coefficients[0],
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function runCycle(runtimes, move, choose) {
|
|
206
|
+
const offers = [];
|
|
207
|
+
let pending = runtimes.length;
|
|
208
|
+
let ready;
|
|
209
|
+
const allReady = new Promise((resolve) => {
|
|
210
|
+
ready = resolve;
|
|
211
|
+
});
|
|
212
|
+
if (pending === 0) ready();
|
|
213
|
+
const markReady = () => {
|
|
214
|
+
if (--pending === 0) ready();
|
|
215
|
+
};
|
|
216
|
+
const tasks = runtimes.map(async (runtime) => {
|
|
217
|
+
let offered = false;
|
|
218
|
+
runtime.offer = (offer) =>
|
|
219
|
+
new Promise((reply) => {
|
|
220
|
+
assert.equal(offered, false);
|
|
221
|
+
offered = true;
|
|
222
|
+
offers.push({ ...offer, runtime, reply });
|
|
223
|
+
markReady();
|
|
224
|
+
});
|
|
225
|
+
try {
|
|
226
|
+
return await move(runtime);
|
|
227
|
+
} finally {
|
|
228
|
+
if (!offered) markReady();
|
|
229
|
+
runtime.offer = undefined;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const completion = Promise.allSettled(tasks);
|
|
233
|
+
await allReady;
|
|
234
|
+
try {
|
|
235
|
+
await choose(offers, tasks);
|
|
236
|
+
} finally {
|
|
237
|
+
for (const offer of offers)
|
|
238
|
+
offer.reply({ allow: false, reason: 'PORTFOLIO_SELECTION' });
|
|
239
|
+
}
|
|
240
|
+
for (const result of await completion) {
|
|
241
|
+
if (result.status === 'rejected') throw result.reason;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function summarize(trades, start, end) {
|
|
246
|
+
let pnl = 0,
|
|
247
|
+
peak = 0,
|
|
248
|
+
maxDrawdown = 0,
|
|
249
|
+
won = 0,
|
|
250
|
+
grossWin = 0,
|
|
251
|
+
grossLoss = 0;
|
|
252
|
+
let date,
|
|
253
|
+
batchPnl = 0;
|
|
254
|
+
function observe() {
|
|
255
|
+
pnl += batchPnl;
|
|
256
|
+
peak = Math.max(peak, pnl);
|
|
257
|
+
maxDrawdown = Math.max(maxDrawdown, peak - pnl);
|
|
258
|
+
batchPnl = 0;
|
|
259
|
+
}
|
|
260
|
+
for (const trade of trades) {
|
|
261
|
+
if (date !== undefined && date !== trade.exit) observe();
|
|
262
|
+
date = trade.exit;
|
|
263
|
+
batchPnl += trade.pnl;
|
|
264
|
+
if (trade.pnl > 0) {
|
|
265
|
+
won++;
|
|
266
|
+
grossWin += trade.pnl;
|
|
267
|
+
} else grossLoss -= trade.pnl;
|
|
268
|
+
}
|
|
269
|
+
observe();
|
|
270
|
+
return {
|
|
271
|
+
n: trades.length,
|
|
272
|
+
pnl,
|
|
273
|
+
maxDrawdown,
|
|
274
|
+
pnlPerTrade: trades.length ? pnl / trades.length : null,
|
|
275
|
+
profitFactor: grossLoss ? grossWin / grossLoss : null,
|
|
276
|
+
winRate: trades.length ? won / trades.length : null,
|
|
277
|
+
tradesPerDay: trades.length / ((end - start) / day),
|
|
278
|
+
fundingFee: trades.reduce((sum, trade) => sum + trade.funding, 0),
|
|
279
|
+
fee: trades.reduce((sum, trade) => sum + trade.fee, 0),
|
|
280
|
+
slippageCost: trades.reduce((sum, trade) => sum + trade.slippage, 0),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function main() {
|
|
285
|
+
const [studyDir, mode, smokeDays, selectedVariant] = process.argv.slice(2);
|
|
286
|
+
assert.ok(
|
|
287
|
+
studyDir && ['smoke', 'train', 'test'].includes(mode),
|
|
288
|
+
'Usage: node portfolio-signal-agent.mjs STUDY_DIR smoke|train|test [smokeDays] [testVariant]',
|
|
289
|
+
);
|
|
290
|
+
const root = path.resolve(studyDir);
|
|
291
|
+
const spec = readJson(path.join(root, 'spec.json'));
|
|
292
|
+
assert.ok(spec.symbols.every((symbol) => /^[A-Z0-9]+USDT$/.test(symbol)));
|
|
293
|
+
assert.ok(
|
|
294
|
+
spec.symbols.includes('BTCUSDT') && spec.symbols.includes('ETHUSDT'),
|
|
295
|
+
);
|
|
296
|
+
assert.ok(new Set(spec.symbols).size === spec.symbols.length);
|
|
297
|
+
const production = readJson(path.join(root, 'production.json'));
|
|
298
|
+
const deployments = [production, ...(production.additionalDeployments ?? [])];
|
|
299
|
+
const strategies = deployments.flatMap(
|
|
300
|
+
({ verification, verificationSha256, verificationBytes, strategies }) => {
|
|
301
|
+
assert.equal(verification.encoding, 'base64');
|
|
302
|
+
const verificationBody = Buffer.from(verification.data, 'base64');
|
|
303
|
+
assert.equal(verificationBody.length, verificationBytes);
|
|
304
|
+
assert.equal(sha(verificationBody), verificationSha256);
|
|
305
|
+
const verified = JSON.parse(verificationBody);
|
|
306
|
+
for (const strategy of strategies) {
|
|
307
|
+
assert.equal(
|
|
308
|
+
strategy.deploymentCompositionId,
|
|
309
|
+
verified.deploymentCompositionId,
|
|
310
|
+
);
|
|
311
|
+
assert.ok(
|
|
312
|
+
verified.verification.strategies.some(
|
|
313
|
+
(item) =>
|
|
314
|
+
item.strategyName === strategy.strategyName &&
|
|
315
|
+
item.strategyRevision === strategy.strategyRevision,
|
|
316
|
+
),
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
return strategies;
|
|
320
|
+
},
|
|
321
|
+
);
|
|
322
|
+
assert.equal(
|
|
323
|
+
new Set(strategies.map((strategy) => strategy.strategyName)).size,
|
|
324
|
+
strategies.length,
|
|
325
|
+
);
|
|
326
|
+
const verificationSha256 = production.verificationSha256;
|
|
327
|
+
const additionalDeploymentHashes = deployments
|
|
328
|
+
.slice(1)
|
|
329
|
+
.map((deployment) => deployment.verificationSha256);
|
|
330
|
+
|
|
331
|
+
const runtimeRoot = path.join(root, 'runtime');
|
|
332
|
+
const require = createRequire(path.join(runtimeRoot, 'loader.cjs'));
|
|
333
|
+
const originalProject = process.cwd();
|
|
334
|
+
process.env.PROJECT_CWD = runtimeRoot;
|
|
335
|
+
process.env.TRADEJS_TIMESCALE_READ_ONLY = 'true';
|
|
336
|
+
const {
|
|
337
|
+
createStrategyRuntime,
|
|
338
|
+
registerStrategyEntries,
|
|
339
|
+
} = require('@tradejs/node/strategies');
|
|
340
|
+
const { createTestConnector } = require('@tradejs/node/backtest');
|
|
341
|
+
const { closeRedisConnection } = require('@tradejs/infra/redis');
|
|
342
|
+
const { closeTimescalePool } = require('@tradejs/infra/timescale/client');
|
|
343
|
+
assert.equal(
|
|
344
|
+
readJson(path.join(runtimeRoot, 'node_modules/@tradejs/node/package.json'))
|
|
345
|
+
.version,
|
|
346
|
+
strategies[0].runtimePackageVersion,
|
|
347
|
+
);
|
|
348
|
+
const plugins = new Map(
|
|
349
|
+
strategies.map((strategy) => {
|
|
350
|
+
const packagePath = path.join(
|
|
351
|
+
runtimeRoot,
|
|
352
|
+
'node_modules',
|
|
353
|
+
strategy.strategyPackage,
|
|
354
|
+
'package.json',
|
|
355
|
+
);
|
|
356
|
+
assert.equal(
|
|
357
|
+
readJson(packagePath).version,
|
|
358
|
+
strategy.strategyPackageVersion,
|
|
359
|
+
);
|
|
360
|
+
const entry = require(strategy.strategyPackage).strategyEntries.find(
|
|
361
|
+
(item) => item.manifest.name === strategy.strategyName,
|
|
362
|
+
);
|
|
363
|
+
assert.ok(entry, strategy.strategyName);
|
|
364
|
+
return [strategy.strategyName, entry];
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
367
|
+
registerStrategyEntries([...plugins.values()]);
|
|
368
|
+
const series = await readCandles(
|
|
369
|
+
path.join(root, 'candles.csv.gz'),
|
|
370
|
+
spec.symbols,
|
|
371
|
+
);
|
|
372
|
+
const intervalSeries = new Map([[15, series]]);
|
|
373
|
+
for (const interval of new Set(
|
|
374
|
+
strategies.map((strategy) => Number(strategy.strategyConfig.INTERVAL)),
|
|
375
|
+
)) {
|
|
376
|
+
if (interval === 15) continue;
|
|
377
|
+
assert.ok(
|
|
378
|
+
interval > 15 && interval % 15 === 0,
|
|
379
|
+
`Unsupported interval ${interval}`,
|
|
380
|
+
);
|
|
381
|
+
const native = await readCandles(
|
|
382
|
+
path.join(root, `candles-${interval}.csv.gz`),
|
|
383
|
+
spec.symbols,
|
|
384
|
+
interval * 60_000,
|
|
385
|
+
);
|
|
386
|
+
const primaryBtc = series.get('BTCUSDT'),
|
|
387
|
+
nativeBtc = native.get('BTCUSDT');
|
|
388
|
+
assert.equal(nativeBtc[0].timestamp, primaryBtc[0].timestamp);
|
|
389
|
+
assert.equal(
|
|
390
|
+
nativeBtc.at(-1).timestamp + interval * 60_000,
|
|
391
|
+
primaryBtc.at(-1).timestamp + step,
|
|
392
|
+
);
|
|
393
|
+
intervalSeries.set(interval, native);
|
|
394
|
+
}
|
|
395
|
+
const split = Date.parse(spec.split),
|
|
396
|
+
start = Date.parse(spec.start),
|
|
397
|
+
end = Date.parse(spec.end);
|
|
398
|
+
assert.ok(start < split && (mode === 'train' ? split <= end : split < end));
|
|
399
|
+
const frozenEvaluation = spec.frozenModelSha256 != null;
|
|
400
|
+
if (frozenEvaluation) {
|
|
401
|
+
assert.equal(mode, 'test', 'An externally frozen model is evaluation-only');
|
|
402
|
+
assert.ok(Date.parse(spec.frozenModelTrainingEnd) <= split);
|
|
403
|
+
}
|
|
404
|
+
const trainingWithoutFunding = spec.trainingWithoutFunding === true;
|
|
405
|
+
if (trainingWithoutFunding) assert.equal(mode, 'train');
|
|
406
|
+
const fundingStart = mode === 'test' ? split : start;
|
|
407
|
+
const funding = new Map(
|
|
408
|
+
spec.symbols.map((symbol) => [
|
|
409
|
+
symbol,
|
|
410
|
+
trainingWithoutFunding
|
|
411
|
+
? { rates: [], hash: null }
|
|
412
|
+
: loadFunding(
|
|
413
|
+
path.resolve(originalProject, spec.fundingDirectory),
|
|
414
|
+
symbol,
|
|
415
|
+
fundingStart,
|
|
416
|
+
end,
|
|
417
|
+
),
|
|
418
|
+
]),
|
|
419
|
+
);
|
|
420
|
+
const priority = new Map(spec.priority.map((name, index) => [name, index]));
|
|
421
|
+
assert.equal(priority.size, plugins.size);
|
|
422
|
+
const excludedEvaluationStrategies = new Set(
|
|
423
|
+
spec.excludedEvaluationStrategies ?? [],
|
|
424
|
+
);
|
|
425
|
+
for (const name of excludedEvaluationStrategies)
|
|
426
|
+
assert.ok(plugins.has(name), name);
|
|
427
|
+
if (excludedEvaluationStrategies.size) assert.equal(mode, 'test');
|
|
428
|
+
const btc = series.get('BTCUSDT');
|
|
429
|
+
const indexAt = (time) => {
|
|
430
|
+
const index = (time - btc[0].timestamp) / step;
|
|
431
|
+
assert.ok(
|
|
432
|
+
Number.isInteger(index) &&
|
|
433
|
+
index >= spec.warmupBars &&
|
|
434
|
+
index <= btc.length,
|
|
435
|
+
time,
|
|
436
|
+
);
|
|
437
|
+
return index;
|
|
438
|
+
};
|
|
439
|
+
const modelPath = path.join(root, 'model.json');
|
|
440
|
+
if (frozenEvaluation)
|
|
441
|
+
assert.equal(sha(readFileSync(modelPath)), spec.frozenModelSha256);
|
|
442
|
+
const savedModel =
|
|
443
|
+
mode === 'test' && (!selectedVariant || selectedVariant === 'agent')
|
|
444
|
+
? readJson(modelPath)
|
|
445
|
+
: null;
|
|
446
|
+
const output = {
|
|
447
|
+
verificationSha256,
|
|
448
|
+
...(trainingWithoutFunding ? { trainingWithoutFunding } : {}),
|
|
449
|
+
...(excludedEvaluationStrategies.size
|
|
450
|
+
? { excludedEvaluationStrategies: [...excludedEvaluationStrategies] }
|
|
451
|
+
: {}),
|
|
452
|
+
...(frozenEvaluation ? { frozenModelSha256: spec.frozenModelSha256 } : {}),
|
|
453
|
+
...(additionalDeploymentHashes.length
|
|
454
|
+
? { additionalDeploymentHashes }
|
|
455
|
+
: {}),
|
|
456
|
+
fundingSha256: Object.fromEntries(
|
|
457
|
+
Array.from(funding, ([symbol, data]) => [symbol, data.hash]),
|
|
458
|
+
),
|
|
459
|
+
variants: {},
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
async function replay(variant, from, to) {
|
|
463
|
+
const first = indexAt(from),
|
|
464
|
+
last = indexAt(to);
|
|
465
|
+
const training = variant === 'training';
|
|
466
|
+
const trades = [],
|
|
467
|
+
trainRows = [];
|
|
468
|
+
const stats = {
|
|
469
|
+
offers: 0,
|
|
470
|
+
filled: 0,
|
|
471
|
+
filteredByCurrentGate: 0,
|
|
472
|
+
otherSkips: {},
|
|
473
|
+
forcedExits: 0,
|
|
474
|
+
maxOpenPositions: 0,
|
|
475
|
+
byStrategy: Object.fromEntries(
|
|
476
|
+
spec.priority.map((name) => [
|
|
477
|
+
name,
|
|
478
|
+
{ offers: 0, filled: 0, filteredByCurrentGate: 0 },
|
|
479
|
+
]),
|
|
480
|
+
),
|
|
481
|
+
};
|
|
482
|
+
const runtimes = [];
|
|
483
|
+
|
|
484
|
+
for (const observed of strategies) {
|
|
485
|
+
const name = observed.strategyName;
|
|
486
|
+
if (excludedEvaluationStrategies.has(name)) continue;
|
|
487
|
+
const entry = plugins.get(name);
|
|
488
|
+
const config = entry.parseConfig({
|
|
489
|
+
...observed.strategyConfig,
|
|
490
|
+
ENV: 'PARITY',
|
|
491
|
+
MAKE_ORDERS: true,
|
|
492
|
+
AI_ENABLED:
|
|
493
|
+
variant === 'current' && observed.strategyConfig.AI_ENABLED === true,
|
|
494
|
+
MAX_LOSS_VALUE: spec.risk,
|
|
495
|
+
});
|
|
496
|
+
const interval = Number(config.INTERVAL);
|
|
497
|
+
const nativeRatio = interval / 15;
|
|
498
|
+
const native = intervalSeries.get(interval);
|
|
499
|
+
assert.ok(
|
|
500
|
+
native &&
|
|
501
|
+
first % nativeRatio === 0 &&
|
|
502
|
+
spec.warmupBars % nativeRatio === 0,
|
|
503
|
+
);
|
|
504
|
+
const warm = (bars) =>
|
|
505
|
+
bars.slice(
|
|
506
|
+
(first - spec.warmupBars) / nativeRatio,
|
|
507
|
+
first / nativeRatio,
|
|
508
|
+
);
|
|
509
|
+
for (const symbol of spec.symbols) {
|
|
510
|
+
if (observed.selection && !observed.selection.tickers.includes(symbol))
|
|
511
|
+
continue;
|
|
512
|
+
const test = createTestConnector(
|
|
513
|
+
{
|
|
514
|
+
universe: 'crypto',
|
|
515
|
+
capabilities: {},
|
|
516
|
+
kline: async () => {
|
|
517
|
+
throw Error('External candle request in offline replay');
|
|
518
|
+
},
|
|
519
|
+
listInstruments: async () => [],
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
aiEnabled: true,
|
|
523
|
+
fastMode: true,
|
|
524
|
+
fundingRates: funding.get(symbol).rates,
|
|
525
|
+
executionCostModel: {
|
|
526
|
+
fees: {
|
|
527
|
+
makerRate: spec.feeRate,
|
|
528
|
+
takerRate: spec.feeRate,
|
|
529
|
+
source: 'config',
|
|
530
|
+
},
|
|
531
|
+
slippage: {
|
|
532
|
+
baseBps: spec.slippageBps,
|
|
533
|
+
spreadMultiplier: 0,
|
|
534
|
+
marketImpactBps: 0,
|
|
535
|
+
delayRiskMultiplier: 0,
|
|
536
|
+
source: 'config',
|
|
537
|
+
},
|
|
538
|
+
funding: trainingWithoutFunding
|
|
539
|
+
? { enabled: false, source: 'unavailable', points: 0 }
|
|
540
|
+
: {
|
|
541
|
+
enabled: true,
|
|
542
|
+
source: 'historical',
|
|
543
|
+
points: funding.get(symbol).rates.length,
|
|
544
|
+
},
|
|
545
|
+
leverage: {
|
|
546
|
+
requested: config.LEVERAGE,
|
|
547
|
+
effective: config.LEVERAGE,
|
|
548
|
+
maxAllowed: null,
|
|
549
|
+
},
|
|
550
|
+
quality: 'full',
|
|
551
|
+
capturedAt: 0,
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
);
|
|
555
|
+
const runtime = {
|
|
556
|
+
test,
|
|
557
|
+
symbol,
|
|
558
|
+
name,
|
|
559
|
+
claims: new Map(),
|
|
560
|
+
native,
|
|
561
|
+
nativeRatio,
|
|
562
|
+
executionTime: null,
|
|
563
|
+
taskIndex: runtimes.length,
|
|
564
|
+
};
|
|
565
|
+
// Native H1 candles are stamped at their open. Use the shared decision
|
|
566
|
+
// tick for fills so nothing is timestamped before that candle is known.
|
|
567
|
+
if (nativeRatio > 1) {
|
|
568
|
+
const placeOrder = test.placeOrder;
|
|
569
|
+
const closePosition = test.closePosition;
|
|
570
|
+
const atDecisionTick = (order) => ({
|
|
571
|
+
...order,
|
|
572
|
+
timestamp: Math.max(
|
|
573
|
+
order.timestamp,
|
|
574
|
+
runtime.executionTime ?? order.timestamp,
|
|
575
|
+
),
|
|
576
|
+
});
|
|
577
|
+
test.placeOrder = (order) => placeOrder(atDecisionTick(order));
|
|
578
|
+
test.closePosition = (order) => closePosition(atDecisionTick(order));
|
|
579
|
+
}
|
|
580
|
+
const existing = entry.manifest.hooks?.beforeEntryGate;
|
|
581
|
+
const create = createStrategyRuntime({
|
|
582
|
+
strategyName: name,
|
|
583
|
+
defaults: entry.defaults,
|
|
584
|
+
createCore: entry.createCore,
|
|
585
|
+
manifest: {
|
|
586
|
+
...entry.manifest,
|
|
587
|
+
hooks: {
|
|
588
|
+
...entry.manifest.hooks,
|
|
589
|
+
async beforeEntryGate(params) {
|
|
590
|
+
const previous = await existing?.(params);
|
|
591
|
+
if (previous?.allow === false) return previous;
|
|
592
|
+
const { decision, market } = params;
|
|
593
|
+
const stop = decision.orderPlan.stopLossPrice;
|
|
594
|
+
const target = decision.orderPlan.takeProfits?.[0]?.price;
|
|
595
|
+
assert.ok(decision.signal?.signalId, 'Entry without a signal');
|
|
596
|
+
return runtime.offer({
|
|
597
|
+
strategy: name,
|
|
598
|
+
symbol,
|
|
599
|
+
time: market.candle.timestamp + (nativeRatio - 1) * step,
|
|
600
|
+
direction: decision.entryContext.direction,
|
|
601
|
+
stop,
|
|
602
|
+
target,
|
|
603
|
+
signalId: decision.signal.signalId,
|
|
604
|
+
});
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
runtime.run = await create({
|
|
610
|
+
userName: 'offline-signal-selection',
|
|
611
|
+
connectorName: 'bybit',
|
|
612
|
+
symbol,
|
|
613
|
+
universe: 'crypto',
|
|
614
|
+
assetClass: 'crypto_perpetual',
|
|
615
|
+
config,
|
|
616
|
+
policyProfileId: config.POLICY_PROFILE_ID,
|
|
617
|
+
runtimeConfigSnapshot: { userConfig: {} },
|
|
618
|
+
...(spec.shareIndicators
|
|
619
|
+
? {
|
|
620
|
+
sharedIndicatorsReplayKey: `signal-agent:${variant}:${symbol}:${interval}`,
|
|
621
|
+
}
|
|
622
|
+
: {}),
|
|
623
|
+
data: warm(native.get(symbol)),
|
|
624
|
+
btcData: warm(native.get('BTCUSDT')),
|
|
625
|
+
ethData: warm(native.get('ETHUSDT')),
|
|
626
|
+
connector: test,
|
|
627
|
+
});
|
|
628
|
+
runtimes.push(runtime);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
assert.ok(runtimes.length > 0);
|
|
632
|
+
|
|
633
|
+
async function collect(runtime) {
|
|
634
|
+
for (const record of await runtime.test.drainMlResultsBatch()) {
|
|
635
|
+
const result = record.tradeResult;
|
|
636
|
+
assert.ok(result, 'Filled trade has no economics');
|
|
637
|
+
assert.ok(
|
|
638
|
+
Number.isFinite(result.netProfit) &&
|
|
639
|
+
result.entryTimestamp <= result.exitTimestamp,
|
|
640
|
+
);
|
|
641
|
+
const claim = runtime.claims.get(record.signalId);
|
|
642
|
+
assert.ok(claim, 'Exit without admission');
|
|
643
|
+
runtime.claims.delete(record.signalId);
|
|
644
|
+
if (training) {
|
|
645
|
+
if (result.exitTimestamp < to) {
|
|
646
|
+
trainRows.push({
|
|
647
|
+
time: claim.time,
|
|
648
|
+
x: claim.x,
|
|
649
|
+
y: result.netProfit / spec.risk,
|
|
650
|
+
strategy: runtime.name,
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
} else {
|
|
654
|
+
trades.push({
|
|
655
|
+
strategy: runtime.name,
|
|
656
|
+
symbol: runtime.symbol,
|
|
657
|
+
direction: result.direction,
|
|
658
|
+
entry: result.entryTimestamp,
|
|
659
|
+
exit: result.exitTimestamp,
|
|
660
|
+
pnl: result.netProfit,
|
|
661
|
+
funding: result.fundingFee ?? 0,
|
|
662
|
+
slippage: result.totalSlippageCost ?? 0,
|
|
663
|
+
fee: result.openFee + result.closeFee,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
for (let i = first; i < last; i++) {
|
|
670
|
+
const time = btc[i].timestamp;
|
|
671
|
+
const positions = new Set();
|
|
672
|
+
let openCount = 0;
|
|
673
|
+
async function refreshPositions() {
|
|
674
|
+
positions.clear();
|
|
675
|
+
openCount = 0;
|
|
676
|
+
for (const runtime of runtimes) {
|
|
677
|
+
if (await runtime.test.getPosition(runtime.symbol)) {
|
|
678
|
+
openCount++;
|
|
679
|
+
positions.add(runtime.symbol);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
for (const runtime of runtimes) {
|
|
684
|
+
const candle = series.get(runtime.symbol)[i];
|
|
685
|
+
await runtime.test.checkExits(candle);
|
|
686
|
+
await collect(runtime);
|
|
687
|
+
}
|
|
688
|
+
if (i < last - 1) {
|
|
689
|
+
await runCycle(
|
|
690
|
+
runtimes,
|
|
691
|
+
async (runtime) => {
|
|
692
|
+
if ((i + 1) % runtime.nativeRatio !== 0) return undefined;
|
|
693
|
+
const nativeIndex = (i + 1) / runtime.nativeRatio - 1;
|
|
694
|
+
runtime.executionTime = time;
|
|
695
|
+
const result = await runtime.run(
|
|
696
|
+
runtime.native.get(runtime.symbol)[nativeIndex],
|
|
697
|
+
runtime.native.get('BTCUSDT')[nativeIndex],
|
|
698
|
+
runtime.native.get('ETHUSDT')[nativeIndex],
|
|
699
|
+
);
|
|
700
|
+
if (result && typeof result !== 'string') {
|
|
701
|
+
const reason =
|
|
702
|
+
result.orderSkipReason ?? result.orderFailureReason;
|
|
703
|
+
if (reason?.startsWith('AI_')) {
|
|
704
|
+
stats.filteredByCurrentGate++;
|
|
705
|
+
stats.byStrategy[runtime.name].filteredByCurrentGate++;
|
|
706
|
+
} else if (reason && !reason.includes('PORTFOLIO_SELECTION')) {
|
|
707
|
+
stats.otherSkips[reason] = (stats.otherSkips[reason] ?? 0) + 1;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return result;
|
|
711
|
+
},
|
|
712
|
+
async (offers, tasks) => {
|
|
713
|
+
await refreshPositions();
|
|
714
|
+
stats.offers += offers.length;
|
|
715
|
+
for (const offer of offers) {
|
|
716
|
+
stats.byStrategy[offer.strategy].offers++;
|
|
717
|
+
assert.equal(offer.time, time, 'Unexpected decision time');
|
|
718
|
+
if (training || variant === 'agent') {
|
|
719
|
+
assert.ok(
|
|
720
|
+
Number.isFinite(offer.stop) && Number.isFinite(offer.target),
|
|
721
|
+
'Missing fixed protection levels',
|
|
722
|
+
);
|
|
723
|
+
offer.x = modelFeatures(offer, spec.priority, series, i);
|
|
724
|
+
assert.ok(offer.x.every(Number.isFinite));
|
|
725
|
+
if (variant === 'agent')
|
|
726
|
+
offer.score = predict(savedModel, offer.x);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
const ordered = offers.sort(
|
|
730
|
+
(a, b) =>
|
|
731
|
+
(variant === 'agent' ? b.score - a.score : 0) ||
|
|
732
|
+
priority.get(a.strategy) - priority.get(b.strategy) ||
|
|
733
|
+
a.symbol.localeCompare(b.symbol),
|
|
734
|
+
);
|
|
735
|
+
for (const offer of ordered) {
|
|
736
|
+
if (
|
|
737
|
+
!training &&
|
|
738
|
+
(openCount >= spec.maxPositions || positions.has(offer.symbol))
|
|
739
|
+
)
|
|
740
|
+
continue;
|
|
741
|
+
if (variant === 'agent' && offer.score <= spec.agentMinExpectedR)
|
|
742
|
+
continue;
|
|
743
|
+
const live = offer.runtime;
|
|
744
|
+
assert.equal(
|
|
745
|
+
await live.test.getPosition(live.symbol),
|
|
746
|
+
null,
|
|
747
|
+
'Unexpected scale-in submission',
|
|
748
|
+
);
|
|
749
|
+
offer.reply({ allow: true });
|
|
750
|
+
const result = await tasks[live.taskIndex];
|
|
751
|
+
if (await live.test.getPosition(live.symbol)) {
|
|
752
|
+
stats.filled++;
|
|
753
|
+
stats.byStrategy[offer.strategy].filled++;
|
|
754
|
+
openCount++;
|
|
755
|
+
positions.add(live.symbol);
|
|
756
|
+
live.claims.set(offer.signalId, { time, x: offer.x });
|
|
757
|
+
} else if (result?.orderStatus === 'completed') {
|
|
758
|
+
throw new Error(
|
|
759
|
+
`Completed without a position: ${offer.signalId}`,
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
);
|
|
765
|
+
} else {
|
|
766
|
+
await refreshPositions();
|
|
767
|
+
}
|
|
768
|
+
stats.maxOpenPositions = Math.max(stats.maxOpenPositions, openCount);
|
|
769
|
+
if (!training)
|
|
770
|
+
assert.equal(positions.size, openCount, 'Duplicate symbol position');
|
|
771
|
+
const logEveryDays = frozenEvaluation ? 3 : 30;
|
|
772
|
+
if ((i - first + 1) % (logEveryDays * 96) === 0) {
|
|
773
|
+
console.error(
|
|
774
|
+
variant,
|
|
775
|
+
new Date(time).toISOString(),
|
|
776
|
+
stats.offers,
|
|
777
|
+
stats.filled,
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
const finalTime = btc[last - 1].timestamp;
|
|
782
|
+
for (const runtime of runtimes) {
|
|
783
|
+
const position = await runtime.test.getPosition(runtime.symbol);
|
|
784
|
+
if (!position) continue;
|
|
785
|
+
stats.forcedExits++;
|
|
786
|
+
if (!training) {
|
|
787
|
+
await runtime.test.closePosition({
|
|
788
|
+
...position,
|
|
789
|
+
timestamp: finalTime,
|
|
790
|
+
price: series.get(runtime.symbol)[last - 1].close,
|
|
791
|
+
});
|
|
792
|
+
await collect(runtime);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (!training)
|
|
796
|
+
assert.equal(trades.length, stats.filled, 'Fill and trade counts differ');
|
|
797
|
+
else
|
|
798
|
+
assert.equal(
|
|
799
|
+
trainRows.length + stats.forcedExits,
|
|
800
|
+
stats.filled,
|
|
801
|
+
'Training outcome counts differ',
|
|
802
|
+
);
|
|
803
|
+
trades.sort(
|
|
804
|
+
(a, b) =>
|
|
805
|
+
a.exit - b.exit ||
|
|
806
|
+
a.entry - b.entry ||
|
|
807
|
+
a.symbol.localeCompare(b.symbol),
|
|
808
|
+
);
|
|
809
|
+
console.error(variant, JSON.stringify(stats));
|
|
810
|
+
return { trades, trainRows, stats };
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
try {
|
|
814
|
+
if (mode === 'train') {
|
|
815
|
+
const result = await replay('training', start, split);
|
|
816
|
+
const subsets = spec.trainingSubsets ?? { model: spec.priority };
|
|
817
|
+
for (const [id, names] of Object.entries(subsets)) {
|
|
818
|
+
assert.match(id, /^[a-zA-Z0-9-]+$/);
|
|
819
|
+
assert.ok(
|
|
820
|
+
names.length > 0 && names.every((name) => priority.has(name)),
|
|
821
|
+
);
|
|
822
|
+
assert.equal(new Set(names).size, names.length);
|
|
823
|
+
const width = spec.priority.length;
|
|
824
|
+
const indices = names.map((name) => priority.get(name));
|
|
825
|
+
const subsetRows = result.trainRows
|
|
826
|
+
.filter((row) => names.includes(row.strategy))
|
|
827
|
+
.map((row) => ({
|
|
828
|
+
...row,
|
|
829
|
+
x: [
|
|
830
|
+
...indices.map((i) => row.x[i]),
|
|
831
|
+
row.x[width],
|
|
832
|
+
...indices.map((i) => row.x[width + 1 + i]),
|
|
833
|
+
...row.x.slice(2 * width + 1),
|
|
834
|
+
],
|
|
835
|
+
}));
|
|
836
|
+
const model = fitRidge(subsetRows, spec.ridgePenalty);
|
|
837
|
+
const byStrategy = Object.fromEntries(
|
|
838
|
+
names.map((name) => [
|
|
839
|
+
name,
|
|
840
|
+
subsetRows.filter((row) => row.strategy === name).length,
|
|
841
|
+
]),
|
|
842
|
+
);
|
|
843
|
+
writeFileSync(
|
|
844
|
+
path.join(root, `${id}.json`),
|
|
845
|
+
JSON.stringify(
|
|
846
|
+
{
|
|
847
|
+
...model,
|
|
848
|
+
...output,
|
|
849
|
+
byStrategy,
|
|
850
|
+
...(spec.trainingSubsets
|
|
851
|
+
? { featureStrategies: names }
|
|
852
|
+
: { stats: result.stats }),
|
|
853
|
+
},
|
|
854
|
+
null,
|
|
855
|
+
2,
|
|
856
|
+
),
|
|
857
|
+
{ flag: 'wx' },
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
} else {
|
|
861
|
+
const variants =
|
|
862
|
+
mode === 'smoke'
|
|
863
|
+
? ['current', 'training']
|
|
864
|
+
: ['current', 'simple', 'agent'];
|
|
865
|
+
if (savedModel) {
|
|
866
|
+
assert.equal(savedModel.verificationSha256, verificationSha256);
|
|
867
|
+
if (savedModel.featureStrategies)
|
|
868
|
+
assert.deepEqual(savedModel.featureStrategies, spec.priority);
|
|
869
|
+
assert.deepEqual(
|
|
870
|
+
savedModel.additionalDeploymentHashes ?? [],
|
|
871
|
+
additionalDeploymentHashes,
|
|
872
|
+
);
|
|
873
|
+
if (!frozenEvaluation)
|
|
874
|
+
assert.deepEqual(savedModel.fundingSha256, output.fundingSha256);
|
|
875
|
+
}
|
|
876
|
+
const from =
|
|
877
|
+
mode === 'smoke' ? split - Number(smokeDays ?? 7) * day : split;
|
|
878
|
+
const to = mode === 'smoke' ? split : end;
|
|
879
|
+
for (const variant of variants) {
|
|
880
|
+
if (selectedVariant && selectedVariant !== variant) continue;
|
|
881
|
+
const result = await replay(variant, from, to);
|
|
882
|
+
output.variants[variant] = {
|
|
883
|
+
stats: result.stats,
|
|
884
|
+
groups: Object.fromEntries(
|
|
885
|
+
['ALL', 'LONG', 'SHORT'].map((side) => [
|
|
886
|
+
side,
|
|
887
|
+
summarize(
|
|
888
|
+
result.trades.filter(
|
|
889
|
+
(trade) => side === 'ALL' || trade.direction === side,
|
|
890
|
+
),
|
|
891
|
+
from,
|
|
892
|
+
to,
|
|
893
|
+
),
|
|
894
|
+
]),
|
|
895
|
+
),
|
|
896
|
+
trades: result.trades,
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
assert.ok(
|
|
900
|
+
Object.keys(output.variants).length,
|
|
901
|
+
'Unknown selected variant',
|
|
902
|
+
);
|
|
903
|
+
writeFileSync(
|
|
904
|
+
path.join(
|
|
905
|
+
root,
|
|
906
|
+
`${mode}${selectedVariant ? '-' + selectedVariant : ''}.json`,
|
|
907
|
+
),
|
|
908
|
+
JSON.stringify({ ...output, from, to }, null, 2),
|
|
909
|
+
{ flag: 'wx' },
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
} finally {
|
|
913
|
+
await Promise.all([closeRedisConnection(), closeTimescalePool()]);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
main()
|
|
918
|
+
.then(() => {
|
|
919
|
+
process.exitCode = 0;
|
|
920
|
+
})
|
|
921
|
+
.catch((error) => {
|
|
922
|
+
console.error(error);
|
|
923
|
+
process.exitCode = 1;
|
|
924
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "tradejs-skill-bundle/v1",
|
|
3
3
|
"source": "TradeJS-Dev/TradeJS:.codex/skills",
|
|
4
|
-
"bundleSha256": "
|
|
4
|
+
"bundleSha256": "dd0ad3bdacb0f8110da8632f130ddad954d81a11e6edd05e56f0f8c1be71d9f4",
|
|
5
5
|
"skills": [
|
|
6
6
|
"ai-train-local-research",
|
|
7
7
|
"backtest-config-redis",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
".codex/skills/strategy-backtest-research/scripts/fast-ai-export-metrics.test.mjs": "447453e2415004336293297b7f68ffd16ae35053d9725accaa5f42e1bbe28a58",
|
|
60
60
|
".codex/skills/strategy-backtest-research/scripts/metric-snapshot.mjs": "b96ece871772c82074a188c105520f773362980fa09677456bc5dff895855ade",
|
|
61
61
|
".codex/skills/strategy-backtest-research/scripts/metric-snapshot.test.mjs": "77ef641d1f8590063db13aa9fe12d1db30b28c622f44c774be502d0a9fa487dc",
|
|
62
|
+
".codex/skills/strategy-backtest-research/scripts/portfolio-signal-agent.mjs": "44fb6bcf41a3e08ef697b30258c79d18ed57503b910bf5486e19ec72e4f1eff8",
|
|
62
63
|
".codex/skills/strategy-backtest-research/scripts/research-comparison-chart.mjs": "e995ed31cb311b065c1062cd5fe6102dc6e5aaf25dcdc9567af9dc45367ec8fc",
|
|
63
64
|
".codex/skills/strategy-backtest-research/scripts/research-comparison-chart.test.mjs": "fa79560ccf00601997401ef6e248d8639edf5c1808ec92e81094a4baf6e1a7be",
|
|
64
65
|
".codex/skills/strategy-backtest-research/scripts/research-notes-check.mjs": "196f420845f0cc841bdbb1651063a485c90a1140f767e88f4dbf3543adb881de",
|