backtest-kit 2.1.2 → 2.2.1
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/build/index.cjs +463 -2324
- package/build/index.mjs +465 -2318
- package/package.json +1 -1
- package/types.d.ts +111 -1325
package/types.d.ts
CHANGED
|
@@ -58,11 +58,6 @@ interface ValidateArgs<T = Enum> {
|
|
|
58
58
|
* @example { FIXED_1000: "fixed-1000" }
|
|
59
59
|
*/
|
|
60
60
|
SizingName?: T;
|
|
61
|
-
/**
|
|
62
|
-
* Optimizer name enum to validate
|
|
63
|
-
* @example { GRID_SEARCH: "grid-search" }
|
|
64
|
-
*/
|
|
65
|
-
OptimizerName?: T;
|
|
66
61
|
/**
|
|
67
62
|
* Walker (parameter sweep) name enum to validate
|
|
68
63
|
* @example { RSI_SWEEP: "rsi-sweep" }
|
|
@@ -73,7 +68,7 @@ interface ValidateArgs<T = Enum> {
|
|
|
73
68
|
* Validates the existence of all provided entity names across validation services.
|
|
74
69
|
*
|
|
75
70
|
* This function accepts enum objects for various entity types (exchanges, frames,
|
|
76
|
-
* strategies, risks, sizings,
|
|
71
|
+
* strategies, risks, sizings, walkers) and validates that each entity
|
|
77
72
|
* name exists in its respective registry. Validation results are memoized for performance.
|
|
78
73
|
*
|
|
79
74
|
* If no arguments are provided (or specific entity types are omitted), the function
|
|
@@ -397,6 +392,26 @@ interface IExchange {
|
|
|
397
392
|
* @returns Promise resolving to order book data
|
|
398
393
|
*/
|
|
399
394
|
getOrderBook: (symbol: string, depth?: number) => Promise<IOrderBookData>;
|
|
395
|
+
/**
|
|
396
|
+
* Fetch raw candles with flexible date/limit parameters.
|
|
397
|
+
*
|
|
398
|
+
* All modes respect execution context and prevent look-ahead bias.
|
|
399
|
+
*
|
|
400
|
+
* Parameter combinations:
|
|
401
|
+
* 1. sDate + eDate + limit: fetches with explicit parameters, validates eDate <= when
|
|
402
|
+
* 2. sDate + eDate: calculates limit from date range, validates eDate <= when
|
|
403
|
+
* 3. eDate + limit: calculates sDate backward, validates eDate <= when
|
|
404
|
+
* 4. sDate + limit: fetches forward, validates calculated endTimestamp <= when
|
|
405
|
+
* 5. Only limit: uses execution.context.when as reference (backward)
|
|
406
|
+
*
|
|
407
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
408
|
+
* @param interval - Candle interval (e.g., "1m", "1h")
|
|
409
|
+
* @param limit - Optional number of candles to fetch
|
|
410
|
+
* @param sDate - Optional start date in milliseconds
|
|
411
|
+
* @param eDate - Optional end date in milliseconds
|
|
412
|
+
* @returns Promise resolving to array of candles
|
|
413
|
+
*/
|
|
414
|
+
getRawCandles: (symbol: string, interval: CandleInterval, limit?: number, sDate?: number, eDate?: number) => Promise<ICandleData[]>;
|
|
400
415
|
}
|
|
401
416
|
/**
|
|
402
417
|
* Unique exchange identifier.
|
|
@@ -3246,418 +3261,6 @@ interface ISizing {
|
|
|
3246
3261
|
*/
|
|
3247
3262
|
type SizingName = string;
|
|
3248
3263
|
|
|
3249
|
-
/**
|
|
3250
|
-
* Message role type for LLM conversation context.
|
|
3251
|
-
* Defines the sender of a message in a chat-based interaction.
|
|
3252
|
-
*/
|
|
3253
|
-
type MessageRole = "assistant" | "system" | "user";
|
|
3254
|
-
/**
|
|
3255
|
-
* Message model for LLM conversation history.
|
|
3256
|
-
* Used in Optimizer to build prompts and maintain conversation context.
|
|
3257
|
-
*/
|
|
3258
|
-
interface MessageModel {
|
|
3259
|
-
/**
|
|
3260
|
-
* The sender of the message.
|
|
3261
|
-
* - "system": System instructions and context
|
|
3262
|
-
* - "user": User input and questions
|
|
3263
|
-
* - "assistant": LLM responses
|
|
3264
|
-
*/
|
|
3265
|
-
role: MessageRole;
|
|
3266
|
-
/**
|
|
3267
|
-
* The text content of the message.
|
|
3268
|
-
* Contains the actual message text sent or received.
|
|
3269
|
-
*/
|
|
3270
|
-
content: string;
|
|
3271
|
-
}
|
|
3272
|
-
|
|
3273
|
-
/**
|
|
3274
|
-
* Unique identifier for data rows in optimizer sources.
|
|
3275
|
-
* Can be either a string or numeric ID.
|
|
3276
|
-
*/
|
|
3277
|
-
type RowId = string | number;
|
|
3278
|
-
/**
|
|
3279
|
-
* Time range configuration for optimizer training or testing periods.
|
|
3280
|
-
* Used to define date boundaries for data collection.
|
|
3281
|
-
*/
|
|
3282
|
-
interface IOptimizerRange {
|
|
3283
|
-
/**
|
|
3284
|
-
* Optional description of this time range.
|
|
3285
|
-
* Example: "Bull market period 2024-Q1"
|
|
3286
|
-
*/
|
|
3287
|
-
note?: string;
|
|
3288
|
-
/**
|
|
3289
|
-
* Start date of the range (inclusive).
|
|
3290
|
-
*/
|
|
3291
|
-
startDate: Date;
|
|
3292
|
-
/**
|
|
3293
|
-
* End date of the range (inclusive).
|
|
3294
|
-
*/
|
|
3295
|
-
endDate: Date;
|
|
3296
|
-
}
|
|
3297
|
-
/**
|
|
3298
|
-
* Base interface for optimizer data sources.
|
|
3299
|
-
* All data fetched from sources must have a unique ID for deduplication.
|
|
3300
|
-
*/
|
|
3301
|
-
interface IOptimizerData {
|
|
3302
|
-
/**
|
|
3303
|
-
* Unique identifier for this data row.
|
|
3304
|
-
* Used for deduplication when paginating data sources.
|
|
3305
|
-
*/
|
|
3306
|
-
id: RowId;
|
|
3307
|
-
}
|
|
3308
|
-
/**
|
|
3309
|
-
* Filter arguments for data source queries without pagination.
|
|
3310
|
-
* Used internally to filter data by symbol and time range.
|
|
3311
|
-
*/
|
|
3312
|
-
interface IOptimizerFilterArgs {
|
|
3313
|
-
/**
|
|
3314
|
-
* Trading pair symbol (e.g., "BTCUSDT").
|
|
3315
|
-
*/
|
|
3316
|
-
symbol: string;
|
|
3317
|
-
/**
|
|
3318
|
-
* Start date of the data range (inclusive).
|
|
3319
|
-
*/
|
|
3320
|
-
startDate: Date;
|
|
3321
|
-
/**
|
|
3322
|
-
* End date of the data range (inclusive).
|
|
3323
|
-
*/
|
|
3324
|
-
endDate: Date;
|
|
3325
|
-
}
|
|
3326
|
-
/**
|
|
3327
|
-
* Fetch arguments for paginated data source queries.
|
|
3328
|
-
* Extends filter arguments with pagination parameters.
|
|
3329
|
-
*/
|
|
3330
|
-
interface IOptimizerFetchArgs extends IOptimizerFilterArgs {
|
|
3331
|
-
/**
|
|
3332
|
-
* Maximum number of records to fetch per request.
|
|
3333
|
-
* Default: 25 (ITERATION_LIMIT)
|
|
3334
|
-
*/
|
|
3335
|
-
limit: number;
|
|
3336
|
-
/**
|
|
3337
|
-
* Number of records to skip from the beginning.
|
|
3338
|
-
* Used for pagination (offset = page * limit).
|
|
3339
|
-
*/
|
|
3340
|
-
offset: number;
|
|
3341
|
-
}
|
|
3342
|
-
/**
|
|
3343
|
-
* Data source function for fetching optimizer training data.
|
|
3344
|
-
* Must support pagination and return data with unique IDs.
|
|
3345
|
-
*
|
|
3346
|
-
* @param args - Fetch arguments including symbol, dates, limit, offset
|
|
3347
|
-
* @returns Array of data rows or Promise resolving to data array
|
|
3348
|
-
*/
|
|
3349
|
-
interface IOptimizerSourceFn<Data extends IOptimizerData = any> {
|
|
3350
|
-
(args: IOptimizerFetchArgs): Data[] | Promise<Data[]>;
|
|
3351
|
-
}
|
|
3352
|
-
/**
|
|
3353
|
-
* Generated strategy data with LLM conversation history.
|
|
3354
|
-
* Contains the full context used to generate a trading strategy.
|
|
3355
|
-
*/
|
|
3356
|
-
interface IOptimizerStrategy {
|
|
3357
|
-
/**
|
|
3358
|
-
* Trading pair symbol this strategy was generated for.
|
|
3359
|
-
*/
|
|
3360
|
-
symbol: string;
|
|
3361
|
-
/**
|
|
3362
|
-
* Unique name taken from data source.
|
|
3363
|
-
* Used in callbacks and logging.
|
|
3364
|
-
*/
|
|
3365
|
-
name: string;
|
|
3366
|
-
/**
|
|
3367
|
-
* LLM conversation history used to generate the strategy.
|
|
3368
|
-
* Contains user prompts and assistant responses for each data source.
|
|
3369
|
-
*/
|
|
3370
|
-
messages: MessageModel[];
|
|
3371
|
-
/**
|
|
3372
|
-
* Generated strategy prompt/description.
|
|
3373
|
-
* Output from getPrompt() function, used as strategy logic.
|
|
3374
|
-
*/
|
|
3375
|
-
strategy: string;
|
|
3376
|
-
}
|
|
3377
|
-
/**
|
|
3378
|
-
* Data source configuration with custom message formatters.
|
|
3379
|
-
* Defines how to fetch data and format it for LLM conversation.
|
|
3380
|
-
*/
|
|
3381
|
-
interface IOptimizerSource<Data extends IOptimizerData = any> {
|
|
3382
|
-
/**
|
|
3383
|
-
* Optional description of this data source.
|
|
3384
|
-
* Example: "Historical backtest results for training"
|
|
3385
|
-
*/
|
|
3386
|
-
note?: string;
|
|
3387
|
-
/**
|
|
3388
|
-
* Unique name identifying this data source.
|
|
3389
|
-
* Used in callbacks and logging.
|
|
3390
|
-
*/
|
|
3391
|
-
name: string;
|
|
3392
|
-
/**
|
|
3393
|
-
* Function to fetch data from this source.
|
|
3394
|
-
* Must support pagination via limit/offset.
|
|
3395
|
-
*/
|
|
3396
|
-
fetch: IOptimizerSourceFn<Data>;
|
|
3397
|
-
/**
|
|
3398
|
-
* Optional custom formatter for user messages.
|
|
3399
|
-
* If not provided, uses default template from OptimizerTemplateService.
|
|
3400
|
-
*
|
|
3401
|
-
* @param symbol - Trading pair symbol
|
|
3402
|
-
* @param data - Fetched data array
|
|
3403
|
-
* @param name - Source name
|
|
3404
|
-
* @returns Formatted user message content
|
|
3405
|
-
*/
|
|
3406
|
-
user?: (symbol: string, data: Data[], name: string) => string | Promise<string>;
|
|
3407
|
-
/**
|
|
3408
|
-
* Optional custom formatter for assistant messages.
|
|
3409
|
-
* If not provided, uses default template from OptimizerTemplateService.
|
|
3410
|
-
*
|
|
3411
|
-
* @param symbol - Trading pair symbol
|
|
3412
|
-
* @param data - Fetched data array
|
|
3413
|
-
* @param name - Source name
|
|
3414
|
-
* @returns Formatted assistant message content
|
|
3415
|
-
*/
|
|
3416
|
-
assistant?: (symbol: string, data: Data[], name: string) => string | Promise<string>;
|
|
3417
|
-
}
|
|
3418
|
-
/**
|
|
3419
|
-
* Union type for data source configuration.
|
|
3420
|
-
* Can be either a simple fetch function or a full source configuration object.
|
|
3421
|
-
*/
|
|
3422
|
-
type Source<Data extends IOptimizerData = any> = IOptimizerSourceFn<Data> | IOptimizerSource<Data>;
|
|
3423
|
-
/**
|
|
3424
|
-
* Lifecycle callbacks for optimizer events.
|
|
3425
|
-
* Provides hooks for monitoring and validating optimizer operations.
|
|
3426
|
-
*/
|
|
3427
|
-
interface IOptimizerCallbacks {
|
|
3428
|
-
/**
|
|
3429
|
-
* Called after strategy data is generated for all train ranges.
|
|
3430
|
-
* Useful for logging or validating the generated strategies.
|
|
3431
|
-
*
|
|
3432
|
-
* @param symbol - Trading pair symbol
|
|
3433
|
-
* @param strategyData - Array of generated strategies with their messages
|
|
3434
|
-
*/
|
|
3435
|
-
onData?: (symbol: string, strategyData: IOptimizerStrategy[]) => void | Promise<void>;
|
|
3436
|
-
/**
|
|
3437
|
-
* Called after strategy code is generated.
|
|
3438
|
-
* Useful for logging or validating the generated code.
|
|
3439
|
-
*
|
|
3440
|
-
* @param symbol - Trading pair symbol
|
|
3441
|
-
* @param code - Generated strategy code
|
|
3442
|
-
*/
|
|
3443
|
-
onCode?: (symbol: string, code: string) => void | Promise<void>;
|
|
3444
|
-
/**
|
|
3445
|
-
* Called after strategy code is dumped to file.
|
|
3446
|
-
* Useful for logging or performing additional actions after file write.
|
|
3447
|
-
*
|
|
3448
|
-
* @param symbol - Trading pair symbol
|
|
3449
|
-
* @param filepath - Path where the file was saved
|
|
3450
|
-
*/
|
|
3451
|
-
onDump?: (symbol: string, filepath: string) => void | Promise<void>;
|
|
3452
|
-
/**
|
|
3453
|
-
* Called after data is fetched from a source.
|
|
3454
|
-
* Useful for logging or validating the fetched data.
|
|
3455
|
-
*
|
|
3456
|
-
* @param symbol - Trading pair symbol
|
|
3457
|
-
* @param sourceName - Name of the data source
|
|
3458
|
-
* @param data - Array of fetched data
|
|
3459
|
-
* @param startDate - Start date of the data range
|
|
3460
|
-
* @param endDate - End date of the data range
|
|
3461
|
-
*/
|
|
3462
|
-
onSourceData?: <Data extends IOptimizerData = any>(symbol: string, sourceName: string, data: Data[], startDate: Date, endDate: Date) => void | Promise<void>;
|
|
3463
|
-
}
|
|
3464
|
-
/**
|
|
3465
|
-
* Template interface for generating code snippets and LLM messages.
|
|
3466
|
-
* Each method returns TypeScript/JavaScript code as a string.
|
|
3467
|
-
*/
|
|
3468
|
-
interface IOptimizerTemplate {
|
|
3469
|
-
/**
|
|
3470
|
-
* Generates the top banner with imports and initialization.
|
|
3471
|
-
*
|
|
3472
|
-
* @param symbol - Trading pair symbol
|
|
3473
|
-
* @returns Generated import statements and setup code
|
|
3474
|
-
*/
|
|
3475
|
-
getTopBanner(symbol: string): string | Promise<string>;
|
|
3476
|
-
/**
|
|
3477
|
-
* Generates default user message content for LLM conversation.
|
|
3478
|
-
*
|
|
3479
|
-
* @param symbol - Trading pair symbol
|
|
3480
|
-
* @param data - Data array from source
|
|
3481
|
-
* @param name - Source name
|
|
3482
|
-
* @returns Formatted user message content
|
|
3483
|
-
*/
|
|
3484
|
-
getUserMessage<Data extends IOptimizerData = any>(symbol: string, data: Data[], name: string): string | Promise<string>;
|
|
3485
|
-
/**
|
|
3486
|
-
* Generates default assistant message content for LLM conversation.
|
|
3487
|
-
*
|
|
3488
|
-
* @param symbol - Trading pair symbol
|
|
3489
|
-
* @param data - Data array from source
|
|
3490
|
-
* @param name - Source name
|
|
3491
|
-
* @returns Formatted assistant message content
|
|
3492
|
-
*/
|
|
3493
|
-
getAssistantMessage<Data extends IOptimizerData = any>(symbol: string, data: Data[], name: string): string | Promise<string>;
|
|
3494
|
-
/**
|
|
3495
|
-
* Generates Walker configuration code.
|
|
3496
|
-
*
|
|
3497
|
-
* @param walkerName - Unique walker identifier
|
|
3498
|
-
* @param exchangeName - Exchange name to use
|
|
3499
|
-
* @param frameName - Frame name for testing
|
|
3500
|
-
* @param strategies - Array of strategy names to compare
|
|
3501
|
-
* @returns Generated addWalker() call
|
|
3502
|
-
*/
|
|
3503
|
-
getWalkerTemplate(walkerName: WalkerName, exchangeName: ExchangeName, frameName: FrameName, strategies: string[]): string | Promise<string>;
|
|
3504
|
-
/**
|
|
3505
|
-
* Generates Exchange configuration code.
|
|
3506
|
-
*
|
|
3507
|
-
* @param symbol - Trading pair symbol
|
|
3508
|
-
* @param exchangeName - Unique exchange identifier
|
|
3509
|
-
* @returns Generated addExchange() call with CCXT integration
|
|
3510
|
-
*/
|
|
3511
|
-
getExchangeTemplate(symbol: string, exchangeName: ExchangeName): string | Promise<string>;
|
|
3512
|
-
/**
|
|
3513
|
-
* Generates Frame (timeframe) configuration code.
|
|
3514
|
-
*
|
|
3515
|
-
* @param symbol - Trading pair symbol
|
|
3516
|
-
* @param frameName - Unique frame identifier
|
|
3517
|
-
* @param interval - Candle interval (e.g., "1m", "5m")
|
|
3518
|
-
* @param startDate - Frame start date
|
|
3519
|
-
* @param endDate - Frame end date
|
|
3520
|
-
* @returns Generated addFrame() call
|
|
3521
|
-
*/
|
|
3522
|
-
getFrameTemplate(symbol: string, frameName: FrameName, interval: CandleInterval, startDate: Date, endDate: Date): string | Promise<string>;
|
|
3523
|
-
/**
|
|
3524
|
-
* Generates Strategy configuration code with LLM integration.
|
|
3525
|
-
*
|
|
3526
|
-
* @param strategyName - Unique strategy identifier
|
|
3527
|
-
* @param interval - Signal throttling interval (e.g., "5m")
|
|
3528
|
-
* @param prompt - Strategy logic prompt from getPrompt()
|
|
3529
|
-
* @returns Generated addStrategy() call with getSignal() function
|
|
3530
|
-
*/
|
|
3531
|
-
getStrategyTemplate(strategyName: StrategyName, interval: CandleInterval, prompt: string): string | Promise<string>;
|
|
3532
|
-
/**
|
|
3533
|
-
* Generates launcher code to run Walker and listen to events.
|
|
3534
|
-
*
|
|
3535
|
-
* @param symbol - Trading pair symbol
|
|
3536
|
-
* @param walkerName - Walker name to launch
|
|
3537
|
-
* @returns Generated Walker.background() call with event listeners
|
|
3538
|
-
*/
|
|
3539
|
-
getLauncherTemplate(symbol: string, walkerName: WalkerName): string | Promise<string>;
|
|
3540
|
-
/**
|
|
3541
|
-
* Generates text() helper function for LLM text generation.
|
|
3542
|
-
*
|
|
3543
|
-
* @param symbol - Trading pair symbol
|
|
3544
|
-
* @returns Generated async text() function using Ollama
|
|
3545
|
-
*/
|
|
3546
|
-
getTextTemplate(symbol: string): string | Promise<string>;
|
|
3547
|
-
/**
|
|
3548
|
-
* Generates json() helper function for structured LLM output.
|
|
3549
|
-
*
|
|
3550
|
-
* @param symbol - Trading pair symbol
|
|
3551
|
-
* @returns Generated async json() function with signal schema
|
|
3552
|
-
*/
|
|
3553
|
-
getJsonTemplate(symbol: string): string | Promise<string>;
|
|
3554
|
-
/**
|
|
3555
|
-
* Generates dumpJson() helper function for debug output.
|
|
3556
|
-
*
|
|
3557
|
-
* @param symbol - Trading pair symbol
|
|
3558
|
-
* @returns Generated async dumpJson() function for file logging
|
|
3559
|
-
*/
|
|
3560
|
-
getJsonDumpTemplate: (symbol: string) => string | Promise<string>;
|
|
3561
|
-
}
|
|
3562
|
-
/**
|
|
3563
|
-
* Schema configuration for optimizer registration.
|
|
3564
|
-
* Defines how to collect data, generate strategies, and create executable code.
|
|
3565
|
-
*/
|
|
3566
|
-
interface IOptimizerSchema {
|
|
3567
|
-
/**
|
|
3568
|
-
* Optional description of this optimizer configuration.
|
|
3569
|
-
*/
|
|
3570
|
-
note?: string;
|
|
3571
|
-
/**
|
|
3572
|
-
* Unique identifier for this optimizer.
|
|
3573
|
-
* Used to retrieve optimizer instance from registry.
|
|
3574
|
-
*/
|
|
3575
|
-
optimizerName: OptimizerName;
|
|
3576
|
-
/**
|
|
3577
|
-
* Array of training time ranges.
|
|
3578
|
-
* Each range generates a separate strategy variant for comparison.
|
|
3579
|
-
*/
|
|
3580
|
-
rangeTrain: IOptimizerRange[];
|
|
3581
|
-
/**
|
|
3582
|
-
* Testing time range for strategy validation.
|
|
3583
|
-
* Used in generated Walker to evaluate strategy performance.
|
|
3584
|
-
*/
|
|
3585
|
-
rangeTest: IOptimizerRange;
|
|
3586
|
-
/**
|
|
3587
|
-
* Array of data sources for strategy generation.
|
|
3588
|
-
* Each source contributes to the LLM conversation context.
|
|
3589
|
-
*/
|
|
3590
|
-
source: Source[];
|
|
3591
|
-
/**
|
|
3592
|
-
* Function to generate strategy prompt from conversation history.
|
|
3593
|
-
* Called after all sources are processed for each training range.
|
|
3594
|
-
*
|
|
3595
|
-
* @param symbol - Trading pair symbol
|
|
3596
|
-
* @param messages - Complete conversation history with all sources
|
|
3597
|
-
* @returns Strategy prompt/logic description
|
|
3598
|
-
*/
|
|
3599
|
-
getPrompt: (symbol: string, messages: MessageModel[]) => string | Promise<string>;
|
|
3600
|
-
/**
|
|
3601
|
-
* Optional custom template overrides.
|
|
3602
|
-
* If not provided, uses defaults from OptimizerTemplateService.
|
|
3603
|
-
*/
|
|
3604
|
-
template?: Partial<IOptimizerTemplate>;
|
|
3605
|
-
/**
|
|
3606
|
-
* Optional lifecycle callbacks for monitoring.
|
|
3607
|
-
*/
|
|
3608
|
-
callbacks?: Partial<IOptimizerCallbacks>;
|
|
3609
|
-
}
|
|
3610
|
-
/**
|
|
3611
|
-
* Internal parameters for ClientOptimizer instantiation.
|
|
3612
|
-
* Extends schema with resolved dependencies (logger, complete template).
|
|
3613
|
-
*/
|
|
3614
|
-
interface IOptimizerParams extends IOptimizerSchema {
|
|
3615
|
-
/**
|
|
3616
|
-
* Logger instance for debug and info messages.
|
|
3617
|
-
* Injected by OptimizerConnectionService.
|
|
3618
|
-
*/
|
|
3619
|
-
logger: ILogger;
|
|
3620
|
-
/**
|
|
3621
|
-
* Complete template implementation with all methods.
|
|
3622
|
-
* Merged from schema.template and OptimizerTemplateService defaults.
|
|
3623
|
-
*/
|
|
3624
|
-
template: IOptimizerTemplate;
|
|
3625
|
-
}
|
|
3626
|
-
/**
|
|
3627
|
-
* Optimizer client interface for strategy generation and code export.
|
|
3628
|
-
* Implemented by ClientOptimizer class.
|
|
3629
|
-
*/
|
|
3630
|
-
interface IOptimizer {
|
|
3631
|
-
/**
|
|
3632
|
-
* Fetches data from all sources and generates strategy metadata.
|
|
3633
|
-
* Processes each training range and builds LLM conversation history.
|
|
3634
|
-
*
|
|
3635
|
-
* @param symbol - Trading pair symbol
|
|
3636
|
-
* @returns Array of generated strategies with conversation context
|
|
3637
|
-
*/
|
|
3638
|
-
getData(symbol: string): Promise<IOptimizerStrategy[]>;
|
|
3639
|
-
/**
|
|
3640
|
-
* Generates complete executable strategy code.
|
|
3641
|
-
* Includes imports, helpers, strategies, walker, and launcher.
|
|
3642
|
-
*
|
|
3643
|
-
* @param symbol - Trading pair symbol
|
|
3644
|
-
* @returns Generated TypeScript/JavaScript code as string
|
|
3645
|
-
*/
|
|
3646
|
-
getCode(symbol: string): Promise<string>;
|
|
3647
|
-
/**
|
|
3648
|
-
* Generates and saves strategy code to file.
|
|
3649
|
-
* Creates directory if needed, writes .mjs file.
|
|
3650
|
-
*
|
|
3651
|
-
* @param symbol - Trading pair symbol
|
|
3652
|
-
* @param path - Output directory path (default: "./")
|
|
3653
|
-
*/
|
|
3654
|
-
dump(symbol: string, path?: string): Promise<void>;
|
|
3655
|
-
}
|
|
3656
|
-
/**
|
|
3657
|
-
* Unique string identifier for registered optimizers.
|
|
3658
|
-
*/
|
|
3659
|
-
type OptimizerName = string;
|
|
3660
|
-
|
|
3661
3264
|
/**
|
|
3662
3265
|
* Retrieves a registered strategy schema by name.
|
|
3663
3266
|
*
|
|
@@ -3752,23 +3355,6 @@ declare function getSizingSchema(sizingName: SizingName): ISizingSchema;
|
|
|
3752
3355
|
* ```
|
|
3753
3356
|
*/
|
|
3754
3357
|
declare function getRiskSchema(riskName: RiskName): IRiskSchema;
|
|
3755
|
-
/**
|
|
3756
|
-
* Retrieves a registered optimizer schema by name.
|
|
3757
|
-
*
|
|
3758
|
-
* @param optimizerName - Unique optimizer identifier
|
|
3759
|
-
* @returns The optimizer schema configuration object
|
|
3760
|
-
* @throws Error if optimizer is not registered
|
|
3761
|
-
*
|
|
3762
|
-
* @example
|
|
3763
|
-
* ```typescript
|
|
3764
|
-
* const optimizer = getOptimizer("llm-strategy-generator");
|
|
3765
|
-
* console.log(optimizer.rangeTrain); // Array of training ranges
|
|
3766
|
-
* console.log(optimizer.rangeTest); // Testing range
|
|
3767
|
-
* console.log(optimizer.source); // Array of data sources
|
|
3768
|
-
* console.log(optimizer.getPrompt); // async function
|
|
3769
|
-
* ```
|
|
3770
|
-
*/
|
|
3771
|
-
declare function getOptimizerSchema(optimizerName: OptimizerName): IOptimizerSchema;
|
|
3772
3358
|
/**
|
|
3773
3359
|
* Retrieves a registered action schema by name.
|
|
3774
3360
|
*
|
|
@@ -4696,94 +4282,6 @@ declare function addSizingSchema(sizingSchema: ISizingSchema): void;
|
|
|
4696
4282
|
* ```
|
|
4697
4283
|
*/
|
|
4698
4284
|
declare function addRiskSchema(riskSchema: IRiskSchema): void;
|
|
4699
|
-
/**
|
|
4700
|
-
* Registers an optimizer configuration in the framework.
|
|
4701
|
-
*
|
|
4702
|
-
* The optimizer generates trading strategies by:
|
|
4703
|
-
* - Collecting data from multiple sources across training periods
|
|
4704
|
-
* - Building LLM conversation history with fetched data
|
|
4705
|
-
* - Generating strategy prompts using getPrompt()
|
|
4706
|
-
* - Creating executable backtest code with templates
|
|
4707
|
-
*
|
|
4708
|
-
* The optimizer produces a complete .mjs file containing:
|
|
4709
|
-
* - Exchange, Frame, Strategy, and Walker configurations
|
|
4710
|
-
* - Multi-timeframe analysis logic
|
|
4711
|
-
* - LLM integration for signal generation
|
|
4712
|
-
* - Event listeners for progress tracking
|
|
4713
|
-
*
|
|
4714
|
-
* @param optimizerSchema - Optimizer configuration object
|
|
4715
|
-
* @param optimizerSchema.optimizerName - Unique optimizer identifier
|
|
4716
|
-
* @param optimizerSchema.rangeTrain - Array of training time ranges (each generates a strategy variant)
|
|
4717
|
-
* @param optimizerSchema.rangeTest - Testing time range for strategy validation
|
|
4718
|
-
* @param optimizerSchema.source - Array of data sources (functions or source objects with custom formatters)
|
|
4719
|
-
* @param optimizerSchema.getPrompt - Function to generate strategy prompt from conversation history
|
|
4720
|
-
* @param optimizerSchema.template - Optional custom template overrides (top banner, helpers, strategy logic, etc.)
|
|
4721
|
-
* @param optimizerSchema.callbacks - Optional lifecycle callbacks (onData, onCode, onDump, onSourceData)
|
|
4722
|
-
*
|
|
4723
|
-
* @example
|
|
4724
|
-
* ```typescript
|
|
4725
|
-
* // Basic optimizer with single data source
|
|
4726
|
-
* addOptimizer({
|
|
4727
|
-
* optimizerName: "llm-strategy-generator",
|
|
4728
|
-
* rangeTrain: [
|
|
4729
|
-
* {
|
|
4730
|
-
* note: "Bull market period",
|
|
4731
|
-
* startDate: new Date("2024-01-01"),
|
|
4732
|
-
* endDate: new Date("2024-01-31"),
|
|
4733
|
-
* },
|
|
4734
|
-
* {
|
|
4735
|
-
* note: "Bear market period",
|
|
4736
|
-
* startDate: new Date("2024-02-01"),
|
|
4737
|
-
* endDate: new Date("2024-02-28"),
|
|
4738
|
-
* },
|
|
4739
|
-
* ],
|
|
4740
|
-
* rangeTest: {
|
|
4741
|
-
* note: "Validation period",
|
|
4742
|
-
* startDate: new Date("2024-03-01"),
|
|
4743
|
-
* endDate: new Date("2024-03-31"),
|
|
4744
|
-
* },
|
|
4745
|
-
* source: [
|
|
4746
|
-
* {
|
|
4747
|
-
* name: "historical-backtests",
|
|
4748
|
-
* fetch: async ({ symbol, startDate, endDate, limit, offset }) => {
|
|
4749
|
-
* // Fetch historical backtest results from database
|
|
4750
|
-
* return await db.backtests.find({
|
|
4751
|
-
* symbol,
|
|
4752
|
-
* date: { $gte: startDate, $lte: endDate },
|
|
4753
|
-
* })
|
|
4754
|
-
* .skip(offset)
|
|
4755
|
-
* .limit(limit);
|
|
4756
|
-
* },
|
|
4757
|
-
* user: async (symbol, data, name) => {
|
|
4758
|
-
* return `Analyze these ${data.length} backtest results for ${symbol}:\n${JSON.stringify(data)}`;
|
|
4759
|
-
* },
|
|
4760
|
-
* assistant: async (symbol, data, name) => {
|
|
4761
|
-
* return "Historical data analyzed successfully";
|
|
4762
|
-
* },
|
|
4763
|
-
* },
|
|
4764
|
-
* ],
|
|
4765
|
-
* getPrompt: async (symbol, messages) => {
|
|
4766
|
-
* // Generate strategy prompt from conversation
|
|
4767
|
-
* return `"Analyze ${symbol} using RSI and MACD. Enter LONG when RSI < 30 and MACD crosses above signal."`;
|
|
4768
|
-
* },
|
|
4769
|
-
* callbacks: {
|
|
4770
|
-
* onData: (symbol, strategyData) => {
|
|
4771
|
-
* console.log(`Generated ${strategyData.length} strategies for ${symbol}`);
|
|
4772
|
-
* },
|
|
4773
|
-
* onCode: (symbol, code) => {
|
|
4774
|
-
* console.log(`Generated ${code.length} characters of code for ${symbol}`);
|
|
4775
|
-
* },
|
|
4776
|
-
* onDump: (symbol, filepath) => {
|
|
4777
|
-
* console.log(`Saved strategy to ${filepath}`);
|
|
4778
|
-
* },
|
|
4779
|
-
* onSourceData: (symbol, sourceName, data, startDate, endDate) => {
|
|
4780
|
-
* console.log(`Fetched ${data.length} rows from ${sourceName} for ${symbol}`);
|
|
4781
|
-
* },
|
|
4782
|
-
* },
|
|
4783
|
-
* });
|
|
4784
|
-
* ```
|
|
4785
|
-
*/
|
|
4786
|
-
declare function addOptimizerSchema(optimizerSchema: IOptimizerSchema): void;
|
|
4787
4285
|
/**
|
|
4788
4286
|
* Registers an action handler in the framework.
|
|
4789
4287
|
*
|
|
@@ -4995,35 +4493,6 @@ type TSizingSchema = {
|
|
|
4995
4493
|
type TRiskSchema = {
|
|
4996
4494
|
riskName: IRiskSchema["riskName"];
|
|
4997
4495
|
} & Partial<IRiskSchema>;
|
|
4998
|
-
/**
|
|
4999
|
-
* Partial optimizer schema for override operations.
|
|
5000
|
-
*
|
|
5001
|
-
* Requires only the optimizer name identifier, all other fields are optional.
|
|
5002
|
-
* Used by overrideOptimizer() to perform partial updates without replacing entire configuration.
|
|
5003
|
-
*
|
|
5004
|
-
* @property optimizerName - Required: Unique optimizer identifier (must exist in registry)
|
|
5005
|
-
* @property rangeTrain - Optional: Updated training time ranges
|
|
5006
|
-
* @property rangeTest - Optional: Updated testing time range
|
|
5007
|
-
* @property source - Optional: Updated data sources array
|
|
5008
|
-
* @property getPrompt - Optional: New prompt generation function
|
|
5009
|
-
* @property template - Optional: Updated template overrides
|
|
5010
|
-
* @property callbacks - Optional: Updated optimizer callbacks
|
|
5011
|
-
*
|
|
5012
|
-
* @example
|
|
5013
|
-
* ```typescript
|
|
5014
|
-
* const partialUpdate: TOptimizerSchema = {
|
|
5015
|
-
* optimizerName: "llm-strategy-gen",
|
|
5016
|
-
* rangeTest: {
|
|
5017
|
-
* note: "Extended test period",
|
|
5018
|
-
* startDate: new Date("2024-04-01"),
|
|
5019
|
-
* endDate: new Date("2024-06-30")
|
|
5020
|
-
* }
|
|
5021
|
-
* };
|
|
5022
|
-
* ```
|
|
5023
|
-
*/
|
|
5024
|
-
type TOptimizerSchema = {
|
|
5025
|
-
optimizerName: IOptimizerSchema["optimizerName"];
|
|
5026
|
-
} & Partial<IOptimizerSchema>;
|
|
5027
4496
|
/**
|
|
5028
4497
|
* Partial action schema for override operations.
|
|
5029
4498
|
*
|
|
@@ -5184,34 +4653,6 @@ declare function overrideSizingSchema(sizingSchema: TSizingSchema): Promise<ISiz
|
|
|
5184
4653
|
* ```
|
|
5185
4654
|
*/
|
|
5186
4655
|
declare function overrideRiskSchema(riskSchema: TRiskSchema): Promise<IRiskSchema>;
|
|
5187
|
-
/**
|
|
5188
|
-
* Overrides an existing optimizer configuration in the framework.
|
|
5189
|
-
*
|
|
5190
|
-
* This function partially updates a previously registered optimizer with new configuration.
|
|
5191
|
-
* Only the provided fields will be updated, other fields remain unchanged.
|
|
5192
|
-
*
|
|
5193
|
-
* @param optimizerSchema - Partial optimizer configuration object
|
|
5194
|
-
* @param optimizerSchema.optimizerName - Unique optimizer identifier (must exist)
|
|
5195
|
-
* @param optimizerSchema.rangeTrain - Optional: Array of training time ranges
|
|
5196
|
-
* @param optimizerSchema.rangeTest - Optional: Testing time range
|
|
5197
|
-
* @param optimizerSchema.source - Optional: Array of data sources
|
|
5198
|
-
* @param optimizerSchema.getPrompt - Optional: Function to generate strategy prompt
|
|
5199
|
-
* @param optimizerSchema.template - Optional: Custom template overrides
|
|
5200
|
-
* @param optimizerSchema.callbacks - Optional: Lifecycle callbacks
|
|
5201
|
-
*
|
|
5202
|
-
* @example
|
|
5203
|
-
* ```typescript
|
|
5204
|
-
* overrideOptimizer({
|
|
5205
|
-
* optimizerName: "llm-strategy-generator",
|
|
5206
|
-
* rangeTest: {
|
|
5207
|
-
* note: "Updated validation period",
|
|
5208
|
-
* startDate: new Date("2024-04-01"),
|
|
5209
|
-
* endDate: new Date("2024-04-30"),
|
|
5210
|
-
* },
|
|
5211
|
-
* });
|
|
5212
|
-
* ```
|
|
5213
|
-
*/
|
|
5214
|
-
declare function overrideOptimizerSchema(optimizerSchema: TOptimizerSchema): Promise<IOptimizerSchema>;
|
|
5215
4656
|
/**
|
|
5216
4657
|
* Overrides an existing action handler configuration in the framework.
|
|
5217
4658
|
*
|
|
@@ -5453,43 +4894,6 @@ declare function listSizingSchema(): Promise<ISizingSchema[]>;
|
|
|
5453
4894
|
* ```
|
|
5454
4895
|
*/
|
|
5455
4896
|
declare function listRiskSchema(): Promise<IRiskSchema[]>;
|
|
5456
|
-
/**
|
|
5457
|
-
* Returns a list of all registered optimizer schemas.
|
|
5458
|
-
*
|
|
5459
|
-
* Retrieves all optimizers that have been registered via addOptimizer().
|
|
5460
|
-
* Useful for debugging, documentation, or building dynamic UIs.
|
|
5461
|
-
*
|
|
5462
|
-
* @returns Array of optimizer schemas with their configurations
|
|
5463
|
-
*
|
|
5464
|
-
* @example
|
|
5465
|
-
* ```typescript
|
|
5466
|
-
* import { listOptimizers, addOptimizer } from "backtest-kit";
|
|
5467
|
-
*
|
|
5468
|
-
* addOptimizer({
|
|
5469
|
-
* optimizerName: "llm-strategy-generator",
|
|
5470
|
-
* note: "Generates trading strategies using LLM",
|
|
5471
|
-
* rangeTrain: [
|
|
5472
|
-
* {
|
|
5473
|
-
* note: "Training period 1",
|
|
5474
|
-
* startDate: new Date("2024-01-01"),
|
|
5475
|
-
* endDate: new Date("2024-01-31"),
|
|
5476
|
-
* },
|
|
5477
|
-
* ],
|
|
5478
|
-
* rangeTest: {
|
|
5479
|
-
* note: "Testing period",
|
|
5480
|
-
* startDate: new Date("2024-02-01"),
|
|
5481
|
-
* endDate: new Date("2024-02-28"),
|
|
5482
|
-
* },
|
|
5483
|
-
* source: [],
|
|
5484
|
-
* getPrompt: async (symbol, messages) => "Generate strategy",
|
|
5485
|
-
* });
|
|
5486
|
-
*
|
|
5487
|
-
* const optimizers = listOptimizers();
|
|
5488
|
-
* console.log(optimizers);
|
|
5489
|
-
* // [{ optimizerName: "llm-strategy-generator", note: "Generates...", ... }]
|
|
5490
|
-
* ```
|
|
5491
|
-
*/
|
|
5492
|
-
declare function listOptimizerSchema(): Promise<IOptimizerSchema[]>;
|
|
5493
4897
|
|
|
5494
4898
|
/**
|
|
5495
4899
|
* Contract for background execution completion events.
|
|
@@ -5587,35 +4991,6 @@ interface ProgressWalkerContract {
|
|
|
5587
4991
|
progress: number;
|
|
5588
4992
|
}
|
|
5589
4993
|
|
|
5590
|
-
/**
|
|
5591
|
-
* Contract for optimizer progress events.
|
|
5592
|
-
*
|
|
5593
|
-
* Emitted during optimizer execution to track progress.
|
|
5594
|
-
* Contains information about total sources, processed sources, and completion percentage.
|
|
5595
|
-
*
|
|
5596
|
-
* @example
|
|
5597
|
-
* ```typescript
|
|
5598
|
-
* import { listenOptimizerProgress } from "backtest-kit";
|
|
5599
|
-
*
|
|
5600
|
-
* listenOptimizerProgress((event) => {
|
|
5601
|
-
* console.log(`Progress: ${(event.progress * 100).toFixed(2)}%`);
|
|
5602
|
-
* console.log(`Processed: ${event.processedSources} / ${event.totalSources}`);
|
|
5603
|
-
* });
|
|
5604
|
-
* ```
|
|
5605
|
-
*/
|
|
5606
|
-
interface ProgressOptimizerContract {
|
|
5607
|
-
/** optimizerName - Name of the optimizer being executed */
|
|
5608
|
-
optimizerName: string;
|
|
5609
|
-
/** symbol - Trading symbol (e.g., "BTCUSDT") */
|
|
5610
|
-
symbol: string;
|
|
5611
|
-
/** totalSources - Total number of sources to process */
|
|
5612
|
-
totalSources: number;
|
|
5613
|
-
/** processedSources - Number of sources processed so far */
|
|
5614
|
-
processedSources: number;
|
|
5615
|
-
/** progress - Completion percentage from 0.0 to 1.0 */
|
|
5616
|
-
progress: number;
|
|
5617
|
-
}
|
|
5618
|
-
|
|
5619
4994
|
/**
|
|
5620
4995
|
* Performance metric types tracked by the system.
|
|
5621
4996
|
*
|
|
@@ -6118,31 +5493,6 @@ declare function listenBacktestProgress(fn: (event: ProgressBacktestContract) =>
|
|
|
6118
5493
|
* ```
|
|
6119
5494
|
*/
|
|
6120
5495
|
declare function listenWalkerProgress(fn: (event: ProgressWalkerContract) => void): () => void;
|
|
6121
|
-
/**
|
|
6122
|
-
* Subscribes to optimizer progress events with queued async processing.
|
|
6123
|
-
*
|
|
6124
|
-
* Emits during optimizer execution to track data source processing progress.
|
|
6125
|
-
* Events are processed sequentially in order received, even if callback is async.
|
|
6126
|
-
* Uses queued wrapper to prevent concurrent execution of the callback.
|
|
6127
|
-
*
|
|
6128
|
-
* @param fn - Callback function to handle optimizer progress events
|
|
6129
|
-
* @returns Unsubscribe function to stop listening to events
|
|
6130
|
-
*
|
|
6131
|
-
* @example
|
|
6132
|
-
* ```typescript
|
|
6133
|
-
* import { listenOptimizerProgress } from "backtest-kit";
|
|
6134
|
-
*
|
|
6135
|
-
* const unsubscribe = listenOptimizerProgress((event) => {
|
|
6136
|
-
* console.log(`Progress: ${(event.progress * 100).toFixed(2)}%`);
|
|
6137
|
-
* console.log(`${event.processedSources} / ${event.totalSources} sources`);
|
|
6138
|
-
* console.log(`Optimizer: ${event.optimizerName}, Symbol: ${event.symbol}`);
|
|
6139
|
-
* });
|
|
6140
|
-
*
|
|
6141
|
-
* // Later: stop listening
|
|
6142
|
-
* unsubscribe();
|
|
6143
|
-
* ```
|
|
6144
|
-
*/
|
|
6145
|
-
declare function listenOptimizerProgress(fn: (event: ProgressOptimizerContract) => void): () => void;
|
|
6146
5496
|
/**
|
|
6147
5497
|
* Subscribes to performance metric events with queued async processing.
|
|
6148
5498
|
*
|
|
@@ -6825,100 +6175,38 @@ declare function getContext(): Promise<IMethodContext>;
|
|
|
6825
6175
|
* ```
|
|
6826
6176
|
*/
|
|
6827
6177
|
declare function getOrderBook(symbol: string, depth?: number): Promise<IOrderBookData>;
|
|
6828
|
-
|
|
6829
|
-
/**
|
|
6830
|
-
* Commits signal prompt history to the message array.
|
|
6831
|
-
*
|
|
6832
|
-
* Extracts trading context from ExecutionContext and MethodContext,
|
|
6833
|
-
* then adds signal-specific system prompts at the beginning and user prompt
|
|
6834
|
-
* at the end of the history array if they are not empty.
|
|
6835
|
-
*
|
|
6836
|
-
* Context extraction:
|
|
6837
|
-
* - symbol: Provided as parameter for debugging convenience
|
|
6838
|
-
* - backtest mode: From ExecutionContext
|
|
6839
|
-
* - strategyName, exchangeName, frameName: From MethodContext
|
|
6840
|
-
*
|
|
6841
|
-
* @param symbol - Trading symbol (e.g., "BTCUSDT") for debugging convenience
|
|
6842
|
-
* @param history - Message array to append prompts to
|
|
6843
|
-
* @returns Promise that resolves when prompts are added
|
|
6844
|
-
* @throws Error if ExecutionContext or MethodContext is not active
|
|
6845
|
-
*
|
|
6846
|
-
* @example
|
|
6847
|
-
* ```typescript
|
|
6848
|
-
* const messages: MessageModel[] = [];
|
|
6849
|
-
* await commitSignalPromptHistory("BTCUSDT", messages);
|
|
6850
|
-
* // messages now contains system prompts at start and user prompt at end
|
|
6851
|
-
* ```
|
|
6852
|
-
*/
|
|
6853
|
-
declare function commitSignalPromptHistory(symbol: string, history: MessageModel[]): Promise<void>;
|
|
6854
|
-
|
|
6855
6178
|
/**
|
|
6856
|
-
*
|
|
6857
|
-
* Used by AI-powered strategies to save debug logs for analysis.
|
|
6179
|
+
* Fetches raw candles with flexible date/limit parameters.
|
|
6858
6180
|
*
|
|
6859
|
-
*
|
|
6860
|
-
* - 00_system_prompt.md - System messages and output summary
|
|
6861
|
-
* - XX_user_message.md - Each user message in separate file (numbered)
|
|
6862
|
-
* - XX_llm_output.md - Final LLM output with signal data
|
|
6181
|
+
* All modes respect execution context and prevent look-ahead bias.
|
|
6863
6182
|
*
|
|
6864
|
-
*
|
|
6183
|
+
* Parameter combinations:
|
|
6184
|
+
* 1. sDate + eDate + limit: fetches with explicit parameters, validates eDate <= when
|
|
6185
|
+
* 2. sDate + eDate: calculates limit from date range, validates eDate <= when
|
|
6186
|
+
* 3. eDate + limit: calculates sDate backward, validates eDate <= when
|
|
6187
|
+
* 4. sDate + limit: fetches forward, validates calculated endTimestamp <= when
|
|
6188
|
+
* 5. Only limit: uses execution.context.when as reference (backward)
|
|
6865
6189
|
*
|
|
6866
|
-
* @param
|
|
6867
|
-
* @param
|
|
6868
|
-
* @param
|
|
6869
|
-
* @param
|
|
6870
|
-
* @
|
|
6190
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
6191
|
+
* @param interval - Candle interval ("1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h")
|
|
6192
|
+
* @param limit - Optional number of candles to fetch
|
|
6193
|
+
* @param sDate - Optional start date in milliseconds
|
|
6194
|
+
* @param eDate - Optional end date in milliseconds
|
|
6195
|
+
* @returns Promise resolving to array of candle data
|
|
6871
6196
|
*
|
|
6872
6197
|
* @example
|
|
6873
6198
|
* ```typescript
|
|
6874
|
-
*
|
|
6875
|
-
*
|
|
6876
|
-
*
|
|
6877
|
-
* addStrategy({
|
|
6878
|
-
* strategyName: "llm-strategy",
|
|
6879
|
-
* interval: "5m",
|
|
6880
|
-
* getSignal: async (symbol) => {
|
|
6881
|
-
* const messages = [];
|
|
6882
|
-
*
|
|
6883
|
-
* // Build multi-timeframe analysis conversation
|
|
6884
|
-
* const candles1h = await getCandles(symbol, "1h", 24);
|
|
6885
|
-
* messages.push(
|
|
6886
|
-
* { role: "user", content: `Analyze 1h trend:\n${formatCandles(candles1h)}` },
|
|
6887
|
-
* { role: "assistant", content: "Trend analyzed" }
|
|
6888
|
-
* );
|
|
6889
|
-
*
|
|
6890
|
-
* const candles5m = await getCandles(symbol, "5m", 24);
|
|
6891
|
-
* messages.push(
|
|
6892
|
-
* { role: "user", content: `Analyze 5m structure:\n${formatCandles(candles5m)}` },
|
|
6893
|
-
* { role: "assistant", content: "Structure analyzed" }
|
|
6894
|
-
* );
|
|
6895
|
-
*
|
|
6896
|
-
* // Request signal
|
|
6897
|
-
* messages.push({
|
|
6898
|
-
* role: "user",
|
|
6899
|
-
* content: "Generate trading signal. Use position: 'wait' if uncertain."
|
|
6900
|
-
* });
|
|
6901
|
-
*
|
|
6902
|
-
* const resultId = uuid();
|
|
6903
|
-
* const signal = await llmRequest(messages);
|
|
6904
|
-
*
|
|
6905
|
-
* // Save conversation and result for debugging
|
|
6906
|
-
* await dumpSignal(resultId, messages, signal);
|
|
6199
|
+
* // Fetch 100 candles backward from current context time
|
|
6200
|
+
* const candles = await getRawCandles("BTCUSDT", "1m", 100);
|
|
6907
6201
|
*
|
|
6908
|
-
*
|
|
6909
|
-
*
|
|
6910
|
-
* });
|
|
6202
|
+
* // Fetch candles for specific date range
|
|
6203
|
+
* const rangeCandles = await getRawCandles("BTCUSDT", "1h", undefined, startMs, endMs);
|
|
6911
6204
|
*
|
|
6912
|
-
* //
|
|
6913
|
-
*
|
|
6914
|
-
* // ./dump/strategy/{uuid}/02_assistant_message.md
|
|
6915
|
-
* // ./dump/strategy/{uuid}/03_user_message.md (5m analysis)
|
|
6916
|
-
* // ./dump/strategy/{uuid}/04_assistant_message.md
|
|
6917
|
-
* // ./dump/strategy/{uuid}/05_user_message.md (signal request)
|
|
6918
|
-
* // ./dump/strategy/{uuid}/06_llm_output.md (final signal)
|
|
6205
|
+
* // Fetch with all parameters specified
|
|
6206
|
+
* const exactCandles = await getRawCandles("BTCUSDT", "1m", 100, startMs, endMs);
|
|
6919
6207
|
* ```
|
|
6920
6208
|
*/
|
|
6921
|
-
declare function
|
|
6209
|
+
declare function getRawCandles(symbol: string, interval: CandleInterval, limit?: number, sDate?: number, eDate?: number): Promise<ICandleData[]>;
|
|
6922
6210
|
|
|
6923
6211
|
/**
|
|
6924
6212
|
* Portfolio heatmap statistics for a single symbol.
|
|
@@ -11791,107 +11079,30 @@ declare class PositionSizeUtils {
|
|
|
11791
11079
|
* @param accountBalance - Current account balance
|
|
11792
11080
|
* @param priceOpen - Planned entry price
|
|
11793
11081
|
* @param winRate - Win rate (0-1)
|
|
11794
|
-
* @param winLossRatio - Average win/loss ratio
|
|
11795
|
-
* @param context - Execution context with sizing name
|
|
11796
|
-
* @returns Promise resolving to calculated position size
|
|
11797
|
-
* @throws Error if sizing schema method is not "kelly-criterion"
|
|
11798
|
-
*/
|
|
11799
|
-
static kellyCriterion: (symbol: string, accountBalance: number, priceOpen: number, winRate: number, winLossRatio: number, context: {
|
|
11800
|
-
sizingName: SizingName;
|
|
11801
|
-
}) => Promise<number>;
|
|
11802
|
-
/**
|
|
11803
|
-
* Calculates position size using ATR-based method.
|
|
11804
|
-
*
|
|
11805
|
-
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
11806
|
-
* @param accountBalance - Current account balance
|
|
11807
|
-
* @param priceOpen - Planned entry price
|
|
11808
|
-
* @param atr - Current ATR value
|
|
11809
|
-
* @param context - Execution context with sizing name
|
|
11810
|
-
* @returns Promise resolving to calculated position size
|
|
11811
|
-
* @throws Error if sizing schema method is not "atr-based"
|
|
11812
|
-
*/
|
|
11813
|
-
static atrBased: (symbol: string, accountBalance: number, priceOpen: number, atr: number, context: {
|
|
11814
|
-
sizingName: SizingName;
|
|
11815
|
-
}) => Promise<number>;
|
|
11816
|
-
}
|
|
11817
|
-
declare const PositionSize: typeof PositionSizeUtils;
|
|
11818
|
-
|
|
11819
|
-
/**
|
|
11820
|
-
* Public API utilities for optimizer operations.
|
|
11821
|
-
* Provides high-level methods for strategy generation and code export.
|
|
11822
|
-
*
|
|
11823
|
-
* Usage:
|
|
11824
|
-
* ```typescript
|
|
11825
|
-
* import { Optimizer } from "backtest-kit";
|
|
11826
|
-
*
|
|
11827
|
-
* // Get strategy data
|
|
11828
|
-
* const strategies = await Optimizer.getData("BTCUSDT", {
|
|
11829
|
-
* optimizerName: "my-optimizer"
|
|
11830
|
-
* });
|
|
11831
|
-
*
|
|
11832
|
-
* // Generate code
|
|
11833
|
-
* const code = await Optimizer.getCode("BTCUSDT", {
|
|
11834
|
-
* optimizerName: "my-optimizer"
|
|
11835
|
-
* });
|
|
11836
|
-
*
|
|
11837
|
-
* // Save to file
|
|
11838
|
-
* await Optimizer.dump("BTCUSDT", {
|
|
11839
|
-
* optimizerName: "my-optimizer"
|
|
11840
|
-
* }, "./output");
|
|
11841
|
-
* ```
|
|
11842
|
-
*/
|
|
11843
|
-
declare class OptimizerUtils {
|
|
11844
|
-
/**
|
|
11845
|
-
* Fetches data from all sources and generates strategy metadata.
|
|
11846
|
-
* Processes each training range and builds LLM conversation history.
|
|
11847
|
-
*
|
|
11848
|
-
* @param symbol - Trading pair symbol
|
|
11849
|
-
* @param context - Context with optimizerName
|
|
11850
|
-
* @returns Array of generated strategies with conversation context
|
|
11851
|
-
* @throws Error if optimizer not found
|
|
11852
|
-
*/
|
|
11853
|
-
getData: (symbol: string, context: {
|
|
11854
|
-
optimizerName: OptimizerName;
|
|
11855
|
-
}) => Promise<IOptimizerStrategy[]>;
|
|
11856
|
-
/**
|
|
11857
|
-
* Generates complete executable strategy code.
|
|
11858
|
-
* Includes imports, helpers, strategies, walker, and launcher.
|
|
11859
|
-
*
|
|
11860
|
-
* @param symbol - Trading pair symbol
|
|
11861
|
-
* @param context - Context with optimizerName
|
|
11862
|
-
* @returns Generated TypeScript/JavaScript code as string
|
|
11863
|
-
* @throws Error if optimizer not found
|
|
11082
|
+
* @param winLossRatio - Average win/loss ratio
|
|
11083
|
+
* @param context - Execution context with sizing name
|
|
11084
|
+
* @returns Promise resolving to calculated position size
|
|
11085
|
+
* @throws Error if sizing schema method is not "kelly-criterion"
|
|
11864
11086
|
*/
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
}) => Promise<
|
|
11087
|
+
static kellyCriterion: (symbol: string, accountBalance: number, priceOpen: number, winRate: number, winLossRatio: number, context: {
|
|
11088
|
+
sizingName: SizingName;
|
|
11089
|
+
}) => Promise<number>;
|
|
11868
11090
|
/**
|
|
11869
|
-
*
|
|
11870
|
-
* Creates directory if needed, writes .mjs file.
|
|
11871
|
-
*
|
|
11872
|
-
* Format: `{optimizerName}_{symbol}.mjs`
|
|
11091
|
+
* Calculates position size using ATR-based method.
|
|
11873
11092
|
*
|
|
11874
|
-
* @param symbol - Trading pair symbol
|
|
11875
|
-
* @param
|
|
11876
|
-
* @param
|
|
11877
|
-
* @
|
|
11093
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
11094
|
+
* @param accountBalance - Current account balance
|
|
11095
|
+
* @param priceOpen - Planned entry price
|
|
11096
|
+
* @param atr - Current ATR value
|
|
11097
|
+
* @param context - Execution context with sizing name
|
|
11098
|
+
* @returns Promise resolving to calculated position size
|
|
11099
|
+
* @throws Error if sizing schema method is not "atr-based"
|
|
11878
11100
|
*/
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
}
|
|
11101
|
+
static atrBased: (symbol: string, accountBalance: number, priceOpen: number, atr: number, context: {
|
|
11102
|
+
sizingName: SizingName;
|
|
11103
|
+
}) => Promise<number>;
|
|
11882
11104
|
}
|
|
11883
|
-
|
|
11884
|
-
* Singleton instance of OptimizerUtils.
|
|
11885
|
-
* Public API for optimizer operations.
|
|
11886
|
-
*
|
|
11887
|
-
* @example
|
|
11888
|
-
* ```typescript
|
|
11889
|
-
* import { Optimizer } from "backtest-kit";
|
|
11890
|
-
*
|
|
11891
|
-
* await Optimizer.dump("BTCUSDT", { optimizerName: "my-optimizer" });
|
|
11892
|
-
* ```
|
|
11893
|
-
*/
|
|
11894
|
-
declare const Optimizer: OptimizerUtils;
|
|
11105
|
+
declare const PositionSize: typeof PositionSizeUtils;
|
|
11895
11106
|
|
|
11896
11107
|
/**
|
|
11897
11108
|
* Type alias for column configuration used in partial profit/loss markdown reports.
|
|
@@ -12788,6 +11999,22 @@ declare class ExchangeUtils {
|
|
|
12788
11999
|
getOrderBook: (symbol: string, context: {
|
|
12789
12000
|
exchangeName: ExchangeName;
|
|
12790
12001
|
}, depth?: number) => Promise<IOrderBookData>;
|
|
12002
|
+
/**
|
|
12003
|
+
* Fetches raw candles with flexible date/limit parameters.
|
|
12004
|
+
*
|
|
12005
|
+
* Uses Date.now() instead of execution context when for look-ahead bias protection.
|
|
12006
|
+
*
|
|
12007
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
12008
|
+
* @param interval - Candle interval (e.g., "1m", "1h")
|
|
12009
|
+
* @param context - Execution context with exchange name
|
|
12010
|
+
* @param limit - Optional number of candles to fetch
|
|
12011
|
+
* @param sDate - Optional start date in milliseconds
|
|
12012
|
+
* @param eDate - Optional end date in milliseconds
|
|
12013
|
+
* @returns Promise resolving to array of candle data
|
|
12014
|
+
*/
|
|
12015
|
+
getRawCandles: (symbol: string, interval: CandleInterval, context: {
|
|
12016
|
+
exchangeName: ExchangeName;
|
|
12017
|
+
}, limit?: number, sDate?: number, eDate?: number) => Promise<ICandleData[]>;
|
|
12791
12018
|
}
|
|
12792
12019
|
/**
|
|
12793
12020
|
* Singleton instance of ExchangeUtils for convenient exchange operations.
|
|
@@ -14085,11 +13312,6 @@ declare const progressBacktestEmitter: Subject<ProgressBacktestContract>;
|
|
|
14085
13312
|
* Emits progress updates during walker execution.
|
|
14086
13313
|
*/
|
|
14087
13314
|
declare const progressWalkerEmitter: Subject<ProgressWalkerContract>;
|
|
14088
|
-
/**
|
|
14089
|
-
* Progress emitter for optimizer execution progress.
|
|
14090
|
-
* Emits progress updates during optimizer execution.
|
|
14091
|
-
*/
|
|
14092
|
-
declare const progressOptimizerEmitter: Subject<ProgressOptimizerContract>;
|
|
14093
13315
|
/**
|
|
14094
13316
|
* Performance emitter for execution metrics.
|
|
14095
13317
|
* Emits performance metrics for profiling and bottleneck detection.
|
|
@@ -14162,7 +13384,6 @@ declare const emitters_partialLossSubject: typeof partialLossSubject;
|
|
|
14162
13384
|
declare const emitters_partialProfitSubject: typeof partialProfitSubject;
|
|
14163
13385
|
declare const emitters_performanceEmitter: typeof performanceEmitter;
|
|
14164
13386
|
declare const emitters_progressBacktestEmitter: typeof progressBacktestEmitter;
|
|
14165
|
-
declare const emitters_progressOptimizerEmitter: typeof progressOptimizerEmitter;
|
|
14166
13387
|
declare const emitters_progressWalkerEmitter: typeof progressWalkerEmitter;
|
|
14167
13388
|
declare const emitters_riskSubject: typeof riskSubject;
|
|
14168
13389
|
declare const emitters_schedulePingSubject: typeof schedulePingSubject;
|
|
@@ -14174,7 +13395,7 @@ declare const emitters_walkerCompleteSubject: typeof walkerCompleteSubject;
|
|
|
14174
13395
|
declare const emitters_walkerEmitter: typeof walkerEmitter;
|
|
14175
13396
|
declare const emitters_walkerStopSubject: typeof walkerStopSubject;
|
|
14176
13397
|
declare namespace emitters {
|
|
14177
|
-
export { emitters_activePingSubject as activePingSubject, emitters_breakevenSubject as breakevenSubject, emitters_doneBacktestSubject as doneBacktestSubject, emitters_doneLiveSubject as doneLiveSubject, emitters_doneWalkerSubject as doneWalkerSubject, emitters_errorEmitter as errorEmitter, emitters_exitEmitter as exitEmitter, emitters_partialLossSubject as partialLossSubject, emitters_partialProfitSubject as partialProfitSubject, emitters_performanceEmitter as performanceEmitter, emitters_progressBacktestEmitter as progressBacktestEmitter,
|
|
13398
|
+
export { emitters_activePingSubject as activePingSubject, emitters_breakevenSubject as breakevenSubject, emitters_doneBacktestSubject as doneBacktestSubject, emitters_doneLiveSubject as doneLiveSubject, emitters_doneWalkerSubject as doneWalkerSubject, emitters_errorEmitter as errorEmitter, emitters_exitEmitter as exitEmitter, emitters_partialLossSubject as partialLossSubject, emitters_partialProfitSubject as partialProfitSubject, emitters_performanceEmitter as performanceEmitter, emitters_progressBacktestEmitter as progressBacktestEmitter, emitters_progressWalkerEmitter as progressWalkerEmitter, emitters_riskSubject as riskSubject, emitters_schedulePingSubject as schedulePingSubject, emitters_signalBacktestEmitter as signalBacktestEmitter, emitters_signalEmitter as signalEmitter, emitters_signalLiveEmitter as signalLiveEmitter, emitters_validationSubject as validationSubject, emitters_walkerCompleteSubject as walkerCompleteSubject, emitters_walkerEmitter as walkerEmitter, emitters_walkerStopSubject as walkerStopSubject };
|
|
14178
13399
|
}
|
|
14179
13400
|
|
|
14180
13401
|
/**
|
|
@@ -14421,22 +13642,19 @@ declare class ClientExchange implements IExchange {
|
|
|
14421
13642
|
/**
|
|
14422
13643
|
* Fetches raw candles with flexible date/limit parameters.
|
|
14423
13644
|
*
|
|
14424
|
-
*
|
|
14425
|
-
* - RAW MODE (sDate + eDate + limit): fetches exactly as specified, NO look-ahead bias protection
|
|
14426
|
-
* - Other modes: respects execution context and prevents look-ahead bias
|
|
13645
|
+
* All modes respect execution context and prevent look-ahead bias.
|
|
14427
13646
|
*
|
|
14428
13647
|
* Parameter combinations:
|
|
14429
|
-
* 1. sDate + eDate + limit:
|
|
14430
|
-
* 2. sDate + eDate: calculates limit from date range, validates
|
|
14431
|
-
* 3. eDate + limit: calculates sDate backward, validates
|
|
14432
|
-
* 4. sDate + limit: fetches forward, validates endTimestamp <= when
|
|
13648
|
+
* 1. sDate + eDate + limit: fetches with explicit parameters, validates eDate <= when
|
|
13649
|
+
* 2. sDate + eDate: calculates limit from date range, validates eDate <= when
|
|
13650
|
+
* 3. eDate + limit: calculates sDate backward, validates eDate <= when
|
|
13651
|
+
* 4. sDate + limit: fetches forward, validates calculated endTimestamp <= when
|
|
14433
13652
|
* 5. Only limit: uses execution.context.when as reference (backward)
|
|
14434
13653
|
*
|
|
14435
13654
|
* Edge cases:
|
|
14436
13655
|
* - If calculated limit is 0 or negative: throws error
|
|
14437
13656
|
* - If sDate >= eDate: throws error
|
|
14438
|
-
* - If
|
|
14439
|
-
* - If endTimestamp > when (non-RAW modes only): throws error to prevent look-ahead bias
|
|
13657
|
+
* - If eDate > when: throws error to prevent look-ahead bias
|
|
14440
13658
|
*
|
|
14441
13659
|
* @param symbol - Trading pair symbol
|
|
14442
13660
|
* @param interval - Candle interval
|
|
@@ -14564,6 +13782,19 @@ declare class ExchangeConnectionService implements IExchange {
|
|
|
14564
13782
|
* @returns Promise resolving to order book data
|
|
14565
13783
|
*/
|
|
14566
13784
|
getOrderBook: (symbol: string, depth?: number) => Promise<IOrderBookData>;
|
|
13785
|
+
/**
|
|
13786
|
+
* Fetches raw candles with flexible date/limit parameters.
|
|
13787
|
+
*
|
|
13788
|
+
* Routes to exchange determined by methodContextService.context.exchangeName.
|
|
13789
|
+
*
|
|
13790
|
+
* @param symbol - Trading pair symbol (e.g., "BTCUSDT")
|
|
13791
|
+
* @param interval - Candle interval (e.g., "1h", "1d")
|
|
13792
|
+
* @param limit - Optional number of candles to fetch
|
|
13793
|
+
* @param sDate - Optional start date in milliseconds
|
|
13794
|
+
* @param eDate - Optional end date in milliseconds
|
|
13795
|
+
* @returns Promise resolving to array of candle data
|
|
13796
|
+
*/
|
|
13797
|
+
getRawCandles: (symbol: string, interval: CandleInterval, limit?: number, sDate?: number, eDate?: number) => Promise<ICandleData[]>;
|
|
14567
13798
|
}
|
|
14568
13799
|
|
|
14569
13800
|
/**
|
|
@@ -16243,6 +15474,19 @@ declare class ExchangeCoreService implements TExchange {
|
|
|
16243
15474
|
* @returns Promise resolving to order book data
|
|
16244
15475
|
*/
|
|
16245
15476
|
getOrderBook: (symbol: string, when: Date, backtest: boolean, depth?: number) => Promise<IOrderBookData>;
|
|
15477
|
+
/**
|
|
15478
|
+
* Fetches raw candles with flexible date/limit parameters and execution context.
|
|
15479
|
+
*
|
|
15480
|
+
* @param symbol - Trading pair symbol
|
|
15481
|
+
* @param interval - Candle interval (e.g., "1m", "1h")
|
|
15482
|
+
* @param when - Timestamp for context (used in backtest mode)
|
|
15483
|
+
* @param backtest - Whether running in backtest mode
|
|
15484
|
+
* @param limit - Optional number of candles to fetch
|
|
15485
|
+
* @param sDate - Optional start date in milliseconds
|
|
15486
|
+
* @param eDate - Optional end date in milliseconds
|
|
15487
|
+
* @returns Promise resolving to array of candles
|
|
15488
|
+
*/
|
|
15489
|
+
getRawCandles: (symbol: string, interval: CandleInterval, when: Date, backtest: boolean, limit?: number, sDate?: number, eDate?: number) => Promise<ICandleData[]>;
|
|
16246
15490
|
}
|
|
16247
15491
|
|
|
16248
15492
|
/**
|
|
@@ -17956,364 +17200,6 @@ declare class ActionValidationService {
|
|
|
17956
17200
|
list: () => Promise<IActionSchema[]>;
|
|
17957
17201
|
}
|
|
17958
17202
|
|
|
17959
|
-
/**
|
|
17960
|
-
* Default template service for generating optimizer code snippets.
|
|
17961
|
-
* Implements all IOptimizerTemplate methods with Ollama LLM integration.
|
|
17962
|
-
*
|
|
17963
|
-
* Features:
|
|
17964
|
-
* - Multi-timeframe analysis (1m, 5m, 15m, 1h)
|
|
17965
|
-
* - JSON structured output for signals
|
|
17966
|
-
* - Debug logging to ./dump/strategy
|
|
17967
|
-
* - CCXT exchange integration
|
|
17968
|
-
* - Walker-based strategy comparison
|
|
17969
|
-
*
|
|
17970
|
-
* Can be partially overridden in optimizer schema configuration.
|
|
17971
|
-
*/
|
|
17972
|
-
declare class OptimizerTemplateService implements IOptimizerTemplate {
|
|
17973
|
-
private readonly loggerService;
|
|
17974
|
-
/**
|
|
17975
|
-
* Generates the top banner with imports and constants.
|
|
17976
|
-
*
|
|
17977
|
-
* @param symbol - Trading pair symbol
|
|
17978
|
-
* @returns Shebang, imports, and WARN_KB constant
|
|
17979
|
-
*/
|
|
17980
|
-
getTopBanner: (symbol: string) => Promise<string>;
|
|
17981
|
-
/**
|
|
17982
|
-
* Generates default user message for LLM conversation.
|
|
17983
|
-
* Simple prompt to read and acknowledge data.
|
|
17984
|
-
*
|
|
17985
|
-
* @param symbol - Trading pair symbol
|
|
17986
|
-
* @param data - Fetched data array
|
|
17987
|
-
* @param name - Source name
|
|
17988
|
-
* @returns User message with JSON data
|
|
17989
|
-
*/
|
|
17990
|
-
getUserMessage: (symbol: string, data: IOptimizerData[], name: string) => Promise<string>;
|
|
17991
|
-
/**
|
|
17992
|
-
* Generates default assistant message for LLM conversation.
|
|
17993
|
-
* Simple acknowledgment response.
|
|
17994
|
-
*
|
|
17995
|
-
* @param symbol - Trading pair symbol
|
|
17996
|
-
* @param data - Fetched data array
|
|
17997
|
-
* @param name - Source name
|
|
17998
|
-
* @returns Assistant acknowledgment message
|
|
17999
|
-
*/
|
|
18000
|
-
getAssistantMessage: (symbol: string, data: IOptimizerData[], name: string) => Promise<string>;
|
|
18001
|
-
/**
|
|
18002
|
-
* Generates Walker configuration code.
|
|
18003
|
-
* Compares multiple strategies on test frame.
|
|
18004
|
-
*
|
|
18005
|
-
* @param walkerName - Unique walker identifier
|
|
18006
|
-
* @param exchangeName - Exchange to use for backtesting
|
|
18007
|
-
* @param frameName - Test frame name
|
|
18008
|
-
* @param strategies - Array of strategy names to compare
|
|
18009
|
-
* @returns Generated addWalker() call
|
|
18010
|
-
*/
|
|
18011
|
-
getWalkerTemplate: (walkerName: WalkerName, exchangeName: ExchangeName, frameName: FrameName, strategies: string[]) => Promise<string>;
|
|
18012
|
-
/**
|
|
18013
|
-
* Generates Strategy configuration with LLM integration.
|
|
18014
|
-
* Includes multi-timeframe analysis and signal generation.
|
|
18015
|
-
*
|
|
18016
|
-
* @param strategyName - Unique strategy identifier
|
|
18017
|
-
* @param interval - Signal throttling interval (e.g., "5m")
|
|
18018
|
-
* @param prompt - Strategy logic from getPrompt()
|
|
18019
|
-
* @returns Generated addStrategy() call with getSignal() function
|
|
18020
|
-
*/
|
|
18021
|
-
getStrategyTemplate: (strategyName: StrategyName, interval: CandleInterval, prompt: string) => Promise<string>;
|
|
18022
|
-
/**
|
|
18023
|
-
* Generates Exchange configuration code.
|
|
18024
|
-
* Uses CCXT Binance with standard formatters.
|
|
18025
|
-
*
|
|
18026
|
-
* @param symbol - Trading pair symbol (unused, for consistency)
|
|
18027
|
-
* @param exchangeName - Unique exchange identifier
|
|
18028
|
-
* @returns Generated addExchange() call with CCXT integration
|
|
18029
|
-
*/
|
|
18030
|
-
getExchangeTemplate: (symbol: string, exchangeName: ExchangeName) => Promise<string>;
|
|
18031
|
-
/**
|
|
18032
|
-
* Generates Frame (timeframe) configuration code.
|
|
18033
|
-
*
|
|
18034
|
-
* @param symbol - Trading pair symbol (unused, for consistency)
|
|
18035
|
-
* @param frameName - Unique frame identifier
|
|
18036
|
-
* @param interval - Candle interval (e.g., "1m")
|
|
18037
|
-
* @param startDate - Frame start date
|
|
18038
|
-
* @param endDate - Frame end date
|
|
18039
|
-
* @returns Generated addFrame() call
|
|
18040
|
-
*/
|
|
18041
|
-
getFrameTemplate: (symbol: string, frameName: FrameName, interval: CandleInterval, startDate: Date, endDate: Date) => Promise<string>;
|
|
18042
|
-
/**
|
|
18043
|
-
* Generates launcher code to run Walker with event listeners.
|
|
18044
|
-
* Includes progress tracking and completion handlers.
|
|
18045
|
-
*
|
|
18046
|
-
* @param symbol - Trading pair symbol
|
|
18047
|
-
* @param walkerName - Walker name to launch
|
|
18048
|
-
* @returns Generated Walker.background() call with listeners
|
|
18049
|
-
*/
|
|
18050
|
-
getLauncherTemplate: (symbol: string, walkerName: WalkerName) => Promise<string>;
|
|
18051
|
-
/**
|
|
18052
|
-
* Generates dumpJson() helper function for debug output.
|
|
18053
|
-
* Saves LLM conversations and results to ./dump/strategy/{resultId}/
|
|
18054
|
-
*
|
|
18055
|
-
* @param symbol - Trading pair symbol (unused, for consistency)
|
|
18056
|
-
* @returns Generated async dumpJson() function
|
|
18057
|
-
*/
|
|
18058
|
-
getJsonDumpTemplate: (symbol: string) => Promise<string>;
|
|
18059
|
-
/**
|
|
18060
|
-
* Generates text() helper for LLM text generation.
|
|
18061
|
-
* Uses Ollama deepseek-v3.1:671b model for market analysis.
|
|
18062
|
-
*
|
|
18063
|
-
* @param symbol - Trading pair symbol (used in prompt)
|
|
18064
|
-
* @returns Generated async text() function
|
|
18065
|
-
*/
|
|
18066
|
-
getTextTemplate: (symbol: string) => Promise<string>;
|
|
18067
|
-
/**
|
|
18068
|
-
* Generates json() helper for structured LLM output.
|
|
18069
|
-
* Uses Ollama with JSON schema for trading signals.
|
|
18070
|
-
*
|
|
18071
|
-
* Signal schema:
|
|
18072
|
-
* - position: "wait" | "long" | "short"
|
|
18073
|
-
* - note: strategy explanation
|
|
18074
|
-
* - priceOpen: entry price
|
|
18075
|
-
* - priceTakeProfit: target price
|
|
18076
|
-
* - priceStopLoss: stop price
|
|
18077
|
-
* - minuteEstimatedTime: expected duration (max 360 min)
|
|
18078
|
-
*
|
|
18079
|
-
* @param symbol - Trading pair symbol (unused, for consistency)
|
|
18080
|
-
* @returns Generated async json() function with signal schema
|
|
18081
|
-
*/
|
|
18082
|
-
getJsonTemplate: (symbol: string) => Promise<string>;
|
|
18083
|
-
}
|
|
18084
|
-
|
|
18085
|
-
/**
|
|
18086
|
-
* Service for managing optimizer schema registration and retrieval.
|
|
18087
|
-
* Provides validation and registry management for optimizer configurations.
|
|
18088
|
-
*
|
|
18089
|
-
* Uses ToolRegistry for immutable schema storage.
|
|
18090
|
-
*/
|
|
18091
|
-
declare class OptimizerSchemaService {
|
|
18092
|
-
readonly loggerService: LoggerService;
|
|
18093
|
-
private _registry;
|
|
18094
|
-
/**
|
|
18095
|
-
* Registers a new optimizer schema.
|
|
18096
|
-
* Validates required fields before registration.
|
|
18097
|
-
*
|
|
18098
|
-
* @param key - Unique optimizer name
|
|
18099
|
-
* @param value - Optimizer schema configuration
|
|
18100
|
-
* @throws Error if schema validation fails
|
|
18101
|
-
*/
|
|
18102
|
-
register: (key: OptimizerName, value: IOptimizerSchema) => void;
|
|
18103
|
-
/**
|
|
18104
|
-
* Validates optimizer schema structure.
|
|
18105
|
-
* Checks required fields: optimizerName, rangeTrain, source, getPrompt.
|
|
18106
|
-
*
|
|
18107
|
-
* @param optimizerSchema - Schema to validate
|
|
18108
|
-
* @throws Error if validation fails
|
|
18109
|
-
*/
|
|
18110
|
-
private validateShallow;
|
|
18111
|
-
/**
|
|
18112
|
-
* Partially overrides an existing optimizer schema.
|
|
18113
|
-
* Merges provided values with existing schema.
|
|
18114
|
-
*
|
|
18115
|
-
* @param key - Optimizer name to override
|
|
18116
|
-
* @param value - Partial schema values to merge
|
|
18117
|
-
* @returns Updated complete schema
|
|
18118
|
-
* @throws Error if optimizer not found
|
|
18119
|
-
*/
|
|
18120
|
-
override: (key: OptimizerName, value: Partial<IOptimizerSchema>) => IOptimizerSchema;
|
|
18121
|
-
/**
|
|
18122
|
-
* Retrieves optimizer schema by name.
|
|
18123
|
-
*
|
|
18124
|
-
* @param key - Optimizer name
|
|
18125
|
-
* @returns Complete optimizer schema
|
|
18126
|
-
* @throws Error if optimizer not found
|
|
18127
|
-
*/
|
|
18128
|
-
get: (key: OptimizerName) => IOptimizerSchema;
|
|
18129
|
-
}
|
|
18130
|
-
|
|
18131
|
-
/**
|
|
18132
|
-
* Service for validating optimizer existence and managing optimizer registry.
|
|
18133
|
-
* Maintains a Map of registered optimizers for validation purposes.
|
|
18134
|
-
*
|
|
18135
|
-
* Uses memoization for efficient repeated validation checks.
|
|
18136
|
-
*/
|
|
18137
|
-
declare class OptimizerValidationService {
|
|
18138
|
-
private readonly loggerService;
|
|
18139
|
-
private _optimizerMap;
|
|
18140
|
-
/**
|
|
18141
|
-
* Adds optimizer to validation registry.
|
|
18142
|
-
* Prevents duplicate optimizer names.
|
|
18143
|
-
*
|
|
18144
|
-
* @param optimizerName - Unique optimizer identifier
|
|
18145
|
-
* @param optimizerSchema - Complete optimizer schema
|
|
18146
|
-
* @throws Error if optimizer with same name already exists
|
|
18147
|
-
*/
|
|
18148
|
-
addOptimizer: (optimizerName: OptimizerName, optimizerSchema: IOptimizerSchema) => void;
|
|
18149
|
-
/**
|
|
18150
|
-
* Validates that optimizer exists in registry.
|
|
18151
|
-
* Memoized for performance on repeated checks.
|
|
18152
|
-
*
|
|
18153
|
-
* @param optimizerName - Optimizer name to validate
|
|
18154
|
-
* @param source - Source method name for error messages
|
|
18155
|
-
* @throws Error if optimizer not found
|
|
18156
|
-
*/
|
|
18157
|
-
validate: (optimizerName: OptimizerName, source: string) => void;
|
|
18158
|
-
/**
|
|
18159
|
-
* Lists all registered optimizer schemas.
|
|
18160
|
-
*
|
|
18161
|
-
* @returns Array of all optimizer schemas
|
|
18162
|
-
*/
|
|
18163
|
-
list: () => Promise<IOptimizerSchema[]>;
|
|
18164
|
-
}
|
|
18165
|
-
|
|
18166
|
-
/**
|
|
18167
|
-
* Client implementation for optimizer operations.
|
|
18168
|
-
*
|
|
18169
|
-
* Features:
|
|
18170
|
-
* - Data collection from multiple sources with pagination
|
|
18171
|
-
* - LLM conversation history building
|
|
18172
|
-
* - Strategy code generation with templates
|
|
18173
|
-
* - File export with callbacks
|
|
18174
|
-
*
|
|
18175
|
-
* Used by OptimizerConnectionService to create optimizer instances.
|
|
18176
|
-
*/
|
|
18177
|
-
declare class ClientOptimizer implements IOptimizer {
|
|
18178
|
-
readonly params: IOptimizerParams;
|
|
18179
|
-
readonly onProgress: (progress: ProgressOptimizerContract) => void;
|
|
18180
|
-
constructor(params: IOptimizerParams, onProgress: (progress: ProgressOptimizerContract) => void);
|
|
18181
|
-
/**
|
|
18182
|
-
* Fetches data from all sources and generates strategy metadata.
|
|
18183
|
-
* Processes each training range and builds LLM conversation history.
|
|
18184
|
-
*
|
|
18185
|
-
* @param symbol - Trading pair symbol
|
|
18186
|
-
* @returns Array of generated strategies with conversation context
|
|
18187
|
-
*/
|
|
18188
|
-
getData: (symbol: string) => Promise<IOptimizerStrategy[]>;
|
|
18189
|
-
/**
|
|
18190
|
-
* Generates complete executable strategy code.
|
|
18191
|
-
* Includes imports, helpers, strategies, walker, and launcher.
|
|
18192
|
-
*
|
|
18193
|
-
* @param symbol - Trading pair symbol
|
|
18194
|
-
* @returns Generated TypeScript/JavaScript code as string
|
|
18195
|
-
*/
|
|
18196
|
-
getCode: (symbol: string) => Promise<string>;
|
|
18197
|
-
/**
|
|
18198
|
-
* Generates and saves strategy code to file.
|
|
18199
|
-
* Creates directory if needed, writes .mjs file.
|
|
18200
|
-
*
|
|
18201
|
-
* @param symbol - Trading pair symbol
|
|
18202
|
-
* @param path - Output directory path (default: "./")
|
|
18203
|
-
*/
|
|
18204
|
-
dump: (symbol: string, path?: string) => Promise<void>;
|
|
18205
|
-
}
|
|
18206
|
-
|
|
18207
|
-
/**
|
|
18208
|
-
* Type helper for optimizer method signatures.
|
|
18209
|
-
* Maps IOptimizer interface methods to any return type.
|
|
18210
|
-
*/
|
|
18211
|
-
type TOptimizer$1 = {
|
|
18212
|
-
[key in keyof IOptimizer]: any;
|
|
18213
|
-
};
|
|
18214
|
-
/**
|
|
18215
|
-
* Service for creating and caching optimizer client instances.
|
|
18216
|
-
* Handles dependency injection and template merging.
|
|
18217
|
-
*
|
|
18218
|
-
* Features:
|
|
18219
|
-
* - Memoized optimizer instances (one per optimizerName)
|
|
18220
|
-
* - Template merging (custom + defaults)
|
|
18221
|
-
* - Logger injection
|
|
18222
|
-
* - Delegates to ClientOptimizer for actual operations
|
|
18223
|
-
*/
|
|
18224
|
-
declare class OptimizerConnectionService implements TOptimizer$1 {
|
|
18225
|
-
private readonly loggerService;
|
|
18226
|
-
private readonly optimizerSchemaService;
|
|
18227
|
-
private readonly optimizerTemplateService;
|
|
18228
|
-
/**
|
|
18229
|
-
* Creates or retrieves cached optimizer instance.
|
|
18230
|
-
* Memoized by optimizerName for performance.
|
|
18231
|
-
*
|
|
18232
|
-
* Merges custom templates from schema with defaults from OptimizerTemplateService.
|
|
18233
|
-
*
|
|
18234
|
-
* @param optimizerName - Unique optimizer identifier
|
|
18235
|
-
* @returns ClientOptimizer instance with resolved dependencies
|
|
18236
|
-
*/
|
|
18237
|
-
getOptimizer: ((optimizerName: OptimizerName) => ClientOptimizer) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientOptimizer>;
|
|
18238
|
-
/**
|
|
18239
|
-
* Fetches data from all sources and generates strategy metadata.
|
|
18240
|
-
*
|
|
18241
|
-
* @param symbol - Trading pair symbol
|
|
18242
|
-
* @param optimizerName - Optimizer identifier
|
|
18243
|
-
* @returns Array of generated strategies with conversation context
|
|
18244
|
-
*/
|
|
18245
|
-
getData: (symbol: string, optimizerName: string) => Promise<IOptimizerStrategy[]>;
|
|
18246
|
-
/**
|
|
18247
|
-
* Generates complete executable strategy code.
|
|
18248
|
-
*
|
|
18249
|
-
* @param symbol - Trading pair symbol
|
|
18250
|
-
* @param optimizerName - Optimizer identifier
|
|
18251
|
-
* @returns Generated TypeScript/JavaScript code as string
|
|
18252
|
-
*/
|
|
18253
|
-
getCode: (symbol: string, optimizerName: string) => Promise<string>;
|
|
18254
|
-
/**
|
|
18255
|
-
* Generates and saves strategy code to file.
|
|
18256
|
-
*
|
|
18257
|
-
* @param symbol - Trading pair symbol
|
|
18258
|
-
* @param optimizerName - Optimizer identifier
|
|
18259
|
-
* @param path - Output directory path (optional)
|
|
18260
|
-
*/
|
|
18261
|
-
dump: (symbol: string, optimizerName: string, path?: string) => Promise<void>;
|
|
18262
|
-
}
|
|
18263
|
-
|
|
18264
|
-
/**
|
|
18265
|
-
* Type definition for optimizer methods.
|
|
18266
|
-
* Maps all keys of IOptimizer to any type.
|
|
18267
|
-
* Used for dynamic method routing in OptimizerGlobalService.
|
|
18268
|
-
*/
|
|
18269
|
-
type TOptimizer = {
|
|
18270
|
-
[key in keyof IOptimizer]: any;
|
|
18271
|
-
};
|
|
18272
|
-
/**
|
|
18273
|
-
* Global service for optimizer operations with validation.
|
|
18274
|
-
* Entry point for public API, performs validation before delegating to ConnectionService.
|
|
18275
|
-
*
|
|
18276
|
-
* Workflow:
|
|
18277
|
-
* 1. Log operation
|
|
18278
|
-
* 2. Validate optimizer exists
|
|
18279
|
-
* 3. Delegate to OptimizerConnectionService
|
|
18280
|
-
*/
|
|
18281
|
-
declare class OptimizerGlobalService implements TOptimizer {
|
|
18282
|
-
private readonly loggerService;
|
|
18283
|
-
private readonly optimizerConnectionService;
|
|
18284
|
-
private readonly optimizerValidationService;
|
|
18285
|
-
/**
|
|
18286
|
-
* Fetches data from all sources and generates strategy metadata.
|
|
18287
|
-
* Validates optimizer existence before execution.
|
|
18288
|
-
*
|
|
18289
|
-
* @param symbol - Trading pair symbol
|
|
18290
|
-
* @param optimizerName - Optimizer identifier
|
|
18291
|
-
* @returns Array of generated strategies with conversation context
|
|
18292
|
-
* @throws Error if optimizer not found
|
|
18293
|
-
*/
|
|
18294
|
-
getData: (symbol: string, optimizerName: string) => Promise<IOptimizerStrategy[]>;
|
|
18295
|
-
/**
|
|
18296
|
-
* Generates complete executable strategy code.
|
|
18297
|
-
* Validates optimizer existence before execution.
|
|
18298
|
-
*
|
|
18299
|
-
* @param symbol - Trading pair symbol
|
|
18300
|
-
* @param optimizerName - Optimizer identifier
|
|
18301
|
-
* @returns Generated TypeScript/JavaScript code as string
|
|
18302
|
-
* @throws Error if optimizer not found
|
|
18303
|
-
*/
|
|
18304
|
-
getCode: (symbol: string, optimizerName: string) => Promise<string>;
|
|
18305
|
-
/**
|
|
18306
|
-
* Generates and saves strategy code to file.
|
|
18307
|
-
* Validates optimizer existence before execution.
|
|
18308
|
-
*
|
|
18309
|
-
* @param symbol - Trading pair symbol
|
|
18310
|
-
* @param optimizerName - Optimizer identifier
|
|
18311
|
-
* @param path - Output directory path (optional)
|
|
18312
|
-
* @throws Error if optimizer not found
|
|
18313
|
-
*/
|
|
18314
|
-
dump: (symbol: string, optimizerName: string, path?: string) => Promise<void>;
|
|
18315
|
-
}
|
|
18316
|
-
|
|
18317
17203
|
/**
|
|
18318
17204
|
* Type definition for partial methods.
|
|
18319
17205
|
* Maps all keys of IPartial to any type.
|
|
@@ -18534,54 +17420,6 @@ declare class BreakevenGlobalService implements TBreakeven {
|
|
|
18534
17420
|
clear: (symbol: string, data: IPublicSignalRow, priceClose: number, backtest: boolean) => Promise<void>;
|
|
18535
17421
|
}
|
|
18536
17422
|
|
|
18537
|
-
/**
|
|
18538
|
-
* Unique identifier for outline result.
|
|
18539
|
-
* Can be string or number for flexible ID formats.
|
|
18540
|
-
*/
|
|
18541
|
-
type ResultId = string | number;
|
|
18542
|
-
/**
|
|
18543
|
-
* Service for generating markdown documentation from LLM outline results.
|
|
18544
|
-
* Used by AI Strategy Optimizer to save debug logs and conversation history.
|
|
18545
|
-
*
|
|
18546
|
-
* Creates directory structure:
|
|
18547
|
-
* - ./dump/strategy/{signalId}/00_system_prompt.md - System messages and output data
|
|
18548
|
-
* - ./dump/strategy/{signalId}/01_user_message.md - First user input
|
|
18549
|
-
* - ./dump/strategy/{signalId}/02_user_message.md - Second user input
|
|
18550
|
-
* - ./dump/strategy/{signalId}/XX_llm_output.md - Final LLM output
|
|
18551
|
-
*/
|
|
18552
|
-
declare class OutlineMarkdownService {
|
|
18553
|
-
/** Logger service injected via DI */
|
|
18554
|
-
private readonly loggerService;
|
|
18555
|
-
/**
|
|
18556
|
-
* Dumps signal data and conversation history to markdown files.
|
|
18557
|
-
* Skips if directory already exists to avoid overwriting previous results.
|
|
18558
|
-
*
|
|
18559
|
-
* Generated files:
|
|
18560
|
-
* - 00_system_prompt.md - System messages and output summary
|
|
18561
|
-
* - XX_user_message.md - Each user message in separate file (numbered)
|
|
18562
|
-
* - XX_llm_output.md - Final LLM output with signal data
|
|
18563
|
-
*
|
|
18564
|
-
* @param signalId - Unique identifier for the result (used as directory name)
|
|
18565
|
-
* @param history - Array of message models from LLM conversation
|
|
18566
|
-
* @param signal - Signal DTO with trade parameters (priceOpen, TP, SL, etc.)
|
|
18567
|
-
* @param outputDir - Output directory path (default: "./dump/strategy")
|
|
18568
|
-
* @returns Promise that resolves when all files are written
|
|
18569
|
-
*
|
|
18570
|
-
* @example
|
|
18571
|
-
* ```typescript
|
|
18572
|
-
* await outlineService.dumpSignal(
|
|
18573
|
-
* "strategy-1",
|
|
18574
|
-
* conversationHistory,
|
|
18575
|
-
* { position: "long", priceTakeProfit: 51000, priceStopLoss: 49000, minuteEstimatedTime: 60 }
|
|
18576
|
-
* );
|
|
18577
|
-
* // Creates: ./dump/strategy/strategy-1/00_system_prompt.md
|
|
18578
|
-
* // ./dump/strategy/strategy-1/01_user_message.md
|
|
18579
|
-
* // ./dump/strategy/strategy-1/02_llm_output.md
|
|
18580
|
-
* ```
|
|
18581
|
-
*/
|
|
18582
|
-
dumpSignal: (signalId: ResultId, history: MessageModel[], signal: ISignalDto, outputDir?: string) => Promise<void>;
|
|
18583
|
-
}
|
|
18584
|
-
|
|
18585
17423
|
/**
|
|
18586
17424
|
* Service for validating GLOBAL_CONFIG parameters to ensure mathematical correctness
|
|
18587
17425
|
* and prevent unprofitable trading configurations.
|
|
@@ -19334,54 +18172,7 @@ declare class RiskReportService {
|
|
|
19334
18172
|
unsubscribe: () => Promise<void>;
|
|
19335
18173
|
}
|
|
19336
18174
|
|
|
19337
|
-
/**
|
|
19338
|
-
* Service for managing signal prompts for AI/LLM integrations.
|
|
19339
|
-
*
|
|
19340
|
-
* Provides access to system and user prompts configured in signal.prompt.cjs.
|
|
19341
|
-
* Supports both static prompt arrays and dynamic prompt functions.
|
|
19342
|
-
*
|
|
19343
|
-
* Key responsibilities:
|
|
19344
|
-
* - Lazy-loads prompt configuration from config/prompt/signal.prompt.cjs
|
|
19345
|
-
* - Resolves system prompts (static arrays or async functions)
|
|
19346
|
-
* - Provides user prompt strings
|
|
19347
|
-
* - Falls back to empty prompts if configuration is missing
|
|
19348
|
-
*
|
|
19349
|
-
* Used for AI-powered signal analysis and strategy recommendations.
|
|
19350
|
-
*/
|
|
19351
|
-
declare class SignalPromptService {
|
|
19352
|
-
private readonly loggerService;
|
|
19353
|
-
/**
|
|
19354
|
-
* Retrieves system prompts for AI context.
|
|
19355
|
-
*
|
|
19356
|
-
* System prompts can be:
|
|
19357
|
-
* - Static array of strings (returned directly)
|
|
19358
|
-
* - Async/sync function returning string array (executed and awaited)
|
|
19359
|
-
* - Undefined (returns empty array)
|
|
19360
|
-
*
|
|
19361
|
-
* @param symbol - Trading symbol (e.g., "BTCUSDT")
|
|
19362
|
-
* @param strategyName - Strategy identifier
|
|
19363
|
-
* @param exchangeName - Exchange identifier
|
|
19364
|
-
* @param frameName - Timeframe identifier
|
|
19365
|
-
* @param backtest - Whether running in backtest mode
|
|
19366
|
-
* @returns Promise resolving to array of system prompt strings
|
|
19367
|
-
*/
|
|
19368
|
-
getSystemPrompt: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<string[]>;
|
|
19369
|
-
/**
|
|
19370
|
-
* Retrieves user prompt string for AI input.
|
|
19371
|
-
*
|
|
19372
|
-
* @param symbol - Trading symbol (e.g., "BTCUSDT")
|
|
19373
|
-
* @param strategyName - Strategy identifier
|
|
19374
|
-
* @param exchangeName - Exchange identifier
|
|
19375
|
-
* @param frameName - Timeframe identifier
|
|
19376
|
-
* @param backtest - Whether running in backtest mode
|
|
19377
|
-
* @returns Promise resolving to user prompt string
|
|
19378
|
-
*/
|
|
19379
|
-
getUserPrompt: (symbol: string, strategyName: StrategyName, exchangeName: ExchangeName, frameName: FrameName, backtest: boolean) => Promise<string>;
|
|
19380
|
-
}
|
|
19381
|
-
|
|
19382
18175
|
declare const backtest: {
|
|
19383
|
-
signalPromptService: SignalPromptService;
|
|
19384
|
-
optimizerTemplateService: OptimizerTemplateService;
|
|
19385
18176
|
exchangeValidationService: ExchangeValidationService;
|
|
19386
18177
|
strategyValidationService: StrategyValidationService;
|
|
19387
18178
|
frameValidationService: FrameValidationService;
|
|
@@ -19389,7 +18180,6 @@ declare const backtest: {
|
|
|
19389
18180
|
sizingValidationService: SizingValidationService;
|
|
19390
18181
|
riskValidationService: RiskValidationService;
|
|
19391
18182
|
actionValidationService: ActionValidationService;
|
|
19392
|
-
optimizerValidationService: OptimizerValidationService;
|
|
19393
18183
|
configValidationService: ConfigValidationService;
|
|
19394
18184
|
columnValidationService: ColumnValidationService;
|
|
19395
18185
|
backtestReportService: BacktestReportService;
|
|
@@ -19409,7 +18199,6 @@ declare const backtest: {
|
|
|
19409
18199
|
heatMarkdownService: HeatMarkdownService;
|
|
19410
18200
|
partialMarkdownService: PartialMarkdownService;
|
|
19411
18201
|
breakevenMarkdownService: BreakevenMarkdownService;
|
|
19412
|
-
outlineMarkdownService: OutlineMarkdownService;
|
|
19413
18202
|
riskMarkdownService: RiskMarkdownService;
|
|
19414
18203
|
backtestLogicPublicService: BacktestLogicPublicService;
|
|
19415
18204
|
liveLogicPublicService: LiveLogicPublicService;
|
|
@@ -19422,7 +18211,6 @@ declare const backtest: {
|
|
|
19422
18211
|
walkerCommandService: WalkerCommandService;
|
|
19423
18212
|
sizingGlobalService: SizingGlobalService;
|
|
19424
18213
|
riskGlobalService: RiskGlobalService;
|
|
19425
|
-
optimizerGlobalService: OptimizerGlobalService;
|
|
19426
18214
|
partialGlobalService: PartialGlobalService;
|
|
19427
18215
|
breakevenGlobalService: BreakevenGlobalService;
|
|
19428
18216
|
exchangeCoreService: ExchangeCoreService;
|
|
@@ -19436,14 +18224,12 @@ declare const backtest: {
|
|
|
19436
18224
|
sizingSchemaService: SizingSchemaService;
|
|
19437
18225
|
riskSchemaService: RiskSchemaService;
|
|
19438
18226
|
actionSchemaService: ActionSchemaService;
|
|
19439
|
-
optimizerSchemaService: OptimizerSchemaService;
|
|
19440
18227
|
exchangeConnectionService: ExchangeConnectionService;
|
|
19441
18228
|
strategyConnectionService: StrategyConnectionService;
|
|
19442
18229
|
frameConnectionService: FrameConnectionService;
|
|
19443
18230
|
sizingConnectionService: SizingConnectionService;
|
|
19444
18231
|
riskConnectionService: RiskConnectionService;
|
|
19445
18232
|
actionConnectionService: ActionConnectionService;
|
|
19446
|
-
optimizerConnectionService: OptimizerConnectionService;
|
|
19447
18233
|
partialConnectionService: PartialConnectionService;
|
|
19448
18234
|
breakevenConnectionService: BreakevenConnectionService;
|
|
19449
18235
|
executionContextService: {
|
|
@@ -19455,4 +18241,4 @@ declare const backtest: {
|
|
|
19455
18241
|
loggerService: LoggerService;
|
|
19456
18242
|
};
|
|
19457
18243
|
|
|
19458
|
-
export { ActionBase, type ActivePingContract, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleData, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type
|
|
18244
|
+
export { ActionBase, type ActivePingContract, Backtest, type BacktestDoneNotification, type BacktestStatisticsModel, Breakeven, type BreakevenContract, type BreakevenData, Cache, type CandleData, type CandleInterval, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IBidData, type ICandleData, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveDoneNotification, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossContract, type PartialLossNotification, type PartialProfitContract, type PartialProfitNotification, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PositionSize, type ProgressBacktestContract, type ProgressBacktestNotification, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TickEvent, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|