@tradejs/types 3.1.0 → 3.1.2
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/README.md +2 -0
- package/dist/index.d.mts +1190 -1119
- package/dist/index.d.ts +1190 -1119
- package/dist/index.js +8 -0
- package/dist/index.mjs +6 -0
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -50,1232 +50,1299 @@ interface MetricThreshold {
|
|
|
50
50
|
precision: number;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
type
|
|
54
|
-
type
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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;
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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;
|
|
85
113
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
type StrategyResultConfig = StrategyConfig;
|
|
115
|
+
type StrategyConfigGrid = Record<string, unknown[]>;
|
|
116
|
+
interface RuntimeStrategyConfigSnapshot {
|
|
117
|
+
userConfig: StrategyConfig;
|
|
118
|
+
symbolResultConfig?: StrategyConfig | null;
|
|
91
119
|
}
|
|
92
|
-
interface
|
|
120
|
+
interface StrategyCreatorParams {
|
|
121
|
+
userName: string;
|
|
122
|
+
connectorName: string;
|
|
93
123
|
symbol: string;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
124
|
+
universe?: MarketUniverse;
|
|
125
|
+
assetClass?: AssetClass;
|
|
126
|
+
instrument?: InstrumentDescriptor;
|
|
127
|
+
accountId?: string;
|
|
128
|
+
deploymentId?: string;
|
|
129
|
+
policyProfileId?: string;
|
|
130
|
+
runtimeConfigId?: string;
|
|
131
|
+
runtimeReleaseVersion?: number;
|
|
132
|
+
entriesPaused?: boolean;
|
|
133
|
+
runtimeLineage?: RuntimeLineage;
|
|
134
|
+
runtimeConfigSnapshot?: RuntimeStrategyConfigSnapshot;
|
|
135
|
+
config: StrategyConfig;
|
|
136
|
+
connector: Connector;
|
|
137
|
+
data: KlineChartData;
|
|
138
|
+
btcData: KlineChartData;
|
|
139
|
+
ethData?: KlineChartData;
|
|
140
|
+
btcBinanceData?: KlineChartData;
|
|
141
|
+
btcCoinbaseData?: KlineChartData;
|
|
142
|
+
backtestExecutionMarketData?: {
|
|
143
|
+
interval: Interval;
|
|
144
|
+
data: KlineChartData;
|
|
145
|
+
btcData?: KlineChartData;
|
|
146
|
+
dataByTimestamp?: Map<number, KlineChartItem>;
|
|
147
|
+
btcDataByTimestamp?: Map<number, KlineChartItem>;
|
|
148
|
+
};
|
|
149
|
+
sharedIndicatorsReplayKey?: string;
|
|
150
|
+
sharedStrategyStateKey?: string;
|
|
151
|
+
onRuntimeClose?: (event: RuntimeStrategyCloseNotification) => void;
|
|
98
152
|
}
|
|
99
|
-
interface
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
enabled: boolean;
|
|
104
|
-
isDefault?: boolean;
|
|
105
|
-
universes: MarketUniverse[];
|
|
106
|
-
environment: 'mainnet' | 'testnet';
|
|
107
|
-
apiKey?: string;
|
|
108
|
-
apiSecret?: string;
|
|
109
|
-
uid?: string;
|
|
110
|
-
readOnly?: boolean;
|
|
111
|
-
lastCheckedAt?: number;
|
|
112
|
-
lastError?: string;
|
|
153
|
+
interface StrategyCreator {
|
|
154
|
+
(params: StrategyCreatorParams): Promise<Strategy>;
|
|
155
|
+
detectorKey?: (config: StrategyConfig) => string | undefined;
|
|
156
|
+
detectorNoSignalSkipReason?: string;
|
|
113
157
|
}
|
|
114
|
-
|
|
158
|
+
type TestingOptions = Pick<KlineRequest, 'start' | 'end'>;
|
|
159
|
+
interface BacktestRunConfig {
|
|
115
160
|
strategyName: string;
|
|
116
|
-
|
|
117
|
-
releaseCompositionId?: string;
|
|
118
|
-
enabled?: boolean;
|
|
119
|
-
config?: Record<string, unknown>;
|
|
120
|
-
}
|
|
121
|
-
interface RuntimeDeployment {
|
|
122
|
-
id: string;
|
|
123
|
-
label: string;
|
|
161
|
+
strategyConfig: StrategyConfig;
|
|
124
162
|
connectorName: string;
|
|
125
|
-
provider: string;
|
|
126
|
-
accountId: string;
|
|
127
|
-
universe: MarketUniverse;
|
|
128
|
-
interval: string;
|
|
129
|
-
enabled: boolean;
|
|
130
|
-
strategies: RuntimeDeploymentStrategy[];
|
|
131
|
-
assetClasses?: AssetClass[];
|
|
132
|
-
tickers?: string[];
|
|
133
|
-
}
|
|
134
|
-
interface RuntimeDeploymentHeartbeat {
|
|
135
|
-
deploymentId: string;
|
|
136
|
-
status: 'running' | 'stopped' | 'error';
|
|
137
|
-
pid: number;
|
|
138
|
-
startedAt: number;
|
|
139
|
-
lastCycleAt: number;
|
|
140
|
-
lastError?: string;
|
|
141
163
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
interface Test extends BacktestRunConfig {
|
|
165
|
+
userName: string;
|
|
166
|
+
name: string;
|
|
167
|
+
testId: string;
|
|
168
|
+
testSuiteId: string;
|
|
169
|
+
configId?: string;
|
|
170
|
+
symbol: string;
|
|
171
|
+
universe?: MarketUniverse;
|
|
172
|
+
assetClass?: AssetClass;
|
|
173
|
+
instrument?: InstrumentDescriptor;
|
|
174
|
+
accountId?: string;
|
|
175
|
+
deploymentId?: string;
|
|
176
|
+
policyProfileId?: string;
|
|
177
|
+
executionCostModel?: ExecutionCostModel;
|
|
178
|
+
interval?: Interval;
|
|
179
|
+
options: TestingOptions;
|
|
180
|
+
ml?: boolean;
|
|
181
|
+
ai?: boolean;
|
|
182
|
+
fast?: boolean;
|
|
183
|
+
collectReplaySignalEvaluations?: boolean;
|
|
184
|
+
researchTrace?: boolean;
|
|
185
|
+
chunkId?: string;
|
|
186
|
+
backtestRunId?: string;
|
|
187
|
+
backtestTestKey?: string;
|
|
188
|
+
timeoutMs?: number;
|
|
162
189
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
190
|
+
type TestSuite = Test[];
|
|
191
|
+
interface TestStat extends Metrics {
|
|
192
|
+
score?: number;
|
|
166
193
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
universe: MarketUniverse;
|
|
171
|
-
symbol: string;
|
|
172
|
-
interval: Interval;
|
|
173
|
-
candle: KlineChartItem;
|
|
174
|
-
confirm: boolean;
|
|
175
|
-
receivedAt: number;
|
|
194
|
+
interface StrategyResultEntry {
|
|
195
|
+
config: StrategyResultConfig;
|
|
196
|
+
stats: TestStat;
|
|
176
197
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
silent?: boolean;
|
|
183
|
-
cacheOnly?: boolean;
|
|
184
|
-
warmOnly?: boolean;
|
|
198
|
+
type StrategyResults = Record<string, StrategyResultEntry>;
|
|
199
|
+
interface MinimalStat {
|
|
200
|
+
amount: number;
|
|
201
|
+
profit: number;
|
|
202
|
+
orders: number;
|
|
185
203
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
symbol: string;
|
|
189
|
-
interval: DerivativesInterval;
|
|
190
|
-
ts: Date;
|
|
191
|
-
openInterest?: number | null;
|
|
192
|
-
fundingRate?: number | null;
|
|
193
|
-
liqLong?: number | null;
|
|
194
|
-
liqShort?: number | null;
|
|
195
|
-
liqTotal?: number | null;
|
|
196
|
-
source?: string | null;
|
|
204
|
+
declare const BACKTEST_WARNING_CODES: {
|
|
205
|
+
readonly TAKE_PROFIT_CROSSED_BEFORE_ENTRY: "TAKE_PROFIT_CROSSED_BEFORE_ENTRY";
|
|
197
206
|
};
|
|
198
|
-
type
|
|
199
|
-
type
|
|
200
|
-
type
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
points: number;
|
|
206
|
-
openInterest: number | null;
|
|
207
|
-
oiChangePct1h: number | null;
|
|
208
|
-
oiChangePct4h: number | null;
|
|
209
|
-
oiChangePct24h: number | null;
|
|
210
|
-
fundingRate: number | null;
|
|
211
|
-
fundingZScore: number | null;
|
|
212
|
-
liqLong: number | null;
|
|
213
|
-
liqShort: number | null;
|
|
214
|
-
liqTotal: number | null;
|
|
215
|
-
liqImbalance: number | null;
|
|
216
|
-
liqSpikeRatio: number | null;
|
|
217
|
-
}
|
|
218
|
-
interface DerivativesSymbolContext {
|
|
219
|
-
source: 'coinalyze';
|
|
207
|
+
type BacktestWarningCode = (typeof BACKTEST_WARNING_CODES)[keyof typeof BACKTEST_WARNING_CODES];
|
|
208
|
+
type BacktestWarningCounts = Partial<Record<BacktestWarningCode, number>>;
|
|
209
|
+
type CoreResearchTraceEvent = {
|
|
210
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
211
|
+
event: 'signal_emitted' | 'entry_rejected' | 'entry_executed';
|
|
212
|
+
timestamp: number;
|
|
213
|
+
strategy: string;
|
|
220
214
|
symbol: string;
|
|
215
|
+
direction: Direction;
|
|
216
|
+
setupIdentity: string;
|
|
217
|
+
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
218
|
+
signalId: string;
|
|
219
|
+
configId?: string;
|
|
220
|
+
backtestRunId?: string;
|
|
221
|
+
backtestTestKey?: string;
|
|
222
|
+
} | {
|
|
223
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
224
|
+
event: 'position_exited';
|
|
221
225
|
timestamp: number;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
strategy: string;
|
|
227
|
+
symbol: string;
|
|
228
|
+
direction: Direction;
|
|
229
|
+
setupIdentity: string;
|
|
230
|
+
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
231
|
+
signalId: string;
|
|
232
|
+
configId?: string;
|
|
233
|
+
backtestRunId?: string;
|
|
234
|
+
backtestTestKey?: string;
|
|
235
|
+
netProfit: number;
|
|
236
|
+
exitReason: TestTradeExitReason;
|
|
237
|
+
} | {
|
|
238
|
+
schema: 'tradejs-core-research-trace/v1';
|
|
239
|
+
event: 'skip_summary';
|
|
240
|
+
timestamp: number;
|
|
241
|
+
strategy: string;
|
|
242
|
+
symbol: string;
|
|
243
|
+
configId?: string;
|
|
244
|
+
backtestRunId?: string;
|
|
245
|
+
backtestTestKey?: string;
|
|
246
|
+
skipCounts: Record<string, number>;
|
|
247
|
+
};
|
|
248
|
+
interface TestingBoxResult {
|
|
249
|
+
orderLogId: string;
|
|
250
|
+
stat: MinimalStat;
|
|
251
|
+
inlineOrderLog?: OrderLogData;
|
|
252
|
+
inlinePositionLog?: PositionLogData;
|
|
253
|
+
inlineReplaySignalEvaluations?: RuntimeSignalEvaluationRecord[];
|
|
254
|
+
researchTraceSummary?: {
|
|
255
|
+
events: Record<string, number>;
|
|
256
|
+
skipCounts: Record<string, number>;
|
|
231
257
|
};
|
|
258
|
+
executionCostModel?: ExecutionCostModel;
|
|
259
|
+
warningCounts?: BacktestWarningCounts;
|
|
232
260
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
sourceSymbol: string;
|
|
237
|
-
referenceSymbol: string | null;
|
|
238
|
-
directionAligned: boolean | null;
|
|
239
|
-
referenceDirectionAligned: boolean | null;
|
|
240
|
-
pressure: DerivativesPressure | null;
|
|
241
|
-
referencePressure: DerivativesPressure | null;
|
|
242
|
-
riskFlags: DerivativesContextRiskFlag[];
|
|
243
|
-
oiChangePct1h: number | null;
|
|
244
|
-
oiAcceleration: number | null;
|
|
245
|
-
fundingRate: number | null;
|
|
246
|
-
fundingZScore: number | null;
|
|
247
|
-
fundingChange1h: number | null;
|
|
248
|
-
liqSpikeRatio: number | null;
|
|
249
|
-
liqImbalance: number | null;
|
|
250
|
-
targetVsPrimaryOiChangePct1hDelta: number | null;
|
|
251
|
-
targetVsPrimaryFundingZScoreDelta: number | null;
|
|
252
|
-
targetReferenceConflict: boolean | null;
|
|
261
|
+
type TestingBox = (test: Test) => Promise<TestingBoxResult | null>;
|
|
262
|
+
interface TestWorkerResult extends TestingBoxResult {
|
|
263
|
+
test: Test;
|
|
253
264
|
}
|
|
254
|
-
interface
|
|
255
|
-
|
|
256
|
-
primaryReferenceSymbol?: string;
|
|
257
|
-
secondaryReferenceSymbol?: string;
|
|
258
|
-
referenceSymbols?: string[];
|
|
259
|
-
referenceContexts?: Record<string, DerivativesSymbolContext>;
|
|
260
|
-
targetContext?: DerivativesSymbolContext;
|
|
261
|
-
targetDerived?: DerivativesTargetDerivedContext;
|
|
265
|
+
interface CompletedTest extends Omit<TestWorkerResult, 'stat'> {
|
|
266
|
+
stat: TestStat;
|
|
262
267
|
}
|
|
263
|
-
type
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
ts: Date;
|
|
277
|
-
updatedAt?: Date | null;
|
|
278
|
-
activeCryptocurrencies?: number | null;
|
|
279
|
-
activeExchanges?: number | null;
|
|
280
|
-
activeMarketPairs?: number | null;
|
|
281
|
-
markets?: number | null;
|
|
282
|
-
totalMarketCapUsd?: number | null;
|
|
283
|
-
totalVolumeUsd?: number | null;
|
|
284
|
-
totalVolumeReportedUsd?: number | null;
|
|
285
|
-
btcDominancePct?: number | null;
|
|
286
|
-
ethDominancePct?: number | null;
|
|
287
|
-
altMarketCapUsd?: number | null;
|
|
288
|
-
altVolumeUsd?: number | null;
|
|
289
|
-
altVolumeReportedUsd?: number | null;
|
|
290
|
-
btcToAltMarketCapRatio?: number | null;
|
|
291
|
-
marketCapChangePct24hUsd?: number | null;
|
|
292
|
-
};
|
|
293
|
-
type MarketReferenceAssetContextRow = {
|
|
294
|
-
source: 'coinmarketcap_reference_asset';
|
|
295
|
-
symbol: 'BTCUSDT' | 'ETHUSDT' | string;
|
|
296
|
-
cmcId: number;
|
|
297
|
-
interval: '1d';
|
|
298
|
-
ts: Date;
|
|
299
|
-
openUsd?: number | null;
|
|
300
|
-
highUsd?: number | null;
|
|
301
|
-
lowUsd?: number | null;
|
|
302
|
-
closeUsd?: number | null;
|
|
303
|
-
volumeUsd?: number | null;
|
|
304
|
-
marketCapUsd?: number | null;
|
|
305
|
-
};
|
|
306
|
-
type CmcExchangeLiquidityRegime = 'expanding' | 'contracting' | 'binance_led' | 'concentrated' | 'balanced' | 'thin' | 'unknown';
|
|
307
|
-
type MarketCmcExchangeLiquidityContextRow = {
|
|
308
|
-
source: 'coinmarketcap_exchange_liquidity';
|
|
309
|
-
interval: '1d' | '1h';
|
|
310
|
-
ts: Date;
|
|
311
|
-
exchangesCount: number;
|
|
312
|
-
totalVolumeUsd?: number | null;
|
|
313
|
-
binanceVolumeUsd?: number | null;
|
|
314
|
-
binanceVolumeShare?: number | null;
|
|
315
|
-
topExchangeVolumeShare?: number | null;
|
|
316
|
-
liquidityRegime?: CmcExchangeLiquidityRegime | null;
|
|
317
|
-
};
|
|
318
|
-
type CmcFearGreedClassification = 'Extreme Fear' | 'Fear' | 'Neutral' | 'Greed' | 'Extreme Greed' | 'Unknown';
|
|
319
|
-
type CmcFearGreedRegime = 'capitulation' | 'risk_off' | 'neutral' | 'risk_on' | 'euphoric' | 'unknown';
|
|
320
|
-
type MarketCmcFearGreedContextRow = {
|
|
321
|
-
source: 'coinmarketcap_fear_greed';
|
|
322
|
-
interval: '1d';
|
|
323
|
-
ts: Date;
|
|
324
|
-
value: number;
|
|
325
|
-
classification: CmcFearGreedClassification;
|
|
326
|
-
sentimentRegime: CmcFearGreedRegime;
|
|
327
|
-
};
|
|
328
|
-
type MarketCmcIndexSlug = 'cmc100' | 'cmc20';
|
|
329
|
-
type MarketCmcIndexConstituent = {
|
|
330
|
-
id?: number | null;
|
|
331
|
-
name?: string | null;
|
|
332
|
-
symbol?: string | null;
|
|
333
|
-
url?: string | null;
|
|
334
|
-
weightPct?: number | null;
|
|
335
|
-
priceUsd?: number | null;
|
|
336
|
-
units?: number | null;
|
|
337
|
-
};
|
|
338
|
-
type MarketCmcIndexContextRow = {
|
|
339
|
-
source: 'coinmarketcap_index';
|
|
340
|
-
indexSlug: MarketCmcIndexSlug;
|
|
341
|
-
interval: '1d';
|
|
342
|
-
ts: Date;
|
|
343
|
-
value: number;
|
|
344
|
-
constituentsCount?: number | null;
|
|
345
|
-
topConstituentSymbol?: string | null;
|
|
346
|
-
topConstituentWeightPct?: number | null;
|
|
347
|
-
constituents?: MarketCmcIndexConstituent[] | null;
|
|
348
|
-
};
|
|
349
|
-
type MarketBreadthRow = {
|
|
350
|
-
universe: string;
|
|
351
|
-
interval: MarketFeatureInterval;
|
|
352
|
-
ts: Date;
|
|
353
|
-
symbolsCount: number;
|
|
354
|
-
advancers: number;
|
|
355
|
-
decliners: number;
|
|
356
|
-
unchanged: number;
|
|
357
|
-
advanceDeclineRatio?: number | null;
|
|
358
|
-
pctAboveMa20?: number | null;
|
|
359
|
-
pctAboveMa50?: number | null;
|
|
360
|
-
equalWeightedReturn?: number | null;
|
|
361
|
-
volumeWeightedReturn?: number | null;
|
|
362
|
-
dispersion?: number | null;
|
|
363
|
-
btcReturn1h?: number | null;
|
|
364
|
-
btcReturn4h?: number | null;
|
|
365
|
-
btcReturn24h?: number | null;
|
|
366
|
-
altBasketReturn1h?: number | null;
|
|
367
|
-
altBasketReturn4h?: number | null;
|
|
368
|
-
altBasketReturn24h?: number | null;
|
|
369
|
-
btcVsAltReturn1h?: number | null;
|
|
370
|
-
btcVsAltReturn4h?: number | null;
|
|
371
|
-
btcVsAltReturn24h?: number | null;
|
|
372
|
-
btcTurnoverShare1h?: number | null;
|
|
373
|
-
btcTurnoverShare24h?: number | null;
|
|
374
|
-
btcTurnoverShareChange24h?: number | null;
|
|
375
|
-
altVolToBtcVol24h?: number | null;
|
|
376
|
-
altDispersion24h?: number | null;
|
|
377
|
-
btcAltRegime?: 'btc_lead' | 'alt_lead' | 'risk_off' | 'risk_on' | 'mixed' | 'neutral' | 'unknown' | null;
|
|
378
|
-
source?: string | null;
|
|
268
|
+
type OrderLog = Order & {
|
|
269
|
+
type: OrderType;
|
|
270
|
+
profit: number;
|
|
271
|
+
amount: number;
|
|
272
|
+
fee?: number;
|
|
273
|
+
index: number;
|
|
274
|
+
executionSlippageStage?: 'entry' | 'exit';
|
|
275
|
+
executionSlippageBps?: number | null;
|
|
276
|
+
executionBaseSlippageBps?: number | null;
|
|
277
|
+
executionSpreadBps?: number | null;
|
|
278
|
+
executionSpreadSlippageBps?: number | null;
|
|
279
|
+
executionMarketImpactBps?: number | null;
|
|
280
|
+
executionDelayRiskBps?: number | null;
|
|
379
281
|
};
|
|
380
|
-
type
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
trades: number;
|
|
385
|
-
buyBaseVolume?: number | null;
|
|
386
|
-
sellBaseVolume?: number | null;
|
|
387
|
-
buyQuoteVolume?: number | null;
|
|
388
|
-
sellQuoteVolume?: number | null;
|
|
389
|
-
netBaseDelta?: number | null;
|
|
390
|
-
netQuoteDelta?: number | null;
|
|
391
|
-
buyPressurePct?: number | null;
|
|
392
|
-
source?: string | null;
|
|
393
|
-
};
|
|
394
|
-
type HyperliquidWhaleTradeEventRow = {
|
|
395
|
-
symbol: string;
|
|
396
|
-
ts: Date;
|
|
397
|
-
tid: string;
|
|
398
|
-
price: number;
|
|
399
|
-
size: number;
|
|
400
|
-
notionalUsd: number;
|
|
401
|
-
buyerAddress?: string | null;
|
|
402
|
-
sellerAddress?: string | null;
|
|
403
|
-
buyerTracked: boolean;
|
|
404
|
-
sellerTracked: boolean;
|
|
405
|
-
buyerStartPosition?: number | null;
|
|
406
|
-
buyerEndPosition?: number | null;
|
|
407
|
-
buyerPositionAction?: HyperliquidPositionAction | null;
|
|
408
|
-
buyerClosedPnl?: number | null;
|
|
409
|
-
buyerLiquidation?: boolean | null;
|
|
410
|
-
sellerStartPosition?: number | null;
|
|
411
|
-
sellerEndPosition?: number | null;
|
|
412
|
-
sellerPositionAction?: HyperliquidPositionAction | null;
|
|
413
|
-
sellerClosedPnl?: number | null;
|
|
414
|
-
sellerLiquidation?: boolean | null;
|
|
415
|
-
universeFingerprint: string;
|
|
416
|
-
whaleRegistryFingerprint: string;
|
|
417
|
-
source?: string | null;
|
|
418
|
-
};
|
|
419
|
-
type HyperliquidPositionAction = 'open' | 'increase' | 'reduce' | 'close' | 'flip';
|
|
420
|
-
type HyperliquidWhaleFlowRow = {
|
|
421
|
-
symbol: string;
|
|
422
|
-
interval: '1m';
|
|
423
|
-
ts: Date;
|
|
424
|
-
trades: number;
|
|
425
|
-
whaleSides: number;
|
|
426
|
-
uniqueWhales: number;
|
|
427
|
-
whaleAddresses?: string[];
|
|
428
|
-
buyNotionalUsd: number;
|
|
429
|
-
sellNotionalUsd: number;
|
|
430
|
-
netNotionalUsd: number;
|
|
431
|
-
buySharePct?: number | null;
|
|
432
|
-
positionAwareWhaleSides: number;
|
|
433
|
-
longEntryWhaleAddresses?: string[];
|
|
434
|
-
shortEntryWhaleAddresses?: string[];
|
|
435
|
-
longExitWhaleAddresses?: string[];
|
|
436
|
-
shortExitWhaleAddresses?: string[];
|
|
437
|
-
longEntryNotionalUsd: number;
|
|
438
|
-
shortEntryNotionalUsd: number;
|
|
439
|
-
longExitNotionalUsd: number;
|
|
440
|
-
shortExitNotionalUsd: number;
|
|
441
|
-
entryNetNotionalUsd: number;
|
|
442
|
-
entryLongSharePct?: number | null;
|
|
443
|
-
universeFingerprint: string;
|
|
444
|
-
whaleRegistryFingerprint: string;
|
|
445
|
-
source?: string | null;
|
|
446
|
-
};
|
|
447
|
-
declare const HYPERLIQUID_WHALE_DATA_MODEL_VERSION = 3;
|
|
448
|
-
type HyperliquidWhaleCoverageRow = {
|
|
449
|
-
ts: Date;
|
|
450
|
-
coveredWhales: number;
|
|
451
|
-
expectedWhales: number;
|
|
452
|
-
coveragePct: number;
|
|
453
|
-
dataModelVersion?: number;
|
|
454
|
-
universeFingerprint: string;
|
|
455
|
-
whaleRegistryFingerprint: string;
|
|
456
|
-
source?: string | null;
|
|
457
|
-
};
|
|
458
|
-
interface Tp {
|
|
459
|
-
price: number;
|
|
460
|
-
rate: number;
|
|
461
|
-
done?: boolean;
|
|
282
|
+
type OrderLogData = OrderLog[];
|
|
283
|
+
type SimpleOrderLogData = [number, number][];
|
|
284
|
+
interface TestResult extends Omit<CompletedTest, 'orderLogId'> {
|
|
285
|
+
orderLog: SimpleOrderLogData;
|
|
462
286
|
}
|
|
463
|
-
|
|
464
|
-
type Direction = 'LONG' | 'SHORT';
|
|
465
|
-
type Trend = 'BULL' | 'BEAR';
|
|
466
|
-
type OrderPositionIntent = 'open' | 'increase';
|
|
467
|
-
type Order = {
|
|
468
|
-
symbol: string;
|
|
469
|
-
isLimit?: boolean;
|
|
470
|
-
positionIntent?: OrderPositionIntent;
|
|
471
|
-
qty: number;
|
|
472
|
-
price: number;
|
|
473
|
-
timestamp: number;
|
|
287
|
+
interface PositionLog {
|
|
474
288
|
direction: Direction;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
289
|
+
open: {
|
|
290
|
+
amount: number;
|
|
291
|
+
timestamp: number;
|
|
292
|
+
};
|
|
293
|
+
close: {
|
|
294
|
+
amount: number;
|
|
295
|
+
timestamp: number;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
type PositionLogData = PositionLog[];
|
|
299
|
+
type TestThresholds = Record<keyof TestStat, MetricThreshold>;
|
|
300
|
+
type TestThresholdsKey = keyof TestThresholds;
|
|
301
|
+
interface TestConnector extends Connector {
|
|
302
|
+
getResult: () => Promise<TestingBoxResult>;
|
|
303
|
+
checkTp: (candle: Candle) => Promise<void>;
|
|
304
|
+
checkSl: (candle: Candle) => Promise<void>;
|
|
305
|
+
checkExits: (candle: Candle) => Promise<void>;
|
|
306
|
+
drainMlResultsBatch: () => Promise<TestClosedSignalResult[]>;
|
|
307
|
+
}
|
|
308
|
+
type TestTradeExitReason = 'take_profit' | 'stop_loss' | 'exit';
|
|
309
|
+
interface TestTradeResult {
|
|
310
|
+
signalId: string;
|
|
311
|
+
/** Stable id shared by every entry leg belonging to one position lifecycle. */
|
|
312
|
+
positionCycleId?: string;
|
|
483
313
|
direction: Direction;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
314
|
+
qty: number;
|
|
315
|
+
closedQty: number;
|
|
316
|
+
entryTimestamp: number;
|
|
317
|
+
exitTimestamp: number;
|
|
318
|
+
exitReason: TestTradeExitReason;
|
|
319
|
+
requestedEntryPrice: number;
|
|
320
|
+
entryPrice: number;
|
|
321
|
+
requestedExitPrice: number | null;
|
|
322
|
+
exitPrice: number | null;
|
|
323
|
+
grossProfit: number;
|
|
324
|
+
netProfit: number;
|
|
325
|
+
openFee: number;
|
|
326
|
+
closeFee: number;
|
|
327
|
+
fundingFee: number | null;
|
|
328
|
+
totalFee: number;
|
|
329
|
+
entrySlippagePrice: number;
|
|
330
|
+
entrySlippageBps: number;
|
|
331
|
+
entryBaseSlippageBps: number;
|
|
332
|
+
entrySpreadBps: number;
|
|
333
|
+
entrySpreadSlippageBps: number;
|
|
334
|
+
entryMarketImpactBps: number;
|
|
335
|
+
entryDelayRiskBps: number | null;
|
|
336
|
+
entrySlippageCost: number;
|
|
337
|
+
exitSlippagePrice: number | null;
|
|
338
|
+
exitSlippageBps: number | null;
|
|
339
|
+
exitBaseSlippageBps: number | null;
|
|
340
|
+
exitSpreadBps: number | null;
|
|
341
|
+
exitSpreadSlippageBps: number | null;
|
|
342
|
+
exitMarketImpactBps: number | null;
|
|
343
|
+
exitDelayRiskBps: number | null;
|
|
344
|
+
exitSlippageCost: number;
|
|
345
|
+
totalSlippageCost: number;
|
|
493
346
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
deploymentId?: string;
|
|
499
|
-
universe?: MarketUniverse;
|
|
347
|
+
interface TestClosedSignalResult {
|
|
348
|
+
signalId: string;
|
|
349
|
+
profit: number;
|
|
350
|
+
tradeResult?: TestTradeResult;
|
|
500
351
|
}
|
|
501
|
-
interface
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
352
|
+
interface TestConnectorContext {
|
|
353
|
+
userName?: string;
|
|
354
|
+
mlEnabled?: boolean;
|
|
355
|
+
aiEnabled?: boolean;
|
|
356
|
+
fastMode?: boolean;
|
|
357
|
+
instrument?: InstrumentDescriptor;
|
|
358
|
+
executionCostModel?: ExecutionCostModel;
|
|
359
|
+
fundingRates?: FundingRatePoint[];
|
|
506
360
|
}
|
|
507
|
-
type
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}) => Promise<TradingAccountRef | null>;
|
|
513
|
-
type ConnectorCachedKlineFactory = (options: {
|
|
514
|
-
provider: string;
|
|
515
|
-
request: Kline;
|
|
516
|
-
intervalToMinutes: (interval: Interval) => number | null;
|
|
517
|
-
limit?: number;
|
|
518
|
-
cacheFallbackWindow?: number;
|
|
519
|
-
}) => Kline;
|
|
520
|
-
interface ConnectorRuntime {
|
|
521
|
-
logger: ConnectorLogger;
|
|
522
|
-
resolveTradingAccount: ConnectorAccountResolver;
|
|
523
|
-
createCachedKline: ConnectorCachedKlineFactory;
|
|
361
|
+
type TestConnectorCreator = (connector: Connector, context?: TestConnectorContext) => TestConnector;
|
|
362
|
+
type ChartColor = string;
|
|
363
|
+
interface TestCompare {
|
|
364
|
+
testResult: TestResult;
|
|
365
|
+
color: ChartColor;
|
|
524
366
|
}
|
|
525
|
-
type
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
367
|
+
type TestCompareList = TestCompare[];
|
|
368
|
+
type OnChangeCompare = (testId: string) => void;
|
|
369
|
+
|
|
370
|
+
declare const RUNTIME_STRATEGY_RELEASE_SCHEMA: "tradejs-runtime-strategy-release/v2";
|
|
371
|
+
declare const RUNTIME_STRATEGY_DRAFT_SCHEMA: "tradejs-runtime-strategy-draft/v2";
|
|
372
|
+
type RuntimeStrategyControlState = 'active' | 'entries_paused';
|
|
373
|
+
/**
|
|
374
|
+
* An immutable strategy-owned runtime snapshot. Deployment/account bindings are
|
|
375
|
+
* intentionally not part of this record.
|
|
376
|
+
*/
|
|
377
|
+
interface RuntimeStrategyRelease {
|
|
378
|
+
schema: typeof RUNTIME_STRATEGY_RELEASE_SCHEMA;
|
|
379
|
+
strategyName: string;
|
|
380
|
+
releaseVersion: number;
|
|
381
|
+
config: StrategyConfig;
|
|
382
|
+
strategyPackage: string | null;
|
|
383
|
+
strategyPackageVersion: string | null;
|
|
384
|
+
runtimePackageVersion: string | null;
|
|
385
|
+
createdAt: number;
|
|
386
|
+
createdBy: string;
|
|
387
|
+
contentSha256: string;
|
|
530
388
|
}
|
|
531
|
-
interface
|
|
532
|
-
|
|
389
|
+
interface RuntimeStrategyDraft {
|
|
390
|
+
schema: typeof RUNTIME_STRATEGY_DRAFT_SCHEMA;
|
|
391
|
+
strategyName: string;
|
|
392
|
+
baseReleaseVersion: number | null;
|
|
393
|
+
config: StrategyConfig;
|
|
394
|
+
updatedAt: number;
|
|
395
|
+
updatedBy: string;
|
|
533
396
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
symbol: string;
|
|
539
|
-
qty: number;
|
|
540
|
-
entryPrice: number | null;
|
|
541
|
-
exitPrice: number | null;
|
|
542
|
-
closedPnl: number;
|
|
543
|
-
closedAt: number;
|
|
544
|
-
direction?: Direction;
|
|
545
|
-
entryTimestamp?: number;
|
|
546
|
-
orderId?: string;
|
|
547
|
-
orderLinkId?: string;
|
|
548
|
-
openFee?: number | null;
|
|
549
|
-
closeFee?: number | null;
|
|
550
|
-
fundingFee?: number | null;
|
|
551
|
-
totalFee?: number | null;
|
|
397
|
+
interface RuntimeStrategyReleaseRef {
|
|
398
|
+
strategyName: string;
|
|
399
|
+
releaseVersion: number;
|
|
400
|
+
controlState: RuntimeStrategyControlState;
|
|
552
401
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
exitTimestamp?: number | null;
|
|
565
|
-
closedPnl?: number | null;
|
|
566
|
-
openFee?: number | null;
|
|
567
|
-
closeFee?: number | null;
|
|
568
|
-
fundingFee?: number | null;
|
|
569
|
-
totalFee?: number | null;
|
|
402
|
+
type RuntimeStrategyControlEventAction = 'pause_entries' | 'resume';
|
|
403
|
+
interface RuntimeStrategyControlEvent {
|
|
404
|
+
eventId: string;
|
|
405
|
+
deploymentId: string;
|
|
406
|
+
strategyName: string;
|
|
407
|
+
releaseVersion: number;
|
|
408
|
+
action: RuntimeStrategyControlEventAction;
|
|
409
|
+
previousState: RuntimeStrategyControlState;
|
|
410
|
+
nextState: RuntimeStrategyControlState;
|
|
411
|
+
createdAt: number;
|
|
412
|
+
createdBy: string;
|
|
570
413
|
}
|
|
571
|
-
|
|
572
|
-
|
|
414
|
+
|
|
415
|
+
type MarketUniverse = 'crypto' | 'tradfi';
|
|
416
|
+
type AssetClass = 'crypto' | 'equity' | 'commodity' | 'forex';
|
|
417
|
+
type InstrumentKind = 'perpetual' | 'spot';
|
|
418
|
+
type InstrumentStatus = 'trading' | 'inactive' | 'unknown';
|
|
419
|
+
interface InstrumentDescriptor {
|
|
420
|
+
provider: string;
|
|
421
|
+
symbol: string;
|
|
422
|
+
kind: InstrumentKind;
|
|
423
|
+
assetClass: AssetClass;
|
|
424
|
+
universe: MarketUniverse;
|
|
425
|
+
status: InstrumentStatus;
|
|
426
|
+
baseAsset?: string;
|
|
427
|
+
quoteAsset?: string;
|
|
428
|
+
settleAsset?: string;
|
|
429
|
+
displayName?: string;
|
|
430
|
+
venueMetadata?: Record<string, unknown>;
|
|
431
|
+
}
|
|
432
|
+
interface ConnectorCapabilities {
|
|
433
|
+
supportedUniverses: readonly MarketUniverse[];
|
|
434
|
+
defaultUniverse: MarketUniverse;
|
|
435
|
+
}
|
|
436
|
+
interface InstrumentQuery {
|
|
437
|
+
universe?: MarketUniverse;
|
|
438
|
+
assetClasses?: readonly AssetClass[];
|
|
439
|
+
symbols?: readonly string[];
|
|
440
|
+
}
|
|
441
|
+
interface TickerQuery extends InstrumentQuery {
|
|
442
|
+
}
|
|
443
|
+
interface FundingRatePoint {
|
|
444
|
+
symbol: string;
|
|
445
|
+
timestamp: number;
|
|
446
|
+
rate: number;
|
|
447
|
+
}
|
|
448
|
+
interface FundingRateHistoryRequest {
|
|
449
|
+
symbol: string;
|
|
450
|
+
startTime?: number;
|
|
573
451
|
endTime: number;
|
|
574
|
-
symbol?: string;
|
|
575
452
|
limit?: number;
|
|
576
453
|
}
|
|
577
|
-
|
|
578
|
-
type GetEntryExecutions = (params: GetClosedPnlParams) => Promise<ExchangeEntryRecord[]>;
|
|
579
|
-
type PlaceOrder = (order: Order) => Promise<boolean>;
|
|
580
|
-
type ClosePosition = (order: Omit<Order, 'qty'>) => Promise<boolean>;
|
|
581
|
-
type SetTakeProfits = (params: {
|
|
582
|
-
symbol: string;
|
|
583
|
-
direction: Direction;
|
|
584
|
-
qty?: number;
|
|
585
|
-
takeProfits: Tp[];
|
|
586
|
-
}) => Promise<boolean>;
|
|
587
|
-
type SetStopLoss = (params: {
|
|
454
|
+
interface TradingFeeRate {
|
|
588
455
|
symbol: string;
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
type GetTickers = (query?: TickerQuery) => Promise<Ticker[]>;
|
|
594
|
-
type ListInstruments = (query?: InstrumentQuery) => Promise<InstrumentDescriptor[]>;
|
|
595
|
-
type GetFundingRateHistory = (request: FundingRateHistoryRequest) => Promise<FundingRatePoint[]>;
|
|
596
|
-
type GetTradingFeeRate = (symbol: string) => Promise<TradingFeeRate | null>;
|
|
597
|
-
type GetTopOfBookTicker = (symbol: string) => Promise<TopOfBookTicker | null>;
|
|
598
|
-
type GetAggTrades = (request: AggTradesRequest) => Promise<AggTrade[]>;
|
|
599
|
-
type GetOrderBookDepth = (request: OrderBookDepthRequest) => Promise<OrderBookDepth | null>;
|
|
600
|
-
interface Connector {
|
|
601
|
-
capabilities: ConnectorCapabilities;
|
|
602
|
-
universe: MarketUniverse;
|
|
603
|
-
accountId?: string;
|
|
604
|
-
deploymentId?: string;
|
|
605
|
-
listInstruments: ListInstruments;
|
|
606
|
-
kline: Kline;
|
|
607
|
-
getState: () => Promise<object>;
|
|
608
|
-
setState: (state: object) => Promise<void>;
|
|
609
|
-
getPosition: GetPosition;
|
|
610
|
-
getPositions: GetPositions;
|
|
611
|
-
getOpenPositionPnl?: GetOpenPositionPnl;
|
|
612
|
-
getClosedPnl?: GetClosedPnl;
|
|
613
|
-
getEntryExecutions?: GetEntryExecutions;
|
|
614
|
-
placeOrder: PlaceOrder;
|
|
615
|
-
setTakeProfits: SetTakeProfits;
|
|
616
|
-
setStopLoss: SetStopLoss;
|
|
617
|
-
closePosition: ClosePosition;
|
|
618
|
-
getTickers: GetTickers;
|
|
619
|
-
getFundingRateHistory?: GetFundingRateHistory;
|
|
620
|
-
getTradingFeeRate?: GetTradingFeeRate;
|
|
621
|
-
getTopOfBookTicker?: GetTopOfBookTicker;
|
|
622
|
-
getAggTrades?: GetAggTrades;
|
|
623
|
-
getOrderBookDepth?: GetOrderBookDepth;
|
|
456
|
+
makerRate: number;
|
|
457
|
+
takerRate: number;
|
|
458
|
+
source: 'exchange-account' | 'connector-default' | 'fallback';
|
|
459
|
+
capturedAt: number;
|
|
624
460
|
}
|
|
625
|
-
interface
|
|
461
|
+
interface TradingAccountRef {
|
|
626
462
|
id: string;
|
|
627
463
|
label: string;
|
|
464
|
+
provider: string;
|
|
628
465
|
enabled: boolean;
|
|
629
|
-
|
|
466
|
+
isDefault?: boolean;
|
|
467
|
+
universes: MarketUniverse[];
|
|
468
|
+
environment: 'mainnet' | 'testnet';
|
|
469
|
+
apiKey?: string;
|
|
470
|
+
apiSecret?: string;
|
|
471
|
+
uid?: string;
|
|
472
|
+
readOnly?: boolean;
|
|
473
|
+
lastCheckedAt?: number;
|
|
474
|
+
lastError?: string;
|
|
630
475
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
476
|
+
interface RuntimeDeploymentStrategy {
|
|
477
|
+
strategyName: string;
|
|
478
|
+
/** Immutable per-strategy release selected for this deployment. */
|
|
479
|
+
releaseVersion?: number;
|
|
480
|
+
/** New entries may be paused while exit/position management keeps running. */
|
|
481
|
+
controlState?: RuntimeStrategyControlState;
|
|
482
|
+
/** @deprecated Legacy runtime identity. Use releaseVersion. */
|
|
483
|
+
policyProfileId?: string;
|
|
484
|
+
/** @deprecated Legacy evidence identity. Use releaseVersion. */
|
|
485
|
+
releaseCompositionId?: string;
|
|
486
|
+
/** @deprecated Legacy all-or-nothing switch. Use controlState. */
|
|
487
|
+
enabled?: boolean;
|
|
488
|
+
/** @deprecated Runtime config belongs to an immutable strategy release. */
|
|
489
|
+
config?: Record<string, unknown>;
|
|
490
|
+
}
|
|
491
|
+
interface RuntimeDeployment {
|
|
492
|
+
id: string;
|
|
493
|
+
label: string;
|
|
494
|
+
connectorName: string;
|
|
495
|
+
provider: string;
|
|
496
|
+
accountId: string;
|
|
497
|
+
universe: MarketUniverse;
|
|
498
|
+
interval: string;
|
|
499
|
+
enabled: boolean;
|
|
500
|
+
strategies: RuntimeDeploymentStrategy[];
|
|
501
|
+
assetClasses?: AssetClass[];
|
|
502
|
+
tickers?: string[];
|
|
503
|
+
}
|
|
504
|
+
interface RuntimeDeploymentHeartbeat {
|
|
505
|
+
deploymentId: string;
|
|
506
|
+
status: 'running' | 'stopped' | 'error';
|
|
507
|
+
pid: number;
|
|
508
|
+
startedAt: number;
|
|
509
|
+
lastCycleAt: number;
|
|
510
|
+
lastError?: string;
|
|
511
|
+
}
|
|
512
|
+
type MarketDataCapability = 'target.mtf' | 'target.funding' | 'target.openInterest' | 'crypto.btcReference' | 'crypto.ethReference' | 'crypto.derivatives' | 'crypto.marketBreadth' | 'crypto.crossVenueSpread' | 'crypto.coinMarketCap';
|
|
513
|
+
declare const DEFAULT_MARKET_UNIVERSE: MarketUniverse;
|
|
514
|
+
declare const isMarketUniverse: (value: unknown) => value is MarketUniverse;
|
|
515
|
+
declare const resolveConnectorUniverse: (capabilities: ConnectorCapabilities, requested?: unknown) => MarketUniverse;
|
|
516
|
+
|
|
517
|
+
type Interval = '1' | '3' | '5' | '15' | '30' | '60' | '120' | '240' | '360' | '720' | 'D' | 'W' | 'M';
|
|
518
|
+
type Provider = 'bybit' | 'binance' | 'coinbase';
|
|
519
|
+
interface Candle {
|
|
520
|
+
open: number;
|
|
521
|
+
high: number;
|
|
522
|
+
low: number;
|
|
523
|
+
close: number;
|
|
524
|
+
volume: number;
|
|
525
|
+
timestamp: number;
|
|
526
|
+
turnover: number;
|
|
527
|
+
trades?: number | null;
|
|
528
|
+
takerBuyBaseVolume?: number | null;
|
|
529
|
+
takerBuyQuoteVolume?: number | null;
|
|
530
|
+
takerSellBaseVolume?: number | null;
|
|
531
|
+
takerSellQuoteVolume?: number | null;
|
|
532
|
+
}
|
|
533
|
+
interface KlineChartItem extends Candle {
|
|
534
|
+
dt: string;
|
|
535
|
+
[key: string]: unknown;
|
|
536
|
+
}
|
|
537
|
+
type KlineChartData = Array<KlineChartItem>;
|
|
538
|
+
interface MarketKlineEvent {
|
|
539
|
+
provider: Provider;
|
|
540
|
+
universe: MarketUniverse;
|
|
635
541
|
symbol: string;
|
|
636
542
|
interval: Interval;
|
|
637
|
-
|
|
638
|
-
|
|
543
|
+
candle: KlineChartItem;
|
|
544
|
+
confirm: boolean;
|
|
545
|
+
receivedAt: number;
|
|
639
546
|
}
|
|
640
|
-
interface
|
|
547
|
+
interface KlineRequest {
|
|
641
548
|
symbol: string;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
lowPrice24h: number;
|
|
649
|
-
prevPrice1h: number;
|
|
650
|
-
openInterest: number;
|
|
651
|
-
openInterestValue: number;
|
|
652
|
-
turnover24h: number;
|
|
653
|
-
volume24h: number;
|
|
654
|
-
fundingRate: number;
|
|
655
|
-
nextFundingTime: number;
|
|
656
|
-
predictedDeliveryPrice: string;
|
|
657
|
-
basisRate: string;
|
|
658
|
-
deliveryFeeRate: string;
|
|
659
|
-
deliveryTime: number;
|
|
660
|
-
ask1Size: number;
|
|
661
|
-
bid1Price: number;
|
|
662
|
-
ask1Price: number;
|
|
663
|
-
bid1Size: number;
|
|
664
|
-
basis: string;
|
|
665
|
-
preOpenPrice: string;
|
|
666
|
-
preQty: string;
|
|
549
|
+
interval: Interval;
|
|
550
|
+
start?: number;
|
|
551
|
+
end: number;
|
|
552
|
+
silent?: boolean;
|
|
553
|
+
cacheOnly?: boolean;
|
|
554
|
+
warmOnly?: boolean;
|
|
667
555
|
}
|
|
668
|
-
|
|
556
|
+
type DerivativesInterval = '15m' | '1h';
|
|
557
|
+
type DerivativesRow = {
|
|
669
558
|
symbol: string;
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
559
|
+
interval: DerivativesInterval;
|
|
560
|
+
ts: Date;
|
|
561
|
+
openInterest?: number | null;
|
|
562
|
+
fundingRate?: number | null;
|
|
563
|
+
liqLong?: number | null;
|
|
564
|
+
liqShort?: number | null;
|
|
565
|
+
liqTotal?: number | null;
|
|
566
|
+
source?: string | null;
|
|
567
|
+
};
|
|
568
|
+
type DerivativesPressure = 'neutral' | 'crowded_long' | 'crowded_short' | 'long_flush' | 'short_flush';
|
|
569
|
+
type DerivativesPriceOiDivergenceType = 'price_up_oi_up' | 'price_up_oi_down' | 'price_down_oi_up' | 'price_down_oi_down' | 'flat_or_mixed' | 'unknown';
|
|
570
|
+
type DerivativesContextRiskFlag = 'missing_derivatives' | 'stale_derivatives' | 'crowded_long' | 'crowded_short' | 'oi_falling' | 'oi_not_confirming' | 'long_liquidation_spike' | 'short_liquidation_spike';
|
|
571
|
+
interface DerivativesIntervalContext {
|
|
572
|
+
interval: DerivativesInterval;
|
|
573
|
+
asOfTs: number | null;
|
|
574
|
+
stale: boolean;
|
|
575
|
+
points: number;
|
|
576
|
+
openInterest: number | null;
|
|
577
|
+
oiChangePct1h: number | null;
|
|
578
|
+
oiChangePct4h: number | null;
|
|
579
|
+
oiChangePct24h: number | null;
|
|
580
|
+
fundingRate: number | null;
|
|
581
|
+
fundingZScore: number | null;
|
|
582
|
+
liqLong: number | null;
|
|
583
|
+
liqShort: number | null;
|
|
584
|
+
liqTotal: number | null;
|
|
585
|
+
liqImbalance: number | null;
|
|
586
|
+
liqSpikeRatio: number | null;
|
|
675
587
|
}
|
|
676
|
-
interface
|
|
588
|
+
interface DerivativesSymbolContext {
|
|
589
|
+
source: 'coinalyze';
|
|
677
590
|
symbol: string;
|
|
678
|
-
startTime: number;
|
|
679
|
-
endTime: number;
|
|
680
|
-
limit?: number;
|
|
681
|
-
}
|
|
682
|
-
interface AggTrade {
|
|
683
|
-
aggregateTradeId: number;
|
|
684
|
-
price: number;
|
|
685
|
-
quantity: number;
|
|
686
|
-
firstTradeId: number;
|
|
687
|
-
lastTradeId: number;
|
|
688
591
|
timestamp: number;
|
|
689
|
-
|
|
592
|
+
intervals: Partial<Record<DerivativesInterval, DerivativesIntervalContext>>;
|
|
593
|
+
summary: {
|
|
594
|
+
pressure: DerivativesPressure;
|
|
595
|
+
directionAligned: boolean | null;
|
|
596
|
+
riskFlags: DerivativesContextRiskFlag[];
|
|
597
|
+
fundingChange1h?: number | null;
|
|
598
|
+
oiAcceleration?: number | null;
|
|
599
|
+
priceOiDivergenceType?: DerivativesPriceOiDivergenceType;
|
|
600
|
+
crowdingPersistenceBars?: number | null;
|
|
601
|
+
};
|
|
690
602
|
}
|
|
691
|
-
interface
|
|
603
|
+
interface DerivativesTargetDerivedContext {
|
|
604
|
+
available: boolean;
|
|
605
|
+
stale: boolean | null;
|
|
606
|
+
sourceSymbol: string;
|
|
607
|
+
referenceSymbol: string | null;
|
|
608
|
+
directionAligned: boolean | null;
|
|
609
|
+
referenceDirectionAligned: boolean | null;
|
|
610
|
+
pressure: DerivativesPressure | null;
|
|
611
|
+
referencePressure: DerivativesPressure | null;
|
|
612
|
+
riskFlags: DerivativesContextRiskFlag[];
|
|
613
|
+
oiChangePct1h: number | null;
|
|
614
|
+
oiAcceleration: number | null;
|
|
615
|
+
fundingRate: number | null;
|
|
616
|
+
fundingZScore: number | null;
|
|
617
|
+
fundingChange1h: number | null;
|
|
618
|
+
liqSpikeRatio: number | null;
|
|
619
|
+
liqImbalance: number | null;
|
|
620
|
+
targetVsPrimaryOiChangePct1hDelta: number | null;
|
|
621
|
+
targetVsPrimaryFundingZScoreDelta: number | null;
|
|
622
|
+
targetReferenceConflict: boolean | null;
|
|
623
|
+
}
|
|
624
|
+
interface DerivativesContext extends DerivativesSymbolContext {
|
|
625
|
+
targetSymbol?: string;
|
|
626
|
+
primaryReferenceSymbol?: string;
|
|
627
|
+
secondaryReferenceSymbol?: string;
|
|
628
|
+
referenceSymbols?: string[];
|
|
629
|
+
referenceContexts?: Record<string, DerivativesSymbolContext>;
|
|
630
|
+
targetContext?: DerivativesSymbolContext;
|
|
631
|
+
targetDerived?: DerivativesTargetDerivedContext;
|
|
632
|
+
}
|
|
633
|
+
type SpreadRow = {
|
|
634
|
+
symbol: string;
|
|
635
|
+
interval: DerivativesInterval;
|
|
636
|
+
ts: Date;
|
|
637
|
+
binancePrice?: number | null;
|
|
638
|
+
coinbasePrice?: number | null;
|
|
639
|
+
spread?: number | null;
|
|
640
|
+
source?: string | null;
|
|
641
|
+
};
|
|
642
|
+
type MarketFeatureInterval = '1m' | '5m' | '15m' | '1h';
|
|
643
|
+
type MarketGlobalContextSource = 'coinmarketcap_global';
|
|
644
|
+
type MarketGlobalContextRow = {
|
|
645
|
+
source: MarketGlobalContextSource;
|
|
646
|
+
ts: Date;
|
|
647
|
+
updatedAt?: Date | null;
|
|
648
|
+
activeCryptocurrencies?: number | null;
|
|
649
|
+
activeExchanges?: number | null;
|
|
650
|
+
activeMarketPairs?: number | null;
|
|
651
|
+
markets?: number | null;
|
|
652
|
+
totalMarketCapUsd?: number | null;
|
|
653
|
+
totalVolumeUsd?: number | null;
|
|
654
|
+
totalVolumeReportedUsd?: number | null;
|
|
655
|
+
btcDominancePct?: number | null;
|
|
656
|
+
ethDominancePct?: number | null;
|
|
657
|
+
altMarketCapUsd?: number | null;
|
|
658
|
+
altVolumeUsd?: number | null;
|
|
659
|
+
altVolumeReportedUsd?: number | null;
|
|
660
|
+
btcToAltMarketCapRatio?: number | null;
|
|
661
|
+
marketCapChangePct24hUsd?: number | null;
|
|
662
|
+
};
|
|
663
|
+
type MarketReferenceAssetContextRow = {
|
|
664
|
+
source: 'coinmarketcap_reference_asset';
|
|
665
|
+
symbol: 'BTCUSDT' | 'ETHUSDT' | string;
|
|
666
|
+
cmcId: number;
|
|
667
|
+
interval: '1d';
|
|
668
|
+
ts: Date;
|
|
669
|
+
openUsd?: number | null;
|
|
670
|
+
highUsd?: number | null;
|
|
671
|
+
lowUsd?: number | null;
|
|
672
|
+
closeUsd?: number | null;
|
|
673
|
+
volumeUsd?: number | null;
|
|
674
|
+
marketCapUsd?: number | null;
|
|
675
|
+
};
|
|
676
|
+
type CmcExchangeLiquidityRegime = 'expanding' | 'contracting' | 'binance_led' | 'concentrated' | 'balanced' | 'thin' | 'unknown';
|
|
677
|
+
type MarketCmcExchangeLiquidityContextRow = {
|
|
678
|
+
source: 'coinmarketcap_exchange_liquidity';
|
|
679
|
+
interval: '1d' | '1h';
|
|
680
|
+
ts: Date;
|
|
681
|
+
exchangesCount: number;
|
|
682
|
+
totalVolumeUsd?: number | null;
|
|
683
|
+
binanceVolumeUsd?: number | null;
|
|
684
|
+
binanceVolumeShare?: number | null;
|
|
685
|
+
topExchangeVolumeShare?: number | null;
|
|
686
|
+
liquidityRegime?: CmcExchangeLiquidityRegime | null;
|
|
687
|
+
};
|
|
688
|
+
type CmcFearGreedClassification = 'Extreme Fear' | 'Fear' | 'Neutral' | 'Greed' | 'Extreme Greed' | 'Unknown';
|
|
689
|
+
type CmcFearGreedRegime = 'capitulation' | 'risk_off' | 'neutral' | 'risk_on' | 'euphoric' | 'unknown';
|
|
690
|
+
type MarketCmcFearGreedContextRow = {
|
|
691
|
+
source: 'coinmarketcap_fear_greed';
|
|
692
|
+
interval: '1d';
|
|
693
|
+
ts: Date;
|
|
694
|
+
value: number;
|
|
695
|
+
classification: CmcFearGreedClassification;
|
|
696
|
+
sentimentRegime: CmcFearGreedRegime;
|
|
697
|
+
};
|
|
698
|
+
type MarketCmcIndexSlug = 'cmc100' | 'cmc20';
|
|
699
|
+
type MarketCmcIndexConstituent = {
|
|
700
|
+
id?: number | null;
|
|
701
|
+
name?: string | null;
|
|
702
|
+
symbol?: string | null;
|
|
703
|
+
url?: string | null;
|
|
704
|
+
weightPct?: number | null;
|
|
705
|
+
priceUsd?: number | null;
|
|
706
|
+
units?: number | null;
|
|
707
|
+
};
|
|
708
|
+
type MarketCmcIndexContextRow = {
|
|
709
|
+
source: 'coinmarketcap_index';
|
|
710
|
+
indexSlug: MarketCmcIndexSlug;
|
|
711
|
+
interval: '1d';
|
|
712
|
+
ts: Date;
|
|
713
|
+
value: number;
|
|
714
|
+
constituentsCount?: number | null;
|
|
715
|
+
topConstituentSymbol?: string | null;
|
|
716
|
+
topConstituentWeightPct?: number | null;
|
|
717
|
+
constituents?: MarketCmcIndexConstituent[] | null;
|
|
718
|
+
};
|
|
719
|
+
type MarketBreadthRow = {
|
|
720
|
+
universe: string;
|
|
721
|
+
interval: MarketFeatureInterval;
|
|
722
|
+
ts: Date;
|
|
723
|
+
symbolsCount: number;
|
|
724
|
+
advancers: number;
|
|
725
|
+
decliners: number;
|
|
726
|
+
unchanged: number;
|
|
727
|
+
advanceDeclineRatio?: number | null;
|
|
728
|
+
pctAboveMa20?: number | null;
|
|
729
|
+
pctAboveMa50?: number | null;
|
|
730
|
+
equalWeightedReturn?: number | null;
|
|
731
|
+
volumeWeightedReturn?: number | null;
|
|
732
|
+
dispersion?: number | null;
|
|
733
|
+
btcReturn1h?: number | null;
|
|
734
|
+
btcReturn4h?: number | null;
|
|
735
|
+
btcReturn24h?: number | null;
|
|
736
|
+
altBasketReturn1h?: number | null;
|
|
737
|
+
altBasketReturn4h?: number | null;
|
|
738
|
+
altBasketReturn24h?: number | null;
|
|
739
|
+
btcVsAltReturn1h?: number | null;
|
|
740
|
+
btcVsAltReturn4h?: number | null;
|
|
741
|
+
btcVsAltReturn24h?: number | null;
|
|
742
|
+
btcTurnoverShare1h?: number | null;
|
|
743
|
+
btcTurnoverShare24h?: number | null;
|
|
744
|
+
btcTurnoverShareChange24h?: number | null;
|
|
745
|
+
altVolToBtcVol24h?: number | null;
|
|
746
|
+
altDispersion24h?: number | null;
|
|
747
|
+
btcAltRegime?: 'btc_lead' | 'alt_lead' | 'risk_off' | 'risk_on' | 'mixed' | 'neutral' | 'unknown' | null;
|
|
748
|
+
source?: string | null;
|
|
749
|
+
};
|
|
750
|
+
type MarketTradeFlowRow = {
|
|
751
|
+
symbol: string;
|
|
752
|
+
interval: MarketFeatureInterval;
|
|
753
|
+
ts: Date;
|
|
754
|
+
trades: number;
|
|
755
|
+
buyBaseVolume?: number | null;
|
|
756
|
+
sellBaseVolume?: number | null;
|
|
757
|
+
buyQuoteVolume?: number | null;
|
|
758
|
+
sellQuoteVolume?: number | null;
|
|
759
|
+
netBaseDelta?: number | null;
|
|
760
|
+
netQuoteDelta?: number | null;
|
|
761
|
+
buyPressurePct?: number | null;
|
|
762
|
+
source?: string | null;
|
|
763
|
+
};
|
|
764
|
+
type HyperliquidWhaleTradeEventRow = {
|
|
765
|
+
symbol: string;
|
|
766
|
+
ts: Date;
|
|
767
|
+
tid: string;
|
|
768
|
+
price: number;
|
|
769
|
+
size: number;
|
|
770
|
+
notionalUsd: number;
|
|
771
|
+
buyerAddress?: string | null;
|
|
772
|
+
sellerAddress?: string | null;
|
|
773
|
+
buyerTracked: boolean;
|
|
774
|
+
sellerTracked: boolean;
|
|
775
|
+
buyerStartPosition?: number | null;
|
|
776
|
+
buyerEndPosition?: number | null;
|
|
777
|
+
buyerPositionAction?: HyperliquidPositionAction | null;
|
|
778
|
+
buyerClosedPnl?: number | null;
|
|
779
|
+
buyerLiquidation?: boolean | null;
|
|
780
|
+
sellerStartPosition?: number | null;
|
|
781
|
+
sellerEndPosition?: number | null;
|
|
782
|
+
sellerPositionAction?: HyperliquidPositionAction | null;
|
|
783
|
+
sellerClosedPnl?: number | null;
|
|
784
|
+
sellerLiquidation?: boolean | null;
|
|
785
|
+
universeFingerprint: string;
|
|
786
|
+
whaleRegistryFingerprint: string;
|
|
787
|
+
source?: string | null;
|
|
788
|
+
};
|
|
789
|
+
type HyperliquidPositionAction = 'open' | 'increase' | 'reduce' | 'close' | 'flip';
|
|
790
|
+
type HyperliquidWhaleFlowRow = {
|
|
692
791
|
symbol: string;
|
|
693
|
-
|
|
792
|
+
interval: '1m';
|
|
793
|
+
ts: Date;
|
|
794
|
+
trades: number;
|
|
795
|
+
whaleSides: number;
|
|
796
|
+
uniqueWhales: number;
|
|
797
|
+
whaleAddresses?: string[];
|
|
798
|
+
buyNotionalUsd: number;
|
|
799
|
+
sellNotionalUsd: number;
|
|
800
|
+
netNotionalUsd: number;
|
|
801
|
+
buySharePct?: number | null;
|
|
802
|
+
positionAwareWhaleSides: number;
|
|
803
|
+
longEntryWhaleAddresses?: string[];
|
|
804
|
+
shortEntryWhaleAddresses?: string[];
|
|
805
|
+
longExitWhaleAddresses?: string[];
|
|
806
|
+
shortExitWhaleAddresses?: string[];
|
|
807
|
+
longEntryNotionalUsd: number;
|
|
808
|
+
shortEntryNotionalUsd: number;
|
|
809
|
+
longExitNotionalUsd: number;
|
|
810
|
+
shortExitNotionalUsd: number;
|
|
811
|
+
entryNetNotionalUsd: number;
|
|
812
|
+
entryLongSharePct?: number | null;
|
|
813
|
+
universeFingerprint: string;
|
|
814
|
+
whaleRegistryFingerprint: string;
|
|
815
|
+
source?: string | null;
|
|
816
|
+
};
|
|
817
|
+
declare const HYPERLIQUID_WHALE_DATA_MODEL_VERSION = 3;
|
|
818
|
+
type HyperliquidWhaleCoverageRow = {
|
|
819
|
+
ts: Date;
|
|
820
|
+
coveredWhales: number;
|
|
821
|
+
expectedWhales: number;
|
|
822
|
+
coveragePct: number;
|
|
823
|
+
dataModelVersion?: number;
|
|
824
|
+
universeFingerprint: string;
|
|
825
|
+
whaleRegistryFingerprint: string;
|
|
826
|
+
source?: string | null;
|
|
827
|
+
};
|
|
828
|
+
interface Tp {
|
|
829
|
+
price: number;
|
|
830
|
+
rate: number;
|
|
831
|
+
done?: boolean;
|
|
694
832
|
}
|
|
695
|
-
|
|
833
|
+
type Sl = number | null;
|
|
834
|
+
type Direction = 'LONG' | 'SHORT';
|
|
835
|
+
type Trend = 'BULL' | 'BEAR';
|
|
836
|
+
type OrderPositionIntent = 'open' | 'increase';
|
|
837
|
+
type Order = {
|
|
696
838
|
symbol: string;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
type TrendLineMode = 'lows' | 'highs';
|
|
703
|
-
type TrendLine = {
|
|
704
|
-
id: string;
|
|
705
|
-
mode: TrendLineMode;
|
|
706
|
-
distance: number;
|
|
707
|
-
touches: {
|
|
708
|
-
timestamp: number;
|
|
709
|
-
value: number;
|
|
710
|
-
}[];
|
|
711
|
-
points: {
|
|
712
|
-
timestamp: number;
|
|
713
|
-
value: number;
|
|
714
|
-
}[];
|
|
715
|
-
alpha?: number[];
|
|
716
|
-
};
|
|
717
|
-
interface StrategyFigurePoint {
|
|
839
|
+
isLimit?: boolean;
|
|
840
|
+
positionIntent?: OrderPositionIntent;
|
|
841
|
+
qty: number;
|
|
842
|
+
price: number;
|
|
718
843
|
timestamp: number;
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
interface StrategyFigureLine {
|
|
722
|
-
id?: string;
|
|
723
|
-
kind?: string;
|
|
724
|
-
points: StrategyFigurePoint[];
|
|
725
|
-
color?: string;
|
|
726
|
-
width?: number;
|
|
727
|
-
style?: 'solid' | 'dashed';
|
|
728
|
-
}
|
|
729
|
-
interface StrategyFigurePoints {
|
|
730
|
-
id?: string;
|
|
731
|
-
kind?: string;
|
|
732
|
-
points: StrategyFigurePoint[];
|
|
733
|
-
color?: string;
|
|
734
|
-
radius?: number;
|
|
735
|
-
}
|
|
736
|
-
interface StrategyFigureZone {
|
|
737
|
-
id?: string;
|
|
738
|
-
kind?: string;
|
|
739
|
-
start: StrategyFigurePoint;
|
|
740
|
-
end: StrategyFigurePoint;
|
|
741
|
-
color?: string;
|
|
742
|
-
borderColor?: string;
|
|
743
|
-
}
|
|
744
|
-
interface StrategyFigureAnnotation {
|
|
745
|
-
id?: string;
|
|
746
|
-
kind?: string;
|
|
747
|
-
point: StrategyFigurePoint;
|
|
748
|
-
title: string;
|
|
749
|
-
items: string[];
|
|
750
|
-
color?: string;
|
|
751
|
-
textColor?: string;
|
|
752
|
-
backgroundColor?: string;
|
|
753
|
-
}
|
|
754
|
-
interface StrategyEntryModelFigures {
|
|
755
|
-
lines?: StrategyFigureLine[];
|
|
756
|
-
points?: StrategyFigurePoints[];
|
|
757
|
-
zones?: StrategyFigureZone[];
|
|
758
|
-
annotations?: StrategyFigureAnnotation[];
|
|
759
|
-
}
|
|
760
|
-
interface TrendLineOptions {
|
|
761
|
-
mode: TrendLineMode;
|
|
762
|
-
maxLines?: number;
|
|
763
|
-
range?: number;
|
|
764
|
-
epsilon?: number;
|
|
765
|
-
epsilonOffset?: number;
|
|
766
|
-
epsilonMode?: 'static' | 'atr';
|
|
767
|
-
epsilonAtrPeriod?: number;
|
|
768
|
-
epsilonAtrMultiplier?: number;
|
|
769
|
-
epsilonOffsetAtrMultiplier?: number;
|
|
770
|
-
epsilonMin?: number;
|
|
771
|
-
epsilonMax?: number;
|
|
772
|
-
epsilonOffsetMin?: number;
|
|
773
|
-
epsilonOffsetMax?: number;
|
|
774
|
-
minTouches?: number;
|
|
775
|
-
minDistance?: number;
|
|
776
|
-
firstRange?: number;
|
|
777
|
-
offset?: number;
|
|
778
|
-
minTouchGap?: number;
|
|
779
|
-
maxTouchGap?: number;
|
|
780
|
-
capture?: boolean;
|
|
781
|
-
bestLines?: number;
|
|
782
|
-
maxDistance?: number;
|
|
783
|
-
}
|
|
784
|
-
interface Signal {
|
|
785
|
-
signalId: string;
|
|
844
|
+
direction: Direction;
|
|
845
|
+
leverage?: number;
|
|
786
846
|
orderId?: string;
|
|
847
|
+
signal?: Signal;
|
|
848
|
+
};
|
|
849
|
+
type Position = {
|
|
787
850
|
symbol: string;
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
universe?: MarketUniverse;
|
|
791
|
-
assetClass?: AssetClass;
|
|
792
|
-
accountId?: string;
|
|
793
|
-
deploymentId?: string;
|
|
794
|
-
policyProfileId?: string;
|
|
795
|
-
runtimeConfigId?: string;
|
|
796
|
-
runtimeLineage?: RuntimeLineage;
|
|
851
|
+
qty: number;
|
|
852
|
+
price: number;
|
|
797
853
|
direction: Direction;
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
probability: number;
|
|
808
|
-
threshold: number;
|
|
809
|
-
passed: boolean;
|
|
810
|
-
};
|
|
811
|
-
figures: {
|
|
812
|
-
trendLine?: TrendLine;
|
|
813
|
-
lines?: StrategyFigureLine[];
|
|
814
|
-
points?: StrategyFigurePoints[];
|
|
815
|
-
zones?: StrategyFigureZone[];
|
|
816
|
-
annotations?: StrategyFigureAnnotation[];
|
|
817
|
-
[key: string]: any;
|
|
818
|
-
};
|
|
819
|
-
prices: {
|
|
820
|
-
currentPrice: number;
|
|
821
|
-
takeProfitPrice: number;
|
|
822
|
-
stopLossPrice: number;
|
|
823
|
-
riskRatio: number;
|
|
824
|
-
};
|
|
825
|
-
indicators: Record<string, any>;
|
|
826
|
-
additionalIndicators?: Record<string, any>;
|
|
854
|
+
slPrice?: number;
|
|
855
|
+
tpPrice?: number;
|
|
856
|
+
};
|
|
857
|
+
interface PositionPnlSnapshot extends Position {
|
|
858
|
+
currentPrice: number;
|
|
859
|
+
unrealizedPnl: number;
|
|
860
|
+
takeProfitPrice?: number | null;
|
|
861
|
+
stopLossPrice?: number | null;
|
|
862
|
+
fundingFee?: number | null;
|
|
827
863
|
}
|
|
828
|
-
type
|
|
829
|
-
interface
|
|
830
|
-
evaluationId: string;
|
|
864
|
+
type OrderType = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT' | 'TAKE_PROFIT_LONG' | 'TAKE_PROFIT_SHORT' | 'STOP_LOSS_LONG' | 'STOP_LOSS_SHORT';
|
|
865
|
+
interface ConnectorConfig {
|
|
831
866
|
userName: string;
|
|
832
|
-
strategy: string;
|
|
833
|
-
universe?: MarketUniverse;
|
|
834
|
-
assetClass?: AssetClass;
|
|
835
867
|
accountId?: string;
|
|
836
868
|
deploymentId?: string;
|
|
837
|
-
|
|
838
|
-
runtimeConfigId?: string;
|
|
839
|
-
runtimeLineage?: RuntimeLineage;
|
|
840
|
-
symbol: string;
|
|
841
|
-
interval: Interval;
|
|
842
|
-
timestamp: number;
|
|
843
|
-
evaluatedAt: number;
|
|
844
|
-
status: RuntimeSignalEvaluationStatus;
|
|
845
|
-
reason?: string;
|
|
846
|
-
signalId?: string;
|
|
847
|
-
direction?: Direction;
|
|
848
|
-
orderStatus?: SignalOrderStatus;
|
|
849
|
-
orderSkipReason?: string;
|
|
850
|
-
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
851
|
-
ml?: Signal['ml'];
|
|
869
|
+
universe?: MarketUniverse;
|
|
852
870
|
}
|
|
853
|
-
interface
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
871
|
+
interface ConnectorLogger {
|
|
872
|
+
log: (level: string, message: string, ...meta: unknown[]) => unknown;
|
|
873
|
+
info: (message: string, ...meta: unknown[]) => unknown;
|
|
874
|
+
warn: (message: string, ...meta: unknown[]) => unknown;
|
|
875
|
+
error: (message: string, ...meta: unknown[]) => unknown;
|
|
876
|
+
}
|
|
877
|
+
type ConnectorAccountResolver = (params: {
|
|
878
|
+
userName: string;
|
|
879
|
+
accountId?: string;
|
|
880
|
+
provider: string;
|
|
881
|
+
universe?: MarketUniverse;
|
|
882
|
+
}) => Promise<TradingAccountRef | null>;
|
|
883
|
+
type ConnectorCachedKlineFactory = (options: {
|
|
884
|
+
provider: string;
|
|
885
|
+
request: Kline;
|
|
886
|
+
intervalToMinutes: (interval: Interval) => number | null;
|
|
887
|
+
limit?: number;
|
|
888
|
+
cacheFallbackWindow?: number;
|
|
889
|
+
}) => Kline;
|
|
890
|
+
interface ConnectorRuntime {
|
|
891
|
+
logger: ConnectorLogger;
|
|
892
|
+
resolveTradingAccount: ConnectorAccountResolver;
|
|
893
|
+
createCachedKline: ConnectorCachedKlineFactory;
|
|
872
894
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
toleranceMs?: number;
|
|
879
|
-
analysis: Partial<SignalAnalysis>;
|
|
895
|
+
type ConnectorCreator = (config: ConnectorConfig, runtime?: ConnectorRuntime) => Promise<Connector>;
|
|
896
|
+
interface ConnectorRegistryEntry {
|
|
897
|
+
name: string;
|
|
898
|
+
creator: ConnectorCreator;
|
|
899
|
+
providers?: string[];
|
|
880
900
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
schemaVersion: 1;
|
|
884
|
-
compositionId?: string | null;
|
|
885
|
-
gitSha: string | null;
|
|
886
|
-
gitDirty: boolean | null;
|
|
887
|
-
gateFingerprint: string;
|
|
888
|
-
configFingerprint: string;
|
|
889
|
-
contextFingerprint: string;
|
|
890
|
-
maxLossValue?: number | null;
|
|
901
|
+
interface ConnectorPluginDefinition {
|
|
902
|
+
connectorEntries: ConnectorRegistryEntry[];
|
|
891
903
|
}
|
|
892
|
-
type
|
|
893
|
-
type
|
|
894
|
-
type
|
|
895
|
-
|
|
896
|
-
interface RuntimeTradeRecord {
|
|
897
|
-
orderId: string;
|
|
898
|
-
signalId?: string;
|
|
899
|
-
runtimeLineage?: RuntimeLineage;
|
|
900
|
-
strategy: string;
|
|
901
|
-
universe?: MarketUniverse;
|
|
902
|
-
assetClass?: AssetClass;
|
|
903
|
-
accountId?: string;
|
|
904
|
-
deploymentId?: string;
|
|
905
|
-
policyProfileId?: string;
|
|
906
|
-
runtimeConfigId?: string;
|
|
904
|
+
type GetPosition = (symbol: string) => Promise<Position | null>;
|
|
905
|
+
type GetPositions = () => Promise<Position[]>;
|
|
906
|
+
type GetOpenPositionPnl = () => Promise<PositionPnlSnapshot[]>;
|
|
907
|
+
interface ClosedPnlRecord {
|
|
907
908
|
symbol: string;
|
|
908
|
-
interval?: Interval;
|
|
909
|
-
direction: Direction;
|
|
910
909
|
qty: number;
|
|
911
|
-
entryPrice: number;
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
signalClosePrice?: number | null;
|
|
920
|
-
arrivalSnapshotTime?: number | null;
|
|
921
|
-
arrivalSource?: string | null;
|
|
922
|
-
arrivalMid?: number | null;
|
|
923
|
-
bid?: number | null;
|
|
924
|
-
ask?: number | null;
|
|
925
|
-
spreadBps?: number | null;
|
|
926
|
-
orderSubmitTime?: number | null;
|
|
927
|
-
orderAckTime?: number | null;
|
|
928
|
-
fillAvgPrice?: number | null;
|
|
929
|
-
fillSource?: RuntimeTradeFillSource | null;
|
|
930
|
-
fillTime?: number | null;
|
|
931
|
-
telemetryQuality?: RuntimeTradeTelemetryQuality | null;
|
|
932
|
-
fee?: number | null;
|
|
933
|
-
status: RuntimeTradeStatus;
|
|
934
|
-
currentPrice?: number | null;
|
|
935
|
-
currentPnl?: number | null;
|
|
936
|
-
closedPnl?: number | null;
|
|
937
|
-
exitPrice?: number | null;
|
|
938
|
-
actualExitPrice?: number | null;
|
|
939
|
-
exitTimestamp?: number | null;
|
|
940
|
-
exitType?: RuntimeTradeExitType | null;
|
|
910
|
+
entryPrice: number | null;
|
|
911
|
+
exitPrice: number | null;
|
|
912
|
+
closedPnl: number;
|
|
913
|
+
closedAt: number;
|
|
914
|
+
direction?: Direction;
|
|
915
|
+
entryTimestamp?: number;
|
|
916
|
+
orderId?: string;
|
|
917
|
+
orderLinkId?: string;
|
|
941
918
|
openFee?: number | null;
|
|
942
919
|
closeFee?: number | null;
|
|
943
920
|
fundingFee?: number | null;
|
|
944
921
|
totalFee?: number | null;
|
|
945
|
-
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
946
|
-
lastSyncedAt?: number;
|
|
947
922
|
}
|
|
948
|
-
interface
|
|
949
|
-
userName?: string;
|
|
950
|
-
strategy: string;
|
|
951
|
-
openedByStrategy: string;
|
|
923
|
+
interface ExchangeEntryRecord {
|
|
952
924
|
symbol: string;
|
|
953
|
-
direction: Direction;
|
|
954
|
-
code: string;
|
|
955
|
-
orderId: string;
|
|
956
|
-
signalId?: string;
|
|
957
925
|
qty: number;
|
|
958
|
-
entryPrice: number;
|
|
926
|
+
entryPrice: number | null;
|
|
959
927
|
entryTimestamp: number;
|
|
928
|
+
direction: Direction;
|
|
929
|
+
orderId?: string;
|
|
930
|
+
orderLinkId?: string;
|
|
931
|
+
takeProfitPrice?: number | null;
|
|
932
|
+
stopLossPrice?: number | null;
|
|
960
933
|
exitPrice?: number | null;
|
|
961
934
|
exitTimestamp?: number | null;
|
|
962
935
|
closedPnl?: number | null;
|
|
963
|
-
|
|
936
|
+
openFee?: number | null;
|
|
937
|
+
closeFee?: number | null;
|
|
938
|
+
fundingFee?: number | null;
|
|
939
|
+
totalFee?: number | null;
|
|
964
940
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
941
|
+
interface GetClosedPnlParams {
|
|
942
|
+
startTime: number;
|
|
943
|
+
endTime: number;
|
|
944
|
+
symbol?: string;
|
|
945
|
+
limit?: number;
|
|
946
|
+
}
|
|
947
|
+
type GetClosedPnl = (params: GetClosedPnlParams) => Promise<ClosedPnlRecord[]>;
|
|
948
|
+
type GetEntryExecutions = (params: GetClosedPnlParams) => Promise<ExchangeEntryRecord[]>;
|
|
949
|
+
type PlaceOrder = (order: Order) => Promise<boolean>;
|
|
950
|
+
type ClosePosition = (order: Omit<Order, 'qty'>) => Promise<boolean>;
|
|
951
|
+
type SetTakeProfits = (params: {
|
|
952
|
+
symbol: string;
|
|
953
|
+
direction: Direction;
|
|
954
|
+
qty?: number;
|
|
955
|
+
takeProfits: Tp[];
|
|
956
|
+
}) => Promise<boolean>;
|
|
957
|
+
type SetStopLoss = (params: {
|
|
958
|
+
symbol: string;
|
|
959
|
+
direction: Direction;
|
|
960
|
+
stopLossPrice: Sl;
|
|
961
|
+
}) => Promise<boolean>;
|
|
962
|
+
type Kline = (options: KlineRequest) => Promise<KlineChartData>;
|
|
963
|
+
type GetTickers = (query?: TickerQuery) => Promise<Ticker[]>;
|
|
964
|
+
type ListInstruments = (query?: InstrumentQuery) => Promise<InstrumentDescriptor[]>;
|
|
965
|
+
type GetFundingRateHistory = (request: FundingRateHistoryRequest) => Promise<FundingRatePoint[]>;
|
|
966
|
+
type GetTradingFeeRate = (symbol: string) => Promise<TradingFeeRate | null>;
|
|
967
|
+
type GetTopOfBookTicker = (symbol: string) => Promise<TopOfBookTicker | null>;
|
|
968
|
+
type GetAggTrades = (request: AggTradesRequest) => Promise<AggTrade[]>;
|
|
969
|
+
type GetOrderBookDepth = (request: OrderBookDepthRequest) => Promise<OrderBookDepth | null>;
|
|
970
|
+
interface Connector {
|
|
971
|
+
capabilities: ConnectorCapabilities;
|
|
972
|
+
universe: MarketUniverse;
|
|
973
|
+
accountId?: string;
|
|
974
|
+
deploymentId?: string;
|
|
975
|
+
listInstruments: ListInstruments;
|
|
976
|
+
kline: Kline;
|
|
977
|
+
getState: () => Promise<object>;
|
|
978
|
+
setState: (state: object) => Promise<void>;
|
|
979
|
+
getPosition: GetPosition;
|
|
980
|
+
getPositions: GetPositions;
|
|
981
|
+
getOpenPositionPnl?: GetOpenPositionPnl;
|
|
982
|
+
getClosedPnl?: GetClosedPnl;
|
|
983
|
+
getEntryExecutions?: GetEntryExecutions;
|
|
984
|
+
placeOrder: PlaceOrder;
|
|
985
|
+
setTakeProfits: SetTakeProfits;
|
|
986
|
+
setStopLoss: SetStopLoss;
|
|
987
|
+
closePosition: ClosePosition;
|
|
988
|
+
getTickers: GetTickers;
|
|
989
|
+
getFundingRateHistory?: GetFundingRateHistory;
|
|
990
|
+
getTradingFeeRate?: GetTradingFeeRate;
|
|
991
|
+
getTopOfBookTicker?: GetTopOfBookTicker;
|
|
992
|
+
getAggTrades?: GetAggTrades;
|
|
993
|
+
getOrderBookDepth?: GetOrderBookDepth;
|
|
994
|
+
}
|
|
995
|
+
interface Indicator {
|
|
996
|
+
id: string;
|
|
997
|
+
label: string;
|
|
998
|
+
enabled: boolean;
|
|
999
|
+
periods?: Array<number>;
|
|
1000
|
+
}
|
|
1001
|
+
type Indicators = Indicator[];
|
|
1002
|
+
interface Filters {
|
|
1003
|
+
provider?: Provider;
|
|
1004
|
+
universe?: MarketUniverse;
|
|
1005
|
+
symbol: string;
|
|
1006
|
+
interval: Interval;
|
|
1007
|
+
start: number;
|
|
1008
|
+
end: number;
|
|
1009
|
+
}
|
|
1010
|
+
interface Ticker {
|
|
1011
|
+
symbol: string;
|
|
1012
|
+
lastPrice: number;
|
|
1013
|
+
indexPrice: number;
|
|
1014
|
+
markPrice: number;
|
|
1015
|
+
prevPrice24h: number;
|
|
1016
|
+
price24hPcnt: number;
|
|
1017
|
+
highPrice24h: number;
|
|
1018
|
+
lowPrice24h: number;
|
|
1019
|
+
prevPrice1h: number;
|
|
1020
|
+
openInterest: number;
|
|
1021
|
+
openInterestValue: number;
|
|
1022
|
+
turnover24h: number;
|
|
1023
|
+
volume24h: number;
|
|
1024
|
+
fundingRate: number;
|
|
1025
|
+
nextFundingTime: number;
|
|
1026
|
+
predictedDeliveryPrice: string;
|
|
1027
|
+
basisRate: string;
|
|
1028
|
+
deliveryFeeRate: string;
|
|
1029
|
+
deliveryTime: number;
|
|
1030
|
+
ask1Size: number;
|
|
1031
|
+
bid1Price: number;
|
|
1032
|
+
ask1Price: number;
|
|
1033
|
+
bid1Size: number;
|
|
1034
|
+
basis: string;
|
|
1035
|
+
preOpenPrice: string;
|
|
1036
|
+
preQty: string;
|
|
1037
|
+
}
|
|
1038
|
+
interface TopOfBookTicker {
|
|
1039
|
+
symbol: string;
|
|
1040
|
+
bidPrice: number;
|
|
1041
|
+
bidQty: number;
|
|
1042
|
+
askPrice: number;
|
|
1043
|
+
askQty: number;
|
|
1044
|
+
timestamp?: number | null;
|
|
1045
|
+
}
|
|
1046
|
+
interface AggTradesRequest {
|
|
1047
|
+
symbol: string;
|
|
1048
|
+
startTime: number;
|
|
1049
|
+
endTime: number;
|
|
1050
|
+
limit?: number;
|
|
995
1051
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
type BacktestPriceMode = 'mid' | 'close' | 'open';
|
|
1005
|
-
interface StrategyConfig {
|
|
1006
|
-
ENABLE?: boolean;
|
|
1007
|
-
INTERVAL?: Interval | string;
|
|
1008
|
-
UNIVERSE?: MarketUniverse;
|
|
1009
|
-
ACCOUNT_ID?: string;
|
|
1010
|
-
BACKTEST_PRICE_MODE?: BacktestPriceMode;
|
|
1011
|
-
BACKTEST_ENTRY_DELAY_BARS?: number;
|
|
1012
|
-
BACKTEST_EXECUTION_INTERVAL?: Interval;
|
|
1013
|
-
BACKTEST_EXECUTION_DELAY_MS?: number;
|
|
1014
|
-
ML_ENABLED?: boolean;
|
|
1015
|
-
POLICY_PROFILE_ID?: string;
|
|
1016
|
-
MAKER_FEE_RATE?: number;
|
|
1017
|
-
TAKER_FEE_RATE?: number;
|
|
1018
|
-
FUNDING_ENABLED?: boolean;
|
|
1019
|
-
LEVERAGE?: number;
|
|
1020
|
-
SLIPPAGE_BASE_BPS?: number;
|
|
1021
|
-
SLIPPAGE_SPREAD_MULTIPLIER?: number;
|
|
1022
|
-
SLIPPAGE_MARKET_IMPACT_BPS?: number;
|
|
1023
|
-
SLIPPAGE_DELAY_RISK_MULTIPLIER?: number;
|
|
1024
|
-
EXECUTION_COSTS_CACHE_ONLY?: boolean;
|
|
1025
|
-
[key: string]: any;
|
|
1052
|
+
interface AggTrade {
|
|
1053
|
+
aggregateTradeId: number;
|
|
1054
|
+
price: number;
|
|
1055
|
+
quantity: number;
|
|
1056
|
+
firstTradeId: number;
|
|
1057
|
+
lastTradeId: number;
|
|
1058
|
+
timestamp: number;
|
|
1059
|
+
isBuyerMaker: boolean;
|
|
1026
1060
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
userConfig: StrategyConfig;
|
|
1031
|
-
symbolResultConfig?: StrategyConfig | null;
|
|
1061
|
+
interface OrderBookDepthRequest {
|
|
1062
|
+
symbol: string;
|
|
1063
|
+
limit?: 5 | 10 | 20 | 50 | 100 | 500 | 1000 | 5000;
|
|
1032
1064
|
}
|
|
1033
|
-
interface
|
|
1034
|
-
userName: string;
|
|
1035
|
-
connectorName: string;
|
|
1065
|
+
interface OrderBookDepth {
|
|
1036
1066
|
symbol: string;
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
deploymentId?: string;
|
|
1042
|
-
policyProfileId?: string;
|
|
1043
|
-
runtimeConfigId?: string;
|
|
1044
|
-
runtimeConfigSnapshot?: RuntimeStrategyConfigSnapshot;
|
|
1045
|
-
config: StrategyConfig;
|
|
1046
|
-
connector: Connector;
|
|
1047
|
-
data: KlineChartData;
|
|
1048
|
-
btcData: KlineChartData;
|
|
1049
|
-
ethData?: KlineChartData;
|
|
1050
|
-
btcBinanceData?: KlineChartData;
|
|
1051
|
-
btcCoinbaseData?: KlineChartData;
|
|
1052
|
-
backtestExecutionMarketData?: {
|
|
1053
|
-
interval: Interval;
|
|
1054
|
-
data: KlineChartData;
|
|
1055
|
-
btcData?: KlineChartData;
|
|
1056
|
-
dataByTimestamp?: Map<number, KlineChartItem>;
|
|
1057
|
-
btcDataByTimestamp?: Map<number, KlineChartItem>;
|
|
1058
|
-
};
|
|
1059
|
-
sharedIndicatorsReplayKey?: string;
|
|
1060
|
-
sharedStrategyStateKey?: string;
|
|
1061
|
-
onRuntimeClose?: (event: RuntimeStrategyCloseNotification) => void;
|
|
1067
|
+
lastUpdateId: number | null;
|
|
1068
|
+
bids: Array<[price: number, quantity: number]>;
|
|
1069
|
+
asks: Array<[price: number, quantity: number]>;
|
|
1070
|
+
timestamp: number;
|
|
1062
1071
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1072
|
+
type TrendLineMode = 'lows' | 'highs';
|
|
1073
|
+
type TrendLine = {
|
|
1074
|
+
id: string;
|
|
1075
|
+
mode: TrendLineMode;
|
|
1076
|
+
distance: number;
|
|
1077
|
+
touches: {
|
|
1078
|
+
timestamp: number;
|
|
1079
|
+
value: number;
|
|
1080
|
+
}[];
|
|
1081
|
+
points: {
|
|
1082
|
+
timestamp: number;
|
|
1083
|
+
value: number;
|
|
1084
|
+
}[];
|
|
1085
|
+
alpha?: number[];
|
|
1086
|
+
};
|
|
1087
|
+
interface StrategyFigurePoint {
|
|
1088
|
+
timestamp: number;
|
|
1089
|
+
value: number;
|
|
1067
1090
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1091
|
+
interface StrategyFigureLine {
|
|
1092
|
+
id?: string;
|
|
1093
|
+
kind?: string;
|
|
1094
|
+
points: StrategyFigurePoint[];
|
|
1095
|
+
color?: string;
|
|
1096
|
+
width?: number;
|
|
1097
|
+
style?: 'solid' | 'dashed';
|
|
1073
1098
|
}
|
|
1074
|
-
interface
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1099
|
+
interface StrategyFigurePoints {
|
|
1100
|
+
id?: string;
|
|
1101
|
+
kind?: string;
|
|
1102
|
+
points: StrategyFigurePoint[];
|
|
1103
|
+
color?: string;
|
|
1104
|
+
radius?: number;
|
|
1105
|
+
}
|
|
1106
|
+
interface StrategyFigureZone {
|
|
1107
|
+
id?: string;
|
|
1108
|
+
kind?: string;
|
|
1109
|
+
start: StrategyFigurePoint;
|
|
1110
|
+
end: StrategyFigurePoint;
|
|
1111
|
+
color?: string;
|
|
1112
|
+
borderColor?: string;
|
|
1113
|
+
}
|
|
1114
|
+
interface StrategyFigureAnnotation {
|
|
1115
|
+
id?: string;
|
|
1116
|
+
kind?: string;
|
|
1117
|
+
point: StrategyFigurePoint;
|
|
1118
|
+
title: string;
|
|
1119
|
+
items: string[];
|
|
1120
|
+
color?: string;
|
|
1121
|
+
textColor?: string;
|
|
1122
|
+
backgroundColor?: string;
|
|
1123
|
+
}
|
|
1124
|
+
interface StrategyEntryModelFigures {
|
|
1125
|
+
lines?: StrategyFigureLine[];
|
|
1126
|
+
points?: StrategyFigurePoints[];
|
|
1127
|
+
zones?: StrategyFigureZone[];
|
|
1128
|
+
annotations?: StrategyFigureAnnotation[];
|
|
1129
|
+
}
|
|
1130
|
+
interface TrendLineOptions {
|
|
1131
|
+
mode: TrendLineMode;
|
|
1132
|
+
maxLines?: number;
|
|
1133
|
+
range?: number;
|
|
1134
|
+
epsilon?: number;
|
|
1135
|
+
epsilonOffset?: number;
|
|
1136
|
+
epsilonMode?: 'static' | 'atr';
|
|
1137
|
+
epsilonAtrPeriod?: number;
|
|
1138
|
+
epsilonAtrMultiplier?: number;
|
|
1139
|
+
epsilonOffsetAtrMultiplier?: number;
|
|
1140
|
+
epsilonMin?: number;
|
|
1141
|
+
epsilonMax?: number;
|
|
1142
|
+
epsilonOffsetMin?: number;
|
|
1143
|
+
epsilonOffsetMax?: number;
|
|
1144
|
+
minTouches?: number;
|
|
1145
|
+
minDistance?: number;
|
|
1146
|
+
firstRange?: number;
|
|
1147
|
+
offset?: number;
|
|
1148
|
+
minTouchGap?: number;
|
|
1149
|
+
maxTouchGap?: number;
|
|
1150
|
+
capture?: boolean;
|
|
1151
|
+
bestLines?: number;
|
|
1152
|
+
maxDistance?: number;
|
|
1153
|
+
}
|
|
1154
|
+
interface Signal {
|
|
1155
|
+
signalId: string;
|
|
1156
|
+
orderId?: string;
|
|
1080
1157
|
symbol: string;
|
|
1158
|
+
interval: Interval;
|
|
1159
|
+
strategy: string;
|
|
1081
1160
|
universe?: MarketUniverse;
|
|
1082
1161
|
assetClass?: AssetClass;
|
|
1083
|
-
instrument?: InstrumentDescriptor;
|
|
1084
1162
|
accountId?: string;
|
|
1085
1163
|
deploymentId?: string;
|
|
1086
1164
|
policyProfileId?: string;
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
ml?: boolean;
|
|
1091
|
-
ai?: boolean;
|
|
1092
|
-
fast?: boolean;
|
|
1093
|
-
collectReplaySignalEvaluations?: boolean;
|
|
1094
|
-
researchTrace?: boolean;
|
|
1095
|
-
chunkId?: string;
|
|
1096
|
-
backtestRunId?: string;
|
|
1097
|
-
backtestTestKey?: string;
|
|
1098
|
-
timeoutMs?: number;
|
|
1099
|
-
}
|
|
1100
|
-
type TestSuite = Test[];
|
|
1101
|
-
interface TestStat extends Metrics {
|
|
1102
|
-
score?: number;
|
|
1103
|
-
}
|
|
1104
|
-
interface StrategyResultEntry {
|
|
1105
|
-
config: StrategyResultConfig;
|
|
1106
|
-
stats: TestStat;
|
|
1107
|
-
}
|
|
1108
|
-
type StrategyResults = Record<string, StrategyResultEntry>;
|
|
1109
|
-
interface MinimalStat {
|
|
1110
|
-
amount: number;
|
|
1111
|
-
profit: number;
|
|
1112
|
-
orders: number;
|
|
1113
|
-
}
|
|
1114
|
-
declare const BACKTEST_WARNING_CODES: {
|
|
1115
|
-
readonly TAKE_PROFIT_CROSSED_BEFORE_ENTRY: "TAKE_PROFIT_CROSSED_BEFORE_ENTRY";
|
|
1116
|
-
};
|
|
1117
|
-
type BacktestWarningCode = (typeof BACKTEST_WARNING_CODES)[keyof typeof BACKTEST_WARNING_CODES];
|
|
1118
|
-
type BacktestWarningCounts = Partial<Record<BacktestWarningCode, number>>;
|
|
1119
|
-
type CoreResearchTraceEvent = {
|
|
1120
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
1121
|
-
event: 'signal_emitted' | 'entry_rejected' | 'entry_executed';
|
|
1122
|
-
timestamp: number;
|
|
1123
|
-
strategy: string;
|
|
1124
|
-
symbol: string;
|
|
1165
|
+
runtimeConfigId?: string;
|
|
1166
|
+
runtimeReleaseVersion?: number;
|
|
1167
|
+
runtimeLineage?: RuntimeLineage;
|
|
1125
1168
|
direction: Direction;
|
|
1126
|
-
setupIdentity: string;
|
|
1127
|
-
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
1128
|
-
signalId: string;
|
|
1129
|
-
configId?: string;
|
|
1130
|
-
backtestRunId?: string;
|
|
1131
|
-
backtestTestKey?: string;
|
|
1132
|
-
} | {
|
|
1133
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
1134
|
-
event: 'position_exited';
|
|
1135
1169
|
timestamp: number;
|
|
1170
|
+
orderStatus?: SignalOrderStatus;
|
|
1171
|
+
orderSkipReason?: string;
|
|
1172
|
+
orderFailureReason?: string;
|
|
1173
|
+
orderQty?: number;
|
|
1174
|
+
orderValue?: number;
|
|
1175
|
+
isConfigFromBacktest?: boolean;
|
|
1176
|
+
aiAnalysis?: Partial<SignalAnalysis>;
|
|
1177
|
+
ml?: {
|
|
1178
|
+
probability: number;
|
|
1179
|
+
threshold: number;
|
|
1180
|
+
passed: boolean;
|
|
1181
|
+
};
|
|
1182
|
+
figures: {
|
|
1183
|
+
trendLine?: TrendLine;
|
|
1184
|
+
lines?: StrategyFigureLine[];
|
|
1185
|
+
points?: StrategyFigurePoints[];
|
|
1186
|
+
zones?: StrategyFigureZone[];
|
|
1187
|
+
annotations?: StrategyFigureAnnotation[];
|
|
1188
|
+
[key: string]: any;
|
|
1189
|
+
};
|
|
1190
|
+
prices: {
|
|
1191
|
+
currentPrice: number;
|
|
1192
|
+
takeProfitPrice: number;
|
|
1193
|
+
stopLossPrice: number;
|
|
1194
|
+
riskRatio: number;
|
|
1195
|
+
};
|
|
1196
|
+
indicators: Record<string, any>;
|
|
1197
|
+
additionalIndicators?: Record<string, any>;
|
|
1198
|
+
}
|
|
1199
|
+
type RuntimeSignalEvaluationStatus = 'signal' | 'skip' | 'error';
|
|
1200
|
+
interface RuntimeSignalEvaluationRecord {
|
|
1201
|
+
evaluationId: string;
|
|
1202
|
+
userName: string;
|
|
1136
1203
|
strategy: string;
|
|
1204
|
+
universe?: MarketUniverse;
|
|
1205
|
+
assetClass?: AssetClass;
|
|
1206
|
+
accountId?: string;
|
|
1207
|
+
deploymentId?: string;
|
|
1208
|
+
policyProfileId?: string;
|
|
1209
|
+
runtimeConfigId?: string;
|
|
1210
|
+
runtimeReleaseVersion?: number;
|
|
1211
|
+
runtimeLineage?: RuntimeLineage;
|
|
1137
1212
|
symbol: string;
|
|
1138
|
-
|
|
1139
|
-
setupIdentity: string;
|
|
1140
|
-
setupIdentitySource: 'strategy-context' | 'signal-time-fallback';
|
|
1141
|
-
signalId: string;
|
|
1142
|
-
configId?: string;
|
|
1143
|
-
backtestRunId?: string;
|
|
1144
|
-
backtestTestKey?: string;
|
|
1145
|
-
netProfit: number;
|
|
1146
|
-
exitReason: TestTradeExitReason;
|
|
1147
|
-
} | {
|
|
1148
|
-
schema: 'tradejs-core-research-trace/v1';
|
|
1149
|
-
event: 'skip_summary';
|
|
1213
|
+
interval: Interval;
|
|
1150
1214
|
timestamp: number;
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
stat: MinimalStat;
|
|
1161
|
-
inlineOrderLog?: OrderLogData;
|
|
1162
|
-
inlinePositionLog?: PositionLogData;
|
|
1163
|
-
inlineReplaySignalEvaluations?: RuntimeSignalEvaluationRecord[];
|
|
1164
|
-
researchTraceSummary?: {
|
|
1165
|
-
events: Record<string, number>;
|
|
1166
|
-
skipCounts: Record<string, number>;
|
|
1167
|
-
};
|
|
1168
|
-
executionCostModel?: ExecutionCostModel;
|
|
1169
|
-
warningCounts?: BacktestWarningCounts;
|
|
1170
|
-
}
|
|
1171
|
-
type TestingBox = (test: Test) => Promise<TestingBoxResult | null>;
|
|
1172
|
-
interface TestWorkerResult extends TestingBoxResult {
|
|
1173
|
-
test: Test;
|
|
1174
|
-
}
|
|
1175
|
-
interface CompletedTest extends Omit<TestWorkerResult, 'stat'> {
|
|
1176
|
-
stat: TestStat;
|
|
1215
|
+
evaluatedAt: number;
|
|
1216
|
+
status: RuntimeSignalEvaluationStatus;
|
|
1217
|
+
reason?: string;
|
|
1218
|
+
signalId?: string;
|
|
1219
|
+
direction?: Direction;
|
|
1220
|
+
orderStatus?: SignalOrderStatus;
|
|
1221
|
+
orderSkipReason?: string;
|
|
1222
|
+
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
1223
|
+
ml?: Signal['ml'];
|
|
1177
1224
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1225
|
+
interface SignalAnalysis {
|
|
1226
|
+
direction: Direction | null;
|
|
1227
|
+
quality: 1 | 2 | 3 | 4 | 5 | number;
|
|
1228
|
+
needRetest: boolean;
|
|
1229
|
+
retestPrice: number | null;
|
|
1230
|
+
takeProfitPrice: number | null;
|
|
1231
|
+
stopLossPrice: number | null;
|
|
1232
|
+
setup?: string;
|
|
1233
|
+
confirmations?: string;
|
|
1234
|
+
btcContext?: string;
|
|
1235
|
+
retestPlan?: string;
|
|
1236
|
+
riskLevels?: string;
|
|
1237
|
+
qualityReason?: string;
|
|
1238
|
+
triggerInvalidation?: string;
|
|
1239
|
+
gateAnalysis?: Partial<SignalAnalysis>;
|
|
1240
|
+
gateContradictsLlm?: boolean;
|
|
1241
|
+
gateDecision?: 'approved' | 'rejected';
|
|
1242
|
+
llmDecision?: 'approved' | 'rejected';
|
|
1243
|
+
comment: string;
|
|
1196
1244
|
}
|
|
1197
|
-
interface
|
|
1245
|
+
interface RuntimeAiAnalysisSnapshot {
|
|
1246
|
+
strategy?: string;
|
|
1247
|
+
symbol: string;
|
|
1198
1248
|
direction: Direction;
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
};
|
|
1203
|
-
close: {
|
|
1204
|
-
amount: number;
|
|
1205
|
-
timestamp: number;
|
|
1206
|
-
};
|
|
1249
|
+
timestamp: number;
|
|
1250
|
+
toleranceMs?: number;
|
|
1251
|
+
analysis: Partial<SignalAnalysis>;
|
|
1207
1252
|
}
|
|
1208
|
-
type
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1253
|
+
type SignalOrderStatus = 'completed' | 'failed' | 'skipped' | 'canceled';
|
|
1254
|
+
interface LegacyRuntimeLineage {
|
|
1255
|
+
schemaVersion: 1;
|
|
1256
|
+
compositionId?: string | null;
|
|
1257
|
+
gitSha: string | null;
|
|
1258
|
+
gitDirty: boolean | null;
|
|
1259
|
+
gateFingerprint: string;
|
|
1260
|
+
configFingerprint: string;
|
|
1261
|
+
contextFingerprint: string;
|
|
1262
|
+
maxLossValue?: number | null;
|
|
1217
1263
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1264
|
+
interface VersionedRuntimeLineage {
|
|
1265
|
+
schemaVersion: 2;
|
|
1266
|
+
releaseVersion: number;
|
|
1267
|
+
strategyPackageVersion?: string | null;
|
|
1268
|
+
runtimePackageVersion?: string | null;
|
|
1269
|
+
maxLossValue?: number | null;
|
|
1270
|
+
}
|
|
1271
|
+
type RuntimeLineage = LegacyRuntimeLineage | VersionedRuntimeLineage;
|
|
1272
|
+
type RuntimeTradeStatus = 'active' | 'closed';
|
|
1273
|
+
type RuntimeTradeExitType = 'exit' | 'tp' | 'sl' | 'unknown';
|
|
1274
|
+
type RuntimeTradeFillSource = 'exchange_position' | 'requested_price' | 'unknown';
|
|
1275
|
+
type RuntimeTradeTelemetryQuality = 'full' | 'partial' | 'price_only' | 'none';
|
|
1276
|
+
interface RuntimeTradeRecord {
|
|
1277
|
+
orderId: string;
|
|
1278
|
+
signalId?: string;
|
|
1279
|
+
runtimeLineage?: RuntimeLineage;
|
|
1280
|
+
strategy: string;
|
|
1281
|
+
universe?: MarketUniverse;
|
|
1282
|
+
assetClass?: AssetClass;
|
|
1283
|
+
accountId?: string;
|
|
1284
|
+
deploymentId?: string;
|
|
1285
|
+
policyProfileId?: string;
|
|
1286
|
+
runtimeConfigId?: string;
|
|
1287
|
+
runtimeReleaseVersion?: number;
|
|
1288
|
+
symbol: string;
|
|
1289
|
+
interval?: Interval;
|
|
1223
1290
|
direction: Direction;
|
|
1224
1291
|
qty: number;
|
|
1225
|
-
closedQty: number;
|
|
1226
|
-
entryTimestamp: number;
|
|
1227
|
-
exitTimestamp: number;
|
|
1228
|
-
exitReason: TestTradeExitReason;
|
|
1229
|
-
requestedEntryPrice: number;
|
|
1230
1292
|
entryPrice: number;
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1293
|
+
entryCount?: number;
|
|
1294
|
+
lastEntryPrice?: number | null;
|
|
1295
|
+
lastEntryQty?: number | null;
|
|
1296
|
+
lastEntryTimestamp?: number | null;
|
|
1297
|
+
actualEntryPrice?: number | null;
|
|
1298
|
+
entryTimestamp: number;
|
|
1299
|
+
signalTimestamp?: number | null;
|
|
1300
|
+
signalClosePrice?: number | null;
|
|
1301
|
+
arrivalSnapshotTime?: number | null;
|
|
1302
|
+
arrivalSource?: string | null;
|
|
1303
|
+
arrivalMid?: number | null;
|
|
1304
|
+
bid?: number | null;
|
|
1305
|
+
ask?: number | null;
|
|
1306
|
+
spreadBps?: number | null;
|
|
1307
|
+
orderSubmitTime?: number | null;
|
|
1308
|
+
orderAckTime?: number | null;
|
|
1309
|
+
fillAvgPrice?: number | null;
|
|
1310
|
+
fillSource?: RuntimeTradeFillSource | null;
|
|
1311
|
+
fillTime?: number | null;
|
|
1312
|
+
telemetryQuality?: RuntimeTradeTelemetryQuality | null;
|
|
1313
|
+
fee?: number | null;
|
|
1314
|
+
status: RuntimeTradeStatus;
|
|
1315
|
+
currentPrice?: number | null;
|
|
1316
|
+
currentPnl?: number | null;
|
|
1317
|
+
closedPnl?: number | null;
|
|
1318
|
+
exitPrice?: number | null;
|
|
1319
|
+
actualExitPrice?: number | null;
|
|
1320
|
+
exitTimestamp?: number | null;
|
|
1321
|
+
exitType?: RuntimeTradeExitType | null;
|
|
1322
|
+
openFee?: number | null;
|
|
1323
|
+
closeFee?: number | null;
|
|
1324
|
+
fundingFee?: number | null;
|
|
1325
|
+
totalFee?: number | null;
|
|
1326
|
+
aiAnalysis?: Partial<SignalAnalysis> | null;
|
|
1327
|
+
lastSyncedAt?: number;
|
|
1261
1328
|
}
|
|
1262
|
-
interface
|
|
1329
|
+
interface RuntimeStrategyCloseNotification {
|
|
1263
1330
|
userName?: string;
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1331
|
+
strategy: string;
|
|
1332
|
+
openedByStrategy: string;
|
|
1333
|
+
symbol: string;
|
|
1334
|
+
direction: Direction;
|
|
1335
|
+
code: string;
|
|
1336
|
+
orderId: string;
|
|
1337
|
+
signalId?: string;
|
|
1338
|
+
qty: number;
|
|
1339
|
+
entryPrice: number;
|
|
1340
|
+
entryTimestamp: number;
|
|
1341
|
+
exitPrice?: number | null;
|
|
1342
|
+
exitTimestamp?: number | null;
|
|
1343
|
+
closedPnl?: number | null;
|
|
1344
|
+
exitType?: RuntimeTradeExitType | null;
|
|
1276
1345
|
}
|
|
1277
|
-
type TestCompareList = TestCompare[];
|
|
1278
|
-
type OnChangeCompare = (testId: string) => void;
|
|
1279
1346
|
|
|
1280
1347
|
interface Bot {
|
|
1281
1348
|
symbol: string;
|
|
@@ -2756,6 +2823,7 @@ type StrategyEvidenceMarker = {
|
|
|
2756
2823
|
artifactId: string;
|
|
2757
2824
|
artifactSha256: string;
|
|
2758
2825
|
compositionId?: string;
|
|
2826
|
+
releaseVersion?: number;
|
|
2759
2827
|
gitSha?: string;
|
|
2760
2828
|
gateFingerprint?: string;
|
|
2761
2829
|
configFingerprint?: string;
|
|
@@ -2768,12 +2836,13 @@ type StrategyEvidenceMarker = {
|
|
|
2768
2836
|
};
|
|
2769
2837
|
};
|
|
2770
2838
|
type StrategyEvidenceTimeline = {
|
|
2771
|
-
status: 'verified' | 'missing' | 'invalid';
|
|
2839
|
+
status: 'verified' | 'not_attached' | 'missing' | 'invalid';
|
|
2772
2840
|
observedFrom: number | null;
|
|
2773
2841
|
markers: StrategyEvidenceMarker[];
|
|
2774
2842
|
};
|
|
2775
2843
|
type StrategyEvidenceTimelineSelector = {
|
|
2776
2844
|
strategy: string;
|
|
2845
|
+
releaseVersion?: number | null;
|
|
2777
2846
|
compositionId?: string | null;
|
|
2778
2847
|
gitSha?: string | null;
|
|
2779
2848
|
gateFingerprint?: string | null;
|
|
@@ -2993,6 +3062,8 @@ interface RuntimeStrategyView {
|
|
|
2993
3062
|
runtimeKey: string;
|
|
2994
3063
|
strategyName: string;
|
|
2995
3064
|
configId: string;
|
|
3065
|
+
releaseVersion?: number;
|
|
3066
|
+
controlState?: RuntimeStrategyControlState;
|
|
2996
3067
|
interval: Interval;
|
|
2997
3068
|
universe: MarketUniverse;
|
|
2998
3069
|
accountId?: string;
|
|
@@ -3022,4 +3093,4 @@ interface RuntimeStrategiesResponse {
|
|
|
3022
3093
|
strategies: RuntimeStrategyView[];
|
|
3023
3094
|
}
|
|
3024
3095
|
|
|
3025
|
-
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 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, type RuntimeAiAnalysisSnapshot, type RuntimeDeployment, type RuntimeDeploymentHeartbeat, type RuntimeDeploymentStrategy, type RuntimeLineage, type RuntimeSignalEvaluationRecord, type RuntimeSignalEvaluationStatus, type RuntimeStrategiesResponse, type RuntimeStrategyCloseNotification, type RuntimeStrategyConfigSnapshot, 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 StrategyEvidenceTimeline, type StrategyEvidenceTimelineSelector, 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 TradingAccountRef, type TradingFeeRate, type Trend, type TrendLine, type TrendLineMode, type TrendLineOptions, isMarketUniverse, resolveConnectorUniverse };
|
|
3096
|
+
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_STRATEGY_DRAFT_SCHEMA, RUNTIME_STRATEGY_RELEASE_SCHEMA, type RuntimeAiAnalysisSnapshot, type RuntimeDeployment, type RuntimeDeploymentHeartbeat, type RuntimeDeploymentStrategy, type RuntimeLineage, type RuntimeSignalEvaluationRecord, type RuntimeSignalEvaluationStatus, type RuntimeStrategiesResponse, type RuntimeStrategyCloseNotification, type RuntimeStrategyConfigSnapshot, type RuntimeStrategyControlEvent, type RuntimeStrategyControlEventAction, type RuntimeStrategyControlState, type RuntimeStrategyDraft, type RuntimeStrategyRelease, type RuntimeStrategyReleaseRef, 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 StrategyEvidenceTimeline, type StrategyEvidenceTimelineSelector, 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 TradingAccountRef, type TradingFeeRate, type Trend, type TrendLine, type TrendLineMode, type TrendLineOptions, type VersionedRuntimeLineage, isMarketUniverse, resolveConnectorUniverse };
|