backtest-kit 1.5.27 → 1.5.28
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 +657 -540
- package/build/index.mjs +657 -540
- package/package.json +1 -1
- package/types.d.ts +159 -110
package/types.d.ts
CHANGED
|
@@ -443,8 +443,9 @@ interface IRiskParams extends IRiskSchema {
|
|
|
443
443
|
* @param activePositionCount - Number of active positions at rejection time
|
|
444
444
|
* @param comment - Rejection reason from validation note or "N/A"
|
|
445
445
|
* @param timestamp - Event timestamp in milliseconds
|
|
446
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
446
447
|
*/
|
|
447
|
-
onRejected: (symbol: string, params: IRiskCheckArgs, activePositionCount: number, comment: string, timestamp: number) => void | Promise<void>;
|
|
448
|
+
onRejected: (symbol: string, params: IRiskCheckArgs, activePositionCount: number, comment: string, timestamp: number, backtest: boolean) => void | Promise<void>;
|
|
448
449
|
}
|
|
449
450
|
/**
|
|
450
451
|
* Risk interface implemented by ClientRisk.
|
|
@@ -780,6 +781,8 @@ interface IStrategyTickResultIdle {
|
|
|
780
781
|
symbol: string;
|
|
781
782
|
/** Current VWAP price during idle state */
|
|
782
783
|
currentPrice: number;
|
|
784
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
785
|
+
backtest: boolean;
|
|
783
786
|
}
|
|
784
787
|
/**
|
|
785
788
|
* Tick result: scheduled signal created, waiting for price to reach entry point.
|
|
@@ -798,6 +801,8 @@ interface IStrategyTickResultScheduled {
|
|
|
798
801
|
symbol: string;
|
|
799
802
|
/** Current VWAP price when scheduled signal created */
|
|
800
803
|
currentPrice: number;
|
|
804
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
805
|
+
backtest: boolean;
|
|
801
806
|
}
|
|
802
807
|
/**
|
|
803
808
|
* Tick result: new signal just created.
|
|
@@ -816,6 +821,8 @@ interface IStrategyTickResultOpened {
|
|
|
816
821
|
symbol: string;
|
|
817
822
|
/** Current VWAP price at signal open */
|
|
818
823
|
currentPrice: number;
|
|
824
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
825
|
+
backtest: boolean;
|
|
819
826
|
}
|
|
820
827
|
/**
|
|
821
828
|
* Tick result: signal is being monitored.
|
|
@@ -838,6 +845,8 @@ interface IStrategyTickResultActive {
|
|
|
838
845
|
percentTp: number;
|
|
839
846
|
/** Percentage progress towards stop loss (0-100%, 0 if moving towards TP) */
|
|
840
847
|
percentSl: number;
|
|
848
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
849
|
+
backtest: boolean;
|
|
841
850
|
}
|
|
842
851
|
/**
|
|
843
852
|
* Tick result: signal closed with PNL.
|
|
@@ -862,6 +871,8 @@ interface IStrategyTickResultClosed {
|
|
|
862
871
|
exchangeName: ExchangeName;
|
|
863
872
|
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
864
873
|
symbol: string;
|
|
874
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
875
|
+
backtest: boolean;
|
|
865
876
|
}
|
|
866
877
|
/**
|
|
867
878
|
* Tick result: scheduled signal cancelled without opening position.
|
|
@@ -882,6 +893,8 @@ interface IStrategyTickResultCancelled {
|
|
|
882
893
|
exchangeName: ExchangeName;
|
|
883
894
|
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
884
895
|
symbol: string;
|
|
896
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
897
|
+
backtest: boolean;
|
|
885
898
|
}
|
|
886
899
|
/**
|
|
887
900
|
* Discriminated union of all tick results.
|
|
@@ -1194,6 +1207,8 @@ interface RiskEvent {
|
|
|
1194
1207
|
activePositionCount: number;
|
|
1195
1208
|
/** Rejection reason from validation note */
|
|
1196
1209
|
comment: string;
|
|
1210
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1211
|
+
backtest: boolean;
|
|
1197
1212
|
}
|
|
1198
1213
|
/**
|
|
1199
1214
|
* Statistical data calculated from risk rejection events.
|
|
@@ -3373,6 +3388,11 @@ interface RiskContract {
|
|
|
3373
3388
|
* ```
|
|
3374
3389
|
*/
|
|
3375
3390
|
timestamp: number;
|
|
3391
|
+
/**
|
|
3392
|
+
* Whether this event is from backtest mode (true) or live mode (false).
|
|
3393
|
+
* Used to separate backtest and live risk rejection tracking.
|
|
3394
|
+
*/
|
|
3395
|
+
backtest: boolean;
|
|
3376
3396
|
}
|
|
3377
3397
|
|
|
3378
3398
|
/**
|
|
@@ -4935,8 +4955,8 @@ declare class BacktestMarkdownService {
|
|
|
4935
4955
|
/** Logger service for debug output */
|
|
4936
4956
|
private readonly loggerService;
|
|
4937
4957
|
/**
|
|
4938
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
4939
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
4958
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy-backtest triple.
|
|
4959
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
4940
4960
|
*/
|
|
4941
4961
|
private getStorage;
|
|
4942
4962
|
/**
|
|
@@ -4965,33 +4985,35 @@ declare class BacktestMarkdownService {
|
|
|
4965
4985
|
*
|
|
4966
4986
|
* @param symbol - Trading pair symbol
|
|
4967
4987
|
* @param strategyName - Strategy name to get data for
|
|
4988
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
4968
4989
|
* @returns Statistical data object with all metrics
|
|
4969
4990
|
*
|
|
4970
4991
|
* @example
|
|
4971
4992
|
* ```typescript
|
|
4972
4993
|
* const service = new BacktestMarkdownService();
|
|
4973
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
4994
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", true);
|
|
4974
4995
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
4975
4996
|
* ```
|
|
4976
4997
|
*/
|
|
4977
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<BacktestStatisticsModel>;
|
|
4998
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<BacktestStatisticsModel>;
|
|
4978
4999
|
/**
|
|
4979
5000
|
* Generates markdown report with all closed signals for a symbol-strategy pair.
|
|
4980
5001
|
* Delegates to ReportStorage.generateReport().
|
|
4981
5002
|
*
|
|
4982
5003
|
* @param symbol - Trading pair symbol
|
|
4983
5004
|
* @param strategyName - Strategy name to generate report for
|
|
5005
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
4984
5006
|
* @param columns - Column configuration for formatting the table
|
|
4985
5007
|
* @returns Markdown formatted report string with table of all closed signals
|
|
4986
5008
|
*
|
|
4987
5009
|
* @example
|
|
4988
5010
|
* ```typescript
|
|
4989
5011
|
* const service = new BacktestMarkdownService();
|
|
4990
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5012
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", true);
|
|
4991
5013
|
* console.log(markdown);
|
|
4992
5014
|
* ```
|
|
4993
5015
|
*/
|
|
4994
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$6[]) => Promise<string>;
|
|
5016
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$6[]) => Promise<string>;
|
|
4995
5017
|
/**
|
|
4996
5018
|
* Saves symbol-strategy report to disk.
|
|
4997
5019
|
* Creates directory if it doesn't exist.
|
|
@@ -4999,6 +5021,7 @@ declare class BacktestMarkdownService {
|
|
|
4999
5021
|
*
|
|
5000
5022
|
* @param symbol - Trading pair symbol
|
|
5001
5023
|
* @param strategyName - Strategy name to save report for
|
|
5024
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5002
5025
|
* @param path - Directory path to save report (default: "./dump/backtest")
|
|
5003
5026
|
* @param columns - Column configuration for formatting the table
|
|
5004
5027
|
*
|
|
@@ -5007,32 +5030,33 @@ declare class BacktestMarkdownService {
|
|
|
5007
5030
|
* const service = new BacktestMarkdownService();
|
|
5008
5031
|
*
|
|
5009
5032
|
* // Save to default path: ./dump/backtest/my-strategy.md
|
|
5010
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5033
|
+
* await service.dump("BTCUSDT", "my-strategy", true);
|
|
5011
5034
|
*
|
|
5012
5035
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5013
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5036
|
+
* await service.dump("BTCUSDT", "my-strategy", true, "./custom/path");
|
|
5014
5037
|
* ```
|
|
5015
5038
|
*/
|
|
5016
|
-
dump: (symbol: string, strategyName: StrategyName, path?: string, columns?: Columns$6[]) => Promise<void>;
|
|
5039
|
+
dump: (symbol: string, strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$6[]) => Promise<void>;
|
|
5017
5040
|
/**
|
|
5018
5041
|
* Clears accumulated signal data from storage.
|
|
5019
|
-
* If ctx is provided, clears only that specific symbol-strategy
|
|
5042
|
+
* If ctx is provided, clears only that specific symbol-strategy-backtest triple's data.
|
|
5020
5043
|
* If nothing is provided, clears all data.
|
|
5021
5044
|
*
|
|
5045
|
+
* @param backtest - Backtest mode flag
|
|
5022
5046
|
* @param ctx - Optional context with symbol and strategyName
|
|
5023
5047
|
*
|
|
5024
5048
|
* @example
|
|
5025
5049
|
* ```typescript
|
|
5026
5050
|
* const service = new BacktestMarkdownService();
|
|
5027
5051
|
*
|
|
5028
|
-
* // Clear specific symbol-strategy
|
|
5029
|
-
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5052
|
+
* // Clear specific symbol-strategy-backtest triple
|
|
5053
|
+
* await service.clear(true, { symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5030
5054
|
*
|
|
5031
5055
|
* // Clear all data
|
|
5032
5056
|
* await service.clear();
|
|
5033
5057
|
* ```
|
|
5034
5058
|
*/
|
|
5035
|
-
clear: (ctx?: {
|
|
5059
|
+
clear: (backtest: boolean, ctx?: {
|
|
5036
5060
|
symbol: string;
|
|
5037
5061
|
strategyName: StrategyName;
|
|
5038
5062
|
}) => Promise<void>;
|
|
@@ -5284,8 +5308,8 @@ declare class LiveMarkdownService {
|
|
|
5284
5308
|
/** Logger service for debug output */
|
|
5285
5309
|
private readonly loggerService;
|
|
5286
5310
|
/**
|
|
5287
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
5288
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
5311
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy-backtest triple.
|
|
5312
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
5289
5313
|
*/
|
|
5290
5314
|
private getStorage;
|
|
5291
5315
|
/**
|
|
@@ -5316,33 +5340,35 @@ declare class LiveMarkdownService {
|
|
|
5316
5340
|
*
|
|
5317
5341
|
* @param symbol - Trading pair symbol
|
|
5318
5342
|
* @param strategyName - Strategy name to get data for
|
|
5343
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5319
5344
|
* @returns Statistical data object with all metrics
|
|
5320
5345
|
*
|
|
5321
5346
|
* @example
|
|
5322
5347
|
* ```typescript
|
|
5323
5348
|
* const service = new LiveMarkdownService();
|
|
5324
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
5349
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
5325
5350
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
5326
5351
|
* ```
|
|
5327
5352
|
*/
|
|
5328
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<LiveStatisticsModel>;
|
|
5353
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<LiveStatisticsModel>;
|
|
5329
5354
|
/**
|
|
5330
5355
|
* Generates markdown report with all events for a symbol-strategy pair.
|
|
5331
5356
|
* Delegates to ReportStorage.getReport().
|
|
5332
5357
|
*
|
|
5333
5358
|
* @param symbol - Trading pair symbol
|
|
5334
5359
|
* @param strategyName - Strategy name to generate report for
|
|
5360
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5335
5361
|
* @param columns - Column configuration for formatting the table
|
|
5336
5362
|
* @returns Markdown formatted report string with table of all events
|
|
5337
5363
|
*
|
|
5338
5364
|
* @example
|
|
5339
5365
|
* ```typescript
|
|
5340
5366
|
* const service = new LiveMarkdownService();
|
|
5341
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5367
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
5342
5368
|
* console.log(markdown);
|
|
5343
5369
|
* ```
|
|
5344
5370
|
*/
|
|
5345
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$5[]) => Promise<string>;
|
|
5371
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$5[]) => Promise<string>;
|
|
5346
5372
|
/**
|
|
5347
5373
|
* Saves symbol-strategy report to disk.
|
|
5348
5374
|
* Creates directory if it doesn't exist.
|
|
@@ -5350,6 +5376,7 @@ declare class LiveMarkdownService {
|
|
|
5350
5376
|
*
|
|
5351
5377
|
* @param symbol - Trading pair symbol
|
|
5352
5378
|
* @param strategyName - Strategy name to save report for
|
|
5379
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5353
5380
|
* @param path - Directory path to save report (default: "./dump/live")
|
|
5354
5381
|
* @param columns - Column configuration for formatting the table
|
|
5355
5382
|
*
|
|
@@ -5358,32 +5385,33 @@ declare class LiveMarkdownService {
|
|
|
5358
5385
|
* const service = new LiveMarkdownService();
|
|
5359
5386
|
*
|
|
5360
5387
|
* // Save to default path: ./dump/live/my-strategy.md
|
|
5361
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5388
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
5362
5389
|
*
|
|
5363
5390
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5364
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5391
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5365
5392
|
* ```
|
|
5366
5393
|
*/
|
|
5367
|
-
dump: (symbol: string, strategyName: StrategyName, path?: string, columns?: Columns$5[]) => Promise<void>;
|
|
5394
|
+
dump: (symbol: string, strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$5[]) => Promise<void>;
|
|
5368
5395
|
/**
|
|
5369
5396
|
* Clears accumulated event data from storage.
|
|
5370
|
-
* If ctx is provided, clears only that specific symbol-strategy
|
|
5397
|
+
* If ctx is provided, clears only that specific symbol-strategy-backtest triple's data.
|
|
5371
5398
|
* If nothing is provided, clears all data.
|
|
5372
5399
|
*
|
|
5400
|
+
* @param backtest - Backtest mode flag
|
|
5373
5401
|
* @param ctx - Optional context with symbol and strategyName
|
|
5374
5402
|
*
|
|
5375
5403
|
* @example
|
|
5376
5404
|
* ```typescript
|
|
5377
5405
|
* const service = new LiveMarkdownService();
|
|
5378
5406
|
*
|
|
5379
|
-
* // Clear specific symbol-strategy
|
|
5380
|
-
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5407
|
+
* // Clear specific symbol-strategy-backtest triple
|
|
5408
|
+
* await service.clear(false, { symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5381
5409
|
*
|
|
5382
5410
|
* // Clear all data
|
|
5383
5411
|
* await service.clear();
|
|
5384
5412
|
* ```
|
|
5385
5413
|
*/
|
|
5386
|
-
clear: (ctx?: {
|
|
5414
|
+
clear: (backtest: boolean, ctx?: {
|
|
5387
5415
|
symbol: string;
|
|
5388
5416
|
strategyName: StrategyName;
|
|
5389
5417
|
}) => Promise<void>;
|
|
@@ -5634,8 +5662,8 @@ declare class ScheduleMarkdownService {
|
|
|
5634
5662
|
/** Logger service for debug output */
|
|
5635
5663
|
private readonly loggerService;
|
|
5636
5664
|
/**
|
|
5637
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
5638
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
5665
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy-backtest triple.
|
|
5666
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
5639
5667
|
*/
|
|
5640
5668
|
private getStorage;
|
|
5641
5669
|
/**
|
|
@@ -5659,33 +5687,35 @@ declare class ScheduleMarkdownService {
|
|
|
5659
5687
|
*
|
|
5660
5688
|
* @param symbol - Trading pair symbol
|
|
5661
5689
|
* @param strategyName - Strategy name to get data for
|
|
5690
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5662
5691
|
* @returns Statistical data object with all metrics
|
|
5663
5692
|
*
|
|
5664
5693
|
* @example
|
|
5665
5694
|
* ```typescript
|
|
5666
5695
|
* const service = new ScheduleMarkdownService();
|
|
5667
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
5696
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
5668
5697
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
5669
5698
|
* ```
|
|
5670
5699
|
*/
|
|
5671
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatisticsModel>;
|
|
5700
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<ScheduleStatisticsModel>;
|
|
5672
5701
|
/**
|
|
5673
5702
|
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
5674
5703
|
* Delegates to ReportStorage.getReport().
|
|
5675
5704
|
*
|
|
5676
5705
|
* @param symbol - Trading pair symbol
|
|
5677
5706
|
* @param strategyName - Strategy name to generate report for
|
|
5707
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5678
5708
|
* @param columns - Column configuration for formatting the table
|
|
5679
5709
|
* @returns Markdown formatted report string with table of all events
|
|
5680
5710
|
*
|
|
5681
5711
|
* @example
|
|
5682
5712
|
* ```typescript
|
|
5683
5713
|
* const service = new ScheduleMarkdownService();
|
|
5684
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5714
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
5685
5715
|
* console.log(markdown);
|
|
5686
5716
|
* ```
|
|
5687
5717
|
*/
|
|
5688
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$4[]) => Promise<string>;
|
|
5718
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$4[]) => Promise<string>;
|
|
5689
5719
|
/**
|
|
5690
5720
|
* Saves symbol-strategy report to disk.
|
|
5691
5721
|
* Creates directory if it doesn't exist.
|
|
@@ -5693,6 +5723,7 @@ declare class ScheduleMarkdownService {
|
|
|
5693
5723
|
*
|
|
5694
5724
|
* @param symbol - Trading pair symbol
|
|
5695
5725
|
* @param strategyName - Strategy name to save report for
|
|
5726
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5696
5727
|
* @param path - Directory path to save report (default: "./dump/schedule")
|
|
5697
5728
|
* @param columns - Column configuration for formatting the table
|
|
5698
5729
|
*
|
|
@@ -5701,32 +5732,33 @@ declare class ScheduleMarkdownService {
|
|
|
5701
5732
|
* const service = new ScheduleMarkdownService();
|
|
5702
5733
|
*
|
|
5703
5734
|
* // Save to default path: ./dump/schedule/my-strategy.md
|
|
5704
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5735
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
5705
5736
|
*
|
|
5706
5737
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5707
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5738
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5708
5739
|
* ```
|
|
5709
5740
|
*/
|
|
5710
|
-
dump: (symbol: string, strategyName: StrategyName, path?: string, columns?: Columns$4[]) => Promise<void>;
|
|
5741
|
+
dump: (symbol: string, strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$4[]) => Promise<void>;
|
|
5711
5742
|
/**
|
|
5712
5743
|
* Clears accumulated event data from storage.
|
|
5713
|
-
* If ctx is provided, clears only that specific symbol-strategy
|
|
5744
|
+
* If ctx is provided, clears only that specific symbol-strategy-backtest triple's data.
|
|
5714
5745
|
* If nothing is provided, clears all data.
|
|
5715
5746
|
*
|
|
5747
|
+
* @param backtest - Backtest mode flag
|
|
5716
5748
|
* @param ctx - Optional context with symbol and strategyName
|
|
5717
5749
|
*
|
|
5718
5750
|
* @example
|
|
5719
5751
|
* ```typescript
|
|
5720
5752
|
* const service = new ScheduleMarkdownService();
|
|
5721
5753
|
*
|
|
5722
|
-
* // Clear specific symbol-strategy
|
|
5723
|
-
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5754
|
+
* // Clear specific symbol-strategy-backtest triple
|
|
5755
|
+
* await service.clear(false, { symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
5724
5756
|
*
|
|
5725
5757
|
* // Clear all data
|
|
5726
5758
|
* await service.clear();
|
|
5727
5759
|
* ```
|
|
5728
5760
|
*/
|
|
5729
|
-
clear: (ctx?: {
|
|
5761
|
+
clear: (backtest: boolean, ctx?: {
|
|
5730
5762
|
symbol: string;
|
|
5731
5763
|
strategyName: StrategyName;
|
|
5732
5764
|
}) => Promise<void>;
|
|
@@ -5783,7 +5815,7 @@ declare class ScheduleUtils {
|
|
|
5783
5815
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
5784
5816
|
* ```
|
|
5785
5817
|
*/
|
|
5786
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatisticsModel>;
|
|
5818
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<ScheduleStatisticsModel>;
|
|
5787
5819
|
/**
|
|
5788
5820
|
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
5789
5821
|
*
|
|
@@ -5798,7 +5830,7 @@ declare class ScheduleUtils {
|
|
|
5798
5830
|
* console.log(markdown);
|
|
5799
5831
|
* ```
|
|
5800
5832
|
*/
|
|
5801
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$4[]) => Promise<string>;
|
|
5833
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$4[]) => Promise<string>;
|
|
5802
5834
|
/**
|
|
5803
5835
|
* Saves strategy report to disk.
|
|
5804
5836
|
*
|
|
@@ -5816,7 +5848,7 @@ declare class ScheduleUtils {
|
|
|
5816
5848
|
* await Schedule.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5817
5849
|
* ```
|
|
5818
5850
|
*/
|
|
5819
|
-
dump: (symbol: string, strategyName: StrategyName, path?: string, columns?: Columns$4[]) => Promise<void>;
|
|
5851
|
+
dump: (symbol: string, strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$4[]) => Promise<void>;
|
|
5820
5852
|
}
|
|
5821
5853
|
/**
|
|
5822
5854
|
* Singleton instance of ScheduleUtils for convenient scheduled signals reporting.
|
|
@@ -5894,8 +5926,8 @@ declare class PerformanceMarkdownService {
|
|
|
5894
5926
|
/** Logger service for debug output */
|
|
5895
5927
|
private readonly loggerService;
|
|
5896
5928
|
/**
|
|
5897
|
-
* Memoized function to get or create PerformanceStorage for a symbol-strategy
|
|
5898
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
5929
|
+
* Memoized function to get or create PerformanceStorage for a symbol-strategy-backtest triple.
|
|
5930
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
5899
5931
|
*/
|
|
5900
5932
|
private getStorage;
|
|
5901
5933
|
/**
|
|
@@ -5910,57 +5942,60 @@ declare class PerformanceMarkdownService {
|
|
|
5910
5942
|
*
|
|
5911
5943
|
* @param symbol - Trading pair symbol
|
|
5912
5944
|
* @param strategyName - Strategy name to get data for
|
|
5945
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5913
5946
|
* @returns Performance statistics with aggregated metrics
|
|
5914
5947
|
*
|
|
5915
5948
|
* @example
|
|
5916
5949
|
* ```typescript
|
|
5917
|
-
* const stats = await performanceService.getData("BTCUSDT", "my-strategy");
|
|
5950
|
+
* const stats = await performanceService.getData("BTCUSDT", "my-strategy", false);
|
|
5918
5951
|
* console.log("Total time:", stats.totalDuration);
|
|
5919
5952
|
* console.log("Slowest operation:", Object.values(stats.metricStats)
|
|
5920
5953
|
* .sort((a, b) => b.avgDuration - a.avgDuration)[0]);
|
|
5921
5954
|
* ```
|
|
5922
5955
|
*/
|
|
5923
|
-
getData: (symbol: string, strategyName: string) => Promise<PerformanceStatisticsModel>;
|
|
5956
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PerformanceStatisticsModel>;
|
|
5924
5957
|
/**
|
|
5925
5958
|
* Generates markdown report with performance analysis.
|
|
5926
5959
|
*
|
|
5927
5960
|
* @param symbol - Trading pair symbol
|
|
5928
5961
|
* @param strategyName - Strategy name to generate report for
|
|
5962
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5929
5963
|
* @param columns - Column configuration for formatting the table
|
|
5930
5964
|
* @returns Markdown formatted report string
|
|
5931
5965
|
*
|
|
5932
5966
|
* @example
|
|
5933
5967
|
* ```typescript
|
|
5934
|
-
* const markdown = await performanceService.getReport("BTCUSDT", "my-strategy");
|
|
5968
|
+
* const markdown = await performanceService.getReport("BTCUSDT", "my-strategy", false);
|
|
5935
5969
|
* console.log(markdown);
|
|
5936
5970
|
* ```
|
|
5937
5971
|
*/
|
|
5938
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$3[]) => Promise<string>;
|
|
5972
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$3[]) => Promise<string>;
|
|
5939
5973
|
/**
|
|
5940
5974
|
* Saves performance report to disk.
|
|
5941
5975
|
*
|
|
5942
5976
|
* @param symbol - Trading pair symbol
|
|
5943
5977
|
* @param strategyName - Strategy name to save report for
|
|
5978
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5944
5979
|
* @param path - Directory path to save report
|
|
5945
5980
|
* @param columns - Column configuration for formatting the table
|
|
5946
5981
|
*
|
|
5947
5982
|
* @example
|
|
5948
5983
|
* ```typescript
|
|
5949
5984
|
* // Save to default path: ./dump/performance/my-strategy.md
|
|
5950
|
-
* await performanceService.dump("BTCUSDT", "my-strategy");
|
|
5985
|
+
* await performanceService.dump("BTCUSDT", "my-strategy", false);
|
|
5951
5986
|
*
|
|
5952
5987
|
* // Save to custom path
|
|
5953
|
-
* await performanceService.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5988
|
+
* await performanceService.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5954
5989
|
* ```
|
|
5955
5990
|
*/
|
|
5956
|
-
dump: (symbol: string, strategyName: string, path?: string, columns?: Columns$3[]) => Promise<void>;
|
|
5991
|
+
dump: (symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns$3[]) => Promise<void>;
|
|
5957
5992
|
/**
|
|
5958
5993
|
* Clears accumulated performance data from storage.
|
|
5959
5994
|
*
|
|
5960
|
-
* @param
|
|
5961
|
-
* @param
|
|
5995
|
+
* @param backtest - Backtest mode flag
|
|
5996
|
+
* @param ctx - Optional context with symbol and strategyName
|
|
5962
5997
|
*/
|
|
5963
|
-
clear: (ctx?: {
|
|
5998
|
+
clear: (backtest: boolean, ctx?: {
|
|
5964
5999
|
symbol: string;
|
|
5965
6000
|
strategyName: string;
|
|
5966
6001
|
}) => Promise<void>;
|
|
@@ -5989,7 +6024,7 @@ declare class PerformanceMarkdownService {
|
|
|
5989
6024
|
* console.log(`${event.metricType}: ${event.duration.toFixed(2)}ms`);
|
|
5990
6025
|
* });
|
|
5991
6026
|
*
|
|
5992
|
-
* // Run
|
|
6027
|
+
* // Run bt...
|
|
5993
6028
|
*
|
|
5994
6029
|
* // Get aggregated statistics
|
|
5995
6030
|
* const stats = await Performance.getData("my-strategy");
|
|
@@ -6032,7 +6067,7 @@ declare class Performance {
|
|
|
6032
6067
|
* }
|
|
6033
6068
|
* ```
|
|
6034
6069
|
*/
|
|
6035
|
-
static getData(symbol: string, strategyName: string): Promise<PerformanceStatisticsModel>;
|
|
6070
|
+
static getData(symbol: string, strategyName: string, backtest: boolean): Promise<PerformanceStatisticsModel>;
|
|
6036
6071
|
/**
|
|
6037
6072
|
* Generates markdown report with performance analysis.
|
|
6038
6073
|
*
|
|
@@ -6056,7 +6091,7 @@ declare class Performance {
|
|
|
6056
6091
|
* await fs.writeFile("performance-report.md", markdown);
|
|
6057
6092
|
* ```
|
|
6058
6093
|
*/
|
|
6059
|
-
static getReport(symbol: string, strategyName: string, columns?: Columns$3[]): Promise<string>;
|
|
6094
|
+
static getReport(symbol: string, strategyName: string, backtest: boolean, columns?: Columns$3[]): Promise<string>;
|
|
6060
6095
|
/**
|
|
6061
6096
|
* Saves performance report to disk.
|
|
6062
6097
|
*
|
|
@@ -6077,7 +6112,7 @@ declare class Performance {
|
|
|
6077
6112
|
* await Performance.dump("BTCUSDT", "my-strategy", "./reports/perf");
|
|
6078
6113
|
* ```
|
|
6079
6114
|
*/
|
|
6080
|
-
static dump(symbol: string, strategyName: string, path?: string, columns?: Columns$3[]): Promise<void>;
|
|
6115
|
+
static dump(symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns$3[]): Promise<void>;
|
|
6081
6116
|
}
|
|
6082
6117
|
|
|
6083
6118
|
/**
|
|
@@ -6515,8 +6550,8 @@ declare class HeatMarkdownService {
|
|
|
6515
6550
|
/** Logger service for debug output */
|
|
6516
6551
|
private readonly loggerService;
|
|
6517
6552
|
/**
|
|
6518
|
-
* Memoized function to get or create HeatmapStorage for a strategy.
|
|
6519
|
-
* Each strategy gets its own isolated heatmap storage instance.
|
|
6553
|
+
* Memoized function to get or create HeatmapStorage for a strategy and backtest mode.
|
|
6554
|
+
* Each strategy + backtest mode combination gets its own isolated heatmap storage instance.
|
|
6520
6555
|
*/
|
|
6521
6556
|
private getStorage;
|
|
6522
6557
|
/**
|
|
@@ -6532,12 +6567,13 @@ declare class HeatMarkdownService {
|
|
|
6532
6567
|
* Gets aggregated portfolio heatmap statistics for a strategy.
|
|
6533
6568
|
*
|
|
6534
6569
|
* @param strategyName - Strategy name to get heatmap data for
|
|
6570
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6535
6571
|
* @returns Promise resolving to heatmap statistics with per-symbol and portfolio-wide metrics
|
|
6536
6572
|
*
|
|
6537
6573
|
* @example
|
|
6538
6574
|
* ```typescript
|
|
6539
6575
|
* const service = new HeatMarkdownService();
|
|
6540
|
-
* const stats = await service.getData("my-strategy");
|
|
6576
|
+
* const stats = await service.getData("my-strategy", true);
|
|
6541
6577
|
*
|
|
6542
6578
|
* console.log(`Total symbols: ${stats.totalSymbols}`);
|
|
6543
6579
|
* console.log(`Portfolio PNL: ${stats.portfolioTotalPnl}%`);
|
|
@@ -6547,18 +6583,19 @@ declare class HeatMarkdownService {
|
|
|
6547
6583
|
* });
|
|
6548
6584
|
* ```
|
|
6549
6585
|
*/
|
|
6550
|
-
getData: (strategyName: StrategyName) => Promise<HeatmapStatisticsModel>;
|
|
6586
|
+
getData: (strategyName: StrategyName, backtest: boolean) => Promise<HeatmapStatisticsModel>;
|
|
6551
6587
|
/**
|
|
6552
6588
|
* Generates markdown report with portfolio heatmap table for a strategy.
|
|
6553
6589
|
*
|
|
6554
6590
|
* @param strategyName - Strategy name to generate heatmap report for
|
|
6591
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6555
6592
|
* @param columns - Column configuration for formatting the table
|
|
6556
6593
|
* @returns Promise resolving to markdown formatted report string
|
|
6557
6594
|
*
|
|
6558
6595
|
* @example
|
|
6559
6596
|
* ```typescript
|
|
6560
6597
|
* const service = new HeatMarkdownService();
|
|
6561
|
-
* const markdown = await service.getReport("my-strategy");
|
|
6598
|
+
* const markdown = await service.getReport("my-strategy", true);
|
|
6562
6599
|
* console.log(markdown);
|
|
6563
6600
|
* // Output:
|
|
6564
6601
|
* // # Portfolio Heatmap: my-strategy
|
|
@@ -6572,7 +6609,7 @@ declare class HeatMarkdownService {
|
|
|
6572
6609
|
* // ...
|
|
6573
6610
|
* ```
|
|
6574
6611
|
*/
|
|
6575
|
-
getReport: (strategyName: StrategyName, columns?: Columns$2[]) => Promise<string>;
|
|
6612
|
+
getReport: (strategyName: StrategyName, backtest: boolean, columns?: Columns$2[]) => Promise<string>;
|
|
6576
6613
|
/**
|
|
6577
6614
|
* Saves heatmap report to disk for a strategy.
|
|
6578
6615
|
*
|
|
@@ -6580,6 +6617,7 @@ declare class HeatMarkdownService {
|
|
|
6580
6617
|
* Default filename: {strategyName}.md
|
|
6581
6618
|
*
|
|
6582
6619
|
* @param strategyName - Strategy name to save heatmap report for
|
|
6620
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6583
6621
|
* @param path - Optional directory path to save report (default: "./dump/heatmap")
|
|
6584
6622
|
* @param columns - Column configuration for formatting the table
|
|
6585
6623
|
*
|
|
@@ -6588,32 +6626,35 @@ declare class HeatMarkdownService {
|
|
|
6588
6626
|
* const service = new HeatMarkdownService();
|
|
6589
6627
|
*
|
|
6590
6628
|
* // Save to default path: ./dump/heatmap/my-strategy.md
|
|
6591
|
-
* await service.dump("my-strategy");
|
|
6629
|
+
* await service.dump("my-strategy", true);
|
|
6592
6630
|
*
|
|
6593
6631
|
* // Save to custom path: ./reports/my-strategy.md
|
|
6594
|
-
* await service.dump("my-strategy", "./reports");
|
|
6632
|
+
* await service.dump("my-strategy", true, "./reports");
|
|
6595
6633
|
* ```
|
|
6596
6634
|
*/
|
|
6597
|
-
dump: (strategyName: StrategyName, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6635
|
+
dump: (strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6598
6636
|
/**
|
|
6599
6637
|
* Clears accumulated heatmap data from storage.
|
|
6600
|
-
* If
|
|
6601
|
-
* If
|
|
6638
|
+
* If ctx is provided, clears only that strategy+backtest combination's data.
|
|
6639
|
+
* If ctx is omitted, clears all data.
|
|
6602
6640
|
*
|
|
6603
|
-
* @param
|
|
6641
|
+
* @param backtest - Backtest mode flag
|
|
6642
|
+
* @param ctx - Optional context with strategyName to clear specific data
|
|
6604
6643
|
*
|
|
6605
6644
|
* @example
|
|
6606
6645
|
* ```typescript
|
|
6607
6646
|
* const service = new HeatMarkdownService();
|
|
6608
6647
|
*
|
|
6609
|
-
* // Clear specific strategy data
|
|
6610
|
-
* await service.clear("my-strategy");
|
|
6648
|
+
* // Clear specific strategy+backtest data
|
|
6649
|
+
* await service.clear(true, { strategyName: "my-strategy" });
|
|
6611
6650
|
*
|
|
6612
|
-
* // Clear all
|
|
6651
|
+
* // Clear all data
|
|
6613
6652
|
* await service.clear();
|
|
6614
6653
|
* ```
|
|
6615
6654
|
*/
|
|
6616
|
-
clear: (
|
|
6655
|
+
clear: (backtest: boolean, ctx?: {
|
|
6656
|
+
strategyName: StrategyName;
|
|
6657
|
+
}) => Promise<void>;
|
|
6617
6658
|
/**
|
|
6618
6659
|
* Initializes the service by subscribing to signal events.
|
|
6619
6660
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -6675,7 +6716,7 @@ declare class HeatUtils {
|
|
|
6675
6716
|
* });
|
|
6676
6717
|
* ```
|
|
6677
6718
|
*/
|
|
6678
|
-
getData: (strategyName: StrategyName) => Promise<HeatmapStatisticsModel>;
|
|
6719
|
+
getData: (strategyName: StrategyName, backtest: boolean) => Promise<HeatmapStatisticsModel>;
|
|
6679
6720
|
/**
|
|
6680
6721
|
* Generates markdown report with portfolio heatmap table for a strategy.
|
|
6681
6722
|
*
|
|
@@ -6702,7 +6743,7 @@ declare class HeatUtils {
|
|
|
6702
6743
|
* // ...
|
|
6703
6744
|
* ```
|
|
6704
6745
|
*/
|
|
6705
|
-
getReport: (strategyName: StrategyName, columns?: Columns$2[]) => Promise<string>;
|
|
6746
|
+
getReport: (strategyName: StrategyName, backtest: boolean, columns?: Columns$2[]) => Promise<string>;
|
|
6706
6747
|
/**
|
|
6707
6748
|
* Saves heatmap report to disk for a strategy.
|
|
6708
6749
|
*
|
|
@@ -6722,7 +6763,7 @@ declare class HeatUtils {
|
|
|
6722
6763
|
* await Heat.dump("my-strategy", "./reports");
|
|
6723
6764
|
* ```
|
|
6724
6765
|
*/
|
|
6725
|
-
dump: (strategyName: StrategyName, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6766
|
+
dump: (strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6726
6767
|
}
|
|
6727
6768
|
/**
|
|
6728
6769
|
* Singleton instance of HeatUtils for convenient heatmap operations.
|
|
@@ -6971,8 +7012,8 @@ declare class PartialMarkdownService {
|
|
|
6971
7012
|
/** Logger service for debug output */
|
|
6972
7013
|
private readonly loggerService;
|
|
6973
7014
|
/**
|
|
6974
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
6975
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
7015
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy-backtest triple.
|
|
7016
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
6976
7017
|
*/
|
|
6977
7018
|
private getStorage;
|
|
6978
7019
|
/**
|
|
@@ -7007,33 +7048,35 @@ declare class PartialMarkdownService {
|
|
|
7007
7048
|
*
|
|
7008
7049
|
* @param symbol - Trading pair symbol to get data for
|
|
7009
7050
|
* @param strategyName - Strategy name to get data for
|
|
7051
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7010
7052
|
* @returns Statistical data object with all metrics
|
|
7011
7053
|
*
|
|
7012
7054
|
* @example
|
|
7013
7055
|
* ```typescript
|
|
7014
7056
|
* const service = new PartialMarkdownService();
|
|
7015
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
7057
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
7016
7058
|
* console.log(stats.totalProfit, stats.totalLoss);
|
|
7017
7059
|
* ```
|
|
7018
7060
|
*/
|
|
7019
|
-
getData: (symbol: string, strategyName: string) => Promise<PartialStatisticsModel>;
|
|
7061
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PartialStatisticsModel>;
|
|
7020
7062
|
/**
|
|
7021
7063
|
* Generates markdown report with all partial events for a symbol-strategy pair.
|
|
7022
7064
|
* Delegates to ReportStorage.getReport().
|
|
7023
7065
|
*
|
|
7024
7066
|
* @param symbol - Trading pair symbol to generate report for
|
|
7025
7067
|
* @param strategyName - Strategy name to generate report for
|
|
7068
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7026
7069
|
* @param columns - Column configuration for formatting the table
|
|
7027
7070
|
* @returns Markdown formatted report string with table of all events
|
|
7028
7071
|
*
|
|
7029
7072
|
* @example
|
|
7030
7073
|
* ```typescript
|
|
7031
7074
|
* const service = new PartialMarkdownService();
|
|
7032
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
7075
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
7033
7076
|
* console.log(markdown);
|
|
7034
7077
|
* ```
|
|
7035
7078
|
*/
|
|
7036
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$1[]) => Promise<string>;
|
|
7079
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$1[]) => Promise<string>;
|
|
7037
7080
|
/**
|
|
7038
7081
|
* Saves symbol-strategy report to disk.
|
|
7039
7082
|
* Creates directory if it doesn't exist.
|
|
@@ -7041,6 +7084,7 @@ declare class PartialMarkdownService {
|
|
|
7041
7084
|
*
|
|
7042
7085
|
* @param symbol - Trading pair symbol to save report for
|
|
7043
7086
|
* @param strategyName - Strategy name to save report for
|
|
7087
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7044
7088
|
* @param path - Directory path to save report (default: "./dump/partial")
|
|
7045
7089
|
* @param columns - Column configuration for formatting the table
|
|
7046
7090
|
*
|
|
@@ -7049,32 +7093,33 @@ declare class PartialMarkdownService {
|
|
|
7049
7093
|
* const service = new PartialMarkdownService();
|
|
7050
7094
|
*
|
|
7051
7095
|
* // Save to default path: ./dump/partial/BTCUSDT_my-strategy.md
|
|
7052
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
7096
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
7053
7097
|
*
|
|
7054
7098
|
* // Save to custom path: ./custom/path/BTCUSDT_my-strategy.md
|
|
7055
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
7099
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
7056
7100
|
* ```
|
|
7057
7101
|
*/
|
|
7058
|
-
dump: (symbol: string, strategyName: string, path?: string, columns?: Columns$1[]) => Promise<void>;
|
|
7102
|
+
dump: (symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns$1[]) => Promise<void>;
|
|
7059
7103
|
/**
|
|
7060
7104
|
* Clears accumulated event data from storage.
|
|
7061
|
-
* If ctx is provided, clears only that specific symbol-strategy
|
|
7105
|
+
* If ctx is provided, clears only that specific symbol-strategy-backtest triple's data.
|
|
7062
7106
|
* If nothing is provided, clears all data.
|
|
7063
7107
|
*
|
|
7108
|
+
* @param backtest - Backtest mode flag
|
|
7064
7109
|
* @param ctx - Optional context with symbol and strategyName
|
|
7065
7110
|
*
|
|
7066
7111
|
* @example
|
|
7067
7112
|
* ```typescript
|
|
7068
7113
|
* const service = new PartialMarkdownService();
|
|
7069
7114
|
*
|
|
7070
|
-
* // Clear specific symbol-strategy
|
|
7071
|
-
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
7115
|
+
* // Clear specific symbol-strategy-backtest triple
|
|
7116
|
+
* await service.clear(false, { symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
7072
7117
|
*
|
|
7073
7118
|
* // Clear all data
|
|
7074
7119
|
* await service.clear();
|
|
7075
7120
|
* ```
|
|
7076
7121
|
*/
|
|
7077
|
-
clear: (ctx?: {
|
|
7122
|
+
clear: (backtest: boolean, ctx?: {
|
|
7078
7123
|
symbol: string;
|
|
7079
7124
|
strategyName: string;
|
|
7080
7125
|
}) => Promise<void>;
|
|
@@ -7152,7 +7197,7 @@ declare class PartialUtils {
|
|
|
7152
7197
|
* }
|
|
7153
7198
|
* ```
|
|
7154
7199
|
*/
|
|
7155
|
-
getData: (symbol: string, strategyName: string) => Promise<PartialStatisticsModel>;
|
|
7200
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PartialStatisticsModel>;
|
|
7156
7201
|
/**
|
|
7157
7202
|
* Generates markdown report with all partial profit/loss events for a symbol-strategy pair.
|
|
7158
7203
|
*
|
|
@@ -7192,7 +7237,7 @@ declare class PartialUtils {
|
|
|
7192
7237
|
* // **Loss events:** 1
|
|
7193
7238
|
* ```
|
|
7194
7239
|
*/
|
|
7195
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$1[]) => Promise<string>;
|
|
7240
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$1[]) => Promise<string>;
|
|
7196
7241
|
/**
|
|
7197
7242
|
* Generates and saves markdown report to file.
|
|
7198
7243
|
*
|
|
@@ -7225,7 +7270,7 @@ declare class PartialUtils {
|
|
|
7225
7270
|
* }
|
|
7226
7271
|
* ```
|
|
7227
7272
|
*/
|
|
7228
|
-
dump: (symbol: string, strategyName: string, path?: string, columns?: Columns$1[]) => Promise<void>;
|
|
7273
|
+
dump: (symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns$1[]) => Promise<void>;
|
|
7229
7274
|
}
|
|
7230
7275
|
/**
|
|
7231
7276
|
* Global singleton instance of PartialUtils.
|
|
@@ -7379,8 +7424,8 @@ declare class RiskMarkdownService {
|
|
|
7379
7424
|
/** Logger service for debug output */
|
|
7380
7425
|
private readonly loggerService;
|
|
7381
7426
|
/**
|
|
7382
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
7383
|
-
* Each symbol-strategy combination gets its own isolated storage instance.
|
|
7427
|
+
* Memoized function to get or create ReportStorage for a symbol-strategy-backtest triple.
|
|
7428
|
+
* Each symbol-strategy-backtest combination gets its own isolated storage instance.
|
|
7384
7429
|
*/
|
|
7385
7430
|
private getStorage;
|
|
7386
7431
|
/**
|
|
@@ -7402,33 +7447,35 @@ declare class RiskMarkdownService {
|
|
|
7402
7447
|
*
|
|
7403
7448
|
* @param symbol - Trading pair symbol to get data for
|
|
7404
7449
|
* @param strategyName - Strategy name to get data for
|
|
7450
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7405
7451
|
* @returns Statistical data object with all metrics
|
|
7406
7452
|
*
|
|
7407
7453
|
* @example
|
|
7408
7454
|
* ```typescript
|
|
7409
7455
|
* const service = new RiskMarkdownService();
|
|
7410
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
7456
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
7411
7457
|
* console.log(stats.totalRejections, stats.bySymbol);
|
|
7412
7458
|
* ```
|
|
7413
7459
|
*/
|
|
7414
|
-
getData: (symbol: string, strategyName: string) => Promise<RiskStatisticsModel>;
|
|
7460
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<RiskStatisticsModel>;
|
|
7415
7461
|
/**
|
|
7416
7462
|
* Generates markdown report with all risk rejection events for a symbol-strategy pair.
|
|
7417
7463
|
* Delegates to ReportStorage.getReport().
|
|
7418
7464
|
*
|
|
7419
7465
|
* @param symbol - Trading pair symbol to generate report for
|
|
7420
7466
|
* @param strategyName - Strategy name to generate report for
|
|
7467
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7421
7468
|
* @param columns - Column configuration for formatting the table
|
|
7422
7469
|
* @returns Markdown formatted report string with table of all events
|
|
7423
7470
|
*
|
|
7424
7471
|
* @example
|
|
7425
7472
|
* ```typescript
|
|
7426
7473
|
* const service = new RiskMarkdownService();
|
|
7427
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
7474
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
7428
7475
|
* console.log(markdown);
|
|
7429
7476
|
* ```
|
|
7430
7477
|
*/
|
|
7431
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns[]) => Promise<string>;
|
|
7478
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns[]) => Promise<string>;
|
|
7432
7479
|
/**
|
|
7433
7480
|
* Saves symbol-strategy report to disk.
|
|
7434
7481
|
* Creates directory if it doesn't exist.
|
|
@@ -7436,6 +7483,7 @@ declare class RiskMarkdownService {
|
|
|
7436
7483
|
*
|
|
7437
7484
|
* @param symbol - Trading pair symbol to save report for
|
|
7438
7485
|
* @param strategyName - Strategy name to save report for
|
|
7486
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7439
7487
|
* @param path - Directory path to save report (default: "./dump/risk")
|
|
7440
7488
|
* @param columns - Column configuration for formatting the table
|
|
7441
7489
|
*
|
|
@@ -7444,32 +7492,33 @@ declare class RiskMarkdownService {
|
|
|
7444
7492
|
* const service = new RiskMarkdownService();
|
|
7445
7493
|
*
|
|
7446
7494
|
* // Save to default path: ./dump/risk/BTCUSDT_my-strategy.md
|
|
7447
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
7495
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
7448
7496
|
*
|
|
7449
7497
|
* // Save to custom path: ./custom/path/BTCUSDT_my-strategy.md
|
|
7450
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
7498
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
7451
7499
|
* ```
|
|
7452
7500
|
*/
|
|
7453
|
-
dump: (symbol: string, strategyName: string, path?: string, columns?: Columns[]) => Promise<void>;
|
|
7501
|
+
dump: (symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns[]) => Promise<void>;
|
|
7454
7502
|
/**
|
|
7455
7503
|
* Clears accumulated event data from storage.
|
|
7456
|
-
* If ctx is provided, clears only that specific symbol-strategy
|
|
7504
|
+
* If ctx is provided, clears only that specific symbol-strategy-backtest triple's data.
|
|
7457
7505
|
* If nothing is provided, clears all data.
|
|
7458
7506
|
*
|
|
7507
|
+
* @param backtest - Backtest mode flag
|
|
7459
7508
|
* @param ctx - Optional context with symbol and strategyName
|
|
7460
7509
|
*
|
|
7461
7510
|
* @example
|
|
7462
7511
|
* ```typescript
|
|
7463
7512
|
* const service = new RiskMarkdownService();
|
|
7464
7513
|
*
|
|
7465
|
-
* // Clear specific symbol-strategy
|
|
7466
|
-
* await service.clear({ symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
7514
|
+
* // Clear specific symbol-strategy-backtest triple
|
|
7515
|
+
* await service.clear(false, { symbol: "BTCUSDT", strategyName: "my-strategy" });
|
|
7467
7516
|
*
|
|
7468
7517
|
* // Clear all data
|
|
7469
7518
|
* await service.clear();
|
|
7470
7519
|
* ```
|
|
7471
7520
|
*/
|
|
7472
|
-
clear: (ctx?: {
|
|
7521
|
+
clear: (backtest: boolean, ctx?: {
|
|
7473
7522
|
symbol: string;
|
|
7474
7523
|
strategyName: string;
|
|
7475
7524
|
}) => Promise<void>;
|
|
@@ -7547,7 +7596,7 @@ declare class RiskUtils {
|
|
|
7547
7596
|
* }
|
|
7548
7597
|
* ```
|
|
7549
7598
|
*/
|
|
7550
|
-
getData: (symbol: string, strategyName: string) => Promise<RiskStatisticsModel>;
|
|
7599
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<RiskStatisticsModel>;
|
|
7551
7600
|
/**
|
|
7552
7601
|
* Generates markdown report with all risk rejection events for a symbol-strategy pair.
|
|
7553
7602
|
*
|
|
@@ -7589,7 +7638,7 @@ declare class RiskUtils {
|
|
|
7589
7638
|
* // - my-strategy: 1
|
|
7590
7639
|
* ```
|
|
7591
7640
|
*/
|
|
7592
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns[]) => Promise<string>;
|
|
7641
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns[]) => Promise<string>;
|
|
7593
7642
|
/**
|
|
7594
7643
|
* Generates and saves markdown report to file.
|
|
7595
7644
|
*
|
|
@@ -7622,7 +7671,7 @@ declare class RiskUtils {
|
|
|
7622
7671
|
* }
|
|
7623
7672
|
* ```
|
|
7624
7673
|
*/
|
|
7625
|
-
dump: (symbol: string, strategyName: string, path?: string, columns?: Columns[]) => Promise<void>;
|
|
7674
|
+
dump: (symbol: string, strategyName: string, backtest: boolean, path?: string, columns?: Columns[]) => Promise<void>;
|
|
7626
7675
|
}
|
|
7627
7676
|
/**
|
|
7628
7677
|
* Global singleton instance of RiskUtils.
|