backtest-kit 6.1.1 → 6.3.0
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 +274 -30
- package/build/index.mjs +274 -30
- package/package.json +1 -1
- package/types.d.ts +138 -6
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -10311,6 +10311,10 @@ interface IStrategyResult {
|
|
|
10311
10311
|
stats: BacktestStatisticsModel;
|
|
10312
10312
|
/** Value of the optimization metric (null if invalid) */
|
|
10313
10313
|
metricValue: number | null;
|
|
10314
|
+
/** Timestamp of the first signal event (pendingAt of earliest signal), null if no signals */
|
|
10315
|
+
firstEventTime: number | null;
|
|
10316
|
+
/** Timestamp of the last signal event (closeTimestamp of latest signal), null if no signals */
|
|
10317
|
+
lastEventTime: number | null;
|
|
10314
10318
|
}
|
|
10315
10319
|
/**
|
|
10316
10320
|
* Alias for walker statistics result interface.
|
|
@@ -10850,6 +10854,12 @@ declare class PersistSignalUtils {
|
|
|
10850
10854
|
* @returns Promise that resolves when write is complete
|
|
10851
10855
|
*/
|
|
10852
10856
|
writeSignalData: (signalRow: ISignalRow | null, symbol: string, strategyName: StrategyName, exchangeName: ExchangeName) => Promise<void>;
|
|
10857
|
+
/**
|
|
10858
|
+
* Clears the memoized storage cache.
|
|
10859
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
10860
|
+
* so new storage instances are created with the updated base path.
|
|
10861
|
+
*/
|
|
10862
|
+
clear(): void;
|
|
10853
10863
|
/**
|
|
10854
10864
|
* Switches to the default JSON persist adapter.
|
|
10855
10865
|
* All future persistence writes will use JSON storage.
|
|
@@ -10935,6 +10945,12 @@ declare class PersistRiskUtils {
|
|
|
10935
10945
|
* @returns Promise that resolves when write is complete
|
|
10936
10946
|
*/
|
|
10937
10947
|
writePositionData: (riskRow: RiskData, riskName: RiskName, exchangeName: ExchangeName) => Promise<void>;
|
|
10948
|
+
/**
|
|
10949
|
+
* Clears the memoized storage cache.
|
|
10950
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
10951
|
+
* so new storage instances are created with the updated base path.
|
|
10952
|
+
*/
|
|
10953
|
+
clear(): void;
|
|
10938
10954
|
/**
|
|
10939
10955
|
* Switches to the default JSON persist adapter.
|
|
10940
10956
|
* All future persistence writes will use JSON storage.
|
|
@@ -11022,6 +11038,12 @@ declare class PersistScheduleUtils {
|
|
|
11022
11038
|
* @returns Promise that resolves when write is complete
|
|
11023
11039
|
*/
|
|
11024
11040
|
writeScheduleData: (scheduledSignalRow: IScheduledSignalRow | null, symbol: string, strategyName: StrategyName, exchangeName: ExchangeName) => Promise<void>;
|
|
11041
|
+
/**
|
|
11042
|
+
* Clears the memoized storage cache.
|
|
11043
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11044
|
+
* so new storage instances are created with the updated base path.
|
|
11045
|
+
*/
|
|
11046
|
+
clear(): void;
|
|
11025
11047
|
/**
|
|
11026
11048
|
* Switches to the default JSON persist adapter.
|
|
11027
11049
|
* All future persistence writes will use JSON storage.
|
|
@@ -11111,6 +11133,12 @@ declare class PersistPartialUtils {
|
|
|
11111
11133
|
* @returns Promise that resolves when write is complete
|
|
11112
11134
|
*/
|
|
11113
11135
|
writePartialData: (partialData: PartialData, symbol: string, strategyName: StrategyName, signalId: string, exchangeName: ExchangeName) => Promise<void>;
|
|
11136
|
+
/**
|
|
11137
|
+
* Clears the memoized storage cache.
|
|
11138
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11139
|
+
* so new storage instances are created with the updated base path.
|
|
11140
|
+
*/
|
|
11141
|
+
clear(): void;
|
|
11114
11142
|
/**
|
|
11115
11143
|
* Switches to the default JSON persist adapter.
|
|
11116
11144
|
* All future persistence writes will use JSON storage.
|
|
@@ -11235,6 +11263,12 @@ declare class PersistBreakevenUtils {
|
|
|
11235
11263
|
* @returns Promise that resolves when write is complete
|
|
11236
11264
|
*/
|
|
11237
11265
|
writeBreakevenData: (breakevenData: BreakevenData, symbol: string, strategyName: StrategyName, signalId: string, exchangeName: ExchangeName) => Promise<void>;
|
|
11266
|
+
/**
|
|
11267
|
+
* Clears the memoized storage cache.
|
|
11268
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11269
|
+
* so new storage instances are created with the updated base path.
|
|
11270
|
+
*/
|
|
11271
|
+
clear(): void;
|
|
11238
11272
|
/**
|
|
11239
11273
|
* Switches to the default JSON persist adapter.
|
|
11240
11274
|
* All future persistence writes will use JSON storage.
|
|
@@ -11323,6 +11357,12 @@ declare class PersistCandleUtils {
|
|
|
11323
11357
|
* @returns Promise that resolves when all writes are complete
|
|
11324
11358
|
*/
|
|
11325
11359
|
writeCandlesData: (candles: CandleData[], symbol: string, interval: CandleInterval, exchangeName: ExchangeName) => Promise<void>;
|
|
11360
|
+
/**
|
|
11361
|
+
* Clears the memoized storage cache.
|
|
11362
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11363
|
+
* so new storage instances are created with the updated base path.
|
|
11364
|
+
*/
|
|
11365
|
+
clear(): void;
|
|
11326
11366
|
/**
|
|
11327
11367
|
* Switches to the default JSON persist adapter.
|
|
11328
11368
|
* All future persistence writes will use JSON storage.
|
|
@@ -11399,6 +11439,12 @@ declare class PersistStorageUtils {
|
|
|
11399
11439
|
* @returns Promise that resolves when write is complete
|
|
11400
11440
|
*/
|
|
11401
11441
|
writeStorageData: (signalData: StorageData, backtest: boolean) => Promise<void>;
|
|
11442
|
+
/**
|
|
11443
|
+
* Clears the memoized storage cache.
|
|
11444
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11445
|
+
* so new storage instances are created with the updated base path.
|
|
11446
|
+
*/
|
|
11447
|
+
clear(): void;
|
|
11402
11448
|
/**
|
|
11403
11449
|
* Switches to the default JSON persist adapter.
|
|
11404
11450
|
* All future persistence writes will use JSON storage.
|
|
@@ -11464,6 +11510,12 @@ declare class PersistNotificationUtils {
|
|
|
11464
11510
|
* @returns Promise that resolves when write is complete
|
|
11465
11511
|
*/
|
|
11466
11512
|
writeNotificationData: (notificationData: NotificationData, backtest: boolean) => Promise<void>;
|
|
11513
|
+
/**
|
|
11514
|
+
* Clears the memoized storage cache.
|
|
11515
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11516
|
+
* so new storage instances are created with the updated base path.
|
|
11517
|
+
*/
|
|
11518
|
+
clear(): void;
|
|
11467
11519
|
/**
|
|
11468
11520
|
* Switches to the default JSON persist adapter.
|
|
11469
11521
|
* All future persistence writes will use JSON storage.
|
|
@@ -11529,6 +11581,12 @@ declare class PersistLogUtils {
|
|
|
11529
11581
|
* @returns Promise that resolves when write is complete
|
|
11530
11582
|
*/
|
|
11531
11583
|
writeLogData: (logData: LogData) => Promise<void>;
|
|
11584
|
+
/**
|
|
11585
|
+
* Clears the cached storage instance.
|
|
11586
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11587
|
+
* so a new storage instance is created with the updated base path.
|
|
11588
|
+
*/
|
|
11589
|
+
clear(): void;
|
|
11532
11590
|
/**
|
|
11533
11591
|
* Switches to the default JSON persist adapter.
|
|
11534
11592
|
* All future persistence writes will use JSON storage.
|
|
@@ -11582,6 +11640,12 @@ declare class PersistMeasureUtils {
|
|
|
11582
11640
|
* @returns Promise that resolves when write is complete
|
|
11583
11641
|
*/
|
|
11584
11642
|
writeMeasureData: (data: MeasureData, bucket: string, key: string) => Promise<void>;
|
|
11643
|
+
/**
|
|
11644
|
+
* Clears the memoized storage cache.
|
|
11645
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11646
|
+
* so new storage instances are created with the updated base path.
|
|
11647
|
+
*/
|
|
11648
|
+
clear(): void;
|
|
11585
11649
|
/**
|
|
11586
11650
|
* Switches to the default JSON persist adapter.
|
|
11587
11651
|
*/
|
|
@@ -11696,12 +11760,20 @@ declare class PersistMemoryUtils {
|
|
|
11696
11760
|
data: MemoryData;
|
|
11697
11761
|
}>;
|
|
11698
11762
|
/**
|
|
11699
|
-
*
|
|
11763
|
+
* Clears the memoized storage cache.
|
|
11764
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
11765
|
+
* so new storage instances are created with the updated base path.
|
|
11766
|
+
*/
|
|
11767
|
+
clear: () => void;
|
|
11768
|
+
/**
|
|
11769
|
+
* Disposes of the memory adapter and releases any resources.
|
|
11770
|
+
* Call this when a signal is removed to clean up its associated storage.
|
|
11700
11771
|
*
|
|
11701
11772
|
* @param signalId - Signal identifier
|
|
11702
11773
|
* @param bucketName - Bucket name
|
|
11774
|
+
* @returns void
|
|
11703
11775
|
*/
|
|
11704
|
-
|
|
11776
|
+
dispose: (signalId: string, bucketName: string) => void;
|
|
11705
11777
|
/**
|
|
11706
11778
|
* Switches to the default JSON persist adapter.
|
|
11707
11779
|
* All future persistence writes will use JSON storage.
|
|
@@ -12000,6 +12072,12 @@ declare class ReportAdapter extends ReportUtils {
|
|
|
12000
12072
|
* @internal - Automatically called by report services, not for direct use
|
|
12001
12073
|
*/
|
|
12002
12074
|
writeData: <T = any>(reportName: ReportName, data: T, options: IReportDumpOptions) => Promise<void>;
|
|
12075
|
+
/**
|
|
12076
|
+
* Clears the memoized storage cache.
|
|
12077
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
12078
|
+
* so new storage instances are created with the updated base path.
|
|
12079
|
+
*/
|
|
12080
|
+
clear(): void;
|
|
12003
12081
|
/**
|
|
12004
12082
|
* Switches to a dummy report adapter that discards all writes.
|
|
12005
12083
|
* All future report writes will be no-ops.
|
|
@@ -12340,6 +12418,12 @@ declare class MarkdownAdapter extends MarkdownUtils {
|
|
|
12340
12418
|
* All dumps append to a single .jsonl file per markdown type.
|
|
12341
12419
|
*/
|
|
12342
12420
|
useJsonl(): void;
|
|
12421
|
+
/**
|
|
12422
|
+
* Clears the memoized storage cache.
|
|
12423
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
12424
|
+
* so new storage instances are created with the updated base path.
|
|
12425
|
+
*/
|
|
12426
|
+
clear(): void;
|
|
12343
12427
|
/**
|
|
12344
12428
|
* Switches to a dummy markdown adapter that discards all writes.
|
|
12345
12429
|
* All future markdown writes will be no-ops.
|
|
@@ -12443,6 +12527,12 @@ declare class LogAdapter implements ILog {
|
|
|
12443
12527
|
* @param dirName - Directory for the JSONL file (default: ./dump/log)
|
|
12444
12528
|
*/
|
|
12445
12529
|
useJsonl: (fileName?: string, dirName?: string) => void;
|
|
12530
|
+
/**
|
|
12531
|
+
* Clears the cached log instance by resetting to the default in-memory adapter.
|
|
12532
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
12533
|
+
* so a new adapter instance is created with the updated base path.
|
|
12534
|
+
*/
|
|
12535
|
+
clear: () => void;
|
|
12446
12536
|
}
|
|
12447
12537
|
/**
|
|
12448
12538
|
* Global singleton instance of LogAdapter.
|
|
@@ -17961,6 +18051,12 @@ declare class StorageBacktestAdapter implements IStorageUtils {
|
|
|
17961
18051
|
* Signals will be stored in memory only.
|
|
17962
18052
|
*/
|
|
17963
18053
|
useMemory: () => void;
|
|
18054
|
+
/**
|
|
18055
|
+
* Clears the cached utils instance by resetting to the default in-memory adapter.
|
|
18056
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18057
|
+
* so a new instance is created with the updated base path.
|
|
18058
|
+
*/
|
|
18059
|
+
clear: () => void;
|
|
17964
18060
|
}
|
|
17965
18061
|
/**
|
|
17966
18062
|
* Live trading storage adapter with pluggable storage backend.
|
|
@@ -18035,6 +18131,12 @@ declare class StorageLiveAdapter implements IStorageUtils {
|
|
|
18035
18131
|
* Signals will be stored in memory only.
|
|
18036
18132
|
*/
|
|
18037
18133
|
useMemory: () => void;
|
|
18134
|
+
/**
|
|
18135
|
+
* Clears the cached utils instance by resetting to the default persistent adapter.
|
|
18136
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18137
|
+
* so a new instance is created with the updated base path.
|
|
18138
|
+
*/
|
|
18139
|
+
clear: () => void;
|
|
18038
18140
|
}
|
|
18039
18141
|
/**
|
|
18040
18142
|
* Main storage adapter that manages both backtest and live signal storage.
|
|
@@ -18161,7 +18263,7 @@ interface INotificationUtils {
|
|
|
18161
18263
|
/**
|
|
18162
18264
|
* Clears all stored notifications.
|
|
18163
18265
|
*/
|
|
18164
|
-
|
|
18266
|
+
dispose(): Promise<void>;
|
|
18165
18267
|
}
|
|
18166
18268
|
/**
|
|
18167
18269
|
* Constructor type for notification adapters.
|
|
@@ -18250,7 +18352,7 @@ declare class NotificationBacktestAdapter implements INotificationUtils {
|
|
|
18250
18352
|
* Clears all stored notifications.
|
|
18251
18353
|
* Proxies call to the underlying notification adapter.
|
|
18252
18354
|
*/
|
|
18253
|
-
|
|
18355
|
+
dispose: () => Promise<void>;
|
|
18254
18356
|
/**
|
|
18255
18357
|
* Sets the notification adapter constructor.
|
|
18256
18358
|
* All future notification operations will use this adapter.
|
|
@@ -18273,6 +18375,12 @@ declare class NotificationBacktestAdapter implements INotificationUtils {
|
|
|
18273
18375
|
* Notifications will be persisted to disk.
|
|
18274
18376
|
*/
|
|
18275
18377
|
usePersist: () => void;
|
|
18378
|
+
/**
|
|
18379
|
+
* Resets the cached utils instance to the default in-memory adapter.
|
|
18380
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18381
|
+
* so a new instance is created with the updated base path.
|
|
18382
|
+
*/
|
|
18383
|
+
clear: () => void;
|
|
18276
18384
|
}
|
|
18277
18385
|
/**
|
|
18278
18386
|
* Live trading notification adapter with pluggable notification backend.
|
|
@@ -18356,7 +18464,7 @@ declare class NotificationLiveAdapter implements INotificationUtils {
|
|
|
18356
18464
|
* Clears all stored notifications.
|
|
18357
18465
|
* Proxies call to the underlying notification adapter.
|
|
18358
18466
|
*/
|
|
18359
|
-
|
|
18467
|
+
dispose: () => Promise<void>;
|
|
18360
18468
|
/**
|
|
18361
18469
|
* Sets the notification adapter constructor.
|
|
18362
18470
|
* All future notification operations will use this adapter.
|
|
@@ -18379,6 +18487,12 @@ declare class NotificationLiveAdapter implements INotificationUtils {
|
|
|
18379
18487
|
* Notifications will be persisted to disk.
|
|
18380
18488
|
*/
|
|
18381
18489
|
usePersist: () => void;
|
|
18490
|
+
/**
|
|
18491
|
+
* Resets the cached utils instance to the default in-memory adapter.
|
|
18492
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18493
|
+
* so a new instance is created with the updated base path.
|
|
18494
|
+
*/
|
|
18495
|
+
clear: () => void;
|
|
18382
18496
|
}
|
|
18383
18497
|
/**
|
|
18384
18498
|
* Main notification adapter that manages both backtest and live notification storage.
|
|
@@ -18414,7 +18528,7 @@ declare class NotificationAdapter {
|
|
|
18414
18528
|
*
|
|
18415
18529
|
* @throws Error if NotificationAdapter is not enabled
|
|
18416
18530
|
*/
|
|
18417
|
-
|
|
18531
|
+
dispose: (isBacktest: boolean) => Promise<void>;
|
|
18418
18532
|
}
|
|
18419
18533
|
/**
|
|
18420
18534
|
* Global singleton instance of NotificationAdapter.
|
|
@@ -18631,6 +18745,12 @@ declare class MemoryAdapter implements TMemoryInstance {
|
|
|
18631
18745
|
* Switches to dummy adapter that discards all writes.
|
|
18632
18746
|
*/
|
|
18633
18747
|
useDummy: () => void;
|
|
18748
|
+
/**
|
|
18749
|
+
* Clears the memoized instance cache.
|
|
18750
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18751
|
+
* so new instances are created with the updated base path.
|
|
18752
|
+
*/
|
|
18753
|
+
clear: () => void;
|
|
18634
18754
|
/**
|
|
18635
18755
|
* Releases resources held by this adapter.
|
|
18636
18756
|
* Delegates to disable() to unsubscribe from signal lifecycle events.
|
|
@@ -18793,6 +18913,12 @@ declare class DumpAdapter {
|
|
|
18793
18913
|
* @param Ctor - Constructor for the custom dump implementation
|
|
18794
18914
|
*/
|
|
18795
18915
|
useDumpAdapter: (Ctor: TDumpInstanceCtor) => void;
|
|
18916
|
+
/**
|
|
18917
|
+
* Clears the memoized instance cache.
|
|
18918
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
18919
|
+
* so new instances are created with the updated base path.
|
|
18920
|
+
*/
|
|
18921
|
+
clear: () => void;
|
|
18796
18922
|
}
|
|
18797
18923
|
declare const Dump: DumpAdapter;
|
|
18798
18924
|
|
|
@@ -21385,6 +21511,12 @@ declare class BrokerAdapter {
|
|
|
21385
21511
|
* ```
|
|
21386
21512
|
*/
|
|
21387
21513
|
disable: () => void;
|
|
21514
|
+
/**
|
|
21515
|
+
* Clears the cached broker instance and resets the enable singleshot.
|
|
21516
|
+
* Call this when process.cwd() changes between strategy iterations
|
|
21517
|
+
* so a new broker instance is created with the updated base path.
|
|
21518
|
+
*/
|
|
21519
|
+
clear: () => void;
|
|
21388
21520
|
}
|
|
21389
21521
|
/**
|
|
21390
21522
|
* Base class for custom broker adapter implementations.
|