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 CHANGED
@@ -908,26 +908,31 @@ const PERSIST_SIGNAL_UTILS_METHOD_NAME_READ_DATA = "PersistSignalUtils.readSigna
908
908
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_WRITE_DATA = "PersistSignalUtils.writeSignalData";
909
909
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_USE_JSON = "PersistSignalUtils.useJson";
910
910
  const PERSIST_SIGNAL_UTILS_METHOD_NAME_USE_DUMMY = "PersistSignalUtils.useDummy";
911
+ const PERSIST_SIGNAL_UTILS_METHOD_NAME_CLEAR = "PersistSignalUtils.clear";
911
912
  const PERSIST_SCHEDULE_UTILS_METHOD_NAME_USE_PERSIST_SCHEDULE_ADAPTER = "PersistScheduleUtils.usePersistScheduleAdapter";
912
913
  const PERSIST_SCHEDULE_UTILS_METHOD_NAME_READ_DATA = "PersistScheduleUtils.readScheduleData";
913
914
  const PERSIST_SCHEDULE_UTILS_METHOD_NAME_WRITE_DATA = "PersistScheduleUtils.writeScheduleData";
914
915
  const PERSIST_SCHEDULE_UTILS_METHOD_NAME_USE_JSON = "PersistScheduleUtils.useJson";
915
916
  const PERSIST_SCHEDULE_UTILS_METHOD_NAME_USE_DUMMY = "PersistScheduleUtils.useDummy";
917
+ const PERSIST_SCHEDULE_UTILS_METHOD_NAME_CLEAR = "PersistScheduleUtils.clear";
916
918
  const PERSIST_PARTIAL_UTILS_METHOD_NAME_USE_PERSIST_PARTIAL_ADAPTER = "PersistPartialUtils.usePersistPartialAdapter";
917
919
  const PERSIST_PARTIAL_UTILS_METHOD_NAME_READ_DATA = "PersistPartialUtils.readPartialData";
918
920
  const PERSIST_PARTIAL_UTILS_METHOD_NAME_WRITE_DATA = "PersistPartialUtils.writePartialData";
919
921
  const PERSIST_PARTIAL_UTILS_METHOD_NAME_USE_JSON = "PersistPartialUtils.useJson";
920
922
  const PERSIST_PARTIAL_UTILS_METHOD_NAME_USE_DUMMY = "PersistPartialUtils.useDummy";
923
+ const PERSIST_PARTIAL_UTILS_METHOD_NAME_CLEAR = "PersistPartialUtils.clear";
921
924
  const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_USE_PERSIST_BREAKEVEN_ADAPTER = "PersistBreakevenUtils.usePersistBreakevenAdapter";
922
925
  const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_READ_DATA = "PersistBreakevenUtils.readBreakevenData";
923
926
  const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_WRITE_DATA = "PersistBreakevenUtils.writeBreakevenData";
924
927
  const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_USE_JSON = "PersistBreakevenUtils.useJson";
925
928
  const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_USE_DUMMY = "PersistBreakevenUtils.useDummy";
929
+ const PERSIST_BREAKEVEN_UTILS_METHOD_NAME_CLEAR = "PersistBreakevenUtils.clear";
926
930
  const PERSIST_RISK_UTILS_METHOD_NAME_USE_PERSIST_RISK_ADAPTER = "PersistRiskUtils.usePersistRiskAdapter";
927
931
  const PERSIST_RISK_UTILS_METHOD_NAME_READ_DATA = "PersistRiskUtils.readPositionData";
928
932
  const PERSIST_RISK_UTILS_METHOD_NAME_WRITE_DATA = "PersistRiskUtils.writePositionData";
929
933
  const PERSIST_RISK_UTILS_METHOD_NAME_USE_JSON = "PersistRiskUtils.useJson";
930
934
  const PERSIST_RISK_UTILS_METHOD_NAME_USE_DUMMY = "PersistRiskUtils.useDummy";
935
+ const PERSIST_RISK_UTILS_METHOD_NAME_CLEAR = "PersistRiskUtils.clear";
931
936
  const PERSIST_BASE_METHOD_NAME_CTOR = "PersistBase.CTOR";
932
937
  const PERSIST_BASE_METHOD_NAME_WAIT_FOR_INIT = "PersistBase.waitForInit";
933
938
  const PERSIST_BASE_METHOD_NAME_READ_VALUE = "PersistBase.readValue";
@@ -938,22 +943,27 @@ const PERSIST_STORAGE_UTILS_METHOD_NAME_READ_DATA = "PersistStorageUtils.readSto
938
943
  const PERSIST_STORAGE_UTILS_METHOD_NAME_WRITE_DATA = "PersistStorageUtils.writeStorageData";
939
944
  const PERSIST_STORAGE_UTILS_METHOD_NAME_USE_JSON = "PersistStorageUtils.useJson";
940
945
  const PERSIST_STORAGE_UTILS_METHOD_NAME_USE_DUMMY = "PersistStorageUtils.useDummy";
946
+ const PERSIST_STORAGE_UTILS_METHOD_NAME_CLEAR = "PersistStorageUtils.clear";
941
947
  const PERSIST_STORAGE_UTILS_METHOD_NAME_USE_PERSIST_STORAGE_ADAPTER = "PersistStorageUtils.usePersistStorageAdapter";
942
948
  const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_READ_DATA = "PersistNotificationUtils.readNotificationData";
943
949
  const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_WRITE_DATA = "PersistNotificationUtils.writeNotificationData";
944
950
  const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_USE_JSON = "PersistNotificationUtils.useJson";
945
951
  const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_USE_DUMMY = "PersistNotificationUtils.useDummy";
952
+ const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_CLEAR = "PersistNotificationUtils.clear";
946
953
  const PERSIST_NOTIFICATION_UTILS_METHOD_NAME_USE_PERSIST_NOTIFICATION_ADAPTER = "PersistNotificationUtils.usePersistNotificationAdapter";
947
954
  const PERSIST_LOG_UTILS_METHOD_NAME_READ_DATA = "PersistLogUtils.readLogData";
948
955
  const PERSIST_LOG_UTILS_METHOD_NAME_WRITE_DATA = "PersistLogUtils.writeLogData";
949
956
  const PERSIST_LOG_UTILS_METHOD_NAME_USE_JSON = "PersistLogUtils.useJson";
950
957
  const PERSIST_LOG_UTILS_METHOD_NAME_USE_DUMMY = "PersistLogUtils.useDummy";
951
958
  const PERSIST_LOG_UTILS_METHOD_NAME_USE_PERSIST_LOG_ADAPTER = "PersistLogUtils.usePersistLogAdapter";
959
+ const PERSIST_LOG_UTILS_METHOD_NAME_CLEAR = "PersistLogUtils.clear";
952
960
  const PERSIST_MEASURE_UTILS_METHOD_NAME_READ_DATA = "PersistMeasureUtils.readMeasureData";
953
961
  const PERSIST_MEASURE_UTILS_METHOD_NAME_WRITE_DATA = "PersistMeasureUtils.writeMeasureData";
954
962
  const PERSIST_MEASURE_UTILS_METHOD_NAME_USE_JSON = "PersistMeasureUtils.useJson";
955
963
  const PERSIST_MEASURE_UTILS_METHOD_NAME_USE_DUMMY = "PersistMeasureUtils.useDummy";
964
+ const PERSIST_MEASURE_UTILS_METHOD_NAME_CLEAR = "PersistMeasureUtils.clear";
956
965
  const PERSIST_MEASURE_UTILS_METHOD_NAME_USE_PERSIST_MEASURE_ADAPTER = "PersistMeasureUtils.usePersistMeasureAdapter";
966
+ const PERSIST_CANDLE_UTILS_METHOD_NAME_CLEAR = "PersistCandleUtils.clear";
957
967
  const PERSIST_MEMORY_UTILS_METHOD_NAME_USE_PERSIST_MEMORY_ADAPTER = "PersistMemoryUtils.usePersistMemoryAdapter";
958
968
  const PERSIST_MEMORY_UTILS_METHOD_NAME_READ_DATA = "PersistMemoryUtils.readMemoryData";
959
969
  const PERSIST_MEMORY_UTILS_METHOD_NAME_WRITE_DATA = "PersistMemoryUtils.writeMemoryData";
@@ -961,6 +971,7 @@ const PERSIST_MEMORY_UTILS_METHOD_NAME_REMOVE_DATA = "PersistMemoryUtils.removeM
961
971
  const PERSIST_MEMORY_UTILS_METHOD_NAME_LIST_DATA = "PersistMemoryUtils.listMemoryData";
962
972
  const PERSIST_MEMORY_UTILS_METHOD_NAME_HAS_DATA = "PersistMemoryUtils.hasMemoryData";
963
973
  const PERSIST_MEMORY_UTILS_METHOD_NAME_CLEAR = "PersistMemoryUtils.clear";
974
+ const PERSIST_MEMORY_UTILS_METHOD_NAME_DISPOSE = "PersistMemoryUtils.dispose";
964
975
  const BASE_WAIT_FOR_INIT_FN_METHOD_NAME = "PersistBase.waitForInitFn";
965
976
  const BASE_UNLINK_RETRY_COUNT = 5;
966
977
  const BASE_UNLINK_RETRY_DELAY = 1000;
@@ -1246,6 +1257,15 @@ class PersistSignalUtils {
1246
1257
  bt.loggerService.info(PERSIST_SIGNAL_UTILS_METHOD_NAME_USE_PERSIST_SIGNAL_ADAPTER);
1247
1258
  this.PersistSignalFactory = Ctor;
1248
1259
  }
1260
+ /**
1261
+ * Clears the memoized storage cache.
1262
+ * Call this when process.cwd() changes between strategy iterations
1263
+ * so new storage instances are created with the updated base path.
1264
+ */
1265
+ clear() {
1266
+ bt.loggerService.log(PERSIST_SIGNAL_UTILS_METHOD_NAME_CLEAR);
1267
+ this.getStorage.clear();
1268
+ }
1249
1269
  /**
1250
1270
  * Switches to the default JSON persist adapter.
1251
1271
  * All future persistence writes will use JSON storage.
@@ -1359,6 +1379,15 @@ class PersistRiskUtils {
1359
1379
  bt.loggerService.info(PERSIST_RISK_UTILS_METHOD_NAME_USE_PERSIST_RISK_ADAPTER);
1360
1380
  this.PersistRiskFactory = Ctor;
1361
1381
  }
1382
+ /**
1383
+ * Clears the memoized storage cache.
1384
+ * Call this when process.cwd() changes between strategy iterations
1385
+ * so new storage instances are created with the updated base path.
1386
+ */
1387
+ clear() {
1388
+ bt.loggerService.log(PERSIST_RISK_UTILS_METHOD_NAME_CLEAR);
1389
+ this.getRiskStorage.clear();
1390
+ }
1362
1391
  /**
1363
1392
  * Switches to the default JSON persist adapter.
1364
1393
  * All future persistence writes will use JSON storage.
@@ -1472,6 +1501,15 @@ class PersistScheduleUtils {
1472
1501
  bt.loggerService.info(PERSIST_SCHEDULE_UTILS_METHOD_NAME_USE_PERSIST_SCHEDULE_ADAPTER);
1473
1502
  this.PersistScheduleFactory = Ctor;
1474
1503
  }
1504
+ /**
1505
+ * Clears the memoized storage cache.
1506
+ * Call this when process.cwd() changes between strategy iterations
1507
+ * so new storage instances are created with the updated base path.
1508
+ */
1509
+ clear() {
1510
+ bt.loggerService.log(PERSIST_SCHEDULE_UTILS_METHOD_NAME_CLEAR);
1511
+ this.getScheduleStorage.clear();
1512
+ }
1475
1513
  /**
1476
1514
  * Switches to the default JSON persist adapter.
1477
1515
  * All future persistence writes will use JSON storage.
@@ -1587,6 +1625,15 @@ class PersistPartialUtils {
1587
1625
  bt.loggerService.info(PERSIST_PARTIAL_UTILS_METHOD_NAME_USE_PERSIST_PARTIAL_ADAPTER);
1588
1626
  this.PersistPartialFactory = Ctor;
1589
1627
  }
1628
+ /**
1629
+ * Clears the memoized storage cache.
1630
+ * Call this when process.cwd() changes between strategy iterations
1631
+ * so new storage instances are created with the updated base path.
1632
+ */
1633
+ clear() {
1634
+ bt.loggerService.log(PERSIST_PARTIAL_UTILS_METHOD_NAME_CLEAR);
1635
+ this.getPartialStorage.clear();
1636
+ }
1590
1637
  /**
1591
1638
  * Switches to the default JSON persist adapter.
1592
1639
  * All future persistence writes will use JSON storage.
@@ -1737,6 +1784,15 @@ class PersistBreakevenUtils {
1737
1784
  bt.loggerService.info(PERSIST_BREAKEVEN_UTILS_METHOD_NAME_USE_PERSIST_BREAKEVEN_ADAPTER);
1738
1785
  this.PersistBreakevenFactory = Ctor;
1739
1786
  }
1787
+ /**
1788
+ * Clears the memoized storage cache.
1789
+ * Call this when process.cwd() changes between strategy iterations
1790
+ * so new storage instances are created with the updated base path.
1791
+ */
1792
+ clear() {
1793
+ bt.loggerService.log(PERSIST_BREAKEVEN_UTILS_METHOD_NAME_CLEAR);
1794
+ this.getBreakevenStorage.clear();
1795
+ }
1740
1796
  /**
1741
1797
  * Switches to the default JSON persist adapter.
1742
1798
  * All future persistence writes will use JSON storage.
@@ -1908,6 +1964,15 @@ class PersistCandleUtils {
1908
1964
  bt.loggerService.info("PersistCandleUtils.usePersistCandleAdapter");
1909
1965
  this.PersistCandlesFactory = Ctor;
1910
1966
  }
1967
+ /**
1968
+ * Clears the memoized storage cache.
1969
+ * Call this when process.cwd() changes between strategy iterations
1970
+ * so new storage instances are created with the updated base path.
1971
+ */
1972
+ clear() {
1973
+ bt.loggerService.log(PERSIST_CANDLE_UTILS_METHOD_NAME_CLEAR);
1974
+ this.getCandlesStorage.clear();
1975
+ }
1911
1976
  /**
1912
1977
  * Switches to the default JSON persist adapter.
1913
1978
  * All future persistence writes will use JSON storage.
@@ -2014,6 +2079,15 @@ class PersistStorageUtils {
2014
2079
  bt.loggerService.info(PERSIST_STORAGE_UTILS_METHOD_NAME_USE_PERSIST_STORAGE_ADAPTER);
2015
2080
  this.PersistStorageFactory = Ctor;
2016
2081
  }
2082
+ /**
2083
+ * Clears the memoized storage cache.
2084
+ * Call this when process.cwd() changes between strategy iterations
2085
+ * so new storage instances are created with the updated base path.
2086
+ */
2087
+ clear() {
2088
+ bt.loggerService.log(PERSIST_STORAGE_UTILS_METHOD_NAME_CLEAR);
2089
+ this.getStorage.clear();
2090
+ }
2017
2091
  /**
2018
2092
  * Switches to the default JSON persist adapter.
2019
2093
  * All future persistence writes will use JSON storage.
@@ -2109,6 +2183,15 @@ class PersistNotificationUtils {
2109
2183
  bt.loggerService.info(PERSIST_NOTIFICATION_UTILS_METHOD_NAME_USE_PERSIST_NOTIFICATION_ADAPTER);
2110
2184
  this.PersistNotificationFactory = Ctor;
2111
2185
  }
2186
+ /**
2187
+ * Clears the memoized storage cache.
2188
+ * Call this when process.cwd() changes between strategy iterations
2189
+ * so new storage instances are created with the updated base path.
2190
+ */
2191
+ clear() {
2192
+ bt.loggerService.log(PERSIST_NOTIFICATION_UTILS_METHOD_NAME_CLEAR);
2193
+ this.getNotificationStorage.clear();
2194
+ }
2112
2195
  /**
2113
2196
  * Switches to the default JSON persist adapter.
2114
2197
  * All future persistence writes will use JSON storage.
@@ -2209,6 +2292,15 @@ class PersistLogUtils {
2209
2292
  bt.loggerService.info(PERSIST_LOG_UTILS_METHOD_NAME_USE_PERSIST_LOG_ADAPTER);
2210
2293
  this.PersistLogFactory = Ctor;
2211
2294
  }
2295
+ /**
2296
+ * Clears the cached storage instance.
2297
+ * Call this when process.cwd() changes between strategy iterations
2298
+ * so a new storage instance is created with the updated base path.
2299
+ */
2300
+ clear() {
2301
+ bt.loggerService.log(PERSIST_LOG_UTILS_METHOD_NAME_CLEAR);
2302
+ this._logStorage = null;
2303
+ }
2212
2304
  /**
2213
2305
  * Switches to the default JSON persist adapter.
2214
2306
  * All future persistence writes will use JSON storage.
@@ -2297,6 +2389,15 @@ class PersistMeasureUtils {
2297
2389
  bt.loggerService.info(PERSIST_MEASURE_UTILS_METHOD_NAME_USE_PERSIST_MEASURE_ADAPTER);
2298
2390
  this.PersistMeasureFactory = Ctor;
2299
2391
  }
2392
+ /**
2393
+ * Clears the memoized storage cache.
2394
+ * Call this when process.cwd() changes between strategy iterations
2395
+ * so new storage instances are created with the updated base path.
2396
+ */
2397
+ clear() {
2398
+ bt.loggerService.log(PERSIST_MEASURE_UTILS_METHOD_NAME_CLEAR);
2399
+ this.getMeasureStorage.clear();
2400
+ }
2300
2401
  /**
2301
2402
  * Switches to the default JSON persist adapter.
2302
2403
  */
@@ -2440,16 +2541,24 @@ class PersistMemoryUtils {
2440
2541
  }
2441
2542
  };
2442
2543
  /**
2443
- * Dispose persist adapter to prevent memory leak
2544
+ * Clears the memoized storage cache.
2545
+ * Call this when process.cwd() changes between strategy iterations
2546
+ * so new storage instances are created with the updated base path.
2547
+ */
2548
+ this.clear = () => {
2549
+ bt.loggerService.info(PERSIST_MEMORY_UTILS_METHOD_NAME_CLEAR);
2550
+ this.getMemoryStorage.clear();
2551
+ };
2552
+ /**
2553
+ * Disposes of the memory adapter and releases any resources.
2554
+ * Call this when a signal is removed to clean up its associated storage.
2444
2555
  *
2445
2556
  * @param signalId - Signal identifier
2446
2557
  * @param bucketName - Bucket name
2558
+ * @returns void
2447
2559
  */
2448
- this.clear = (signalId, bucketName) => {
2449
- bt.loggerService.info(PERSIST_MEMORY_UTILS_METHOD_NAME_CLEAR, {
2450
- signalId,
2451
- bucketName,
2452
- });
2560
+ this.dispose = (signalId, bucketName) => {
2561
+ bt.loggerService.info(PERSIST_MEMORY_UTILS_METHOD_NAME_DISPOSE);
2453
2562
  const key = `${signalId}:${bucketName}`;
2454
2563
  this.getMemoryStorage.clear(key);
2455
2564
  };
@@ -19398,6 +19507,22 @@ const walker_strategy_columns = [
19398
19507
  : "N/A",
19399
19508
  isVisible: () => true,
19400
19509
  },
19510
+ {
19511
+ key: "firstEventTime",
19512
+ label: "First Event",
19513
+ format: (data) => data.firstEventTime !== null
19514
+ ? new Date(data.firstEventTime).toISOString()
19515
+ : "N/A",
19516
+ isVisible: () => true,
19517
+ },
19518
+ {
19519
+ key: "lastEventTime",
19520
+ label: "Last Event",
19521
+ format: (data) => data.lastEventTime !== null
19522
+ ? new Date(data.lastEventTime).toISOString()
19523
+ : "N/A",
19524
+ isVisible: () => true,
19525
+ },
19401
19526
  ];
19402
19527
  /**
19403
19528
  * Column configuration for walker PNL table in markdown reports.
@@ -19538,6 +19663,7 @@ const MARKDOWN_METHOD_NAME_WRITE_DATA = "MarkdownAdapter.writeData";
19538
19663
  const MARKDOWN_METHOD_NAME_USE_MD = "MarkdownAdapter.useMd";
19539
19664
  const MARKDOWN_METHOD_NAME_USE_JSONL = "MarkdownAdapter.useJsonl";
19540
19665
  const MARKDOWN_METHOD_NAME_USE_DUMMY = "MarkdownAdapter.useDummy";
19666
+ const MARKDOWN_METHOD_NAME_CLEAR = "MarkdownAdapter.clear";
19541
19667
  /** Symbol key for the singleshot waitForInit function on MarkdownFileBase instances. */
19542
19668
  const WAIT_FOR_INIT_SYMBOL$2 = Symbol("wait-for-init");
19543
19669
  /** Symbol key for the timeout-protected write function on MarkdownFileBase instances. */
@@ -20009,6 +20135,15 @@ class MarkdownAdapter extends MarkdownUtils {
20009
20135
  bt.loggerService.debug(MARKDOWN_METHOD_NAME_USE_JSONL);
20010
20136
  this.useMarkdownAdapter(MarkdownFileBase);
20011
20137
  }
20138
+ /**
20139
+ * Clears the memoized storage cache.
20140
+ * Call this when process.cwd() changes between strategy iterations
20141
+ * so new storage instances are created with the updated base path.
20142
+ */
20143
+ clear() {
20144
+ bt.loggerService.log(MARKDOWN_METHOD_NAME_CLEAR);
20145
+ this.getMarkdownStorage.clear();
20146
+ }
20012
20147
  /**
20013
20148
  * Switches to a dummy markdown adapter that discards all writes.
20014
20149
  * All future markdown writes will be no-ops.
@@ -22206,10 +22341,19 @@ let ReportStorage$6 = class ReportStorage {
22206
22341
  if (data.strategyName === data.bestStrategy) {
22207
22342
  this._bestStats = data.stats;
22208
22343
  }
22344
+ const signals = data.stats.signalList;
22345
+ const firstEventTime = signals.length > 0
22346
+ ? signals.reduce((acc, s) => s.signal.pendingAt < acc ? s.signal.pendingAt : acc, signals[0].signal.pendingAt)
22347
+ : null;
22348
+ const lastEventTime = signals.length > 0
22349
+ ? signals.reduce((acc, s) => s.closeTimestamp > acc ? s.closeTimestamp : acc, signals[0].closeTimestamp)
22350
+ : null;
22209
22351
  this._strategyResults.unshift({
22210
22352
  strategyName: data.strategyName,
22211
22353
  stats: data.stats,
22212
22354
  metricValue: isUnsafe$1(data.metricValue) ? null : data.metricValue,
22355
+ firstEventTime,
22356
+ lastEventTime,
22213
22357
  });
22214
22358
  }
22215
22359
  /**
@@ -26801,6 +26945,7 @@ const REPORT_UTILS_METHOD_NAME_ENABLE = "ReportUtils.enable";
26801
26945
  const REPORT_UTILS_METHOD_NAME_DISABLE = "ReportUtils.disable";
26802
26946
  const REPORT_UTILS_METHOD_NAME_USE_DUMMY = "ReportUtils.useDummy";
26803
26947
  const REPORT_UTILS_METHOD_NAME_USE_JSONL = "ReportUtils.useJsonl";
26948
+ const REPORT_UTILS_METHOD_NAME_CLEAR = "ReportUtils.clear";
26804
26949
  /** Symbol key for the singleshot waitForInit function on ReportBase instances. */
26805
26950
  const WAIT_FOR_INIT_SYMBOL$1 = Symbol("wait-for-init");
26806
26951
  /** Symbol key for the timeout-protected write function on ReportBase instances. */
@@ -27210,6 +27355,15 @@ class ReportAdapter extends ReportUtils {
27210
27355
  bt.loggerService.info(REPORT_UTILS_METHOD_NAME_USE_REPORT_ADAPTER);
27211
27356
  this.ReportFactory = Ctor;
27212
27357
  }
27358
+ /**
27359
+ * Clears the memoized storage cache.
27360
+ * Call this when process.cwd() changes between strategy iterations
27361
+ * so new storage instances are created with the updated base path.
27362
+ */
27363
+ clear() {
27364
+ bt.loggerService.log(REPORT_UTILS_METHOD_NAME_CLEAR);
27365
+ this.getReportStorage.clear();
27366
+ }
27213
27367
  /**
27214
27368
  * Switches to a dummy report adapter that discards all writes.
27215
27369
  * All future report writes will be no-ops.
@@ -28052,6 +28206,13 @@ class WalkerReportService {
28052
28206
  */
28053
28207
  this.tick = async (data) => {
28054
28208
  this.loggerService.log(WALKER_REPORT_METHOD_NAME_TICK, { data });
28209
+ const signals = data.stats.signalList;
28210
+ const firstEventTime = signals.length > 0
28211
+ ? signals.reduce((acc, s) => s.signal.pendingAt < acc ? s.signal.pendingAt : acc, signals[0].signal.pendingAt)
28212
+ : null;
28213
+ const lastEventTime = signals.length > 0
28214
+ ? signals.reduce((acc, s) => s.closeTimestamp > acc ? s.closeTimestamp : acc, signals[0].closeTimestamp)
28215
+ : null;
28055
28216
  await Report.writeData("walker", {
28056
28217
  timestamp: getContextTimestamp(),
28057
28218
  walkerName: data.walkerName,
@@ -28076,6 +28237,8 @@ class WalkerReportService {
28076
28237
  annualizedSharpeRatio: data.stats.annualizedSharpeRatio,
28077
28238
  certaintyRatio: data.stats.certaintyRatio,
28078
28239
  expectedYearlyReturns: data.stats.expectedYearlyReturns,
28240
+ firstEventTime,
28241
+ lastEventTime,
28079
28242
  }, {
28080
28243
  symbol: data.symbol,
28081
28244
  strategyName: data.strategyName,
@@ -33525,6 +33688,7 @@ const BROKER_METHOD_NAME_COMMIT_AVERAGE_BUY = "BrokerAdapter.commitAverageBuy";
33525
33688
  const BROKER_METHOD_NAME_USE_BROKER_ADAPTER = "BrokerAdapter.useBrokerAdapter";
33526
33689
  const BROKER_METHOD_NAME_ENABLE = "BrokerAdapter.enable";
33527
33690
  const BROKER_METHOD_NAME_DISABLE = "BrokerAdapter.disable";
33691
+ const BROKER_METHOD_NAME_CLEAR = "BrokerAdapter.clear";
33528
33692
  const BROKER_BASE_METHOD_NAME_WAIT_FOR_INIT = "BrokerBase.waitForInit";
33529
33693
  const BROKER_BASE_METHOD_NAME_ON_SIGNAL_OPEN = "BrokerBase.onSignalOpenCommit";
33530
33694
  const BROKER_BASE_METHOD_NAME_ON_SIGNAL_CLOSE = "BrokerBase.onSignalCloseCommit";
@@ -34124,6 +34288,16 @@ class BrokerAdapter {
34124
34288
  lastSubscription();
34125
34289
  }
34126
34290
  };
34291
+ /**
34292
+ * Clears the cached broker instance and resets the enable singleshot.
34293
+ * Call this when process.cwd() changes between strategy iterations
34294
+ * so a new broker instance is created with the updated base path.
34295
+ */
34296
+ this.clear = () => {
34297
+ bt.loggerService.info(BROKER_METHOD_NAME_CLEAR, {});
34298
+ this._brokerInstance = null;
34299
+ this.enable.clear();
34300
+ };
34127
34301
  }
34128
34302
  }
34129
34303
  /**
@@ -43417,6 +43591,7 @@ const MEMORY_ADAPTER_METHOD_NAME_READ = "MemoryAdapter.readMemory";
43417
43591
  const MEMORY_ADAPTER_METHOD_NAME_USE_LOCAL = "MemoryAdapter.useLocal";
43418
43592
  const MEMORY_ADAPTER_METHOD_NAME_USE_PERSIST = "MemoryAdapter.usePersist";
43419
43593
  const MEMORY_ADAPTER_METHOD_NAME_USE_DUMMY = "MemoryAdapter.useDummy";
43594
+ const MEMORY_ADAPTER_METHOD_NAME_CLEAR = "MemoryAdapter.clear";
43420
43595
  /**
43421
43596
  * In-memory BM25 search index backed instance.
43422
43597
  * All data lives in the process memory only - no disk persistence.
@@ -43639,7 +43814,7 @@ class MemoryPersistInstance {
43639
43814
  signalId: this.signalId,
43640
43815
  bucketName: this.bucketName,
43641
43816
  });
43642
- PersistMemoryAdapter.clear(this.signalId, this.bucketName);
43817
+ PersistMemoryAdapter.dispose(this.signalId, this.bucketName);
43643
43818
  }
43644
43819
  }
43645
43820
  /**
@@ -43877,6 +44052,15 @@ class MemoryAdapter {
43877
44052
  bt.loggerService.info(MEMORY_ADAPTER_METHOD_NAME_USE_DUMMY);
43878
44053
  this.MemoryFactory = MemoryDummyInstance;
43879
44054
  };
44055
+ /**
44056
+ * Clears the memoized instance cache.
44057
+ * Call this when process.cwd() changes between strategy iterations
44058
+ * so new instances are created with the updated base path.
44059
+ */
44060
+ this.clear = () => {
44061
+ bt.loggerService.info(MEMORY_ADAPTER_METHOD_NAME_CLEAR);
44062
+ this.getInstance.clear();
44063
+ };
43880
44064
  /**
43881
44065
  * Releases resources held by this adapter.
43882
44066
  * Delegates to disable() to unsubscribe from signal lifecycle events.
@@ -44164,6 +44348,7 @@ const DUMP_ADAPTER_METHOD_NAME_USE_MEMORY = "DumpAdapter.useMemory";
44164
44348
  const DUMP_ADAPTER_METHOD_NAME_USE_DUMMY = "DumpAdapter.useDummy";
44165
44349
  const DUMP_ADAPTER_METHOD_NAME_USE_BOTH = "DumpAdapter.useMarkdownMemoryBoth";
44166
44350
  const DUMP_ADAPTER_METHOD_NAME_USE_ADAPTER = "DumpAdapter.useDumpAdapter";
44351
+ const DUMP_ADAPTER_METHOD_NAME_CLEAR = "DumpAdapter.clear";
44167
44352
  /**
44168
44353
  * Renders a single MessageModel as a markdown section.
44169
44354
  * tool_calls are rendered as a fenced JSON block.
@@ -44921,6 +45106,15 @@ class DumpAdapter {
44921
45106
  bt.loggerService.info(DUMP_ADAPTER_METHOD_NAME_USE_ADAPTER);
44922
45107
  this.DumpFactory = Ctor;
44923
45108
  };
45109
+ /**
45110
+ * Clears the memoized instance cache.
45111
+ * Call this when process.cwd() changes between strategy iterations
45112
+ * so new instances are created with the updated base path.
45113
+ */
45114
+ this.clear = () => {
45115
+ bt.loggerService.info(DUMP_ADAPTER_METHOD_NAME_CLEAR);
45116
+ this.getInstance.clear();
45117
+ };
44924
45118
  }
44925
45119
  }
44926
45120
  const Dump = new DumpAdapter();
@@ -45241,6 +45435,7 @@ const LOG_ADAPTER_METHOD_NAME_USE_PERSIST = "LogAdapter.usePersist";
45241
45435
  const LOG_ADAPTER_METHOD_NAME_USE_MEMORY = "LogAdapter.useMemory";
45242
45436
  const LOG_ADAPTER_METHOD_NAME_USE_DUMMY = "LogAdapter.useDummy";
45243
45437
  const LOG_ADAPTER_METHOD_NAME_USE_JSONL = "LogAdapter.useJsonl";
45438
+ const LOG_ADAPTER_METHOD_NAME_CLEAR = "LogAdapter.clear";
45244
45439
  const LOG_JSONL_METHOD_NAME_LOG = "LogJsonlUtils.log";
45245
45440
  const LOG_JSONL_METHOD_NAME_DEBUG = "LogJsonlUtils.debug";
45246
45441
  const LOG_JSONL_METHOD_NAME_INFO = "LogJsonlUtils.info";
@@ -45862,6 +46057,15 @@ class LogAdapter {
45862
46057
  bt.loggerService.info(LOG_ADAPTER_METHOD_NAME_USE_JSONL);
45863
46058
  this._log = new LogJsonlUtils(fileName, dirName);
45864
46059
  };
46060
+ /**
46061
+ * Clears the cached log instance by resetting to the default in-memory adapter.
46062
+ * Call this when process.cwd() changes between strategy iterations
46063
+ * so a new adapter instance is created with the updated base path.
46064
+ */
46065
+ this.clear = () => {
46066
+ bt.loggerService.info(LOG_ADAPTER_METHOD_NAME_CLEAR);
46067
+ this._log = new LogMemoryUtils();
46068
+ };
45865
46069
  }
45866
46070
  }
45867
46071
  /**
@@ -47589,10 +47793,12 @@ const STORAGE_BACKTEST_ADAPTER_METHOD_NAME_USE_ADAPTER = "StorageBacktestAdapter
47589
47793
  const STORAGE_BACKTEST_ADAPTER_METHOD_NAME_USE_DUMMY = "StorageBacktestAdapter.useDummy";
47590
47794
  const STORAGE_BACKTEST_ADAPTER_METHOD_NAME_USE_PERSIST = "StorageBacktestAdapter.usePersist";
47591
47795
  const STORAGE_BACKTEST_ADAPTER_METHOD_NAME_USE_MEMORY = "StorageBacktestAdapter.useMemory";
47796
+ const STORAGE_BACKTEST_ADAPTER_METHOD_NAME_CLEAR = "StorageBacktestAdapter.clear";
47592
47797
  const STORAGE_LIVE_ADAPTER_METHOD_NAME_USE_ADAPTER = "StorageLiveAdapter.useStorageAdapter";
47593
47798
  const STORAGE_LIVE_ADAPTER_METHOD_NAME_USE_DUMMY = "StorageLiveAdapter.useDummy";
47594
47799
  const STORAGE_LIVE_ADAPTER_METHOD_NAME_USE_PERSIST = "StorageLiveAdapter.usePersist";
47595
47800
  const STORAGE_LIVE_ADAPTER_METHOD_NAME_USE_MEMORY = "StorageLiveAdapter.useMemory";
47801
+ const STORAGE_LIVE_ADAPTER_METHOD_NAME_CLEAR = "StorageLiveAdapter.clear";
47596
47802
  /**
47597
47803
  * Persistent storage adapter for backtest signals.
47598
47804
  *
@@ -48579,6 +48785,15 @@ class StorageBacktestAdapter {
48579
48785
  bt.loggerService.info(STORAGE_BACKTEST_ADAPTER_METHOD_NAME_USE_MEMORY);
48580
48786
  this._signalBacktestUtils = new StorageMemoryBacktestUtils();
48581
48787
  };
48788
+ /**
48789
+ * Clears the cached utils instance by resetting to the default in-memory adapter.
48790
+ * Call this when process.cwd() changes between strategy iterations
48791
+ * so a new instance is created with the updated base path.
48792
+ */
48793
+ this.clear = () => {
48794
+ bt.loggerService.info(STORAGE_BACKTEST_ADAPTER_METHOD_NAME_CLEAR);
48795
+ this._signalBacktestUtils = new StorageMemoryBacktestUtils();
48796
+ };
48582
48797
  }
48583
48798
  }
48584
48799
  /**
@@ -48683,6 +48898,15 @@ class StorageLiveAdapter {
48683
48898
  bt.loggerService.info(STORAGE_LIVE_ADAPTER_METHOD_NAME_USE_MEMORY);
48684
48899
  this._signalLiveUtils = new StorageMemoryLiveUtils();
48685
48900
  };
48901
+ /**
48902
+ * Clears the cached utils instance by resetting to the default persistent adapter.
48903
+ * Call this when process.cwd() changes between strategy iterations
48904
+ * so a new instance is created with the updated base path.
48905
+ */
48906
+ this.clear = () => {
48907
+ bt.loggerService.info(STORAGE_LIVE_ADAPTER_METHOD_NAME_CLEAR);
48908
+ this._signalLiveUtils = new StoragePersistLiveUtils();
48909
+ };
48686
48910
  }
48687
48911
  }
48688
48912
  /**
@@ -49503,7 +49727,7 @@ const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_HANDLE_ERROR = "NotificationMemor
49503
49727
  const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_HANDLE_CRITICAL_ERROR = "NotificationMemoryBacktestUtils.handleCriticalError";
49504
49728
  const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_HANDLE_VALIDATION_ERROR = "NotificationMemoryBacktestUtils.handleValidationError";
49505
49729
  const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_GET_DATA = "NotificationMemoryBacktestUtils.getData";
49506
- const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_CLEAR = "NotificationMemoryBacktestUtils.clear";
49730
+ const NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_DISPOSE = "NotificationMemoryBacktestUtils.dispose";
49507
49731
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_SIGNAL = "NotificationMemoryLiveUtils.handleSignal";
49508
49732
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_PARTIAL_PROFIT = "NotificationMemoryLiveUtils.handlePartialProfit";
49509
49733
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_PARTIAL_LOSS = "NotificationMemoryLiveUtils.handlePartialLoss";
@@ -49515,19 +49739,21 @@ const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_ERROR = "NotificationMemoryLiv
49515
49739
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_CRITICAL_ERROR = "NotificationMemoryLiveUtils.handleCriticalError";
49516
49740
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_HANDLE_VALIDATION_ERROR = "NotificationMemoryLiveUtils.handleValidationError";
49517
49741
  const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_GET_DATA = "NotificationMemoryLiveUtils.getData";
49518
- const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_CLEAR = "NotificationMemoryLiveUtils.clear";
49742
+ const NOTIFICATION_MEMORY_LIVE_METHOD_NAME_DISPOSE = "NotificationMemoryLiveUtils.clear";
49519
49743
  const NOTIFICATION_ADAPTER_METHOD_NAME_ENABLE = "NotificationAdapter.enable";
49520
49744
  const NOTIFICATION_ADAPTER_METHOD_NAME_DISABLE = "NotificationAdapter.disable";
49521
49745
  const NOTIFICATION_ADAPTER_METHOD_NAME_GET_DATA_BACKTEST = "NotificationAdapter.getDataBacktest";
49522
- const NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE = "NotificationAdapter.clearLive";
49746
+ const NOTIFICATION_ADAPTER_METHOD_NAME_DISPOSE_LIVE = "NotificationAdapter.disposeLive";
49523
49747
  const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_ADAPTER = "NotificationBacktestAdapter.useNotificationAdapter";
49524
49748
  const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_DUMMY = "NotificationBacktestAdapter.useDummy";
49525
49749
  const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_MEMORY = "NotificationBacktestAdapter.useMemory";
49526
49750
  const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_PERSIST = "NotificationBacktestAdapter.usePersist";
49751
+ const NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_CLEAR = "NotificationBacktestAdapter.clear";
49527
49752
  const NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_USE_ADAPTER = "NotificationLiveAdapter.useNotificationAdapter";
49528
49753
  const NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_USE_DUMMY = "NotificationLiveAdapter.useDummy";
49529
49754
  const NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_USE_MEMORY = "NotificationLiveAdapter.useMemory";
49530
49755
  const NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_USE_PERSIST = "NotificationLiveAdapter.usePersist";
49756
+ const NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_CLEAR = "NotificationLiveAdapter.clear";
49531
49757
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_WAIT_FOR_INIT = "NotificationPersistBacktestUtils.waitForInit";
49532
49758
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_UPDATE_NOTIFICATIONS = "NotificationPersistBacktestUtils._updateNotifications";
49533
49759
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_HANDLE_SIGNAL = "NotificationPersistBacktestUtils.handleSignal";
@@ -49541,7 +49767,7 @@ const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_HANDLE_ERROR = "NotificationPers
49541
49767
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_HANDLE_CRITICAL_ERROR = "NotificationPersistBacktestUtils.handleCriticalError";
49542
49768
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_HANDLE_VALIDATION_ERROR = "NotificationPersistBacktestUtils.handleValidationError";
49543
49769
  const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_GET_DATA = "NotificationPersistBacktestUtils.getData";
49544
- const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_CLEAR = "NotificationPersistBacktestUtils.clear";
49770
+ const NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_DISPOSE = "NotificationPersistBacktestUtils.clear";
49545
49771
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_WAIT_FOR_INIT = "NotificationPersistLiveUtils.waitForInit";
49546
49772
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_UPDATE_NOTIFICATIONS = "NotificationPersistLiveUtils._updateNotifications";
49547
49773
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_HANDLE_SIGNAL = "NotificationPersistLiveUtils.handleSignal";
@@ -49555,7 +49781,7 @@ const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_HANDLE_ERROR = "NotificationPersistL
49555
49781
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_HANDLE_CRITICAL_ERROR = "NotificationPersistLiveUtils.handleCriticalError";
49556
49782
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_HANDLE_VALIDATION_ERROR = "NotificationPersistLiveUtils.handleValidationError";
49557
49783
  const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_GET_DATA = "NotificationPersistLiveUtils.getData";
49558
- const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_CLEAR = "NotificationPersistLiveUtils.clear";
49784
+ const NOTIFICATION_PERSIST_LIVE_METHOD_NAME_DISPOSE = "NotificationPersistLiveUtils.clear";
49559
49785
  /**
49560
49786
  * In-memory notification adapter for backtest signals.
49561
49787
  *
@@ -49698,8 +49924,8 @@ class NotificationMemoryBacktestUtils {
49698
49924
  /**
49699
49925
  * Clears all stored notifications.
49700
49926
  */
49701
- this.clear = async () => {
49702
- bt.loggerService.info(NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_CLEAR);
49927
+ this.dispose = async () => {
49928
+ bt.loggerService.info(NOTIFICATION_MEMORY_BACKTEST_METHOD_NAME_DISPOSE);
49703
49929
  this._notifications = [];
49704
49930
  };
49705
49931
  }
@@ -49788,7 +50014,7 @@ class NotificationDummyBacktestUtils {
49788
50014
  /**
49789
50015
  * No-op clear operation.
49790
50016
  */
49791
- this.clear = async () => {
50017
+ this.dispose = async () => {
49792
50018
  };
49793
50019
  }
49794
50020
  }
@@ -49968,8 +50194,8 @@ class NotificationPersistBacktestUtils {
49968
50194
  /**
49969
50195
  * Clears all stored notifications.
49970
50196
  */
49971
- this.clear = async () => {
49972
- bt.loggerService.info(NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_CLEAR);
50197
+ this.dispose = async () => {
50198
+ bt.loggerService.info(NOTIFICATION_PERSIST_BACKTEST_METHOD_NAME_DISPOSE);
49973
50199
  await this.waitForInit();
49974
50200
  this._notifications.clear();
49975
50201
  await this._updateNotifications();
@@ -50150,8 +50376,8 @@ class NotificationMemoryLiveUtils {
50150
50376
  /**
50151
50377
  * Clears all stored notifications.
50152
50378
  */
50153
- this.clear = async () => {
50154
- bt.loggerService.info(NOTIFICATION_MEMORY_LIVE_METHOD_NAME_CLEAR);
50379
+ this.dispose = async () => {
50380
+ bt.loggerService.info(NOTIFICATION_MEMORY_LIVE_METHOD_NAME_DISPOSE);
50155
50381
  this._notifications = [];
50156
50382
  };
50157
50383
  }
@@ -50240,7 +50466,7 @@ class NotificationDummyLiveUtils {
50240
50466
  /**
50241
50467
  * No-op clear operation.
50242
50468
  */
50243
- this.clear = async () => {
50469
+ this.dispose = async () => {
50244
50470
  };
50245
50471
  }
50246
50472
  }
@@ -50421,8 +50647,8 @@ class NotificationPersistLiveUtils {
50421
50647
  /**
50422
50648
  * Clears all stored notifications.
50423
50649
  */
50424
- this.clear = async () => {
50425
- bt.loggerService.info(NOTIFICATION_PERSIST_LIVE_METHOD_NAME_CLEAR);
50650
+ this.dispose = async () => {
50651
+ bt.loggerService.info(NOTIFICATION_PERSIST_LIVE_METHOD_NAME_DISPOSE);
50426
50652
  await this.waitForInit();
50427
50653
  this._notifications.clear();
50428
50654
  await this._updateNotifications();
@@ -50570,8 +50796,8 @@ class NotificationBacktestAdapter {
50570
50796
  * Clears all stored notifications.
50571
50797
  * Proxies call to the underlying notification adapter.
50572
50798
  */
50573
- this.clear = async () => {
50574
- return await this._notificationBacktestUtils.clear();
50799
+ this.dispose = async () => {
50800
+ return await this._notificationBacktestUtils.dispose();
50575
50801
  };
50576
50802
  /**
50577
50803
  * Sets the notification adapter constructor.
@@ -50607,6 +50833,15 @@ class NotificationBacktestAdapter {
50607
50833
  bt.loggerService.info(NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_USE_PERSIST);
50608
50834
  this._notificationBacktestUtils = new NotificationPersistBacktestUtils();
50609
50835
  };
50836
+ /**
50837
+ * Resets the cached utils instance to the default in-memory adapter.
50838
+ * Call this when process.cwd() changes between strategy iterations
50839
+ * so a new instance is created with the updated base path.
50840
+ */
50841
+ this.clear = () => {
50842
+ bt.loggerService.info(NOTIFICATION_BACKTEST_ADAPTER_METHOD_NAME_CLEAR);
50843
+ this._notificationBacktestUtils = new NotificationMemoryBacktestUtils();
50844
+ };
50610
50845
  }
50611
50846
  }
50612
50847
  /**
@@ -50716,8 +50951,8 @@ class NotificationLiveAdapter {
50716
50951
  * Clears all stored notifications.
50717
50952
  * Proxies call to the underlying notification adapter.
50718
50953
  */
50719
- this.clear = async () => {
50720
- return await this._notificationLiveUtils.clear();
50954
+ this.dispose = async () => {
50955
+ return await this._notificationLiveUtils.dispose();
50721
50956
  };
50722
50957
  /**
50723
50958
  * Sets the notification adapter constructor.
@@ -50753,6 +50988,15 @@ class NotificationLiveAdapter {
50753
50988
  bt.loggerService.info(NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_USE_PERSIST);
50754
50989
  this._notificationLiveUtils = new NotificationPersistLiveUtils();
50755
50990
  };
50991
+ /**
50992
+ * Resets the cached utils instance to the default in-memory adapter.
50993
+ * Call this when process.cwd() changes between strategy iterations
50994
+ * so a new instance is created with the updated base path.
50995
+ */
50996
+ this.clear = () => {
50997
+ bt.loggerService.info(NOTIFICATION_LIVE_ADAPTER_METHOD_NAME_CLEAR);
50998
+ this._notificationLiveUtils = new NotificationMemoryLiveUtils();
50999
+ };
50756
51000
  }
50757
51001
  }
50758
51002
  /**
@@ -50866,17 +51110,17 @@ class NotificationAdapter {
50866
51110
  *
50867
51111
  * @throws Error if NotificationAdapter is not enabled
50868
51112
  */
50869
- this.clear = async (isBacktest) => {
50870
- bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_CLEAR_LIVE, {
51113
+ this.dispose = async (isBacktest) => {
51114
+ bt.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_DISPOSE_LIVE, {
50871
51115
  backtest: isBacktest,
50872
51116
  });
50873
51117
  if (!this.enable.hasValue()) {
50874
51118
  throw new Error("NotificationAdapter is not enabled. Call enable() first.");
50875
51119
  }
50876
51120
  if (isBacktest) {
50877
- return await NotificationBacktest.clear();
51121
+ return await NotificationBacktest.dispose();
50878
51122
  }
50879
- return await NotificationLive.clear();
51123
+ return await NotificationLive.dispose();
50880
51124
  };
50881
51125
  }
50882
51126
  }