@tradejs/types 3.1.8-beta.207 → 3.1.8-beta.211
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/index.d.mts +409 -415
- package/dist/index.d.ts +409 -415
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -50,351 +50,23 @@ interface MetricThreshold {
|
|
|
50
50
|
precision: number;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
takerRate: number;
|
|
59
|
-
source: ExecutionCostSource;
|
|
60
|
-
};
|
|
61
|
-
funding: {
|
|
62
|
-
enabled: boolean;
|
|
63
|
-
source: ExecutionCostSource;
|
|
64
|
-
points?: number;
|
|
65
|
-
fromTimestamp?: number | null;
|
|
66
|
-
toTimestamp?: number | null;
|
|
67
|
-
};
|
|
68
|
-
slippage: {
|
|
69
|
-
baseBps: number;
|
|
70
|
-
spreadMultiplier: number;
|
|
71
|
-
marketImpactBps: number;
|
|
72
|
-
delayRiskMultiplier: number;
|
|
73
|
-
source: ExecutionCostSource;
|
|
74
|
-
};
|
|
75
|
-
leverage: {
|
|
76
|
-
requested: number;
|
|
77
|
-
effective: number;
|
|
78
|
-
maxAllowed: number | null;
|
|
79
|
-
};
|
|
80
|
-
quality: ExecutionCostQuality;
|
|
81
|
-
capturedAt: number;
|
|
82
|
-
}
|
|
83
|
-
type Strategy = (candle: KlineChartItem, btcCandle: KlineChartItem, ethCandle?: KlineChartItem) => Promise<string | Signal>;
|
|
84
|
-
type BacktestDetectorOptimizedStrategy = Strategy & {
|
|
85
|
-
detectorFanoutKey?: string;
|
|
86
|
-
detectorNoSignalSkipReason?: string;
|
|
87
|
-
canFastAdvanceDetectorNoSignal?: boolean;
|
|
88
|
-
advanceDetectorNoSignal?: (candle: KlineChartItem, btcCandle: KlineChartItem, code: string) => Promise<string | Signal>;
|
|
89
|
-
skipDetectorNoSignal?: (candle: KlineChartItem, btcCandle: KlineChartItem, code: string) => Promise<string | Signal>;
|
|
90
|
-
};
|
|
91
|
-
type BacktestPriceMode = 'mid' | 'close' | 'open';
|
|
92
|
-
interface StrategyConfig {
|
|
93
|
-
ENABLE?: boolean;
|
|
94
|
-
INTERVAL?: Interval | string;
|
|
95
|
-
UNIVERSE?: MarketUniverse;
|
|
96
|
-
ACCOUNT_ID?: string;
|
|
97
|
-
BACKTEST_PRICE_MODE?: BacktestPriceMode;
|
|
98
|
-
BACKTEST_ENTRY_DELAY_BARS?: number;
|
|
99
|
-
BACKTEST_EXECUTION_INTERVAL?: Interval;
|
|
100
|
-
BACKTEST_EXECUTION_DELAY_MS?: number;
|
|
101
|
-
ML_ENABLED?: boolean;
|
|
102
|
-
POLICY_PROFILE_ID?: string;
|
|
103
|
-
MAKER_FEE_RATE?: number;
|
|
104
|
-
TAKER_FEE_RATE?: number;
|
|
105
|
-
FUNDING_ENABLED?: boolean;
|
|
106
|
-
LEVERAGE?: number;
|
|
107
|
-
SLIPPAGE_BASE_BPS?: number;
|
|
108
|
-
SLIPPAGE_SPREAD_MULTIPLIER?: number;
|
|
109
|
-
SLIPPAGE_MARKET_IMPACT_BPS?: number;
|
|
110
|
-
SLIPPAGE_DELAY_RISK_MULTIPLIER?: number;
|
|
111
|
-
EXECUTION_COSTS_CACHE_ONLY?: boolean;
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
}
|
|
114
|
-
type StrategyResultConfig = StrategyConfig;
|
|
115
|
-
type StrategyConfigGrid = Record<string, unknown[]>;
|
|
116
|
-
interface RuntimeStrategyConfigSnapshot {
|
|
117
|
-
userConfig: StrategyConfig;
|
|
118
|
-
}
|
|
119
|
-
interface StrategyCreatorParams {
|
|
120
|
-
userName: string;
|
|
121
|
-
connectorName: string;
|
|
122
|
-
symbol: string;
|
|
123
|
-
universe?: MarketUniverse;
|
|
124
|
-
assetClass?: AssetClass;
|
|
125
|
-
instrument?: InstrumentDescriptor;
|
|
126
|
-
accountId?: string;
|
|
127
|
-
deploymentId?: string;
|
|
128
|
-
policyProfileId?: string;
|
|
129
|
-
runtimeConfigId?: string;
|
|
130
|
-
runtimeReleaseVersion?: number;
|
|
131
|
-
entriesPaused?: boolean;
|
|
132
|
-
runtimeLineage?: RuntimeLineage;
|
|
133
|
-
runtimeConfigSnapshot?: RuntimeStrategyConfigSnapshot;
|
|
134
|
-
config: StrategyConfig;
|
|
135
|
-
connector: Connector;
|
|
136
|
-
data: KlineChartData;
|
|
137
|
-
btcData: KlineChartData;
|
|
138
|
-
ethData?: KlineChartData;
|
|
139
|
-
btcBinanceData?: KlineChartData;
|
|
140
|
-
btcCoinbaseData?: KlineChartData;
|
|
141
|
-
backtestExecutionMarketData?: {
|
|
142
|
-
interval: Interval;
|
|
143
|
-
data: KlineChartData;
|
|
144
|
-
btcData?: KlineChartData;
|
|
145
|
-
dataByTimestamp?: Map<number, KlineChartItem>;
|
|
146
|
-
btcDataByTimestamp?: Map<number, KlineChartItem>;
|
|
147
|
-
};
|
|
148
|
-
sharedIndicatorsReplayKey?: string;
|
|
149
|
-
sharedStrategyStateKey?: string;
|
|
150
|
-
onRuntimeClose?: (event: RuntimeStrategyCloseNotification) => void;
|
|
151
|
-
}
|
|
152
|
-
interface StrategyCreator {
|
|
153
|
-
(params: StrategyCreatorParams): Promise<Strategy>;
|
|
154
|
-
detectorKey?: (config: StrategyConfig) => string | undefined;
|
|
155
|
-
detectorNoSignalSkipReason?: string;
|
|
156
|
-
}
|
|
157
|
-
type TestingOptions = Pick<KlineRequest, 'start' | 'end'>;
|
|
158
|
-
interface BacktestRunConfig {
|
|
159
|
-
strategyName: string;
|
|
160
|
-
strategyConfig: StrategyConfig;
|
|
161
|
-
connectorName: string;
|
|
162
|
-
}
|
|
163
|
-
interface Test extends BacktestRunConfig {
|
|
164
|
-
userName: string;
|
|
165
|
-
name: string;
|
|
166
|
-
testId: string;
|
|
167
|
-
testSuiteId: string;
|
|
168
|
-
configId?: string;
|
|
169
|
-
symbol: string;
|
|
170
|
-
universe?: MarketUniverse;
|
|
171
|
-
assetClass?: AssetClass;
|
|
172
|
-
instrument?: InstrumentDescriptor;
|
|
173
|
-
accountId?: string;
|
|
174
|
-
deploymentId?: string;
|
|
175
|
-
policyProfileId?: string;
|
|
176
|
-
executionCostModel?: ExecutionCostModel;
|
|
177
|
-
interval?: Interval;
|
|
178
|
-
options: TestingOptions;
|
|
179
|
-
ml?: boolean;
|
|
180
|
-
ai?: boolean;
|
|
181
|
-
fast?: boolean;
|
|
182
|
-
collectReplaySignalEvaluations?: boolean;
|
|
183
|
-
researchTrace?: boolean;
|
|
184
|
-
chunkId?: string;
|
|
185
|
-
backtestRunId?: string;
|
|
186
|
-
backtestTestKey?: string;
|
|
187
|
-
timeoutMs?: number;
|
|
188
|
-
}
|
|
189
|
-
type TestSuite = Test[];
|
|
190
|
-
interface TestStat extends Metrics {
|
|
191
|
-
score?: number;
|
|
192
|
-
}
|
|
193
|
-
interface StrategyResultEntry {
|
|
194
|
-
config: StrategyResultConfig;
|
|
195
|
-
stats: TestStat;
|
|
196
|
-
}
|
|
197
|
-
type StrategyResults = Record<string, StrategyResultEntry>;
|
|
198
|
-
interface MinimalStat {
|
|
199
|
-
amount: number;
|
|
200
|
-
profit: number;
|
|
201
|
-
orders: number;
|
|
202
|
-
}
|
|
203
|
-
declare const BACKTEST_WARNING_CODES: {
|
|
204
|
-
readonly TAKE_PROFIT_CROSSED_BEFORE_ENTRY: "TAKE_PROFIT_CROSSED_BEFORE_ENTRY";
|
|
205
|
-
};
|
|
206
|
-
type BacktestWarningCode = (typeof BACKTEST_WARNING_CODES)[keyof typeof BACKTEST_WARNING_CODES];
|
|
207
|
-
type BacktestWarningCounts = Partial<Record<BacktestWarningCode, number>>;
|
|
208
|
-
type CoreResearchTraceEvent = {
|
|
209
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
210
|
-
event: 'signal_emitted' | 'entry_rejected' | 'entry_executed';
|
|
211
|
-
timestamp: number;
|
|
212
|
-
strategy: string;
|
|
213
|
-
symbol: string;
|
|
214
|
-
direction: Direction;
|
|
215
|
-
setupIdentity: string;
|
|
216
|
-
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
217
|
-
signalId: string;
|
|
218
|
-
configId?: string;
|
|
219
|
-
backtestRunId?: string;
|
|
220
|
-
backtestTestKey?: string;
|
|
221
|
-
} | {
|
|
222
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
223
|
-
event: 'position_exited';
|
|
224
|
-
timestamp: number;
|
|
225
|
-
strategy: string;
|
|
226
|
-
symbol: string;
|
|
227
|
-
direction: Direction;
|
|
228
|
-
setupIdentity: string;
|
|
229
|
-
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
230
|
-
signalId: string;
|
|
231
|
-
configId?: string;
|
|
232
|
-
backtestRunId?: string;
|
|
233
|
-
backtestTestKey?: string;
|
|
234
|
-
netProfit: number;
|
|
235
|
-
exitReason: TestTradeExitReason;
|
|
236
|
-
} | {
|
|
237
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
238
|
-
event: 'skip_summary';
|
|
239
|
-
timestamp: number;
|
|
240
|
-
strategy: string;
|
|
241
|
-
symbol: string;
|
|
242
|
-
configId?: string;
|
|
243
|
-
backtestRunId?: string;
|
|
244
|
-
backtestTestKey?: string;
|
|
245
|
-
skipCounts: Record<string, number>;
|
|
246
|
-
};
|
|
247
|
-
interface TestingBoxResult {
|
|
248
|
-
orderLogId: string;
|
|
249
|
-
stat: MinimalStat;
|
|
250
|
-
inlineOrderLog?: OrderLogData;
|
|
251
|
-
inlinePositionLog?: PositionLogData;
|
|
252
|
-
inlineReplaySignalEvaluations?: RuntimeSignalEvaluationRecord[];
|
|
253
|
-
researchTraceSummary?: {
|
|
254
|
-
events: Record<string, number>;
|
|
255
|
-
skipCounts: Record<string, number>;
|
|
256
|
-
};
|
|
257
|
-
executionCostModel?: ExecutionCostModel;
|
|
258
|
-
warningCounts?: BacktestWarningCounts;
|
|
259
|
-
}
|
|
260
|
-
type TestingBox = (test: Test) => Promise<TestingBoxResult | null>;
|
|
261
|
-
interface TestWorkerResult extends TestingBoxResult {
|
|
262
|
-
test: Test;
|
|
263
|
-
}
|
|
264
|
-
interface CompletedTest extends Omit<TestWorkerResult, 'stat'> {
|
|
265
|
-
stat: TestStat;
|
|
266
|
-
}
|
|
267
|
-
type OrderLog = Order & {
|
|
268
|
-
type: OrderType;
|
|
269
|
-
profit: number;
|
|
270
|
-
amount: number;
|
|
271
|
-
fee?: number;
|
|
272
|
-
index: number;
|
|
273
|
-
executionSlippageStage?: 'entry' | 'exit';
|
|
274
|
-
executionSlippageBps?: number | null;
|
|
275
|
-
executionBaseSlippageBps?: number | null;
|
|
276
|
-
executionSpreadBps?: number | null;
|
|
277
|
-
executionSpreadSlippageBps?: number | null;
|
|
278
|
-
executionMarketImpactBps?: number | null;
|
|
279
|
-
executionDelayRiskBps?: number | null;
|
|
280
|
-
};
|
|
281
|
-
type OrderLogData = OrderLog[];
|
|
282
|
-
type SimpleOrderLogData = [number, number][];
|
|
283
|
-
interface TestResult extends Omit<CompletedTest, 'orderLogId'> {
|
|
284
|
-
orderLog: SimpleOrderLogData;
|
|
285
|
-
}
|
|
286
|
-
interface PositionLog {
|
|
287
|
-
direction: Direction;
|
|
288
|
-
open: {
|
|
289
|
-
amount: number;
|
|
290
|
-
timestamp: number;
|
|
291
|
-
};
|
|
292
|
-
close: {
|
|
293
|
-
amount: number;
|
|
294
|
-
timestamp: number;
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
type PositionLogData = PositionLog[];
|
|
298
|
-
type TestThresholds = Record<keyof TestStat, MetricThreshold>;
|
|
299
|
-
type TestThresholdsKey = keyof TestThresholds;
|
|
300
|
-
interface TestConnector extends Connector {
|
|
301
|
-
getResult: () => Promise<TestingBoxResult>;
|
|
302
|
-
checkTp: (candle: Candle) => Promise<void>;
|
|
303
|
-
checkSl: (candle: Candle) => Promise<void>;
|
|
304
|
-
checkExits: (candle: Candle) => Promise<void>;
|
|
305
|
-
drainMlResultsBatch: () => Promise<TestClosedSignalResult[]>;
|
|
53
|
+
declare const RUNTIME_CONTROLS_SCHEMA: "tradejs-runtime-controls/v1";
|
|
54
|
+
interface RuntimeStrategyPauseOverride {
|
|
55
|
+
entriesPaused: true;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
updatedBy: string;
|
|
306
58
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
/** Stable id shared by every entry leg belonging to one position lifecycle. */
|
|
311
|
-
positionCycleId?: string;
|
|
312
|
-
direction: Direction;
|
|
313
|
-
qty: number;
|
|
314
|
-
closedQty: number;
|
|
315
|
-
entryTimestamp: number;
|
|
316
|
-
exitTimestamp: number;
|
|
317
|
-
exitReason: TestTradeExitReason;
|
|
318
|
-
requestedEntryPrice: number;
|
|
319
|
-
entryPrice: number;
|
|
320
|
-
requestedExitPrice: number | null;
|
|
321
|
-
exitPrice: number | null;
|
|
322
|
-
grossProfit: number;
|
|
323
|
-
netProfit: number;
|
|
324
|
-
openFee: number;
|
|
325
|
-
closeFee: number;
|
|
326
|
-
fundingFee: number | null;
|
|
327
|
-
totalFee: number;
|
|
328
|
-
entrySlippagePrice: number;
|
|
329
|
-
entrySlippageBps: number;
|
|
330
|
-
entryBaseSlippageBps: number;
|
|
331
|
-
entrySpreadBps: number;
|
|
332
|
-
entrySpreadSlippageBps: number;
|
|
333
|
-
entryMarketImpactBps: number;
|
|
334
|
-
entryDelayRiskBps: number | null;
|
|
335
|
-
entrySlippageCost: number;
|
|
336
|
-
exitSlippagePrice: number | null;
|
|
337
|
-
exitSlippageBps: number | null;
|
|
338
|
-
exitBaseSlippageBps: number | null;
|
|
339
|
-
exitSpreadBps: number | null;
|
|
340
|
-
exitSpreadSlippageBps: number | null;
|
|
341
|
-
exitMarketImpactBps: number | null;
|
|
342
|
-
exitDelayRiskBps: number | null;
|
|
343
|
-
exitSlippageCost: number;
|
|
344
|
-
totalSlippageCost: number;
|
|
59
|
+
interface RuntimeControls {
|
|
60
|
+
schema: typeof RUNTIME_CONTROLS_SCHEMA;
|
|
61
|
+
deployments: Record<string, Record<string, RuntimeStrategyPauseOverride>>;
|
|
345
62
|
}
|
|
346
|
-
interface TestClosedSignalResult {
|
|
347
|
-
signalId: string;
|
|
348
|
-
profit: number;
|
|
349
|
-
tradeResult?: TestTradeResult;
|
|
350
|
-
}
|
|
351
|
-
interface TestConnectorContext {
|
|
352
|
-
userName?: string;
|
|
353
|
-
mlEnabled?: boolean;
|
|
354
|
-
aiEnabled?: boolean;
|
|
355
|
-
fastMode?: boolean;
|
|
356
|
-
instrument?: InstrumentDescriptor;
|
|
357
|
-
executionCostModel?: ExecutionCostModel;
|
|
358
|
-
fundingRates?: FundingRatePoint[];
|
|
359
|
-
}
|
|
360
|
-
type TestConnectorCreator = (connector: Connector, context?: TestConnectorContext) => TestConnector;
|
|
361
|
-
type ChartColor = string;
|
|
362
|
-
interface TestCompare {
|
|
363
|
-
testResult: TestResult;
|
|
364
|
-
color: ChartColor;
|
|
365
|
-
}
|
|
366
|
-
type TestCompareList = TestCompare[];
|
|
367
|
-
type OnChangeCompare = (testId: string) => void;
|
|
368
|
-
|
|
369
|
-
declare const RUNTIME_STRATEGY_RELEASE_SCHEMA: "tradejs-runtime-strategy-release/v2";
|
|
370
63
|
type RuntimeStrategyControlState = 'active' | 'entries_paused';
|
|
371
|
-
/**
|
|
372
|
-
* An immutable strategy-owned runtime snapshot. Deployment/account bindings are
|
|
373
|
-
* intentionally not part of this record.
|
|
374
|
-
*/
|
|
375
|
-
interface RuntimeStrategyRelease {
|
|
376
|
-
schema: typeof RUNTIME_STRATEGY_RELEASE_SCHEMA;
|
|
377
|
-
strategyName: string;
|
|
378
|
-
releaseVersion: number;
|
|
379
|
-
config: StrategyConfig;
|
|
380
|
-
strategyPackage: string;
|
|
381
|
-
strategyPackageVersion: string;
|
|
382
|
-
runtimePackageVersion: string;
|
|
383
|
-
createdAt: number;
|
|
384
|
-
createdBy: string;
|
|
385
|
-
contentSha256: string;
|
|
386
|
-
}
|
|
387
|
-
interface RuntimeStrategyReleaseRef {
|
|
388
|
-
strategyName: string;
|
|
389
|
-
releaseVersion: number;
|
|
390
|
-
controlState: RuntimeStrategyControlState;
|
|
391
|
-
}
|
|
392
64
|
type RuntimeStrategyControlEventAction = 'pause_entries' | 'resume';
|
|
393
65
|
interface RuntimeStrategyControlEvent {
|
|
394
66
|
eventId: string;
|
|
395
67
|
deploymentId: string;
|
|
396
68
|
strategyName: string;
|
|
397
|
-
|
|
69
|
+
version: number;
|
|
398
70
|
action: RuntimeStrategyControlEventAction;
|
|
399
71
|
previousState: RuntimeStrategyControlState;
|
|
400
72
|
nextState: RuntimeStrategyControlState;
|
|
@@ -465,8 +137,10 @@ interface TradingAccountRef {
|
|
|
465
137
|
}
|
|
466
138
|
interface RuntimeDeploymentStrategy {
|
|
467
139
|
strategyName: string;
|
|
468
|
-
/**
|
|
469
|
-
|
|
140
|
+
/** Explicit Git-owned version of the package plus strategy configuration. */
|
|
141
|
+
version: number;
|
|
142
|
+
/** Desired entry state committed in tradejs.config.ts. */
|
|
143
|
+
enabled: boolean;
|
|
470
144
|
/** New entries may be paused while exit/position management keeps running. */
|
|
471
145
|
controlState: RuntimeStrategyControlState;
|
|
472
146
|
}
|
|
@@ -1143,7 +817,7 @@ interface Signal {
|
|
|
1143
817
|
deploymentId?: string;
|
|
1144
818
|
policyProfileId?: string;
|
|
1145
819
|
runtimeConfigId?: string;
|
|
1146
|
-
|
|
820
|
+
runtimeVersion?: number;
|
|
1147
821
|
runtimeLineage?: RuntimeLineage;
|
|
1148
822
|
direction: Direction;
|
|
1149
823
|
timestamp: number;
|
|
@@ -1187,7 +861,7 @@ interface RuntimeSignalEvaluationRecord {
|
|
|
1187
861
|
deploymentId?: string;
|
|
1188
862
|
policyProfileId?: string;
|
|
1189
863
|
runtimeConfigId?: string;
|
|
1190
|
-
|
|
864
|
+
runtimeVersion?: number;
|
|
1191
865
|
runtimeLineage?: RuntimeLineage;
|
|
1192
866
|
symbol: string;
|
|
1193
867
|
interval: Interval;
|
|
@@ -1243,7 +917,7 @@ interface LegacyRuntimeLineage {
|
|
|
1243
917
|
}
|
|
1244
918
|
interface VersionedRuntimeLineage {
|
|
1245
919
|
schemaVersion: 2;
|
|
1246
|
-
|
|
920
|
+
version: number;
|
|
1247
921
|
strategyPackageVersion?: string | null;
|
|
1248
922
|
runtimePackageVersion?: string | null;
|
|
1249
923
|
maxLossValue?: number | null;
|
|
@@ -1263,66 +937,382 @@ interface RuntimeTradeRecord {
|
|
|
1263
937
|
accountId?: string;
|
|
1264
938
|
deploymentId?: string;
|
|
1265
939
|
policyProfileId?: string;
|
|
1266
|
-
runtimeConfigId?: string;
|
|
1267
|
-
|
|
1268
|
-
symbol: string;
|
|
940
|
+
runtimeConfigId?: string;
|
|
941
|
+
runtimeVersion?: number;
|
|
942
|
+
symbol: string;
|
|
943
|
+
interval?: Interval;
|
|
944
|
+
direction: Direction;
|
|
945
|
+
qty: number;
|
|
946
|
+
entryPrice: number;
|
|
947
|
+
entryCount?: number;
|
|
948
|
+
lastEntryPrice?: number | null;
|
|
949
|
+
lastEntryQty?: number | null;
|
|
950
|
+
lastEntryTimestamp?: number | null;
|
|
951
|
+
actualEntryPrice?: number | null;
|
|
952
|
+
entryTimestamp: number;
|
|
953
|
+
signalTimestamp?: number | null;
|
|
954
|
+
signalClosePrice?: number | null;
|
|
955
|
+
arrivalSnapshotTime?: number | null;
|
|
956
|
+
arrivalSource?: string | null;
|
|
957
|
+
arrivalMid?: number | null;
|
|
958
|
+
bid?: number | null;
|
|
959
|
+
ask?: number | null;
|
|
960
|
+
spreadBps?: number | null;
|
|
961
|
+
orderSubmitTime?: number | null;
|
|
962
|
+
orderAckTime?: number | null;
|
|
963
|
+
fillAvgPrice?: number | null;
|
|
964
|
+
fillSource?: RuntimeTradeFillSource | null;
|
|
965
|
+
fillTime?: number | null;
|
|
966
|
+
telemetryQuality?: RuntimeTradeTelemetryQuality | null;
|
|
967
|
+
fee?: number | null;
|
|
968
|
+
status: RuntimeTradeStatus;
|
|
969
|
+
currentPrice?: number | null;
|
|
970
|
+
currentPnl?: number | null;
|
|
971
|
+
closedPnl?: number | null;
|
|
972
|
+
exitPrice?: number | null;
|
|
973
|
+
actualExitPrice?: number | null;
|
|
974
|
+
exitTimestamp?: number | null;
|
|
975
|
+
exitType?: RuntimeTradeExitType | null;
|
|
976
|
+
openFee?: number | null;
|
|
977
|
+
closeFee?: number | null;
|
|
978
|
+
fundingFee?: number | null;
|
|
979
|
+
totalFee?: number | null;
|
|
980
|
+
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
981
|
+
lastSyncedAt?: number;
|
|
982
|
+
}
|
|
983
|
+
interface RuntimeStrategyCloseNotification {
|
|
984
|
+
userName?: string;
|
|
985
|
+
strategy: string;
|
|
986
|
+
openedByStrategy: string;
|
|
987
|
+
symbol: string;
|
|
988
|
+
direction: Direction;
|
|
989
|
+
code: string;
|
|
990
|
+
orderId: string;
|
|
991
|
+
signalId?: string;
|
|
992
|
+
qty: number;
|
|
993
|
+
entryPrice: number;
|
|
994
|
+
entryTimestamp: number;
|
|
995
|
+
exitPrice?: number | null;
|
|
996
|
+
exitTimestamp?: number | null;
|
|
997
|
+
closedPnl?: number | null;
|
|
998
|
+
exitType?: RuntimeTradeExitType | null;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
type ExecutionCostSource = 'exchange-account' | 'connector-default' | 'config' | 'historical' | 'calibrated' | 'fallback' | 'disabled' | 'unavailable';
|
|
1002
|
+
type ExecutionCostQuality = 'full' | 'partial' | 'fallback';
|
|
1003
|
+
interface ExecutionCostModel {
|
|
1004
|
+
fees: {
|
|
1005
|
+
makerRate: number;
|
|
1006
|
+
takerRate: number;
|
|
1007
|
+
source: ExecutionCostSource;
|
|
1008
|
+
};
|
|
1009
|
+
funding: {
|
|
1010
|
+
enabled: boolean;
|
|
1011
|
+
source: ExecutionCostSource;
|
|
1012
|
+
points?: number;
|
|
1013
|
+
fromTimestamp?: number | null;
|
|
1014
|
+
toTimestamp?: number | null;
|
|
1015
|
+
};
|
|
1016
|
+
slippage: {
|
|
1017
|
+
baseBps: number;
|
|
1018
|
+
spreadMultiplier: number;
|
|
1019
|
+
marketImpactBps: number;
|
|
1020
|
+
delayRiskMultiplier: number;
|
|
1021
|
+
source: ExecutionCostSource;
|
|
1022
|
+
};
|
|
1023
|
+
leverage: {
|
|
1024
|
+
requested: number;
|
|
1025
|
+
effective: number;
|
|
1026
|
+
maxAllowed: number | null;
|
|
1027
|
+
};
|
|
1028
|
+
quality: ExecutionCostQuality;
|
|
1029
|
+
capturedAt: number;
|
|
1030
|
+
}
|
|
1031
|
+
type Strategy = (candle: KlineChartItem, btcCandle: KlineChartItem, ethCandle?: KlineChartItem) => Promise<string | Signal>;
|
|
1032
|
+
type BacktestDetectorOptimizedStrategy = Strategy & {
|
|
1033
|
+
detectorFanoutKey?: string;
|
|
1034
|
+
detectorNoSignalSkipReason?: string;
|
|
1035
|
+
canFastAdvanceDetectorNoSignal?: boolean;
|
|
1036
|
+
advanceDetectorNoSignal?: (candle: KlineChartItem, btcCandle: KlineChartItem, code: string) => Promise<string | Signal>;
|
|
1037
|
+
skipDetectorNoSignal?: (candle: KlineChartItem, btcCandle: KlineChartItem, code: string) => Promise<string | Signal>;
|
|
1038
|
+
};
|
|
1039
|
+
type BacktestPriceMode = 'mid' | 'close' | 'open';
|
|
1040
|
+
interface StrategyConfig {
|
|
1041
|
+
ENABLE?: boolean;
|
|
1042
|
+
INTERVAL?: Interval | string;
|
|
1043
|
+
UNIVERSE?: MarketUniverse;
|
|
1044
|
+
ACCOUNT_ID?: string;
|
|
1045
|
+
BACKTEST_PRICE_MODE?: BacktestPriceMode;
|
|
1046
|
+
BACKTEST_ENTRY_DELAY_BARS?: number;
|
|
1047
|
+
BACKTEST_EXECUTION_INTERVAL?: Interval;
|
|
1048
|
+
BACKTEST_EXECUTION_DELAY_MS?: number;
|
|
1049
|
+
ML_ENABLED?: boolean;
|
|
1050
|
+
POLICY_PROFILE_ID?: string;
|
|
1051
|
+
MAKER_FEE_RATE?: number;
|
|
1052
|
+
TAKER_FEE_RATE?: number;
|
|
1053
|
+
FUNDING_ENABLED?: boolean;
|
|
1054
|
+
LEVERAGE?: number;
|
|
1055
|
+
SLIPPAGE_BASE_BPS?: number;
|
|
1056
|
+
SLIPPAGE_SPREAD_MULTIPLIER?: number;
|
|
1057
|
+
SLIPPAGE_MARKET_IMPACT_BPS?: number;
|
|
1058
|
+
SLIPPAGE_DELAY_RISK_MULTIPLIER?: number;
|
|
1059
|
+
EXECUTION_COSTS_CACHE_ONLY?: boolean;
|
|
1060
|
+
[key: string]: any;
|
|
1061
|
+
}
|
|
1062
|
+
type StrategyResultConfig = StrategyConfig;
|
|
1063
|
+
type StrategyConfigGrid = Record<string, unknown[]>;
|
|
1064
|
+
interface RuntimeStrategyConfigSnapshot {
|
|
1065
|
+
userConfig: StrategyConfig;
|
|
1066
|
+
}
|
|
1067
|
+
interface StrategyCreatorParams {
|
|
1068
|
+
userName: string;
|
|
1069
|
+
connectorName: string;
|
|
1070
|
+
symbol: string;
|
|
1071
|
+
universe?: MarketUniverse;
|
|
1072
|
+
assetClass?: AssetClass;
|
|
1073
|
+
instrument?: InstrumentDescriptor;
|
|
1074
|
+
accountId?: string;
|
|
1075
|
+
deploymentId?: string;
|
|
1076
|
+
policyProfileId?: string;
|
|
1077
|
+
runtimeConfigId?: string;
|
|
1078
|
+
runtimeVersion?: number;
|
|
1079
|
+
entriesPaused?: boolean;
|
|
1080
|
+
runtimeLineage?: RuntimeLineage;
|
|
1081
|
+
runtimeConfigSnapshot?: RuntimeStrategyConfigSnapshot;
|
|
1082
|
+
config: StrategyConfig;
|
|
1083
|
+
connector: Connector;
|
|
1084
|
+
data: KlineChartData;
|
|
1085
|
+
btcData: KlineChartData;
|
|
1086
|
+
ethData?: KlineChartData;
|
|
1087
|
+
btcBinanceData?: KlineChartData;
|
|
1088
|
+
btcCoinbaseData?: KlineChartData;
|
|
1089
|
+
backtestExecutionMarketData?: {
|
|
1090
|
+
interval: Interval;
|
|
1091
|
+
data: KlineChartData;
|
|
1092
|
+
btcData?: KlineChartData;
|
|
1093
|
+
dataByTimestamp?: Map<number, KlineChartItem>;
|
|
1094
|
+
btcDataByTimestamp?: Map<number, KlineChartItem>;
|
|
1095
|
+
};
|
|
1096
|
+
sharedIndicatorsReplayKey?: string;
|
|
1097
|
+
sharedStrategyStateKey?: string;
|
|
1098
|
+
onRuntimeClose?: (event: RuntimeStrategyCloseNotification) => void;
|
|
1099
|
+
}
|
|
1100
|
+
interface StrategyCreator {
|
|
1101
|
+
(params: StrategyCreatorParams): Promise<Strategy>;
|
|
1102
|
+
detectorKey?: (config: StrategyConfig) => string | undefined;
|
|
1103
|
+
detectorNoSignalSkipReason?: string;
|
|
1104
|
+
}
|
|
1105
|
+
type TestingOptions = Pick<KlineRequest, 'start' | 'end'>;
|
|
1106
|
+
interface BacktestRunConfig {
|
|
1107
|
+
strategyName: string;
|
|
1108
|
+
strategyConfig: StrategyConfig;
|
|
1109
|
+
connectorName: string;
|
|
1110
|
+
}
|
|
1111
|
+
interface Test extends BacktestRunConfig {
|
|
1112
|
+
userName: string;
|
|
1113
|
+
name: string;
|
|
1114
|
+
testId: string;
|
|
1115
|
+
testSuiteId: string;
|
|
1116
|
+
configId?: string;
|
|
1117
|
+
symbol: string;
|
|
1118
|
+
universe?: MarketUniverse;
|
|
1119
|
+
assetClass?: AssetClass;
|
|
1120
|
+
instrument?: InstrumentDescriptor;
|
|
1121
|
+
accountId?: string;
|
|
1122
|
+
deploymentId?: string;
|
|
1123
|
+
policyProfileId?: string;
|
|
1124
|
+
executionCostModel?: ExecutionCostModel;
|
|
1269
1125
|
interval?: Interval;
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
signalClosePrice?: number | null;
|
|
1281
|
-
arrivalSnapshotTime?: number | null;
|
|
1282
|
-
arrivalSource?: string | null;
|
|
1283
|
-
arrivalMid?: number | null;
|
|
1284
|
-
bid?: number | null;
|
|
1285
|
-
ask?: number | null;
|
|
1286
|
-
spreadBps?: number | null;
|
|
1287
|
-
orderSubmitTime?: number | null;
|
|
1288
|
-
orderAckTime?: number | null;
|
|
1289
|
-
fillAvgPrice?: number | null;
|
|
1290
|
-
fillSource?: RuntimeTradeFillSource | null;
|
|
1291
|
-
fillTime?: number | null;
|
|
1292
|
-
telemetryQuality?: RuntimeTradeTelemetryQuality | null;
|
|
1293
|
-
fee?: number | null;
|
|
1294
|
-
status: RuntimeTradeStatus;
|
|
1295
|
-
currentPrice?: number | null;
|
|
1296
|
-
currentPnl?: number | null;
|
|
1297
|
-
closedPnl?: number | null;
|
|
1298
|
-
exitPrice?: number | null;
|
|
1299
|
-
actualExitPrice?: number | null;
|
|
1300
|
-
exitTimestamp?: number | null;
|
|
1301
|
-
exitType?: RuntimeTradeExitType | null;
|
|
1302
|
-
openFee?: number | null;
|
|
1303
|
-
closeFee?: number | null;
|
|
1304
|
-
fundingFee?: number | null;
|
|
1305
|
-
totalFee?: number | null;
|
|
1306
|
-
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
1307
|
-
lastSyncedAt?: number;
|
|
1126
|
+
options: TestingOptions;
|
|
1127
|
+
ml?: boolean;
|
|
1128
|
+
ai?: boolean;
|
|
1129
|
+
fast?: boolean;
|
|
1130
|
+
collectReplaySignalEvaluations?: boolean;
|
|
1131
|
+
researchTrace?: boolean;
|
|
1132
|
+
chunkId?: string;
|
|
1133
|
+
backtestRunId?: string;
|
|
1134
|
+
backtestTestKey?: string;
|
|
1135
|
+
timeoutMs?: number;
|
|
1308
1136
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1137
|
+
type TestSuite = Test[];
|
|
1138
|
+
interface TestStat extends Metrics {
|
|
1139
|
+
score?: number;
|
|
1140
|
+
}
|
|
1141
|
+
interface StrategyResultEntry {
|
|
1142
|
+
config: StrategyResultConfig;
|
|
1143
|
+
stats: TestStat;
|
|
1144
|
+
}
|
|
1145
|
+
type StrategyResults = Record<string, StrategyResultEntry>;
|
|
1146
|
+
interface MinimalStat {
|
|
1147
|
+
amount: number;
|
|
1148
|
+
profit: number;
|
|
1149
|
+
orders: number;
|
|
1150
|
+
}
|
|
1151
|
+
declare const BACKTEST_WARNING_CODES: {
|
|
1152
|
+
readonly TAKE_PROFIT_CROSSED_BEFORE_ENTRY: "TAKE_PROFIT_CROSSED_BEFORE_ENTRY";
|
|
1153
|
+
};
|
|
1154
|
+
type BacktestWarningCode = (typeof BACKTEST_WARNING_CODES)[keyof typeof BACKTEST_WARNING_CODES];
|
|
1155
|
+
type BacktestWarningCounts = Partial<Record<BacktestWarningCode, number>>;
|
|
1156
|
+
type CoreResearchTraceEvent = {
|
|
1157
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
1158
|
+
event: 'signal_emitted' | 'entry_rejected' | 'entry_executed';
|
|
1159
|
+
timestamp: number;
|
|
1311
1160
|
strategy: string;
|
|
1312
|
-
openedByStrategy: string;
|
|
1313
1161
|
symbol: string;
|
|
1314
1162
|
direction: Direction;
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
signalId
|
|
1163
|
+
setupIdentity: string;
|
|
1164
|
+
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
1165
|
+
signalId: string;
|
|
1166
|
+
configId?: string;
|
|
1167
|
+
backtestRunId?: string;
|
|
1168
|
+
backtestTestKey?: string;
|
|
1169
|
+
} | {
|
|
1170
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
1171
|
+
event: 'position_exited';
|
|
1172
|
+
timestamp: number;
|
|
1173
|
+
strategy: string;
|
|
1174
|
+
symbol: string;
|
|
1175
|
+
direction: Direction;
|
|
1176
|
+
setupIdentity: string;
|
|
1177
|
+
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
1178
|
+
signalId: string;
|
|
1179
|
+
configId?: string;
|
|
1180
|
+
backtestRunId?: string;
|
|
1181
|
+
backtestTestKey?: string;
|
|
1182
|
+
netProfit: number;
|
|
1183
|
+
exitReason: TestTradeExitReason;
|
|
1184
|
+
} | {
|
|
1185
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
1186
|
+
event: 'skip_summary';
|
|
1187
|
+
timestamp: number;
|
|
1188
|
+
strategy: string;
|
|
1189
|
+
symbol: string;
|
|
1190
|
+
configId?: string;
|
|
1191
|
+
backtestRunId?: string;
|
|
1192
|
+
backtestTestKey?: string;
|
|
1193
|
+
skipCounts: Record<string, number>;
|
|
1194
|
+
};
|
|
1195
|
+
interface TestingBoxResult {
|
|
1196
|
+
orderLogId: string;
|
|
1197
|
+
stat: MinimalStat;
|
|
1198
|
+
inlineOrderLog?: OrderLogData;
|
|
1199
|
+
inlinePositionLog?: PositionLogData;
|
|
1200
|
+
inlineReplaySignalEvaluations?: RuntimeSignalEvaluationRecord[];
|
|
1201
|
+
researchTraceSummary?: {
|
|
1202
|
+
events: Record<string, number>;
|
|
1203
|
+
skipCounts: Record<string, number>;
|
|
1204
|
+
};
|
|
1205
|
+
executionCostModel?: ExecutionCostModel;
|
|
1206
|
+
warningCounts?: BacktestWarningCounts;
|
|
1207
|
+
}
|
|
1208
|
+
type TestingBox = (test: Test) => Promise<TestingBoxResult | null>;
|
|
1209
|
+
interface TestWorkerResult extends TestingBoxResult {
|
|
1210
|
+
test: Test;
|
|
1211
|
+
}
|
|
1212
|
+
interface CompletedTest extends Omit<TestWorkerResult, 'stat'> {
|
|
1213
|
+
stat: TestStat;
|
|
1214
|
+
}
|
|
1215
|
+
type OrderLog = Order & {
|
|
1216
|
+
type: OrderType;
|
|
1217
|
+
profit: number;
|
|
1218
|
+
amount: number;
|
|
1219
|
+
fee?: number;
|
|
1220
|
+
index: number;
|
|
1221
|
+
executionSlippageStage?: 'entry' | 'exit';
|
|
1222
|
+
executionSlippageBps?: number | null;
|
|
1223
|
+
executionBaseSlippageBps?: number | null;
|
|
1224
|
+
executionSpreadBps?: number | null;
|
|
1225
|
+
executionSpreadSlippageBps?: number | null;
|
|
1226
|
+
executionMarketImpactBps?: number | null;
|
|
1227
|
+
executionDelayRiskBps?: number | null;
|
|
1228
|
+
};
|
|
1229
|
+
type OrderLogData = OrderLog[];
|
|
1230
|
+
type SimpleOrderLogData = [number, number][];
|
|
1231
|
+
interface TestResult extends Omit<CompletedTest, 'orderLogId'> {
|
|
1232
|
+
orderLog: SimpleOrderLogData;
|
|
1233
|
+
}
|
|
1234
|
+
interface PositionLog {
|
|
1235
|
+
direction: Direction;
|
|
1236
|
+
open: {
|
|
1237
|
+
amount: number;
|
|
1238
|
+
timestamp: number;
|
|
1239
|
+
};
|
|
1240
|
+
close: {
|
|
1241
|
+
amount: number;
|
|
1242
|
+
timestamp: number;
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
type PositionLogData = PositionLog[];
|
|
1246
|
+
type TestThresholds = Record<keyof TestStat, MetricThreshold>;
|
|
1247
|
+
type TestThresholdsKey = keyof TestThresholds;
|
|
1248
|
+
interface TestConnector extends Connector {
|
|
1249
|
+
getResult: () => Promise<TestingBoxResult>;
|
|
1250
|
+
checkTp: (candle: Candle) => Promise<void>;
|
|
1251
|
+
checkSl: (candle: Candle) => Promise<void>;
|
|
1252
|
+
checkExits: (candle: Candle) => Promise<void>;
|
|
1253
|
+
drainMlResultsBatch: () => Promise<TestClosedSignalResult[]>;
|
|
1254
|
+
}
|
|
1255
|
+
type TestTradeExitReason = 'take_profit' | 'stop_loss' | 'exit';
|
|
1256
|
+
interface TestTradeResult {
|
|
1257
|
+
signalId: string;
|
|
1258
|
+
/** Stable id shared by every entry leg belonging to one position lifecycle. */
|
|
1259
|
+
positionCycleId?: string;
|
|
1260
|
+
direction: Direction;
|
|
1318
1261
|
qty: number;
|
|
1319
|
-
|
|
1262
|
+
closedQty: number;
|
|
1320
1263
|
entryTimestamp: number;
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1264
|
+
exitTimestamp: number;
|
|
1265
|
+
exitReason: TestTradeExitReason;
|
|
1266
|
+
requestedEntryPrice: number;
|
|
1267
|
+
entryPrice: number;
|
|
1268
|
+
requestedExitPrice: number | null;
|
|
1269
|
+
exitPrice: number | null;
|
|
1270
|
+
grossProfit: number;
|
|
1271
|
+
netProfit: number;
|
|
1272
|
+
openFee: number;
|
|
1273
|
+
closeFee: number;
|
|
1274
|
+
fundingFee: number | null;
|
|
1275
|
+
totalFee: number;
|
|
1276
|
+
entrySlippagePrice: number;
|
|
1277
|
+
entrySlippageBps: number;
|
|
1278
|
+
entryBaseSlippageBps: number;
|
|
1279
|
+
entrySpreadBps: number;
|
|
1280
|
+
entrySpreadSlippageBps: number;
|
|
1281
|
+
entryMarketImpactBps: number;
|
|
1282
|
+
entryDelayRiskBps: number | null;
|
|
1283
|
+
entrySlippageCost: number;
|
|
1284
|
+
exitSlippagePrice: number | null;
|
|
1285
|
+
exitSlippageBps: number | null;
|
|
1286
|
+
exitBaseSlippageBps: number | null;
|
|
1287
|
+
exitSpreadBps: number | null;
|
|
1288
|
+
exitSpreadSlippageBps: number | null;
|
|
1289
|
+
exitMarketImpactBps: number | null;
|
|
1290
|
+
exitDelayRiskBps: number | null;
|
|
1291
|
+
exitSlippageCost: number;
|
|
1292
|
+
totalSlippageCost: number;
|
|
1293
|
+
}
|
|
1294
|
+
interface TestClosedSignalResult {
|
|
1295
|
+
signalId: string;
|
|
1296
|
+
profit: number;
|
|
1297
|
+
tradeResult?: TestTradeResult;
|
|
1298
|
+
}
|
|
1299
|
+
interface TestConnectorContext {
|
|
1300
|
+
userName?: string;
|
|
1301
|
+
mlEnabled?: boolean;
|
|
1302
|
+
aiEnabled?: boolean;
|
|
1303
|
+
fastMode?: boolean;
|
|
1304
|
+
instrument?: InstrumentDescriptor;
|
|
1305
|
+
executionCostModel?: ExecutionCostModel;
|
|
1306
|
+
fundingRates?: FundingRatePoint[];
|
|
1307
|
+
}
|
|
1308
|
+
type TestConnectorCreator = (connector: Connector, context?: TestConnectorContext) => TestConnector;
|
|
1309
|
+
type ChartColor = string;
|
|
1310
|
+
interface TestCompare {
|
|
1311
|
+
testResult: TestResult;
|
|
1312
|
+
color: ChartColor;
|
|
1325
1313
|
}
|
|
1314
|
+
type TestCompareList = TestCompare[];
|
|
1315
|
+
type OnChangeCompare = (testId: string) => void;
|
|
1326
1316
|
|
|
1327
1317
|
interface Bot {
|
|
1328
1318
|
symbol: string;
|
|
@@ -2777,7 +2767,8 @@ type StrategyReleaseResearchDecisionInput = {
|
|
|
2777
2767
|
userName: string;
|
|
2778
2768
|
deploymentId: string;
|
|
2779
2769
|
accountId: string;
|
|
2780
|
-
|
|
2770
|
+
strategyName: string;
|
|
2771
|
+
version: number;
|
|
2781
2772
|
} | null;
|
|
2782
2773
|
maxLossValue: number;
|
|
2783
2774
|
};
|
|
@@ -2803,7 +2794,6 @@ type StrategyEvidenceMarker = {
|
|
|
2803
2794
|
artifactId: string;
|
|
2804
2795
|
artifactSha256: string;
|
|
2805
2796
|
compositionId?: string;
|
|
2806
|
-
releaseVersion?: number;
|
|
2807
2797
|
gitSha?: string;
|
|
2808
2798
|
gateFingerprint?: string;
|
|
2809
2799
|
configFingerprint?: string;
|
|
@@ -2815,22 +2805,6 @@ type StrategyEvidenceMarker = {
|
|
|
2815
2805
|
endTime: number;
|
|
2816
2806
|
};
|
|
2817
2807
|
};
|
|
2818
|
-
type StrategyEvidenceTimeline = {
|
|
2819
|
-
status: 'verified' | 'not_attached' | 'missing' | 'invalid';
|
|
2820
|
-
observedFrom: number | null;
|
|
2821
|
-
markers: StrategyEvidenceMarker[];
|
|
2822
|
-
};
|
|
2823
|
-
type StrategyEvidenceTimelineSelector = {
|
|
2824
|
-
strategy: string;
|
|
2825
|
-
releaseVersion?: number | null;
|
|
2826
|
-
compositionId?: string | null;
|
|
2827
|
-
gitSha?: string | null;
|
|
2828
|
-
gateFingerprint?: string | null;
|
|
2829
|
-
configFingerprint?: string | null;
|
|
2830
|
-
contextFingerprint?: string | null;
|
|
2831
|
-
maxLossValue?: number | null;
|
|
2832
|
-
requireCompleteLineage?: boolean;
|
|
2833
|
-
};
|
|
2834
2808
|
type StrategyEvidenceMarkerPayload = {
|
|
2835
2809
|
strategy: string;
|
|
2836
2810
|
createdAt: number;
|
|
@@ -3042,7 +3016,7 @@ interface RuntimeStrategyView {
|
|
|
3042
3016
|
runtimeKey: string;
|
|
3043
3017
|
strategyName: string;
|
|
3044
3018
|
configId: string;
|
|
3045
|
-
|
|
3019
|
+
version: number;
|
|
3046
3020
|
controlState: RuntimeStrategyControlState;
|
|
3047
3021
|
interval: Interval;
|
|
3048
3022
|
universe: MarketUniverse;
|
|
@@ -3057,7 +3031,6 @@ interface RuntimeStrategyView {
|
|
|
3057
3031
|
stat: TestStat;
|
|
3058
3032
|
summary: RuntimeStrategyTradeSummary;
|
|
3059
3033
|
orderLog: SimpleOrderLogData;
|
|
3060
|
-
evidenceTimeline: StrategyEvidenceTimeline;
|
|
3061
3034
|
recentTrades: RuntimeStrategyTradeView[];
|
|
3062
3035
|
orders: RuntimeStrategyTradeView[];
|
|
3063
3036
|
}
|
|
@@ -3073,4 +3046,25 @@ interface RuntimeStrategiesResponse {
|
|
|
3073
3046
|
strategies: RuntimeStrategyView[];
|
|
3074
3047
|
}
|
|
3075
3048
|
|
|
3076
|
-
|
|
3049
|
+
/** One immutable strategy package + effective project config revision. */
|
|
3050
|
+
interface RuntimeStrategyDeclaration {
|
|
3051
|
+
version: number;
|
|
3052
|
+
enabled: boolean;
|
|
3053
|
+
config: StrategyConfig;
|
|
3054
|
+
}
|
|
3055
|
+
/** Git-owned execution target. Credentials remain server-owned. */
|
|
3056
|
+
interface RuntimeDeploymentDeclaration {
|
|
3057
|
+
label?: string;
|
|
3058
|
+
connectorName: string;
|
|
3059
|
+
provider?: string;
|
|
3060
|
+
accountId: string;
|
|
3061
|
+
enabled?: boolean;
|
|
3062
|
+
strategies: Record<string, RuntimeStrategyDeclaration>;
|
|
3063
|
+
assetClasses?: AssetClass[];
|
|
3064
|
+
tickers?: string[];
|
|
3065
|
+
}
|
|
3066
|
+
interface TradejsRuntimeDeclaration {
|
|
3067
|
+
deployments: Record<string, RuntimeDeploymentDeclaration>;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
export { type AIChatHistory, type AIChatMessage, type AggTrade, type AggTradesRequest, type AiDatasetRow, type AiPayload, type AiPromptPair, type AssetClass, BACKTEST_WARNING_CODES, type BacktestDetectorOptimizedStrategy, type BacktestPriceMode, type BacktestRunConfig, type BacktestWarningCode, type BacktestWarningCounts, type BaseContextGateFeatures, type BaseGateFeatureApproveBias, type BaseGateFeatureConfirmation, type BaseGateFeatureConflict, type BaseGateFeatureEntryLocation, type BaseGateFeaturePrimaryIssue, type BaseGateFeatureRiskLevel, type BaseGateFeatureScoreKey, type BaseHyperliquidWhaleFlowContext, type BaseIndicatorsHistorySnapshot, type BaseMarketBreadthContext, type BaseMarketBreadthsContext, type BaseMarketTradeFlowContext, type BaseMultiTimeframeContext, type BaseParticipationContext, type BasePsychologicalLevelAssetContext, type BasePsychologicalLevelWindowContext, type BaseRawIndicatorSnapshot, type BaseRegimeContext, type BaseRelativeContext, type BaseStrategyContextSnapshot, type BaseStructureContext, type Bot, type BotConfig, type BotResults, type BotStatus, type BuildStrategySignalDraft, type BuildStrategySignalParams, type Candle, type ChartColor, type ClosedPnlRecord, type CmcExchangeLiquidityRegime, type CmcFearGreedClassification, type CmcFearGreedRegime, type CompletedTest, type Connector, type ConnectorAccountResolver, type ConnectorCachedKlineFactory, type ConnectorCapabilities, type ConnectorConfig, type ConnectorCreator, type ConnectorLogger, type ConnectorPluginDefinition, type ConnectorRegistryEntry, type ConnectorRuntime, type CoreResearchTraceEvent, type CreateStrategyCore, type CreateStrategyCoreParams, DEFAULT_MARKET_UNIVERSE, type DerivativesContext, type DerivativesContextRiskFlag, type DerivativesInterval, type DerivativesIntervalContext, type DerivativesPressure, type DerivativesPriceOiDivergenceType, type DerivativesRow, type DerivativesSymbolContext, type DerivativesTargetDerivedContext, type Direction, type EOMPoint, type ExchangeEntryRecord, type ExecutionCostModel, type ExecutionCostQuality, type ExecutionCostSource, type Filters, type FundingRateHistoryRequest, type FundingRatePoint, type GetAggTrades, type GetClosedPnlParams, type GetFundingRateHistory, type GetOrderBookDepth, type GetTickers, type GetTopOfBookTicker, type GetTradingFeeRate, HYPERLIQUID_WHALE_DATA_MODEL_VERSION, type HyperliquidPositionAction, type HyperliquidWhaleCoverageRow, type HyperliquidWhaleFlowRow, type HyperliquidWhaleTradeEventRow, type Indicator, type IndicatorPluginComputeParams, type IndicatorPluginDefinition, type IndicatorPluginEntry, type IndicatorPluginFigureRenderer, type IndicatorPluginRenderer, type IndicatorSnapshot, type Indicators, type IndicatorsHistorySnapshot, type InstrumentDescriptor, type InstrumentKind, type InstrumentQuery, type InstrumentStatus, type Interval, type Item, type Items, type Kline, type KlineChartData, type KlineChartItem, type KlineRequest, type LegacyRuntimeLineage, type ListInstruments, type MarketBreadthRow, type MarketCmcExchangeLiquidityContextRow, type MarketCmcFearGreedContextRow, type MarketCmcIndexConstituent, type MarketCmcIndexContextRow, type MarketCmcIndexSlug, type MarketDataCapability, type MarketFeatureInterval, type MarketGlobalContextRow, type MarketGlobalContextSource, type MarketKlineEvent, type MarketReferenceAssetContextRow, type MarketTradeFlowRow, type MarketUniverse, type MetricThreshold, type Metrics, type MinimalStat, type MlCandleIndicatorsSnapshot, type MonthlyEquityStats, type OnChangeCompare, type Order, type OrderBookDepth, type OrderBookDepthRequest, type OrderLog, type OrderLogData, type OrderPositionIntent, type OrderType, type Position, type PositionLog, type PositionLogData, type PositionPnlSnapshot, type Provider, RUNTIME_CONTROLS_SCHEMA, type RuntimeAiAnalysisSnapshot, type RuntimeControls, type RuntimeDeployment, type RuntimeDeploymentDeclaration, type RuntimeDeploymentHeartbeat, type RuntimeDeploymentStrategy, type RuntimeLineage, type RuntimeSignalEvaluationRecord, type RuntimeSignalEvaluationStatus, type RuntimeStrategiesResponse, type RuntimeStrategyCloseNotification, type RuntimeStrategyConfigSnapshot, type RuntimeStrategyControlEvent, type RuntimeStrategyControlEventAction, type RuntimeStrategyControlState, type RuntimeStrategyDeclaration, type RuntimeStrategyPauseOverride, type RuntimeStrategyTradeSummary, type RuntimeStrategyTradeView, type RuntimeStrategyView, type RuntimeTradeExitType, type RuntimeTradeFillSource, type RuntimeTradeRecord, type RuntimeTradeStatus, type RuntimeTradeTelemetryQuality, STRATEGY_EVIDENCE_MARKERS_SCHEMA, STRATEGY_LIVE_DIAGNOSIS_SCHEMA, STRATEGY_RELEASE_SCHEMA, type Signal, type SignalAnalysis, type SignalOrderStatus, type SimpleOrderLogData, type Sl, type SpreadRow, type Strategy, type StrategyAPI, type StrategyAPIEntryParams, type StrategyAPIExitParams, type StrategyAPIProtectParams, type StrategyAdditionalIndicatorsMap, type StrategyAiAdapter, type StrategyAiMode, type StrategyChartDetail, type StrategyChartMetric, type StrategyChartMetricTone, type StrategyChartOrder, type StrategyChartSnapshot, type StrategyChartsSnapshotResponse, type StrategyClosePlan, type StrategyConfig, type StrategyConfigGrid, type StrategyCoreRunner, type StrategyCreator, type StrategyCreatorParams, type StrategyDecision, type StrategyDecisionPriceContext, type StrategyDirectionPolicy, type StrategyDirectionalTpSlParams, type StrategyDirectionalTpSlResult, type StrategyEntryBaseParams, type StrategyEntryModelFigures, type StrategyEntryOrderPlan, type StrategyEntryRuntimeBaseParams, type StrategyEntryRuntimeBuilderParams, type StrategyEntryRuntimeOptions, type StrategyEntrySignalContext, type StrategyEntrySignalDecisionBuilderParams, type StrategyEntryTakeProfitsParams, type StrategyEvidenceMarker, type StrategyEvidenceMarkerEnvelope, type StrategyEvidenceMarkerPayload, type StrategyEvidenceMarkerType, type StrategyEvidenceRetentionEntry, type StrategyEvidenceRetentionPlan, type StrategyFigureAnnotation, type StrategyFigureLine, type StrategyFigurePoint, type StrategyFigurePoints, type StrategyFigureZone, type StrategyHookAfterAiContext, type StrategyHookAfterDecisionContext, type StrategyHookAfterPlaceOrderContext, type StrategyHookAiContext, type StrategyHookAiSkippedReason, type StrategyHookBarContext, type StrategyHookBeforeCloseContext, type StrategyHookBeforeEntryGateContext, type StrategyHookBeforePlaceOrderContext, type StrategyHookCtx, type StrategyHookEnrichContext, type StrategyHookEntryContext, type StrategyHookErrorContext, type StrategyHookErrorPayload, type StrategyHookGateResult, type StrategyHookInitContext, type StrategyHookMarketContext, type StrategyHookMlContext, type StrategyHookMlSkippedReason, type StrategyHookOrderContext, type StrategyHookPolicyContext, type StrategyHookSkipContext, type StrategyHookStage, type StrategyIndicatorsContext, type StrategyIndicatorsMap, type StrategyIndicatorsState, type StrategyLastTradeController, type StrategyLastTradeControllerParams, type StrategyLiveDiagnosis, type StrategyLiveDiagnosisEnvelope, type StrategyLiveDiagnosisVerdict, type StrategyManifest, type StrategyMarketContextSource, type StrategyMlAdapter, type StrategyPluginDefinition, type StrategyPolicyProfile, type StrategyProtectPlan, type StrategyRegistryEntry, type StrategyReleaseEnvelope, type StrategyReleaseEvidenceReference, type StrategyReleaseHistoricalWindow, type StrategyReleaseManifest, type StrategyReleaseReason, type StrategyReleaseResearchDecision, type StrategyReleaseResearchDecisionAction, type StrategyReleaseResearchDecisionBlocker, type StrategyReleaseResearchDecisionInput, type StrategyReleaseVerdict, type StrategyResultConfig, type StrategyResultEntry, type StrategyResults, type StrategyRuntimeAiOptions, type StrategyRuntimeMlOptions, type StrategySharedReplayStateGetter, type StrategySignalMetaParams, type StrategySignalPriceParams, type StrategyStateController, type StrategyStateControllerOptions, type Test, type TestClosedSignalResult, type TestCompare, type TestCompareList, type TestConnector, type TestConnectorContext, type TestConnectorCreator, type TestResult, type TestStat, type TestSuite, type TestThresholds, type TestThresholdsKey, type TestTradeExitReason, type TestTradeResult, type TestWorkerResult, type TestingBox, type TestingBoxResult, type TestingOptions, type ThresholdLevel, type Ticker, type TickerQuery, type TopOfBookTicker, type Tp, type TradejsRuntimeDeclaration, type TradingAccountRef, type TradingFeeRate, type Trend, type TrendLine, type TrendLineMode, type TrendLineOptions, type VersionedRuntimeLineage, isMarketUniverse, resolveConnectorUniverse };
|