@tradejs/types 3.1.10 → 3.1.11

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.
Files changed (3) hide show
  1. package/dist/index.d.mts +823 -816
  2. package/dist/index.d.ts +823 -816
  3. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -50,83 +50,425 @@ interface MetricThreshold {
50
50
  precision: number;
51
51
  }
52
52
 
53
- declare const RUNTIME_CONTROLS_SCHEMA: "tradejs-runtime-controls/v1";
54
- interface RuntimeStrategyPauseOverride {
55
- entriesPaused: true;
56
- updatedAt: string;
57
- updatedBy: string;
53
+ type ExecutionCostSource = 'exchange-account' | 'connector-default' | 'config' | 'historical' | 'calibrated' | 'fallback' | 'disabled' | 'unavailable';
54
+ type ExecutionCostQuality = 'full' | 'partial' | 'fallback';
55
+ interface ExecutionCostModel {
56
+ fees: {
57
+ makerRate: number;
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;
58
82
  }
59
- interface RuntimeControls {
60
- schema: typeof RUNTIME_CONTROLS_SCHEMA;
61
- deployments: Record<string, Record<string, RuntimeStrategyPauseOverride>>;
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;
62
113
  }
63
- type RuntimeStrategyControlState = 'active' | 'entries_paused';
64
- type RuntimeStrategyControlEventAction = 'pause_entries' | 'resume';
65
- interface RuntimeStrategyControlEvent {
66
- eventId: string;
67
- deploymentId: string;
68
- strategyName: string;
69
- version: number;
70
- action: RuntimeStrategyControlEventAction;
71
- previousState: RuntimeStrategyControlState;
72
- nextState: RuntimeStrategyControlState;
73
- createdAt: number;
74
- createdBy: string;
114
+ type StrategyResultConfig = StrategyConfig;
115
+ type StrategyConfigGrid = Record<string, unknown[]>;
116
+ interface RuntimeStrategyConfigSnapshot {
117
+ userConfig: StrategyConfig;
75
118
  }
76
-
77
- type MarketUniverse = 'crypto' | 'tradfi';
78
- type AssetClass = 'crypto' | 'equity' | 'commodity' | 'forex';
79
- type InstrumentKind = 'perpetual' | 'spot';
80
- type InstrumentStatus = 'trading' | 'inactive' | 'unknown';
81
- interface InstrumentDescriptor {
82
- provider: string;
119
+ interface StrategyCreatorParams {
120
+ userName: string;
121
+ connectorName: string;
83
122
  symbol: string;
84
- kind: InstrumentKind;
85
- assetClass: AssetClass;
86
- universe: MarketUniverse;
87
- status: InstrumentStatus;
88
- baseAsset?: string;
89
- quoteAsset?: string;
90
- settleAsset?: string;
91
- displayName?: string;
92
- venueMetadata?: Record<string, unknown>;
123
+ universe?: MarketUniverse;
124
+ assetClass?: AssetClass;
125
+ instrument?: InstrumentDescriptor;
126
+ accountId?: string;
127
+ deploymentId?: string;
128
+ policyProfileId?: string;
129
+ runtimeConfigId?: string;
130
+ runtimeVersion?: 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;
93
151
  }
94
- interface ConnectorCapabilities {
95
- supportedUniverses: readonly MarketUniverse[];
96
- defaultUniverse: MarketUniverse;
152
+ interface StrategyCreator {
153
+ (params: StrategyCreatorParams): Promise<Strategy>;
154
+ detectorKey?: (config: StrategyConfig) => string | undefined;
155
+ detectorNoSignalSkipReason?: string;
97
156
  }
98
- interface InstrumentQuery {
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;
99
170
  universe?: MarketUniverse;
100
- assetClasses?: readonly AssetClass[];
101
- symbols?: readonly string[];
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;
102
188
  }
103
- interface TickerQuery extends InstrumentQuery {
189
+ type TestSuite = Test[];
190
+ interface TestStat extends Metrics {
191
+ score?: number;
104
192
  }
105
- interface FundingRatePoint {
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;
106
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';
107
224
  timestamp: number;
108
- rate: number;
109
- }
110
- interface FundingRateHistoryRequest {
225
+ strategy: string;
111
226
  symbol: string;
112
- startTime?: number;
113
- endTime: number;
114
- limit?: number;
115
- }
116
- interface TradingFeeRate {
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;
117
241
  symbol: string;
118
- makerRate: number;
119
- takerRate: number;
120
- source: 'exchange-account' | 'connector-default' | 'fallback';
121
- capturedAt: number;
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;
122
259
  }
123
- interface TradingAccountRef {
124
- id: string;
125
- label: string;
126
- provider: string;
127
- enabled: boolean;
128
- isDefault?: boolean;
129
- universes: MarketUniverse[];
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[]>;
306
+ }
307
+ type TestTradeExitReason = 'take_profit' | 'stop_loss' | 'exit';
308
+ interface TestTradeResult {
309
+ signalId: string;
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;
345
+ }
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
+ interface RuntimeStrategySelection {
370
+ tickers: string[];
371
+ }
372
+ /** One immutable strategy package + effective project config revision. */
373
+ interface RuntimeStrategyDeclaration {
374
+ version: number;
375
+ enabled: boolean;
376
+ selection?: RuntimeStrategySelection;
377
+ config: StrategyConfig;
378
+ }
379
+ /** Git-owned execution target. Credentials remain server-owned. */
380
+ interface RuntimeDeploymentDeclaration {
381
+ label?: string;
382
+ connectorName: string;
383
+ provider?: string;
384
+ accountId: string;
385
+ enabled?: boolean;
386
+ strategies: Record<string, RuntimeStrategyDeclaration>;
387
+ assetClasses?: AssetClass[];
388
+ /** Default selection for strategy bindings that do not declare one. */
389
+ tickers?: string[];
390
+ }
391
+ interface TradejsRuntimeDeclaration {
392
+ deployments: Record<string, RuntimeDeploymentDeclaration>;
393
+ }
394
+
395
+ declare const RUNTIME_CONTROLS_SCHEMA: "tradejs-runtime-controls/v1";
396
+ interface RuntimeStrategyPauseOverride {
397
+ entriesPaused: true;
398
+ updatedAt: string;
399
+ updatedBy: string;
400
+ }
401
+ interface RuntimeControls {
402
+ schema: typeof RUNTIME_CONTROLS_SCHEMA;
403
+ deployments: Record<string, Record<string, RuntimeStrategyPauseOverride>>;
404
+ }
405
+ type RuntimeStrategyControlState = 'active' | 'entries_paused';
406
+ type RuntimeStrategyControlEventAction = 'pause_entries' | 'resume';
407
+ interface RuntimeStrategyControlEvent {
408
+ eventId: string;
409
+ deploymentId: string;
410
+ strategyName: string;
411
+ version: number;
412
+ action: RuntimeStrategyControlEventAction;
413
+ previousState: RuntimeStrategyControlState;
414
+ nextState: RuntimeStrategyControlState;
415
+ createdAt: number;
416
+ createdBy: string;
417
+ }
418
+
419
+ type MarketUniverse = 'crypto' | 'tradfi';
420
+ type AssetClass = 'crypto' | 'equity' | 'commodity' | 'forex';
421
+ type InstrumentKind = 'perpetual' | 'spot';
422
+ type InstrumentStatus = 'trading' | 'inactive' | 'unknown';
423
+ interface InstrumentDescriptor {
424
+ provider: string;
425
+ symbol: string;
426
+ kind: InstrumentKind;
427
+ assetClass: AssetClass;
428
+ universe: MarketUniverse;
429
+ status: InstrumentStatus;
430
+ baseAsset?: string;
431
+ quoteAsset?: string;
432
+ settleAsset?: string;
433
+ displayName?: string;
434
+ venueMetadata?: Record<string, unknown>;
435
+ }
436
+ interface ConnectorCapabilities {
437
+ supportedUniverses: readonly MarketUniverse[];
438
+ defaultUniverse: MarketUniverse;
439
+ }
440
+ interface InstrumentQuery {
441
+ universe?: MarketUniverse;
442
+ assetClasses?: readonly AssetClass[];
443
+ symbols?: readonly string[];
444
+ }
445
+ interface TickerQuery extends InstrumentQuery {
446
+ }
447
+ interface FundingRatePoint {
448
+ symbol: string;
449
+ timestamp: number;
450
+ rate: number;
451
+ }
452
+ interface FundingRateHistoryRequest {
453
+ symbol: string;
454
+ startTime?: number;
455
+ endTime: number;
456
+ limit?: number;
457
+ }
458
+ interface TradingFeeRate {
459
+ symbol: string;
460
+ makerRate: number;
461
+ takerRate: number;
462
+ source: 'exchange-account' | 'connector-default' | 'fallback';
463
+ capturedAt: number;
464
+ }
465
+ interface TradingAccountRef {
466
+ id: string;
467
+ label: string;
468
+ provider: string;
469
+ enabled: boolean;
470
+ isDefault?: boolean;
471
+ universes: MarketUniverse[];
130
472
  environment: 'mainnet' | 'testnet';
131
473
  apiKey?: string;
132
474
  apiSecret?: string;
@@ -143,6 +485,7 @@ interface RuntimeDeploymentStrategy {
143
485
  enabled: boolean;
144
486
  /** New entries may be paused while exit/position management keeps running. */
145
487
  controlState: RuntimeStrategyControlState;
488
+ selection?: RuntimeStrategySelection;
146
489
  }
147
490
  interface RuntimeDeployment {
148
491
  id: string;
@@ -540,779 +883,463 @@ type ConnectorCachedKlineFactory = (options: {
540
883
  intervalToMinutes: (interval: Interval) => number | null;
541
884
  limit?: number;
542
885
  cacheFallbackWindow?: number;
543
- }) => Kline;
544
- interface ConnectorRuntime {
545
- logger: ConnectorLogger;
546
- resolveTradingAccount: ConnectorAccountResolver;
547
- createCachedKline: ConnectorCachedKlineFactory;
548
- }
549
- type ConnectorCreator = (config: ConnectorConfig, runtime?: ConnectorRuntime) => Promise<Connector>;
550
- interface ConnectorRegistryEntry {
551
- name: string;
552
- creator: ConnectorCreator;
553
- providers?: string[];
554
- }
555
- interface ConnectorPluginDefinition {
556
- connectorEntries: ConnectorRegistryEntry[];
557
- }
558
- type GetPosition = (symbol: string) => Promise<Position | null>;
559
- type GetPositions = () => Promise<Position[]>;
560
- type GetOpenPositionPnl = () => Promise<PositionPnlSnapshot[]>;
561
- interface ClosedPnlRecord {
562
- symbol: string;
563
- qty: number;
564
- entryPrice: number | null;
565
- exitPrice: number | null;
566
- closedPnl: number;
567
- closedAt: number;
568
- direction?: Direction;
569
- entryTimestamp?: number;
570
- orderId?: string;
571
- orderLinkId?: string;
572
- openFee?: number | null;
573
- closeFee?: number | null;
574
- fundingFee?: number | null;
575
- totalFee?: number | null;
576
- }
577
- interface ExchangeEntryRecord {
578
- symbol: string;
579
- qty: number;
580
- entryPrice: number | null;
581
- entryTimestamp: number;
582
- direction: Direction;
583
- orderId?: string;
584
- orderLinkId?: string;
585
- takeProfitPrice?: number | null;
586
- stopLossPrice?: number | null;
587
- exitPrice?: number | null;
588
- exitTimestamp?: number | null;
589
- closedPnl?: number | null;
590
- openFee?: number | null;
591
- closeFee?: number | null;
592
- fundingFee?: number | null;
593
- totalFee?: number | null;
594
- }
595
- interface GetClosedPnlParams {
596
- startTime: number;
597
- endTime: number;
598
- symbol?: string;
599
- limit?: number;
600
- }
601
- type GetClosedPnl = (params: GetClosedPnlParams) => Promise<ClosedPnlRecord[]>;
602
- type GetEntryExecutions = (params: GetClosedPnlParams) => Promise<ExchangeEntryRecord[]>;
603
- type PlaceOrder = (order: Order) => Promise<boolean>;
604
- type ClosePosition = (order: Omit<Order, 'qty'>) => Promise<boolean>;
605
- type SetTakeProfits = (params: {
606
- symbol: string;
607
- direction: Direction;
608
- qty?: number;
609
- takeProfits: Tp[];
610
- }) => Promise<boolean>;
611
- type SetStopLoss = (params: {
612
- symbol: string;
613
- direction: Direction;
614
- stopLossPrice: Sl;
615
- }) => Promise<boolean>;
616
- type Kline = (options: KlineRequest) => Promise<KlineChartData>;
617
- type GetTickers = (query?: TickerQuery) => Promise<Ticker[]>;
618
- type ListInstruments = (query?: InstrumentQuery) => Promise<InstrumentDescriptor[]>;
619
- type GetFundingRateHistory = (request: FundingRateHistoryRequest) => Promise<FundingRatePoint[]>;
620
- type GetTradingFeeRate = (symbol: string) => Promise<TradingFeeRate | null>;
621
- type GetTopOfBookTicker = (symbol: string) => Promise<TopOfBookTicker | null>;
622
- type GetAggTrades = (request: AggTradesRequest) => Promise<AggTrade[]>;
623
- type GetOrderBookDepth = (request: OrderBookDepthRequest) => Promise<OrderBookDepth | null>;
624
- interface Connector {
625
- capabilities: ConnectorCapabilities;
626
- universe: MarketUniverse;
627
- accountId?: string;
628
- deploymentId?: string;
629
- listInstruments: ListInstruments;
630
- kline: Kline;
631
- getState: () => Promise<object>;
632
- setState: (state: object) => Promise<void>;
633
- getPosition: GetPosition;
634
- getPositions: GetPositions;
635
- getOpenPositionPnl?: GetOpenPositionPnl;
636
- getClosedPnl?: GetClosedPnl;
637
- getEntryExecutions?: GetEntryExecutions;
638
- placeOrder: PlaceOrder;
639
- setTakeProfits: SetTakeProfits;
640
- setStopLoss: SetStopLoss;
641
- closePosition: ClosePosition;
642
- getTickers: GetTickers;
643
- getFundingRateHistory?: GetFundingRateHistory;
644
- getTradingFeeRate?: GetTradingFeeRate;
645
- getTopOfBookTicker?: GetTopOfBookTicker;
646
- getAggTrades?: GetAggTrades;
647
- getOrderBookDepth?: GetOrderBookDepth;
648
- }
649
- interface Indicator {
650
- id: string;
651
- label: string;
652
- enabled: boolean;
653
- periods?: Array<number>;
654
- }
655
- type Indicators = Indicator[];
656
- interface Filters {
657
- provider?: Provider;
658
- universe?: MarketUniverse;
659
- symbol: string;
660
- interval: Interval;
661
- start: number;
662
- end: number;
663
- }
664
- interface Ticker {
665
- symbol: string;
666
- lastPrice: number;
667
- indexPrice: number;
668
- markPrice: number;
669
- prevPrice24h: number;
670
- price24hPcnt: number;
671
- highPrice24h: number;
672
- lowPrice24h: number;
673
- prevPrice1h: number;
674
- openInterest: number;
675
- openInterestValue: number;
676
- turnover24h: number;
677
- volume24h: number;
678
- fundingRate: number;
679
- nextFundingTime: number;
680
- predictedDeliveryPrice: string;
681
- basisRate: string;
682
- deliveryFeeRate: string;
683
- deliveryTime: number;
684
- ask1Size: number;
685
- bid1Price: number;
686
- ask1Price: number;
687
- bid1Size: number;
688
- basis: string;
689
- preOpenPrice: string;
690
- preQty: string;
691
- }
692
- interface TopOfBookTicker {
693
- symbol: string;
694
- bidPrice: number;
695
- bidQty: number;
696
- askPrice: number;
697
- askQty: number;
698
- timestamp?: number | null;
699
- }
700
- interface AggTradesRequest {
701
- symbol: string;
702
- startTime: number;
703
- endTime: number;
704
- limit?: number;
705
- }
706
- interface AggTrade {
707
- aggregateTradeId: number;
708
- price: number;
709
- quantity: number;
710
- firstTradeId: number;
711
- lastTradeId: number;
712
- timestamp: number;
713
- isBuyerMaker: boolean;
714
- }
715
- interface OrderBookDepthRequest {
716
- symbol: string;
717
- limit?: 5 | 10 | 20 | 50 | 100 | 500 | 1000 | 5000;
718
- }
719
- interface OrderBookDepth {
720
- symbol: string;
721
- lastUpdateId: number | null;
722
- bids: Array<[price: number, quantity: number]>;
723
- asks: Array<[price: number, quantity: number]>;
724
- timestamp: number;
725
- }
726
- type TrendLineMode = 'lows' | 'highs';
727
- type TrendLine = {
728
- id: string;
729
- mode: TrendLineMode;
730
- distance: number;
731
- touches: {
732
- timestamp: number;
733
- value: number;
734
- }[];
735
- points: {
736
- timestamp: number;
737
- value: number;
738
- }[];
739
- alpha?: number[];
740
- };
741
- interface StrategyFigurePoint {
742
- timestamp: number;
743
- value: number;
744
- }
745
- interface StrategyFigureLine {
746
- id?: string;
747
- kind?: string;
748
- points: StrategyFigurePoint[];
749
- color?: string;
750
- width?: number;
751
- style?: 'solid' | 'dashed';
752
- }
753
- interface StrategyFigurePoints {
754
- id?: string;
755
- kind?: string;
756
- points: StrategyFigurePoint[];
757
- color?: string;
758
- radius?: number;
759
- }
760
- interface StrategyFigureZone {
761
- id?: string;
762
- kind?: string;
763
- start: StrategyFigurePoint;
764
- end: StrategyFigurePoint;
765
- color?: string;
766
- borderColor?: string;
767
- }
768
- interface StrategyFigureAnnotation {
769
- id?: string;
770
- kind?: string;
771
- point: StrategyFigurePoint;
772
- title: string;
773
- items: string[];
774
- color?: string;
775
- textColor?: string;
776
- backgroundColor?: string;
777
- }
778
- interface StrategyEntryModelFigures {
779
- lines?: StrategyFigureLine[];
780
- points?: StrategyFigurePoints[];
781
- zones?: StrategyFigureZone[];
782
- annotations?: StrategyFigureAnnotation[];
783
- }
784
- interface TrendLineOptions {
785
- mode: TrendLineMode;
786
- maxLines?: number;
787
- range?: number;
788
- epsilon?: number;
789
- epsilonOffset?: number;
790
- epsilonMode?: 'static' | 'atr';
791
- epsilonAtrPeriod?: number;
792
- epsilonAtrMultiplier?: number;
793
- epsilonOffsetAtrMultiplier?: number;
794
- epsilonMin?: number;
795
- epsilonMax?: number;
796
- epsilonOffsetMin?: number;
797
- epsilonOffsetMax?: number;
798
- minTouches?: number;
799
- minDistance?: number;
800
- firstRange?: number;
801
- offset?: number;
802
- minTouchGap?: number;
803
- maxTouchGap?: number;
804
- capture?: boolean;
805
- bestLines?: number;
806
- maxDistance?: number;
807
- }
808
- interface Signal {
809
- signalId: string;
810
- orderId?: string;
811
- symbol: string;
812
- interval: Interval;
813
- strategy: string;
814
- universe?: MarketUniverse;
815
- assetClass?: AssetClass;
816
- accountId?: string;
817
- deploymentId?: string;
818
- policyProfileId?: string;
819
- runtimeConfigId?: string;
820
- runtimeVersion?: number;
821
- runtimeLineage?: RuntimeLineage;
822
- direction: Direction;
823
- timestamp: number;
824
- orderStatus?: SignalOrderStatus;
825
- orderSkipReason?: string;
826
- orderFailureReason?: string;
827
- orderQty?: number;
828
- orderValue?: number;
829
- isConfigFromBacktest?: boolean;
830
- aiAnalysis?: Partial<SignalAnalysis>;
831
- ml?: {
832
- probability: number;
833
- threshold: number;
834
- passed: boolean;
835
- };
836
- figures: {
837
- trendLine?: TrendLine;
838
- lines?: StrategyFigureLine[];
839
- points?: StrategyFigurePoints[];
840
- zones?: StrategyFigureZone[];
841
- annotations?: StrategyFigureAnnotation[];
842
- [key: string]: any;
843
- };
844
- prices: {
845
- currentPrice: number;
846
- takeProfitPrice: number;
847
- stopLossPrice: number;
848
- riskRatio: number;
849
- };
850
- indicators: Record<string, any>;
851
- additionalIndicators?: Record<string, any>;
852
- }
853
- type RuntimeSignalEvaluationStatus = 'signal' | 'skip' | 'error';
854
- interface RuntimeSignalEvaluationRecord {
855
- evaluationId: string;
856
- userName: string;
857
- strategy: string;
858
- universe?: MarketUniverse;
859
- assetClass?: AssetClass;
860
- accountId?: string;
861
- deploymentId?: string;
862
- policyProfileId?: string;
863
- runtimeConfigId?: string;
864
- runtimeVersion?: number;
865
- runtimeLineage?: RuntimeLineage;
866
- symbol: string;
867
- interval: Interval;
868
- timestamp: number;
869
- evaluatedAt: number;
870
- status: RuntimeSignalEvaluationStatus;
871
- reason?: string;
872
- signalId?: string;
873
- direction?: Direction;
874
- orderStatus?: SignalOrderStatus;
875
- orderSkipReason?: string;
876
- aiAnalysis?: Partial<SignalAnalysis> | null;
877
- ml?: Signal['ml'];
878
- }
879
- interface SignalAnalysis {
880
- direction: Direction | null;
881
- quality: 1 | 2 | 3 | 4 | 5 | number;
882
- needRetest: boolean;
883
- retestPrice: number | null;
884
- takeProfitPrice: number | null;
885
- stopLossPrice: number | null;
886
- setup?: string;
887
- confirmations?: string;
888
- btcContext?: string;
889
- retestPlan?: string;
890
- riskLevels?: string;
891
- qualityReason?: string;
892
- triggerInvalidation?: string;
893
- gateAnalysis?: Partial<SignalAnalysis>;
894
- gateContradictsLlm?: boolean;
895
- gateDecision?: 'approved' | 'rejected';
896
- llmDecision?: 'approved' | 'rejected';
897
- comment: string;
898
- }
899
- interface RuntimeAiAnalysisSnapshot {
900
- strategy?: string;
901
- symbol: string;
902
- direction: Direction;
903
- timestamp: number;
904
- toleranceMs?: number;
905
- analysis: Partial<SignalAnalysis>;
906
- }
907
- type SignalOrderStatus = 'completed' | 'failed' | 'skipped' | 'canceled';
908
- interface LegacyRuntimeLineage {
909
- schemaVersion: 1;
910
- compositionId?: string | null;
911
- gitSha: string | null;
912
- gitDirty: boolean | null;
913
- gateFingerprint: string;
914
- configFingerprint: string;
915
- contextFingerprint: string;
916
- maxLossValue?: number | null;
917
- }
918
- interface VersionedRuntimeLineage {
919
- schemaVersion: 2;
920
- version: number;
921
- strategyPackageVersion?: string | null;
922
- runtimePackageVersion?: string | null;
923
- maxLossValue?: number | null;
924
- }
925
- type RuntimeLineage = LegacyRuntimeLineage | VersionedRuntimeLineage;
926
- type RuntimeTradeStatus = 'active' | 'closed';
927
- type RuntimeTradeExitType = 'exit' | 'tp' | 'sl' | 'unknown';
928
- type RuntimeTradeFillSource = 'exchange_position' | 'requested_price' | 'unknown';
929
- type RuntimeTradeTelemetryQuality = 'full' | 'partial' | 'price_only' | 'none';
930
- interface RuntimeTradeRecord {
931
- orderId: string;
932
- signalId?: string;
933
- runtimeLineage?: RuntimeLineage;
934
- strategy: string;
935
- universe?: MarketUniverse;
936
- assetClass?: AssetClass;
937
- accountId?: string;
938
- deploymentId?: string;
939
- policyProfileId?: string;
940
- runtimeConfigId?: string;
941
- runtimeVersion?: number;
886
+ }) => Kline;
887
+ interface ConnectorRuntime {
888
+ logger: ConnectorLogger;
889
+ resolveTradingAccount: ConnectorAccountResolver;
890
+ createCachedKline: ConnectorCachedKlineFactory;
891
+ }
892
+ type ConnectorCreator = (config: ConnectorConfig, runtime?: ConnectorRuntime) => Promise<Connector>;
893
+ interface ConnectorRegistryEntry {
894
+ name: string;
895
+ creator: ConnectorCreator;
896
+ providers?: string[];
897
+ }
898
+ interface ConnectorPluginDefinition {
899
+ connectorEntries: ConnectorRegistryEntry[];
900
+ }
901
+ type GetPosition = (symbol: string) => Promise<Position | null>;
902
+ type GetPositions = () => Promise<Position[]>;
903
+ type GetOpenPositionPnl = () => Promise<PositionPnlSnapshot[]>;
904
+ interface ClosedPnlRecord {
942
905
  symbol: string;
943
- interval?: Interval;
944
- direction: Direction;
945
906
  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;
907
+ entryPrice: number | null;
908
+ exitPrice: number | null;
909
+ closedPnl: number;
910
+ closedAt: number;
911
+ direction?: Direction;
912
+ entryTimestamp?: number;
913
+ orderId?: string;
914
+ orderLinkId?: string;
976
915
  openFee?: number | null;
977
916
  closeFee?: number | null;
978
917
  fundingFee?: number | null;
979
918
  totalFee?: number | null;
980
- aiAnalysis?: Partial<SignalAnalysis> | null;
981
- lastSyncedAt?: number;
982
919
  }
983
- interface RuntimeStrategyCloseNotification {
984
- userName?: string;
985
- strategy: string;
986
- openedByStrategy: string;
920
+ interface ExchangeEntryRecord {
987
921
  symbol: string;
988
- direction: Direction;
989
- code: string;
990
- orderId: string;
991
- signalId?: string;
992
922
  qty: number;
993
- entryPrice: number;
923
+ entryPrice: number | null;
994
924
  entryTimestamp: number;
925
+ direction: Direction;
926
+ orderId?: string;
927
+ orderLinkId?: string;
928
+ takeProfitPrice?: number | null;
929
+ stopLossPrice?: number | null;
995
930
  exitPrice?: number | null;
996
931
  exitTimestamp?: number | null;
997
932
  closedPnl?: number | null;
998
- exitType?: RuntimeTradeExitType | null;
933
+ openFee?: number | null;
934
+ closeFee?: number | null;
935
+ fundingFee?: number | null;
936
+ totalFee?: number | null;
999
937
  }
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;
938
+ interface GetClosedPnlParams {
939
+ startTime: number;
940
+ endTime: number;
941
+ symbol?: string;
942
+ limit?: number;
1030
943
  }
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;
944
+ type GetClosedPnl = (params: GetClosedPnlParams) => Promise<ClosedPnlRecord[]>;
945
+ type GetEntryExecutions = (params: GetClosedPnlParams) => Promise<ExchangeEntryRecord[]>;
946
+ type PlaceOrder = (order: Order) => Promise<boolean>;
947
+ type ClosePosition = (order: Omit<Order, 'qty'>) => Promise<boolean>;
948
+ type SetTakeProfits = (params: {
949
+ symbol: string;
950
+ direction: Direction;
951
+ qty?: number;
952
+ takeProfits: Tp[];
953
+ }) => Promise<boolean>;
954
+ type SetStopLoss = (params: {
955
+ symbol: string;
956
+ direction: Direction;
957
+ stopLossPrice: Sl;
958
+ }) => Promise<boolean>;
959
+ type Kline = (options: KlineRequest) => Promise<KlineChartData>;
960
+ type GetTickers = (query?: TickerQuery) => Promise<Ticker[]>;
961
+ type ListInstruments = (query?: InstrumentQuery) => Promise<InstrumentDescriptor[]>;
962
+ type GetFundingRateHistory = (request: FundingRateHistoryRequest) => Promise<FundingRatePoint[]>;
963
+ type GetTradingFeeRate = (symbol: string) => Promise<TradingFeeRate | null>;
964
+ type GetTopOfBookTicker = (symbol: string) => Promise<TopOfBookTicker | null>;
965
+ type GetAggTrades = (request: AggTradesRequest) => Promise<AggTrade[]>;
966
+ type GetOrderBookDepth = (request: OrderBookDepthRequest) => Promise<OrderBookDepth | null>;
967
+ interface Connector {
968
+ capabilities: ConnectorCapabilities;
969
+ universe: MarketUniverse;
970
+ accountId?: string;
971
+ deploymentId?: string;
972
+ listInstruments: ListInstruments;
973
+ kline: Kline;
974
+ getState: () => Promise<object>;
975
+ setState: (state: object) => Promise<void>;
976
+ getPosition: GetPosition;
977
+ getPositions: GetPositions;
978
+ getOpenPositionPnl?: GetOpenPositionPnl;
979
+ getClosedPnl?: GetClosedPnl;
980
+ getEntryExecutions?: GetEntryExecutions;
981
+ placeOrder: PlaceOrder;
982
+ setTakeProfits: SetTakeProfits;
983
+ setStopLoss: SetStopLoss;
984
+ closePosition: ClosePosition;
985
+ getTickers: GetTickers;
986
+ getFundingRateHistory?: GetFundingRateHistory;
987
+ getTradingFeeRate?: GetTradingFeeRate;
988
+ getTopOfBookTicker?: GetTopOfBookTicker;
989
+ getAggTrades?: GetAggTrades;
990
+ getOrderBookDepth?: GetOrderBookDepth;
991
+ }
992
+ interface Indicator {
993
+ id: string;
994
+ label: string;
995
+ enabled: boolean;
996
+ periods?: Array<number>;
997
+ }
998
+ type Indicators = Indicator[];
999
+ interface Filters {
1000
+ provider?: Provider;
1001
+ universe?: MarketUniverse;
1002
+ symbol: string;
1003
+ interval: Interval;
1004
+ start: number;
1005
+ end: number;
1006
+ }
1007
+ interface Ticker {
1008
+ symbol: string;
1009
+ lastPrice: number;
1010
+ indexPrice: number;
1011
+ markPrice: number;
1012
+ prevPrice24h: number;
1013
+ price24hPcnt: number;
1014
+ highPrice24h: number;
1015
+ lowPrice24h: number;
1016
+ prevPrice1h: number;
1017
+ openInterest: number;
1018
+ openInterestValue: number;
1019
+ turnover24h: number;
1020
+ volume24h: number;
1021
+ fundingRate: number;
1022
+ nextFundingTime: number;
1023
+ predictedDeliveryPrice: string;
1024
+ basisRate: string;
1025
+ deliveryFeeRate: string;
1026
+ deliveryTime: number;
1027
+ ask1Size: number;
1028
+ bid1Price: number;
1029
+ ask1Price: number;
1030
+ bid1Size: number;
1031
+ basis: string;
1032
+ preOpenPrice: string;
1033
+ preQty: string;
1034
+ }
1035
+ interface TopOfBookTicker {
1036
+ symbol: string;
1037
+ bidPrice: number;
1038
+ bidQty: number;
1039
+ askPrice: number;
1040
+ askQty: number;
1041
+ timestamp?: number | null;
1042
+ }
1043
+ interface AggTradesRequest {
1044
+ symbol: string;
1045
+ startTime: number;
1046
+ endTime: number;
1047
+ limit?: number;
1048
+ }
1049
+ interface AggTrade {
1050
+ aggregateTradeId: number;
1051
+ price: number;
1052
+ quantity: number;
1053
+ firstTradeId: number;
1054
+ lastTradeId: number;
1055
+ timestamp: number;
1056
+ isBuyerMaker: boolean;
1061
1057
  }
1062
- type StrategyResultConfig = StrategyConfig;
1063
- type StrategyConfigGrid = Record<string, unknown[]>;
1064
- interface RuntimeStrategyConfigSnapshot {
1065
- userConfig: StrategyConfig;
1058
+ interface OrderBookDepthRequest {
1059
+ symbol: string;
1060
+ limit?: 5 | 10 | 20 | 50 | 100 | 500 | 1000 | 5000;
1066
1061
  }
1067
- interface StrategyCreatorParams {
1068
- userName: string;
1069
- connectorName: string;
1062
+ interface OrderBookDepth {
1070
1063
  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;
1064
+ lastUpdateId: number | null;
1065
+ bids: Array<[price: number, quantity: number]>;
1066
+ asks: Array<[price: number, quantity: number]>;
1067
+ timestamp: number;
1099
1068
  }
1100
- interface StrategyCreator {
1101
- (params: StrategyCreatorParams): Promise<Strategy>;
1102
- detectorKey?: (config: StrategyConfig) => string | undefined;
1103
- detectorNoSignalSkipReason?: string;
1069
+ type TrendLineMode = 'lows' | 'highs';
1070
+ type TrendLine = {
1071
+ id: string;
1072
+ mode: TrendLineMode;
1073
+ distance: number;
1074
+ touches: {
1075
+ timestamp: number;
1076
+ value: number;
1077
+ }[];
1078
+ points: {
1079
+ timestamp: number;
1080
+ value: number;
1081
+ }[];
1082
+ alpha?: number[];
1083
+ };
1084
+ interface StrategyFigurePoint {
1085
+ timestamp: number;
1086
+ value: number;
1104
1087
  }
1105
- type TestingOptions = Pick<KlineRequest, 'start' | 'end'>;
1106
- interface BacktestRunConfig {
1107
- strategyName: string;
1108
- strategyConfig: StrategyConfig;
1109
- connectorName: string;
1088
+ interface StrategyFigureLine {
1089
+ id?: string;
1090
+ kind?: string;
1091
+ points: StrategyFigurePoint[];
1092
+ color?: string;
1093
+ width?: number;
1094
+ style?: 'solid' | 'dashed';
1110
1095
  }
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;
1125
- interval?: Interval;
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;
1096
+ interface StrategyFigurePoints {
1097
+ id?: string;
1098
+ kind?: string;
1099
+ points: StrategyFigurePoint[];
1100
+ color?: string;
1101
+ radius?: number;
1136
1102
  }
1137
- type TestSuite = Test[];
1138
- interface TestStat extends Metrics {
1139
- score?: number;
1103
+ interface StrategyFigureZone {
1104
+ id?: string;
1105
+ kind?: string;
1106
+ start: StrategyFigurePoint;
1107
+ end: StrategyFigurePoint;
1108
+ color?: string;
1109
+ borderColor?: string;
1140
1110
  }
1141
- interface StrategyResultEntry {
1142
- config: StrategyResultConfig;
1143
- stats: TestStat;
1111
+ interface StrategyFigureAnnotation {
1112
+ id?: string;
1113
+ kind?: string;
1114
+ point: StrategyFigurePoint;
1115
+ title: string;
1116
+ items: string[];
1117
+ color?: string;
1118
+ textColor?: string;
1119
+ backgroundColor?: string;
1144
1120
  }
1145
- type StrategyResults = Record<string, StrategyResultEntry>;
1146
- interface MinimalStat {
1147
- amount: number;
1148
- profit: number;
1149
- orders: number;
1121
+ interface StrategyEntryModelFigures {
1122
+ lines?: StrategyFigureLine[];
1123
+ points?: StrategyFigurePoints[];
1124
+ zones?: StrategyFigureZone[];
1125
+ annotations?: StrategyFigureAnnotation[];
1150
1126
  }
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;
1160
- strategy: string;
1161
- symbol: string;
1162
- direction: Direction;
1163
- setupIdentity: string;
1164
- setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
1127
+ interface TrendLineOptions {
1128
+ mode: TrendLineMode;
1129
+ maxLines?: number;
1130
+ range?: number;
1131
+ epsilon?: number;
1132
+ epsilonOffset?: number;
1133
+ epsilonMode?: 'static' | 'atr';
1134
+ epsilonAtrPeriod?: number;
1135
+ epsilonAtrMultiplier?: number;
1136
+ epsilonOffsetAtrMultiplier?: number;
1137
+ epsilonMin?: number;
1138
+ epsilonMax?: number;
1139
+ epsilonOffsetMin?: number;
1140
+ epsilonOffsetMax?: number;
1141
+ minTouches?: number;
1142
+ minDistance?: number;
1143
+ firstRange?: number;
1144
+ offset?: number;
1145
+ minTouchGap?: number;
1146
+ maxTouchGap?: number;
1147
+ capture?: boolean;
1148
+ bestLines?: number;
1149
+ maxDistance?: number;
1150
+ }
1151
+ interface Signal {
1165
1152
  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;
1153
+ orderId?: string;
1174
1154
  symbol: string;
1155
+ interval: Interval;
1156
+ strategy: string;
1157
+ universe?: MarketUniverse;
1158
+ assetClass?: AssetClass;
1159
+ accountId?: string;
1160
+ deploymentId?: string;
1161
+ policyProfileId?: string;
1162
+ runtimeConfigId?: string;
1163
+ runtimeVersion?: number;
1164
+ runtimeLineage?: RuntimeLineage;
1175
1165
  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
1166
  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>;
1167
+ orderStatus?: SignalOrderStatus;
1168
+ orderSkipReason?: string;
1169
+ orderFailureReason?: string;
1170
+ orderQty?: number;
1171
+ orderValue?: number;
1172
+ isConfigFromBacktest?: boolean;
1173
+ aiAnalysis?: Partial<SignalAnalysis>;
1174
+ ml?: {
1175
+ probability: number;
1176
+ threshold: number;
1177
+ passed: boolean;
1204
1178
  };
1205
- executionCostModel?: ExecutionCostModel;
1206
- warningCounts?: BacktestWarningCounts;
1207
- }
1208
- type TestingBox = (test: Test) => Promise<TestingBoxResult | null>;
1209
- interface TestWorkerResult extends TestingBoxResult {
1210
- test: Test;
1179
+ figures: {
1180
+ trendLine?: TrendLine;
1181
+ lines?: StrategyFigureLine[];
1182
+ points?: StrategyFigurePoints[];
1183
+ zones?: StrategyFigureZone[];
1184
+ annotations?: StrategyFigureAnnotation[];
1185
+ [key: string]: any;
1186
+ };
1187
+ prices: {
1188
+ currentPrice: number;
1189
+ takeProfitPrice: number;
1190
+ stopLossPrice: number;
1191
+ riskRatio: number;
1192
+ };
1193
+ indicators: Record<string, any>;
1194
+ additionalIndicators?: Record<string, any>;
1211
1195
  }
1212
- interface CompletedTest extends Omit<TestWorkerResult, 'stat'> {
1213
- stat: TestStat;
1196
+ type RuntimeSignalEvaluationStatus = 'signal' | 'skip' | 'error';
1197
+ interface RuntimeSignalEvaluationRecord {
1198
+ evaluationId: string;
1199
+ userName: string;
1200
+ strategy: string;
1201
+ universe?: MarketUniverse;
1202
+ assetClass?: AssetClass;
1203
+ accountId?: string;
1204
+ deploymentId?: string;
1205
+ policyProfileId?: string;
1206
+ runtimeConfigId?: string;
1207
+ runtimeVersion?: number;
1208
+ runtimeLineage?: RuntimeLineage;
1209
+ symbol: string;
1210
+ interval: Interval;
1211
+ timestamp: number;
1212
+ evaluatedAt: number;
1213
+ status: RuntimeSignalEvaluationStatus;
1214
+ reason?: string;
1215
+ signalId?: string;
1216
+ direction?: Direction;
1217
+ orderStatus?: SignalOrderStatus;
1218
+ orderSkipReason?: string;
1219
+ aiAnalysis?: Partial<SignalAnalysis> | null;
1220
+ ml?: Signal['ml'];
1214
1221
  }
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;
1222
+ interface SignalAnalysis {
1223
+ direction: Direction | null;
1224
+ quality: 1 | 2 | 3 | 4 | 5 | number;
1225
+ needRetest: boolean;
1226
+ retestPrice: number | null;
1227
+ takeProfitPrice: number | null;
1228
+ stopLossPrice: number | null;
1229
+ setup?: string;
1230
+ confirmations?: string;
1231
+ btcContext?: string;
1232
+ retestPlan?: string;
1233
+ riskLevels?: string;
1234
+ qualityReason?: string;
1235
+ triggerInvalidation?: string;
1236
+ gateAnalysis?: Partial<SignalAnalysis>;
1237
+ gateContradictsLlm?: boolean;
1238
+ gateDecision?: 'approved' | 'rejected';
1239
+ llmDecision?: 'approved' | 'rejected';
1240
+ comment: string;
1233
1241
  }
1234
- interface PositionLog {
1242
+ interface RuntimeAiAnalysisSnapshot {
1243
+ strategy?: string;
1244
+ symbol: string;
1235
1245
  direction: Direction;
1236
- open: {
1237
- amount: number;
1238
- timestamp: number;
1239
- };
1240
- close: {
1241
- amount: number;
1242
- timestamp: number;
1243
- };
1246
+ timestamp: number;
1247
+ toleranceMs?: number;
1248
+ analysis: Partial<SignalAnalysis>;
1244
1249
  }
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[]>;
1250
+ type SignalOrderStatus = 'completed' | 'failed' | 'skipped' | 'canceled';
1251
+ interface LegacyRuntimeLineage {
1252
+ schemaVersion: 1;
1253
+ compositionId?: string | null;
1254
+ gitSha: string | null;
1255
+ gitDirty: boolean | null;
1256
+ gateFingerprint: string;
1257
+ configFingerprint: string;
1258
+ contextFingerprint: string;
1259
+ maxLossValue?: number | null;
1254
1260
  }
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;
1261
+ interface VersionedRuntimeLineage {
1262
+ schemaVersion: 2;
1263
+ version: number;
1264
+ strategyPackageVersion?: string | null;
1265
+ runtimePackageVersion?: string | null;
1266
+ maxLossValue?: number | null;
1267
+ }
1268
+ type RuntimeLineage = LegacyRuntimeLineage | VersionedRuntimeLineage;
1269
+ type RuntimeTradeStatus = 'active' | 'closed';
1270
+ type RuntimeTradeExitType = 'exit' | 'tp' | 'sl' | 'unknown';
1271
+ type RuntimeTradeFillSource = 'exchange_position' | 'requested_price' | 'unknown';
1272
+ type RuntimeTradeTelemetryQuality = 'full' | 'partial' | 'price_only' | 'none';
1273
+ interface RuntimeTradeRecord {
1274
+ orderId: string;
1275
+ signalId?: string;
1276
+ runtimeLineage?: RuntimeLineage;
1277
+ strategy: string;
1278
+ universe?: MarketUniverse;
1279
+ assetClass?: AssetClass;
1280
+ accountId?: string;
1281
+ deploymentId?: string;
1282
+ policyProfileId?: string;
1283
+ runtimeConfigId?: string;
1284
+ runtimeVersion?: number;
1285
+ symbol: string;
1286
+ interval?: Interval;
1260
1287
  direction: Direction;
1261
1288
  qty: number;
1262
- closedQty: number;
1263
- entryTimestamp: number;
1264
- exitTimestamp: number;
1265
- exitReason: TestTradeExitReason;
1266
- requestedEntryPrice: number;
1267
1289
  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;
1290
+ entryCount?: number;
1291
+ lastEntryPrice?: number | null;
1292
+ lastEntryQty?: number | null;
1293
+ lastEntryTimestamp?: number | null;
1294
+ actualEntryPrice?: number | null;
1295
+ entryTimestamp: number;
1296
+ signalTimestamp?: number | null;
1297
+ signalClosePrice?: number | null;
1298
+ arrivalSnapshotTime?: number | null;
1299
+ arrivalSource?: string | null;
1300
+ arrivalMid?: number | null;
1301
+ bid?: number | null;
1302
+ ask?: number | null;
1303
+ spreadBps?: number | null;
1304
+ orderSubmitTime?: number | null;
1305
+ orderAckTime?: number | null;
1306
+ fillAvgPrice?: number | null;
1307
+ fillSource?: RuntimeTradeFillSource | null;
1308
+ fillTime?: number | null;
1309
+ telemetryQuality?: RuntimeTradeTelemetryQuality | null;
1310
+ fee?: number | null;
1311
+ status: RuntimeTradeStatus;
1312
+ currentPrice?: number | null;
1313
+ currentPnl?: number | null;
1314
+ closedPnl?: number | null;
1315
+ exitPrice?: number | null;
1316
+ actualExitPrice?: number | null;
1317
+ exitTimestamp?: number | null;
1318
+ exitType?: RuntimeTradeExitType | null;
1319
+ openFee?: number | null;
1320
+ closeFee?: number | null;
1321
+ fundingFee?: number | null;
1322
+ totalFee?: number | null;
1323
+ aiAnalysis?: Partial<SignalAnalysis> | null;
1324
+ lastSyncedAt?: number;
1298
1325
  }
1299
- interface TestConnectorContext {
1326
+ interface RuntimeStrategyCloseNotification {
1300
1327
  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;
1328
+ strategy: string;
1329
+ openedByStrategy: string;
1330
+ symbol: string;
1331
+ direction: Direction;
1332
+ code: string;
1333
+ orderId: string;
1334
+ signalId?: string;
1335
+ qty: number;
1336
+ entryPrice: number;
1337
+ entryTimestamp: number;
1338
+ exitPrice?: number | null;
1339
+ exitTimestamp?: number | null;
1340
+ closedPnl?: number | null;
1341
+ exitType?: RuntimeTradeExitType | null;
1313
1342
  }
1314
- type TestCompareList = TestCompare[];
1315
- type OnChangeCompare = (testId: string) => void;
1316
1343
 
1317
1344
  interface Bot {
1318
1345
  symbol: string;
@@ -3023,6 +3050,7 @@ interface RuntimeStrategyView {
3023
3050
  accountId?: string;
3024
3051
  accountLabel?: string;
3025
3052
  deploymentId: string;
3053
+ selection?: RuntimeStrategySelection;
3026
3054
  policyProfileId?: string;
3027
3055
  connected: boolean;
3028
3056
  enabled: boolean;
@@ -3046,25 +3074,4 @@ interface RuntimeStrategiesResponse {
3046
3074
  strategies: RuntimeStrategyView[];
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 };
3077
+ 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 RuntimeStrategySelection, 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 };