backtest-kit 1.5.26 → 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 +820 -628
- package/build/index.mjs +820 -628
- package/package.json +1 -1
- package/types.d.ts +197 -136
package/types.d.ts
CHANGED
|
@@ -431,6 +431,8 @@ interface IRiskSchema {
|
|
|
431
431
|
interface IRiskParams extends IRiskSchema {
|
|
432
432
|
/** Logger service for debug output */
|
|
433
433
|
logger: ILogger;
|
|
434
|
+
/** True if backtest mode, false if live mode */
|
|
435
|
+
backtest: boolean;
|
|
434
436
|
/**
|
|
435
437
|
* Callback invoked when a signal is rejected due to risk limits.
|
|
436
438
|
* Called before emitting to riskSubject.
|
|
@@ -441,8 +443,9 @@ interface IRiskParams extends IRiskSchema {
|
|
|
441
443
|
* @param activePositionCount - Number of active positions at rejection time
|
|
442
444
|
* @param comment - Rejection reason from validation note or "N/A"
|
|
443
445
|
* @param timestamp - Event timestamp in milliseconds
|
|
446
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
444
447
|
*/
|
|
445
|
-
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>;
|
|
446
449
|
}
|
|
447
450
|
/**
|
|
448
451
|
* Risk interface implemented by ClientRisk.
|
|
@@ -778,6 +781,8 @@ interface IStrategyTickResultIdle {
|
|
|
778
781
|
symbol: string;
|
|
779
782
|
/** Current VWAP price during idle state */
|
|
780
783
|
currentPrice: number;
|
|
784
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
785
|
+
backtest: boolean;
|
|
781
786
|
}
|
|
782
787
|
/**
|
|
783
788
|
* Tick result: scheduled signal created, waiting for price to reach entry point.
|
|
@@ -796,6 +801,8 @@ interface IStrategyTickResultScheduled {
|
|
|
796
801
|
symbol: string;
|
|
797
802
|
/** Current VWAP price when scheduled signal created */
|
|
798
803
|
currentPrice: number;
|
|
804
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
805
|
+
backtest: boolean;
|
|
799
806
|
}
|
|
800
807
|
/**
|
|
801
808
|
* Tick result: new signal just created.
|
|
@@ -814,6 +821,8 @@ interface IStrategyTickResultOpened {
|
|
|
814
821
|
symbol: string;
|
|
815
822
|
/** Current VWAP price at signal open */
|
|
816
823
|
currentPrice: number;
|
|
824
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
825
|
+
backtest: boolean;
|
|
817
826
|
}
|
|
818
827
|
/**
|
|
819
828
|
* Tick result: signal is being monitored.
|
|
@@ -836,6 +845,8 @@ interface IStrategyTickResultActive {
|
|
|
836
845
|
percentTp: number;
|
|
837
846
|
/** Percentage progress towards stop loss (0-100%, 0 if moving towards TP) */
|
|
838
847
|
percentSl: number;
|
|
848
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
849
|
+
backtest: boolean;
|
|
839
850
|
}
|
|
840
851
|
/**
|
|
841
852
|
* Tick result: signal closed with PNL.
|
|
@@ -860,6 +871,8 @@ interface IStrategyTickResultClosed {
|
|
|
860
871
|
exchangeName: ExchangeName;
|
|
861
872
|
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
862
873
|
symbol: string;
|
|
874
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
875
|
+
backtest: boolean;
|
|
863
876
|
}
|
|
864
877
|
/**
|
|
865
878
|
* Tick result: scheduled signal cancelled without opening position.
|
|
@@ -880,6 +893,8 @@ interface IStrategyTickResultCancelled {
|
|
|
880
893
|
exchangeName: ExchangeName;
|
|
881
894
|
/** Trading pair symbol (e.g., "BTCUSDT") */
|
|
882
895
|
symbol: string;
|
|
896
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
897
|
+
backtest: boolean;
|
|
883
898
|
}
|
|
884
899
|
/**
|
|
885
900
|
* Discriminated union of all tick results.
|
|
@@ -1192,6 +1207,8 @@ interface RiskEvent {
|
|
|
1192
1207
|
activePositionCount: number;
|
|
1193
1208
|
/** Rejection reason from validation note */
|
|
1194
1209
|
comment: string;
|
|
1210
|
+
/** Whether this event is from backtest mode (true) or live mode (false) */
|
|
1211
|
+
backtest: boolean;
|
|
1195
1212
|
}
|
|
1196
1213
|
/**
|
|
1197
1214
|
* Statistical data calculated from risk rejection events.
|
|
@@ -3371,6 +3388,11 @@ interface RiskContract {
|
|
|
3371
3388
|
* ```
|
|
3372
3389
|
*/
|
|
3373
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;
|
|
3374
3396
|
}
|
|
3375
3397
|
|
|
3376
3398
|
/**
|
|
@@ -4803,7 +4825,7 @@ type PartialData = Record<string, IPartialData>;
|
|
|
4803
4825
|
* Utility class for managing partial profit/loss levels persistence.
|
|
4804
4826
|
*
|
|
4805
4827
|
* Features:
|
|
4806
|
-
* - Memoized storage instances per symbol
|
|
4828
|
+
* - Memoized storage instances per symbol:strategyName
|
|
4807
4829
|
* - Custom adapter support
|
|
4808
4830
|
* - Atomic read/write operations for partial data
|
|
4809
4831
|
* - Crash-safe partial state management
|
|
@@ -4829,15 +4851,16 @@ declare class PersistPartialUtils {
|
|
|
4829
4851
|
*/
|
|
4830
4852
|
usePersistPartialAdapter(Ctor: TPersistBaseCtor<string, PartialData>): void;
|
|
4831
4853
|
/**
|
|
4832
|
-
* Reads persisted partial data for a symbol.
|
|
4854
|
+
* Reads persisted partial data for a symbol and strategy.
|
|
4833
4855
|
*
|
|
4834
4856
|
* Called by ClientPartial.waitForInit() to restore state.
|
|
4835
4857
|
* Returns empty object if no partial data exists.
|
|
4836
4858
|
*
|
|
4837
4859
|
* @param symbol - Trading pair symbol
|
|
4860
|
+
* @param strategyName - Strategy identifier
|
|
4838
4861
|
* @returns Promise resolving to partial data record
|
|
4839
4862
|
*/
|
|
4840
|
-
readPartialData: (symbol: string) => Promise<PartialData>;
|
|
4863
|
+
readPartialData: (symbol: string, strategyName: StrategyName) => Promise<PartialData>;
|
|
4841
4864
|
/**
|
|
4842
4865
|
* Writes partial data to disk with atomic file writes.
|
|
4843
4866
|
*
|
|
@@ -4846,9 +4869,10 @@ declare class PersistPartialUtils {
|
|
|
4846
4869
|
*
|
|
4847
4870
|
* @param partialData - Record of signal IDs to partial data
|
|
4848
4871
|
* @param symbol - Trading pair symbol
|
|
4872
|
+
* @param strategyName - Strategy identifier
|
|
4849
4873
|
* @returns Promise that resolves when write is complete
|
|
4850
4874
|
*/
|
|
4851
|
-
writePartialData: (partialData: PartialData, symbol: string) => Promise<void>;
|
|
4875
|
+
writePartialData: (partialData: PartialData, symbol: string, strategyName: StrategyName) => Promise<void>;
|
|
4852
4876
|
}
|
|
4853
4877
|
/**
|
|
4854
4878
|
* Global singleton instance of PersistPartialUtils.
|
|
@@ -4860,10 +4884,10 @@ declare class PersistPartialUtils {
|
|
|
4860
4884
|
* PersistPartialAdapter.usePersistPartialAdapter(RedisPersist);
|
|
4861
4885
|
*
|
|
4862
4886
|
* // Read partial data
|
|
4863
|
-
* const partialData = await PersistPartialAdapter.readPartialData("BTCUSDT");
|
|
4887
|
+
* const partialData = await PersistPartialAdapter.readPartialData("BTCUSDT", "my-strategy");
|
|
4864
4888
|
*
|
|
4865
4889
|
* // Write partial data
|
|
4866
|
-
* await PersistPartialAdapter.writePartialData(partialData, "BTCUSDT");
|
|
4890
|
+
* await PersistPartialAdapter.writePartialData(partialData, "BTCUSDT", "my-strategy");
|
|
4867
4891
|
* ```
|
|
4868
4892
|
*/
|
|
4869
4893
|
declare const PersistPartialAdapter: PersistPartialUtils;
|
|
@@ -4931,8 +4955,8 @@ declare class BacktestMarkdownService {
|
|
|
4931
4955
|
/** Logger service for debug output */
|
|
4932
4956
|
private readonly loggerService;
|
|
4933
4957
|
/**
|
|
4934
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
4935
|
-
* 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.
|
|
4936
4960
|
*/
|
|
4937
4961
|
private getStorage;
|
|
4938
4962
|
/**
|
|
@@ -4961,33 +4985,35 @@ declare class BacktestMarkdownService {
|
|
|
4961
4985
|
*
|
|
4962
4986
|
* @param symbol - Trading pair symbol
|
|
4963
4987
|
* @param strategyName - Strategy name to get data for
|
|
4988
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
4964
4989
|
* @returns Statistical data object with all metrics
|
|
4965
4990
|
*
|
|
4966
4991
|
* @example
|
|
4967
4992
|
* ```typescript
|
|
4968
4993
|
* const service = new BacktestMarkdownService();
|
|
4969
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
4994
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", true);
|
|
4970
4995
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
4971
4996
|
* ```
|
|
4972
4997
|
*/
|
|
4973
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<BacktestStatisticsModel>;
|
|
4998
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<BacktestStatisticsModel>;
|
|
4974
4999
|
/**
|
|
4975
5000
|
* Generates markdown report with all closed signals for a symbol-strategy pair.
|
|
4976
5001
|
* Delegates to ReportStorage.generateReport().
|
|
4977
5002
|
*
|
|
4978
5003
|
* @param symbol - Trading pair symbol
|
|
4979
5004
|
* @param strategyName - Strategy name to generate report for
|
|
5005
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
4980
5006
|
* @param columns - Column configuration for formatting the table
|
|
4981
5007
|
* @returns Markdown formatted report string with table of all closed signals
|
|
4982
5008
|
*
|
|
4983
5009
|
* @example
|
|
4984
5010
|
* ```typescript
|
|
4985
5011
|
* const service = new BacktestMarkdownService();
|
|
4986
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5012
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", true);
|
|
4987
5013
|
* console.log(markdown);
|
|
4988
5014
|
* ```
|
|
4989
5015
|
*/
|
|
4990
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$6[]) => Promise<string>;
|
|
5016
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$6[]) => Promise<string>;
|
|
4991
5017
|
/**
|
|
4992
5018
|
* Saves symbol-strategy report to disk.
|
|
4993
5019
|
* Creates directory if it doesn't exist.
|
|
@@ -4995,6 +5021,7 @@ declare class BacktestMarkdownService {
|
|
|
4995
5021
|
*
|
|
4996
5022
|
* @param symbol - Trading pair symbol
|
|
4997
5023
|
* @param strategyName - Strategy name to save report for
|
|
5024
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
4998
5025
|
* @param path - Directory path to save report (default: "./dump/backtest")
|
|
4999
5026
|
* @param columns - Column configuration for formatting the table
|
|
5000
5027
|
*
|
|
@@ -5003,32 +5030,33 @@ declare class BacktestMarkdownService {
|
|
|
5003
5030
|
* const service = new BacktestMarkdownService();
|
|
5004
5031
|
*
|
|
5005
5032
|
* // Save to default path: ./dump/backtest/my-strategy.md
|
|
5006
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5033
|
+
* await service.dump("BTCUSDT", "my-strategy", true);
|
|
5007
5034
|
*
|
|
5008
5035
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5009
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5036
|
+
* await service.dump("BTCUSDT", "my-strategy", true, "./custom/path");
|
|
5010
5037
|
* ```
|
|
5011
5038
|
*/
|
|
5012
|
-
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>;
|
|
5013
5040
|
/**
|
|
5014
5041
|
* Clears accumulated signal data from storage.
|
|
5015
|
-
* 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.
|
|
5016
5043
|
* If nothing is provided, clears all data.
|
|
5017
5044
|
*
|
|
5045
|
+
* @param backtest - Backtest mode flag
|
|
5018
5046
|
* @param ctx - Optional context with symbol and strategyName
|
|
5019
5047
|
*
|
|
5020
5048
|
* @example
|
|
5021
5049
|
* ```typescript
|
|
5022
5050
|
* const service = new BacktestMarkdownService();
|
|
5023
5051
|
*
|
|
5024
|
-
* // Clear specific symbol-strategy
|
|
5025
|
-
* 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" });
|
|
5026
5054
|
*
|
|
5027
5055
|
* // Clear all data
|
|
5028
5056
|
* await service.clear();
|
|
5029
5057
|
* ```
|
|
5030
5058
|
*/
|
|
5031
|
-
clear: (ctx?: {
|
|
5059
|
+
clear: (backtest: boolean, ctx?: {
|
|
5032
5060
|
symbol: string;
|
|
5033
5061
|
strategyName: StrategyName;
|
|
5034
5062
|
}) => Promise<void>;
|
|
@@ -5280,8 +5308,8 @@ declare class LiveMarkdownService {
|
|
|
5280
5308
|
/** Logger service for debug output */
|
|
5281
5309
|
private readonly loggerService;
|
|
5282
5310
|
/**
|
|
5283
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
5284
|
-
* 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.
|
|
5285
5313
|
*/
|
|
5286
5314
|
private getStorage;
|
|
5287
5315
|
/**
|
|
@@ -5312,33 +5340,35 @@ declare class LiveMarkdownService {
|
|
|
5312
5340
|
*
|
|
5313
5341
|
* @param symbol - Trading pair symbol
|
|
5314
5342
|
* @param strategyName - Strategy name to get data for
|
|
5343
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5315
5344
|
* @returns Statistical data object with all metrics
|
|
5316
5345
|
*
|
|
5317
5346
|
* @example
|
|
5318
5347
|
* ```typescript
|
|
5319
5348
|
* const service = new LiveMarkdownService();
|
|
5320
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
5349
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
5321
5350
|
* console.log(stats.sharpeRatio, stats.winRate);
|
|
5322
5351
|
* ```
|
|
5323
5352
|
*/
|
|
5324
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<LiveStatisticsModel>;
|
|
5353
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<LiveStatisticsModel>;
|
|
5325
5354
|
/**
|
|
5326
5355
|
* Generates markdown report with all events for a symbol-strategy pair.
|
|
5327
5356
|
* Delegates to ReportStorage.getReport().
|
|
5328
5357
|
*
|
|
5329
5358
|
* @param symbol - Trading pair symbol
|
|
5330
5359
|
* @param strategyName - Strategy name to generate report for
|
|
5360
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5331
5361
|
* @param columns - Column configuration for formatting the table
|
|
5332
5362
|
* @returns Markdown formatted report string with table of all events
|
|
5333
5363
|
*
|
|
5334
5364
|
* @example
|
|
5335
5365
|
* ```typescript
|
|
5336
5366
|
* const service = new LiveMarkdownService();
|
|
5337
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5367
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
5338
5368
|
* console.log(markdown);
|
|
5339
5369
|
* ```
|
|
5340
5370
|
*/
|
|
5341
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$5[]) => Promise<string>;
|
|
5371
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$5[]) => Promise<string>;
|
|
5342
5372
|
/**
|
|
5343
5373
|
* Saves symbol-strategy report to disk.
|
|
5344
5374
|
* Creates directory if it doesn't exist.
|
|
@@ -5346,6 +5376,7 @@ declare class LiveMarkdownService {
|
|
|
5346
5376
|
*
|
|
5347
5377
|
* @param symbol - Trading pair symbol
|
|
5348
5378
|
* @param strategyName - Strategy name to save report for
|
|
5379
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5349
5380
|
* @param path - Directory path to save report (default: "./dump/live")
|
|
5350
5381
|
* @param columns - Column configuration for formatting the table
|
|
5351
5382
|
*
|
|
@@ -5354,32 +5385,33 @@ declare class LiveMarkdownService {
|
|
|
5354
5385
|
* const service = new LiveMarkdownService();
|
|
5355
5386
|
*
|
|
5356
5387
|
* // Save to default path: ./dump/live/my-strategy.md
|
|
5357
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5388
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
5358
5389
|
*
|
|
5359
5390
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5360
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5391
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5361
5392
|
* ```
|
|
5362
5393
|
*/
|
|
5363
|
-
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>;
|
|
5364
5395
|
/**
|
|
5365
5396
|
* Clears accumulated event data from storage.
|
|
5366
|
-
* 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.
|
|
5367
5398
|
* If nothing is provided, clears all data.
|
|
5368
5399
|
*
|
|
5400
|
+
* @param backtest - Backtest mode flag
|
|
5369
5401
|
* @param ctx - Optional context with symbol and strategyName
|
|
5370
5402
|
*
|
|
5371
5403
|
* @example
|
|
5372
5404
|
* ```typescript
|
|
5373
5405
|
* const service = new LiveMarkdownService();
|
|
5374
5406
|
*
|
|
5375
|
-
* // Clear specific symbol-strategy
|
|
5376
|
-
* 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" });
|
|
5377
5409
|
*
|
|
5378
5410
|
* // Clear all data
|
|
5379
5411
|
* await service.clear();
|
|
5380
5412
|
* ```
|
|
5381
5413
|
*/
|
|
5382
|
-
clear: (ctx?: {
|
|
5414
|
+
clear: (backtest: boolean, ctx?: {
|
|
5383
5415
|
symbol: string;
|
|
5384
5416
|
strategyName: StrategyName;
|
|
5385
5417
|
}) => Promise<void>;
|
|
@@ -5630,8 +5662,8 @@ declare class ScheduleMarkdownService {
|
|
|
5630
5662
|
/** Logger service for debug output */
|
|
5631
5663
|
private readonly loggerService;
|
|
5632
5664
|
/**
|
|
5633
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
5634
|
-
* 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.
|
|
5635
5667
|
*/
|
|
5636
5668
|
private getStorage;
|
|
5637
5669
|
/**
|
|
@@ -5655,33 +5687,35 @@ declare class ScheduleMarkdownService {
|
|
|
5655
5687
|
*
|
|
5656
5688
|
* @param symbol - Trading pair symbol
|
|
5657
5689
|
* @param strategyName - Strategy name to get data for
|
|
5690
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5658
5691
|
* @returns Statistical data object with all metrics
|
|
5659
5692
|
*
|
|
5660
5693
|
* @example
|
|
5661
5694
|
* ```typescript
|
|
5662
5695
|
* const service = new ScheduleMarkdownService();
|
|
5663
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
5696
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
5664
5697
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
5665
5698
|
* ```
|
|
5666
5699
|
*/
|
|
5667
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatisticsModel>;
|
|
5700
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<ScheduleStatisticsModel>;
|
|
5668
5701
|
/**
|
|
5669
5702
|
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
5670
5703
|
* Delegates to ReportStorage.getReport().
|
|
5671
5704
|
*
|
|
5672
5705
|
* @param symbol - Trading pair symbol
|
|
5673
5706
|
* @param strategyName - Strategy name to generate report for
|
|
5707
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5674
5708
|
* @param columns - Column configuration for formatting the table
|
|
5675
5709
|
* @returns Markdown formatted report string with table of all events
|
|
5676
5710
|
*
|
|
5677
5711
|
* @example
|
|
5678
5712
|
* ```typescript
|
|
5679
5713
|
* const service = new ScheduleMarkdownService();
|
|
5680
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
5714
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
5681
5715
|
* console.log(markdown);
|
|
5682
5716
|
* ```
|
|
5683
5717
|
*/
|
|
5684
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$4[]) => Promise<string>;
|
|
5718
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$4[]) => Promise<string>;
|
|
5685
5719
|
/**
|
|
5686
5720
|
* Saves symbol-strategy report to disk.
|
|
5687
5721
|
* Creates directory if it doesn't exist.
|
|
@@ -5689,6 +5723,7 @@ declare class ScheduleMarkdownService {
|
|
|
5689
5723
|
*
|
|
5690
5724
|
* @param symbol - Trading pair symbol
|
|
5691
5725
|
* @param strategyName - Strategy name to save report for
|
|
5726
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5692
5727
|
* @param path - Directory path to save report (default: "./dump/schedule")
|
|
5693
5728
|
* @param columns - Column configuration for formatting the table
|
|
5694
5729
|
*
|
|
@@ -5697,32 +5732,33 @@ declare class ScheduleMarkdownService {
|
|
|
5697
5732
|
* const service = new ScheduleMarkdownService();
|
|
5698
5733
|
*
|
|
5699
5734
|
* // Save to default path: ./dump/schedule/my-strategy.md
|
|
5700
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
5735
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
5701
5736
|
*
|
|
5702
5737
|
* // Save to custom path: ./custom/path/my-strategy.md
|
|
5703
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5738
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5704
5739
|
* ```
|
|
5705
5740
|
*/
|
|
5706
|
-
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>;
|
|
5707
5742
|
/**
|
|
5708
5743
|
* Clears accumulated event data from storage.
|
|
5709
|
-
* 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.
|
|
5710
5745
|
* If nothing is provided, clears all data.
|
|
5711
5746
|
*
|
|
5747
|
+
* @param backtest - Backtest mode flag
|
|
5712
5748
|
* @param ctx - Optional context with symbol and strategyName
|
|
5713
5749
|
*
|
|
5714
5750
|
* @example
|
|
5715
5751
|
* ```typescript
|
|
5716
5752
|
* const service = new ScheduleMarkdownService();
|
|
5717
5753
|
*
|
|
5718
|
-
* // Clear specific symbol-strategy
|
|
5719
|
-
* 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" });
|
|
5720
5756
|
*
|
|
5721
5757
|
* // Clear all data
|
|
5722
5758
|
* await service.clear();
|
|
5723
5759
|
* ```
|
|
5724
5760
|
*/
|
|
5725
|
-
clear: (ctx?: {
|
|
5761
|
+
clear: (backtest: boolean, ctx?: {
|
|
5726
5762
|
symbol: string;
|
|
5727
5763
|
strategyName: StrategyName;
|
|
5728
5764
|
}) => Promise<void>;
|
|
@@ -5779,7 +5815,7 @@ declare class ScheduleUtils {
|
|
|
5779
5815
|
* console.log(stats.cancellationRate, stats.avgWaitTime);
|
|
5780
5816
|
* ```
|
|
5781
5817
|
*/
|
|
5782
|
-
getData: (symbol: string, strategyName: StrategyName) => Promise<ScheduleStatisticsModel>;
|
|
5818
|
+
getData: (symbol: string, strategyName: StrategyName, backtest: boolean) => Promise<ScheduleStatisticsModel>;
|
|
5783
5819
|
/**
|
|
5784
5820
|
* Generates markdown report with all scheduled events for a symbol-strategy pair.
|
|
5785
5821
|
*
|
|
@@ -5794,7 +5830,7 @@ declare class ScheduleUtils {
|
|
|
5794
5830
|
* console.log(markdown);
|
|
5795
5831
|
* ```
|
|
5796
5832
|
*/
|
|
5797
|
-
getReport: (symbol: string, strategyName: StrategyName, columns?: Columns$4[]) => Promise<string>;
|
|
5833
|
+
getReport: (symbol: string, strategyName: StrategyName, backtest: boolean, columns?: Columns$4[]) => Promise<string>;
|
|
5798
5834
|
/**
|
|
5799
5835
|
* Saves strategy report to disk.
|
|
5800
5836
|
*
|
|
@@ -5812,7 +5848,7 @@ declare class ScheduleUtils {
|
|
|
5812
5848
|
* await Schedule.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5813
5849
|
* ```
|
|
5814
5850
|
*/
|
|
5815
|
-
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>;
|
|
5816
5852
|
}
|
|
5817
5853
|
/**
|
|
5818
5854
|
* Singleton instance of ScheduleUtils for convenient scheduled signals reporting.
|
|
@@ -5890,8 +5926,8 @@ declare class PerformanceMarkdownService {
|
|
|
5890
5926
|
/** Logger service for debug output */
|
|
5891
5927
|
private readonly loggerService;
|
|
5892
5928
|
/**
|
|
5893
|
-
* Memoized function to get or create PerformanceStorage for a symbol-strategy
|
|
5894
|
-
* 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.
|
|
5895
5931
|
*/
|
|
5896
5932
|
private getStorage;
|
|
5897
5933
|
/**
|
|
@@ -5906,57 +5942,60 @@ declare class PerformanceMarkdownService {
|
|
|
5906
5942
|
*
|
|
5907
5943
|
* @param symbol - Trading pair symbol
|
|
5908
5944
|
* @param strategyName - Strategy name to get data for
|
|
5945
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5909
5946
|
* @returns Performance statistics with aggregated metrics
|
|
5910
5947
|
*
|
|
5911
5948
|
* @example
|
|
5912
5949
|
* ```typescript
|
|
5913
|
-
* const stats = await performanceService.getData("BTCUSDT", "my-strategy");
|
|
5950
|
+
* const stats = await performanceService.getData("BTCUSDT", "my-strategy", false);
|
|
5914
5951
|
* console.log("Total time:", stats.totalDuration);
|
|
5915
5952
|
* console.log("Slowest operation:", Object.values(stats.metricStats)
|
|
5916
5953
|
* .sort((a, b) => b.avgDuration - a.avgDuration)[0]);
|
|
5917
5954
|
* ```
|
|
5918
5955
|
*/
|
|
5919
|
-
getData: (symbol: string, strategyName: string) => Promise<PerformanceStatisticsModel>;
|
|
5956
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PerformanceStatisticsModel>;
|
|
5920
5957
|
/**
|
|
5921
5958
|
* Generates markdown report with performance analysis.
|
|
5922
5959
|
*
|
|
5923
5960
|
* @param symbol - Trading pair symbol
|
|
5924
5961
|
* @param strategyName - Strategy name to generate report for
|
|
5962
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5925
5963
|
* @param columns - Column configuration for formatting the table
|
|
5926
5964
|
* @returns Markdown formatted report string
|
|
5927
5965
|
*
|
|
5928
5966
|
* @example
|
|
5929
5967
|
* ```typescript
|
|
5930
|
-
* const markdown = await performanceService.getReport("BTCUSDT", "my-strategy");
|
|
5968
|
+
* const markdown = await performanceService.getReport("BTCUSDT", "my-strategy", false);
|
|
5931
5969
|
* console.log(markdown);
|
|
5932
5970
|
* ```
|
|
5933
5971
|
*/
|
|
5934
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$3[]) => Promise<string>;
|
|
5972
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$3[]) => Promise<string>;
|
|
5935
5973
|
/**
|
|
5936
5974
|
* Saves performance report to disk.
|
|
5937
5975
|
*
|
|
5938
5976
|
* @param symbol - Trading pair symbol
|
|
5939
5977
|
* @param strategyName - Strategy name to save report for
|
|
5978
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
5940
5979
|
* @param path - Directory path to save report
|
|
5941
5980
|
* @param columns - Column configuration for formatting the table
|
|
5942
5981
|
*
|
|
5943
5982
|
* @example
|
|
5944
5983
|
* ```typescript
|
|
5945
5984
|
* // Save to default path: ./dump/performance/my-strategy.md
|
|
5946
|
-
* await performanceService.dump("BTCUSDT", "my-strategy");
|
|
5985
|
+
* await performanceService.dump("BTCUSDT", "my-strategy", false);
|
|
5947
5986
|
*
|
|
5948
5987
|
* // Save to custom path
|
|
5949
|
-
* await performanceService.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
5988
|
+
* await performanceService.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
5950
5989
|
* ```
|
|
5951
5990
|
*/
|
|
5952
|
-
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>;
|
|
5953
5992
|
/**
|
|
5954
5993
|
* Clears accumulated performance data from storage.
|
|
5955
5994
|
*
|
|
5956
|
-
* @param
|
|
5957
|
-
* @param
|
|
5995
|
+
* @param backtest - Backtest mode flag
|
|
5996
|
+
* @param ctx - Optional context with symbol and strategyName
|
|
5958
5997
|
*/
|
|
5959
|
-
clear: (ctx?: {
|
|
5998
|
+
clear: (backtest: boolean, ctx?: {
|
|
5960
5999
|
symbol: string;
|
|
5961
6000
|
strategyName: string;
|
|
5962
6001
|
}) => Promise<void>;
|
|
@@ -5985,7 +6024,7 @@ declare class PerformanceMarkdownService {
|
|
|
5985
6024
|
* console.log(`${event.metricType}: ${event.duration.toFixed(2)}ms`);
|
|
5986
6025
|
* });
|
|
5987
6026
|
*
|
|
5988
|
-
* // Run
|
|
6027
|
+
* // Run bt...
|
|
5989
6028
|
*
|
|
5990
6029
|
* // Get aggregated statistics
|
|
5991
6030
|
* const stats = await Performance.getData("my-strategy");
|
|
@@ -6028,7 +6067,7 @@ declare class Performance {
|
|
|
6028
6067
|
* }
|
|
6029
6068
|
* ```
|
|
6030
6069
|
*/
|
|
6031
|
-
static getData(symbol: string, strategyName: string): Promise<PerformanceStatisticsModel>;
|
|
6070
|
+
static getData(symbol: string, strategyName: string, backtest: boolean): Promise<PerformanceStatisticsModel>;
|
|
6032
6071
|
/**
|
|
6033
6072
|
* Generates markdown report with performance analysis.
|
|
6034
6073
|
*
|
|
@@ -6052,7 +6091,7 @@ declare class Performance {
|
|
|
6052
6091
|
* await fs.writeFile("performance-report.md", markdown);
|
|
6053
6092
|
* ```
|
|
6054
6093
|
*/
|
|
6055
|
-
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>;
|
|
6056
6095
|
/**
|
|
6057
6096
|
* Saves performance report to disk.
|
|
6058
6097
|
*
|
|
@@ -6073,7 +6112,7 @@ declare class Performance {
|
|
|
6073
6112
|
* await Performance.dump("BTCUSDT", "my-strategy", "./reports/perf");
|
|
6074
6113
|
* ```
|
|
6075
6114
|
*/
|
|
6076
|
-
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>;
|
|
6077
6116
|
}
|
|
6078
6117
|
|
|
6079
6118
|
/**
|
|
@@ -6511,8 +6550,8 @@ declare class HeatMarkdownService {
|
|
|
6511
6550
|
/** Logger service for debug output */
|
|
6512
6551
|
private readonly loggerService;
|
|
6513
6552
|
/**
|
|
6514
|
-
* Memoized function to get or create HeatmapStorage for a strategy.
|
|
6515
|
-
* 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.
|
|
6516
6555
|
*/
|
|
6517
6556
|
private getStorage;
|
|
6518
6557
|
/**
|
|
@@ -6528,12 +6567,13 @@ declare class HeatMarkdownService {
|
|
|
6528
6567
|
* Gets aggregated portfolio heatmap statistics for a strategy.
|
|
6529
6568
|
*
|
|
6530
6569
|
* @param strategyName - Strategy name to get heatmap data for
|
|
6570
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6531
6571
|
* @returns Promise resolving to heatmap statistics with per-symbol and portfolio-wide metrics
|
|
6532
6572
|
*
|
|
6533
6573
|
* @example
|
|
6534
6574
|
* ```typescript
|
|
6535
6575
|
* const service = new HeatMarkdownService();
|
|
6536
|
-
* const stats = await service.getData("my-strategy");
|
|
6576
|
+
* const stats = await service.getData("my-strategy", true);
|
|
6537
6577
|
*
|
|
6538
6578
|
* console.log(`Total symbols: ${stats.totalSymbols}`);
|
|
6539
6579
|
* console.log(`Portfolio PNL: ${stats.portfolioTotalPnl}%`);
|
|
@@ -6543,18 +6583,19 @@ declare class HeatMarkdownService {
|
|
|
6543
6583
|
* });
|
|
6544
6584
|
* ```
|
|
6545
6585
|
*/
|
|
6546
|
-
getData: (strategyName: StrategyName) => Promise<HeatmapStatisticsModel>;
|
|
6586
|
+
getData: (strategyName: StrategyName, backtest: boolean) => Promise<HeatmapStatisticsModel>;
|
|
6547
6587
|
/**
|
|
6548
6588
|
* Generates markdown report with portfolio heatmap table for a strategy.
|
|
6549
6589
|
*
|
|
6550
6590
|
* @param strategyName - Strategy name to generate heatmap report for
|
|
6591
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6551
6592
|
* @param columns - Column configuration for formatting the table
|
|
6552
6593
|
* @returns Promise resolving to markdown formatted report string
|
|
6553
6594
|
*
|
|
6554
6595
|
* @example
|
|
6555
6596
|
* ```typescript
|
|
6556
6597
|
* const service = new HeatMarkdownService();
|
|
6557
|
-
* const markdown = await service.getReport("my-strategy");
|
|
6598
|
+
* const markdown = await service.getReport("my-strategy", true);
|
|
6558
6599
|
* console.log(markdown);
|
|
6559
6600
|
* // Output:
|
|
6560
6601
|
* // # Portfolio Heatmap: my-strategy
|
|
@@ -6568,7 +6609,7 @@ declare class HeatMarkdownService {
|
|
|
6568
6609
|
* // ...
|
|
6569
6610
|
* ```
|
|
6570
6611
|
*/
|
|
6571
|
-
getReport: (strategyName: StrategyName, columns?: Columns$2[]) => Promise<string>;
|
|
6612
|
+
getReport: (strategyName: StrategyName, backtest: boolean, columns?: Columns$2[]) => Promise<string>;
|
|
6572
6613
|
/**
|
|
6573
6614
|
* Saves heatmap report to disk for a strategy.
|
|
6574
6615
|
*
|
|
@@ -6576,6 +6617,7 @@ declare class HeatMarkdownService {
|
|
|
6576
6617
|
* Default filename: {strategyName}.md
|
|
6577
6618
|
*
|
|
6578
6619
|
* @param strategyName - Strategy name to save heatmap report for
|
|
6620
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
6579
6621
|
* @param path - Optional directory path to save report (default: "./dump/heatmap")
|
|
6580
6622
|
* @param columns - Column configuration for formatting the table
|
|
6581
6623
|
*
|
|
@@ -6584,32 +6626,35 @@ declare class HeatMarkdownService {
|
|
|
6584
6626
|
* const service = new HeatMarkdownService();
|
|
6585
6627
|
*
|
|
6586
6628
|
* // Save to default path: ./dump/heatmap/my-strategy.md
|
|
6587
|
-
* await service.dump("my-strategy");
|
|
6629
|
+
* await service.dump("my-strategy", true);
|
|
6588
6630
|
*
|
|
6589
6631
|
* // Save to custom path: ./reports/my-strategy.md
|
|
6590
|
-
* await service.dump("my-strategy", "./reports");
|
|
6632
|
+
* await service.dump("my-strategy", true, "./reports");
|
|
6591
6633
|
* ```
|
|
6592
6634
|
*/
|
|
6593
|
-
dump: (strategyName: StrategyName, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6635
|
+
dump: (strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6594
6636
|
/**
|
|
6595
6637
|
* Clears accumulated heatmap data from storage.
|
|
6596
|
-
* If
|
|
6597
|
-
* If
|
|
6638
|
+
* If ctx is provided, clears only that strategy+backtest combination's data.
|
|
6639
|
+
* If ctx is omitted, clears all data.
|
|
6598
6640
|
*
|
|
6599
|
-
* @param
|
|
6641
|
+
* @param backtest - Backtest mode flag
|
|
6642
|
+
* @param ctx - Optional context with strategyName to clear specific data
|
|
6600
6643
|
*
|
|
6601
6644
|
* @example
|
|
6602
6645
|
* ```typescript
|
|
6603
6646
|
* const service = new HeatMarkdownService();
|
|
6604
6647
|
*
|
|
6605
|
-
* // Clear specific strategy data
|
|
6606
|
-
* await service.clear("my-strategy");
|
|
6648
|
+
* // Clear specific strategy+backtest data
|
|
6649
|
+
* await service.clear(true, { strategyName: "my-strategy" });
|
|
6607
6650
|
*
|
|
6608
|
-
* // Clear all
|
|
6651
|
+
* // Clear all data
|
|
6609
6652
|
* await service.clear();
|
|
6610
6653
|
* ```
|
|
6611
6654
|
*/
|
|
6612
|
-
clear: (
|
|
6655
|
+
clear: (backtest: boolean, ctx?: {
|
|
6656
|
+
strategyName: StrategyName;
|
|
6657
|
+
}) => Promise<void>;
|
|
6613
6658
|
/**
|
|
6614
6659
|
* Initializes the service by subscribing to signal events.
|
|
6615
6660
|
* Uses singleshot to ensure initialization happens only once.
|
|
@@ -6671,7 +6716,7 @@ declare class HeatUtils {
|
|
|
6671
6716
|
* });
|
|
6672
6717
|
* ```
|
|
6673
6718
|
*/
|
|
6674
|
-
getData: (strategyName: StrategyName) => Promise<HeatmapStatisticsModel>;
|
|
6719
|
+
getData: (strategyName: StrategyName, backtest: boolean) => Promise<HeatmapStatisticsModel>;
|
|
6675
6720
|
/**
|
|
6676
6721
|
* Generates markdown report with portfolio heatmap table for a strategy.
|
|
6677
6722
|
*
|
|
@@ -6698,7 +6743,7 @@ declare class HeatUtils {
|
|
|
6698
6743
|
* // ...
|
|
6699
6744
|
* ```
|
|
6700
6745
|
*/
|
|
6701
|
-
getReport: (strategyName: StrategyName, columns?: Columns$2[]) => Promise<string>;
|
|
6746
|
+
getReport: (strategyName: StrategyName, backtest: boolean, columns?: Columns$2[]) => Promise<string>;
|
|
6702
6747
|
/**
|
|
6703
6748
|
* Saves heatmap report to disk for a strategy.
|
|
6704
6749
|
*
|
|
@@ -6718,7 +6763,7 @@ declare class HeatUtils {
|
|
|
6718
6763
|
* await Heat.dump("my-strategy", "./reports");
|
|
6719
6764
|
* ```
|
|
6720
6765
|
*/
|
|
6721
|
-
dump: (strategyName: StrategyName, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6766
|
+
dump: (strategyName: StrategyName, backtest: boolean, path?: string, columns?: Columns$2[]) => Promise<void>;
|
|
6722
6767
|
}
|
|
6723
6768
|
/**
|
|
6724
6769
|
* Singleton instance of HeatUtils for convenient heatmap operations.
|
|
@@ -6967,8 +7012,8 @@ declare class PartialMarkdownService {
|
|
|
6967
7012
|
/** Logger service for debug output */
|
|
6968
7013
|
private readonly loggerService;
|
|
6969
7014
|
/**
|
|
6970
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
6971
|
-
* 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.
|
|
6972
7017
|
*/
|
|
6973
7018
|
private getStorage;
|
|
6974
7019
|
/**
|
|
@@ -7003,33 +7048,35 @@ declare class PartialMarkdownService {
|
|
|
7003
7048
|
*
|
|
7004
7049
|
* @param symbol - Trading pair symbol to get data for
|
|
7005
7050
|
* @param strategyName - Strategy name to get data for
|
|
7051
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7006
7052
|
* @returns Statistical data object with all metrics
|
|
7007
7053
|
*
|
|
7008
7054
|
* @example
|
|
7009
7055
|
* ```typescript
|
|
7010
7056
|
* const service = new PartialMarkdownService();
|
|
7011
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
7057
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
7012
7058
|
* console.log(stats.totalProfit, stats.totalLoss);
|
|
7013
7059
|
* ```
|
|
7014
7060
|
*/
|
|
7015
|
-
getData: (symbol: string, strategyName: string) => Promise<PartialStatisticsModel>;
|
|
7061
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PartialStatisticsModel>;
|
|
7016
7062
|
/**
|
|
7017
7063
|
* Generates markdown report with all partial events for a symbol-strategy pair.
|
|
7018
7064
|
* Delegates to ReportStorage.getReport().
|
|
7019
7065
|
*
|
|
7020
7066
|
* @param symbol - Trading pair symbol to generate report for
|
|
7021
7067
|
* @param strategyName - Strategy name to generate report for
|
|
7068
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7022
7069
|
* @param columns - Column configuration for formatting the table
|
|
7023
7070
|
* @returns Markdown formatted report string with table of all events
|
|
7024
7071
|
*
|
|
7025
7072
|
* @example
|
|
7026
7073
|
* ```typescript
|
|
7027
7074
|
* const service = new PartialMarkdownService();
|
|
7028
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
7075
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
7029
7076
|
* console.log(markdown);
|
|
7030
7077
|
* ```
|
|
7031
7078
|
*/
|
|
7032
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$1[]) => Promise<string>;
|
|
7079
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$1[]) => Promise<string>;
|
|
7033
7080
|
/**
|
|
7034
7081
|
* Saves symbol-strategy report to disk.
|
|
7035
7082
|
* Creates directory if it doesn't exist.
|
|
@@ -7037,6 +7084,7 @@ declare class PartialMarkdownService {
|
|
|
7037
7084
|
*
|
|
7038
7085
|
* @param symbol - Trading pair symbol to save report for
|
|
7039
7086
|
* @param strategyName - Strategy name to save report for
|
|
7087
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7040
7088
|
* @param path - Directory path to save report (default: "./dump/partial")
|
|
7041
7089
|
* @param columns - Column configuration for formatting the table
|
|
7042
7090
|
*
|
|
@@ -7045,32 +7093,33 @@ declare class PartialMarkdownService {
|
|
|
7045
7093
|
* const service = new PartialMarkdownService();
|
|
7046
7094
|
*
|
|
7047
7095
|
* // Save to default path: ./dump/partial/BTCUSDT_my-strategy.md
|
|
7048
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
7096
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
7049
7097
|
*
|
|
7050
7098
|
* // Save to custom path: ./custom/path/BTCUSDT_my-strategy.md
|
|
7051
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
7099
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
7052
7100
|
* ```
|
|
7053
7101
|
*/
|
|
7054
|
-
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>;
|
|
7055
7103
|
/**
|
|
7056
7104
|
* Clears accumulated event data from storage.
|
|
7057
|
-
* 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.
|
|
7058
7106
|
* If nothing is provided, clears all data.
|
|
7059
7107
|
*
|
|
7108
|
+
* @param backtest - Backtest mode flag
|
|
7060
7109
|
* @param ctx - Optional context with symbol and strategyName
|
|
7061
7110
|
*
|
|
7062
7111
|
* @example
|
|
7063
7112
|
* ```typescript
|
|
7064
7113
|
* const service = new PartialMarkdownService();
|
|
7065
7114
|
*
|
|
7066
|
-
* // Clear specific symbol-strategy
|
|
7067
|
-
* 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" });
|
|
7068
7117
|
*
|
|
7069
7118
|
* // Clear all data
|
|
7070
7119
|
* await service.clear();
|
|
7071
7120
|
* ```
|
|
7072
7121
|
*/
|
|
7073
|
-
clear: (ctx?: {
|
|
7122
|
+
clear: (backtest: boolean, ctx?: {
|
|
7074
7123
|
symbol: string;
|
|
7075
7124
|
strategyName: string;
|
|
7076
7125
|
}) => Promise<void>;
|
|
@@ -7148,7 +7197,7 @@ declare class PartialUtils {
|
|
|
7148
7197
|
* }
|
|
7149
7198
|
* ```
|
|
7150
7199
|
*/
|
|
7151
|
-
getData: (symbol: string, strategyName: string) => Promise<PartialStatisticsModel>;
|
|
7200
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<PartialStatisticsModel>;
|
|
7152
7201
|
/**
|
|
7153
7202
|
* Generates markdown report with all partial profit/loss events for a symbol-strategy pair.
|
|
7154
7203
|
*
|
|
@@ -7188,7 +7237,7 @@ declare class PartialUtils {
|
|
|
7188
7237
|
* // **Loss events:** 1
|
|
7189
7238
|
* ```
|
|
7190
7239
|
*/
|
|
7191
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns$1[]) => Promise<string>;
|
|
7240
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns$1[]) => Promise<string>;
|
|
7192
7241
|
/**
|
|
7193
7242
|
* Generates and saves markdown report to file.
|
|
7194
7243
|
*
|
|
@@ -7221,7 +7270,7 @@ declare class PartialUtils {
|
|
|
7221
7270
|
* }
|
|
7222
7271
|
* ```
|
|
7223
7272
|
*/
|
|
7224
|
-
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>;
|
|
7225
7274
|
}
|
|
7226
7275
|
/**
|
|
7227
7276
|
* Global singleton instance of PartialUtils.
|
|
@@ -7375,8 +7424,8 @@ declare class RiskMarkdownService {
|
|
|
7375
7424
|
/** Logger service for debug output */
|
|
7376
7425
|
private readonly loggerService;
|
|
7377
7426
|
/**
|
|
7378
|
-
* Memoized function to get or create ReportStorage for a symbol-strategy
|
|
7379
|
-
* 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.
|
|
7380
7429
|
*/
|
|
7381
7430
|
private getStorage;
|
|
7382
7431
|
/**
|
|
@@ -7398,33 +7447,35 @@ declare class RiskMarkdownService {
|
|
|
7398
7447
|
*
|
|
7399
7448
|
* @param symbol - Trading pair symbol to get data for
|
|
7400
7449
|
* @param strategyName - Strategy name to get data for
|
|
7450
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7401
7451
|
* @returns Statistical data object with all metrics
|
|
7402
7452
|
*
|
|
7403
7453
|
* @example
|
|
7404
7454
|
* ```typescript
|
|
7405
7455
|
* const service = new RiskMarkdownService();
|
|
7406
|
-
* const stats = await service.getData("BTCUSDT", "my-strategy");
|
|
7456
|
+
* const stats = await service.getData("BTCUSDT", "my-strategy", false);
|
|
7407
7457
|
* console.log(stats.totalRejections, stats.bySymbol);
|
|
7408
7458
|
* ```
|
|
7409
7459
|
*/
|
|
7410
|
-
getData: (symbol: string, strategyName: string) => Promise<RiskStatisticsModel>;
|
|
7460
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<RiskStatisticsModel>;
|
|
7411
7461
|
/**
|
|
7412
7462
|
* Generates markdown report with all risk rejection events for a symbol-strategy pair.
|
|
7413
7463
|
* Delegates to ReportStorage.getReport().
|
|
7414
7464
|
*
|
|
7415
7465
|
* @param symbol - Trading pair symbol to generate report for
|
|
7416
7466
|
* @param strategyName - Strategy name to generate report for
|
|
7467
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7417
7468
|
* @param columns - Column configuration for formatting the table
|
|
7418
7469
|
* @returns Markdown formatted report string with table of all events
|
|
7419
7470
|
*
|
|
7420
7471
|
* @example
|
|
7421
7472
|
* ```typescript
|
|
7422
7473
|
* const service = new RiskMarkdownService();
|
|
7423
|
-
* const markdown = await service.getReport("BTCUSDT", "my-strategy");
|
|
7474
|
+
* const markdown = await service.getReport("BTCUSDT", "my-strategy", false);
|
|
7424
7475
|
* console.log(markdown);
|
|
7425
7476
|
* ```
|
|
7426
7477
|
*/
|
|
7427
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns[]) => Promise<string>;
|
|
7478
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns[]) => Promise<string>;
|
|
7428
7479
|
/**
|
|
7429
7480
|
* Saves symbol-strategy report to disk.
|
|
7430
7481
|
* Creates directory if it doesn't exist.
|
|
@@ -7432,6 +7483,7 @@ declare class RiskMarkdownService {
|
|
|
7432
7483
|
*
|
|
7433
7484
|
* @param symbol - Trading pair symbol to save report for
|
|
7434
7485
|
* @param strategyName - Strategy name to save report for
|
|
7486
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
7435
7487
|
* @param path - Directory path to save report (default: "./dump/risk")
|
|
7436
7488
|
* @param columns - Column configuration for formatting the table
|
|
7437
7489
|
*
|
|
@@ -7440,32 +7492,33 @@ declare class RiskMarkdownService {
|
|
|
7440
7492
|
* const service = new RiskMarkdownService();
|
|
7441
7493
|
*
|
|
7442
7494
|
* // Save to default path: ./dump/risk/BTCUSDT_my-strategy.md
|
|
7443
|
-
* await service.dump("BTCUSDT", "my-strategy");
|
|
7495
|
+
* await service.dump("BTCUSDT", "my-strategy", false);
|
|
7444
7496
|
*
|
|
7445
7497
|
* // Save to custom path: ./custom/path/BTCUSDT_my-strategy.md
|
|
7446
|
-
* await service.dump("BTCUSDT", "my-strategy", "./custom/path");
|
|
7498
|
+
* await service.dump("BTCUSDT", "my-strategy", false, "./custom/path");
|
|
7447
7499
|
* ```
|
|
7448
7500
|
*/
|
|
7449
|
-
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>;
|
|
7450
7502
|
/**
|
|
7451
7503
|
* Clears accumulated event data from storage.
|
|
7452
|
-
* 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.
|
|
7453
7505
|
* If nothing is provided, clears all data.
|
|
7454
7506
|
*
|
|
7507
|
+
* @param backtest - Backtest mode flag
|
|
7455
7508
|
* @param ctx - Optional context with symbol and strategyName
|
|
7456
7509
|
*
|
|
7457
7510
|
* @example
|
|
7458
7511
|
* ```typescript
|
|
7459
7512
|
* const service = new RiskMarkdownService();
|
|
7460
7513
|
*
|
|
7461
|
-
* // Clear specific symbol-strategy
|
|
7462
|
-
* 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" });
|
|
7463
7516
|
*
|
|
7464
7517
|
* // Clear all data
|
|
7465
7518
|
* await service.clear();
|
|
7466
7519
|
* ```
|
|
7467
7520
|
*/
|
|
7468
|
-
clear: (ctx?: {
|
|
7521
|
+
clear: (backtest: boolean, ctx?: {
|
|
7469
7522
|
symbol: string;
|
|
7470
7523
|
strategyName: string;
|
|
7471
7524
|
}) => Promise<void>;
|
|
@@ -7543,7 +7596,7 @@ declare class RiskUtils {
|
|
|
7543
7596
|
* }
|
|
7544
7597
|
* ```
|
|
7545
7598
|
*/
|
|
7546
|
-
getData: (symbol: string, strategyName: string) => Promise<RiskStatisticsModel>;
|
|
7599
|
+
getData: (symbol: string, strategyName: string, backtest: boolean) => Promise<RiskStatisticsModel>;
|
|
7547
7600
|
/**
|
|
7548
7601
|
* Generates markdown report with all risk rejection events for a symbol-strategy pair.
|
|
7549
7602
|
*
|
|
@@ -7585,7 +7638,7 @@ declare class RiskUtils {
|
|
|
7585
7638
|
* // - my-strategy: 1
|
|
7586
7639
|
* ```
|
|
7587
7640
|
*/
|
|
7588
|
-
getReport: (symbol: string, strategyName: string, columns?: Columns[]) => Promise<string>;
|
|
7641
|
+
getReport: (symbol: string, strategyName: string, backtest: boolean, columns?: Columns[]) => Promise<string>;
|
|
7589
7642
|
/**
|
|
7590
7643
|
* Generates and saves markdown report to file.
|
|
7591
7644
|
*
|
|
@@ -7618,7 +7671,7 @@ declare class RiskUtils {
|
|
|
7618
7671
|
* }
|
|
7619
7672
|
* ```
|
|
7620
7673
|
*/
|
|
7621
|
-
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>;
|
|
7622
7675
|
}
|
|
7623
7676
|
/**
|
|
7624
7677
|
* Global singleton instance of RiskUtils.
|
|
@@ -8107,6 +8160,7 @@ declare class ClientRisk implements IRisk {
|
|
|
8107
8160
|
private waitForInit;
|
|
8108
8161
|
/**
|
|
8109
8162
|
* Persists current active positions to disk.
|
|
8163
|
+
* Skips in backtest mode.
|
|
8110
8164
|
*/
|
|
8111
8165
|
private _updatePositions;
|
|
8112
8166
|
/**
|
|
@@ -8177,15 +8231,16 @@ declare class RiskConnectionService {
|
|
|
8177
8231
|
private readonly loggerService;
|
|
8178
8232
|
private readonly riskSchemaService;
|
|
8179
8233
|
/**
|
|
8180
|
-
* Retrieves memoized ClientRisk instance for given risk name.
|
|
8234
|
+
* Retrieves memoized ClientRisk instance for given risk name and backtest mode.
|
|
8181
8235
|
*
|
|
8182
8236
|
* Creates ClientRisk on first call, returns cached instance on subsequent calls.
|
|
8183
|
-
* Cache key is riskName string.
|
|
8237
|
+
* Cache key is "riskName:backtest" string to separate live and backtest instances.
|
|
8184
8238
|
*
|
|
8185
8239
|
* @param riskName - Name of registered risk schema
|
|
8240
|
+
* @param backtest - True if backtest mode, false if live mode
|
|
8186
8241
|
* @returns Configured ClientRisk instance
|
|
8187
8242
|
*/
|
|
8188
|
-
getRisk: ((riskName: RiskName) => ClientRisk) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientRisk>;
|
|
8243
|
+
getRisk: ((riskName: RiskName, backtest: boolean) => ClientRisk) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, ClientRisk>;
|
|
8189
8244
|
/**
|
|
8190
8245
|
* Checks if a signal should be allowed based on risk limits.
|
|
8191
8246
|
*
|
|
@@ -8194,40 +8249,43 @@ declare class RiskConnectionService {
|
|
|
8194
8249
|
* ClientRisk will emit riskSubject event via onRejected callback when signal is rejected.
|
|
8195
8250
|
*
|
|
8196
8251
|
* @param params - Risk check arguments (portfolio state, position details)
|
|
8197
|
-
* @param context - Execution context with risk name
|
|
8252
|
+
* @param context - Execution context with risk name and backtest mode
|
|
8198
8253
|
* @returns Promise resolving to risk check result
|
|
8199
8254
|
*/
|
|
8200
8255
|
checkSignal: (params: IRiskCheckArgs, context: {
|
|
8201
8256
|
riskName: RiskName;
|
|
8257
|
+
backtest: boolean;
|
|
8202
8258
|
}) => Promise<boolean>;
|
|
8203
8259
|
/**
|
|
8204
8260
|
* Registers an opened signal with the risk management system.
|
|
8205
8261
|
* Routes to appropriate ClientRisk instance.
|
|
8206
8262
|
*
|
|
8207
8263
|
* @param symbol - Trading pair symbol
|
|
8208
|
-
* @param context - Context information (strategyName, riskName)
|
|
8264
|
+
* @param context - Context information (strategyName, riskName, backtest)
|
|
8209
8265
|
*/
|
|
8210
8266
|
addSignal: (symbol: string, context: {
|
|
8211
8267
|
strategyName: string;
|
|
8212
8268
|
riskName: RiskName;
|
|
8269
|
+
backtest: boolean;
|
|
8213
8270
|
}) => Promise<void>;
|
|
8214
8271
|
/**
|
|
8215
8272
|
* Removes a closed signal from the risk management system.
|
|
8216
8273
|
* Routes to appropriate ClientRisk instance.
|
|
8217
8274
|
*
|
|
8218
8275
|
* @param symbol - Trading pair symbol
|
|
8219
|
-
* @param context - Context information (strategyName, riskName)
|
|
8276
|
+
* @param context - Context information (strategyName, riskName, backtest)
|
|
8220
8277
|
*/
|
|
8221
8278
|
removeSignal: (symbol: string, context: {
|
|
8222
8279
|
strategyName: string;
|
|
8223
8280
|
riskName: RiskName;
|
|
8281
|
+
backtest: boolean;
|
|
8224
8282
|
}) => Promise<void>;
|
|
8225
8283
|
/**
|
|
8226
8284
|
* Clears the cached ClientRisk instance for the given risk name.
|
|
8227
8285
|
*
|
|
8228
8286
|
* @param riskName - Name of the risk schema to clear from cache
|
|
8229
8287
|
*/
|
|
8230
|
-
clear: (riskName?: RiskName) => Promise<void>;
|
|
8288
|
+
clear: (backtest: boolean, riskName?: RiskName) => Promise<void>;
|
|
8231
8289
|
}
|
|
8232
8290
|
|
|
8233
8291
|
/**
|
|
@@ -8270,10 +8328,10 @@ declare class PartialConnectionService implements IPartial {
|
|
|
8270
8328
|
/**
|
|
8271
8329
|
* Memoized factory function for ClientPartial instances.
|
|
8272
8330
|
*
|
|
8273
|
-
* Creates one ClientPartial per signal ID with configured callbacks.
|
|
8331
|
+
* Creates one ClientPartial per signal ID and backtest mode with configured callbacks.
|
|
8274
8332
|
* Instances are cached until clear() is called.
|
|
8275
8333
|
*
|
|
8276
|
-
* Key format: signalId
|
|
8334
|
+
* Key format: "signalId:backtest" or "signalId:live"
|
|
8277
8335
|
* Value: ClientPartial instance with logger and event emitters
|
|
8278
8336
|
*/
|
|
8279
8337
|
private getPartial;
|
|
@@ -8380,7 +8438,7 @@ declare class StrategyConnectionService {
|
|
|
8380
8438
|
*
|
|
8381
8439
|
* @returns Promise resolving to pending signal or null
|
|
8382
8440
|
*/
|
|
8383
|
-
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
8441
|
+
getPendingSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
8384
8442
|
/**
|
|
8385
8443
|
* Retrieves the stopped state of the strategy.
|
|
8386
8444
|
*
|
|
@@ -8391,7 +8449,7 @@ declare class StrategyConnectionService {
|
|
|
8391
8449
|
* @param strategyName - Name of the strategy
|
|
8392
8450
|
* @returns Promise resolving to true if strategy is stopped, false otherwise
|
|
8393
8451
|
*/
|
|
8394
|
-
getStopped: (symbol: string, strategyName: StrategyName) => Promise<boolean>;
|
|
8452
|
+
getStopped: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<boolean>;
|
|
8395
8453
|
/**
|
|
8396
8454
|
* Executes live trading tick for current strategy.
|
|
8397
8455
|
*
|
|
@@ -8425,10 +8483,10 @@ declare class StrategyConnectionService {
|
|
|
8425
8483
|
* @param strategyName - Name of strategy to stop
|
|
8426
8484
|
* @returns Promise that resolves when stop flag is set
|
|
8427
8485
|
*/
|
|
8428
|
-
stop: (ctx: {
|
|
8486
|
+
stop: (backtest: boolean, ctx: {
|
|
8429
8487
|
symbol: string;
|
|
8430
8488
|
strategyName: StrategyName;
|
|
8431
|
-
}
|
|
8489
|
+
}) => Promise<void>;
|
|
8432
8490
|
/**
|
|
8433
8491
|
* Clears the memoized ClientStrategy instance from cache.
|
|
8434
8492
|
*
|
|
@@ -8437,7 +8495,7 @@ declare class StrategyConnectionService {
|
|
|
8437
8495
|
*
|
|
8438
8496
|
* @param ctx - Optional context with symbol and strategyName (clears all if not provided)
|
|
8439
8497
|
*/
|
|
8440
|
-
clear: (ctx?: {
|
|
8498
|
+
clear: (backtest: boolean, ctx?: {
|
|
8441
8499
|
symbol: string;
|
|
8442
8500
|
strategyName: StrategyName;
|
|
8443
8501
|
}) => Promise<void>;
|
|
@@ -8705,7 +8763,7 @@ declare class StrategyCoreService {
|
|
|
8705
8763
|
* @param strategyName - Name of the strategy
|
|
8706
8764
|
* @returns Promise resolving to pending signal or null
|
|
8707
8765
|
*/
|
|
8708
|
-
getPendingSignal: (symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
8766
|
+
getPendingSignal: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<ISignalRow | null>;
|
|
8709
8767
|
/**
|
|
8710
8768
|
* Checks if the strategy has been stopped.
|
|
8711
8769
|
*
|
|
@@ -8716,7 +8774,7 @@ declare class StrategyCoreService {
|
|
|
8716
8774
|
* @param strategyName - Name of the strategy
|
|
8717
8775
|
* @returns Promise resolving to true if strategy is stopped, false otherwise
|
|
8718
8776
|
*/
|
|
8719
|
-
getStopped: (symbol: string, strategyName: StrategyName) => Promise<boolean>;
|
|
8777
|
+
getStopped: (backtest: boolean, symbol: string, strategyName: StrategyName) => Promise<boolean>;
|
|
8720
8778
|
/**
|
|
8721
8779
|
* Checks signal status at a specific timestamp.
|
|
8722
8780
|
*
|
|
@@ -8752,10 +8810,10 @@ declare class StrategyCoreService {
|
|
|
8752
8810
|
* @param strategyName - Name of strategy to stop
|
|
8753
8811
|
* @returns Promise that resolves when stop flag is set
|
|
8754
8812
|
*/
|
|
8755
|
-
stop: (ctx: {
|
|
8813
|
+
stop: (backtest: boolean, ctx: {
|
|
8756
8814
|
symbol: string;
|
|
8757
8815
|
strategyName: StrategyName;
|
|
8758
|
-
}
|
|
8816
|
+
}) => Promise<void>;
|
|
8759
8817
|
/**
|
|
8760
8818
|
* Clears the memoized ClientStrategy instance from cache.
|
|
8761
8819
|
*
|
|
@@ -8764,7 +8822,7 @@ declare class StrategyCoreService {
|
|
|
8764
8822
|
*
|
|
8765
8823
|
* @param ctx - Optional context with symbol and strategyName (clears all if not provided)
|
|
8766
8824
|
*/
|
|
8767
|
-
clear: (ctx?: {
|
|
8825
|
+
clear: (backtest: boolean, ctx?: {
|
|
8768
8826
|
symbol: string;
|
|
8769
8827
|
strategyName: StrategyName;
|
|
8770
8828
|
}) => Promise<void>;
|
|
@@ -8838,6 +8896,7 @@ declare class RiskGlobalService {
|
|
|
8838
8896
|
*/
|
|
8839
8897
|
checkSignal: (params: IRiskCheckArgs, context: {
|
|
8840
8898
|
riskName: RiskName;
|
|
8899
|
+
backtest: boolean;
|
|
8841
8900
|
}) => Promise<boolean>;
|
|
8842
8901
|
/**
|
|
8843
8902
|
* Registers an opened signal with the risk management system.
|
|
@@ -8848,6 +8907,7 @@ declare class RiskGlobalService {
|
|
|
8848
8907
|
addSignal: (symbol: string, context: {
|
|
8849
8908
|
strategyName: string;
|
|
8850
8909
|
riskName: RiskName;
|
|
8910
|
+
backtest: boolean;
|
|
8851
8911
|
}) => Promise<void>;
|
|
8852
8912
|
/**
|
|
8853
8913
|
* Removes a closed signal from the risk management system.
|
|
@@ -8858,6 +8918,7 @@ declare class RiskGlobalService {
|
|
|
8858
8918
|
removeSignal: (symbol: string, context: {
|
|
8859
8919
|
strategyName: string;
|
|
8860
8920
|
riskName: RiskName;
|
|
8921
|
+
backtest: boolean;
|
|
8861
8922
|
}) => Promise<void>;
|
|
8862
8923
|
/**
|
|
8863
8924
|
* Clears risk data.
|
|
@@ -8865,7 +8926,7 @@ declare class RiskGlobalService {
|
|
|
8865
8926
|
* If no riskName is provided, clears all risk data.
|
|
8866
8927
|
* @param riskName - Optional name of the risk instance to clear
|
|
8867
8928
|
*/
|
|
8868
|
-
clear: (riskName?: RiskName) => Promise<void>;
|
|
8929
|
+
clear: (backtest: boolean, riskName?: RiskName) => Promise<void>;
|
|
8869
8930
|
}
|
|
8870
8931
|
|
|
8871
8932
|
/**
|