backtest-kit 6.4.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  Build reliable trading systems: backtest on historical data, deploy live bots with recovery, and optimize strategies using LLMs like Ollama.
15
15
 
16
- 📚 **[API Reference](https://backtest-kit.github.io/documents/example_02_first_backtest.html)** | 🌟 **[Quick Start](https://github.com/tripolskypetr/backtest-kit/tree/master/demo)** | **📰 [Article](https://backtest-kit.github.io/documents/article_02_second_order_chaos.html)**
16
+ 📚 **[API Reference](https://backtest-kit.github.io/documents/example_02_first_backtest.html)** | 🌟 **[Quick Start](https://github.com/tripolskypetr/backtest-kit/tree/master/demo)** | **📰 [Article](https://backtest-kit.github.io/documents/article_05_ai_strategy_workflow.html)**
17
17
 
18
18
  ## 🚀 Quick Start
19
19
 
package/build/index.cjs CHANGED
@@ -2729,6 +2729,12 @@ const METHOD_NAME_RELEASE_LOCK = "CandleUtils.releaseLock";
2729
2729
  class CandleUtils {
2730
2730
  constructor() {
2731
2731
  this._lock = new Lock();
2732
+ /**
2733
+ * Acquires the candle fetch mutex if CC_ENABLE_CANDLE_FETCH_MUTEX is enabled.
2734
+ * Prevents concurrent candle fetches from the same exchange.
2735
+ *
2736
+ * @param source - Caller identifier for logging
2737
+ */
2732
2738
  this.acquireLock = async (source) => {
2733
2739
  bt.loggerService.info(METHOD_NAME_ACQUIRE_LOCK, {
2734
2740
  source,
@@ -2738,6 +2744,12 @@ class CandleUtils {
2738
2744
  }
2739
2745
  return await this._lock.acquireLock();
2740
2746
  };
2747
+ /**
2748
+ * Releases the candle fetch mutex if CC_ENABLE_CANDLE_FETCH_MUTEX is enabled.
2749
+ * Must be called after acquireLock, typically in a finally block.
2750
+ *
2751
+ * @param source - Caller identifier for logging
2752
+ */
2741
2753
  this.releaseLock = async (source) => {
2742
2754
  bt.loggerService.info(METHOD_NAME_RELEASE_LOCK, {
2743
2755
  source,
@@ -14316,6 +14328,20 @@ class StrategyCoreService {
14316
14328
  await this.validate(context);
14317
14329
  return await this.strategyConnectionService.getTotalCostClosed(backtest, symbol, context);
14318
14330
  };
14331
+ /**
14332
+ * Returns the effective (DCA-averaged) entry price for the current pending signal.
14333
+ *
14334
+ * This is the harmonic mean of all _entry prices, which is the correct
14335
+ * cost-basis price used in all PNL calculations.
14336
+ * With no DCA entries, equals the original priceOpen.
14337
+ *
14338
+ * Returns null if no pending signal exists.
14339
+ *
14340
+ * @param backtest - Whether running in backtest mode
14341
+ * @param symbol - Trading pair symbol
14342
+ * @param context - Execution context with strategyName, exchangeName, frameName
14343
+ * @returns Promise resolving to effective entry price or null
14344
+ */
14319
14345
  this.getPositionEffectivePrice = async (backtest, symbol, context) => {
14320
14346
  this.loggerService.log("strategyCoreService getPositionEffectivePrice", {
14321
14347
  symbol,
@@ -14324,6 +14350,19 @@ class StrategyCoreService {
14324
14350
  await this.validate(context);
14325
14351
  return await this.strategyConnectionService.getPositionEffectivePrice(backtest, symbol, context);
14326
14352
  };
14353
+ /**
14354
+ * Returns the number of DCA entries made for the current pending signal.
14355
+ *
14356
+ * 1 = original entry only (no DCA).
14357
+ * Increases by 1 with each successful commitAverageBuy().
14358
+ *
14359
+ * Returns null if no pending signal exists.
14360
+ *
14361
+ * @param backtest - Whether running in backtest mode
14362
+ * @param symbol - Trading pair symbol
14363
+ * @param context - Execution context with strategyName, exchangeName, frameName
14364
+ * @returns Promise resolving to entry count or null
14365
+ */
14327
14366
  this.getPositionInvestedCount = async (backtest, symbol, context) => {
14328
14367
  this.loggerService.log("strategyCoreService getPositionInvestedCount", {
14329
14368
  symbol,
@@ -14332,6 +14371,19 @@ class StrategyCoreService {
14332
14371
  await this.validate(context);
14333
14372
  return await this.strategyConnectionService.getPositionInvestedCount(backtest, symbol, context);
14334
14373
  };
14374
+ /**
14375
+ * Returns the total invested cost basis in dollars for the current pending signal.
14376
+ *
14377
+ * Equal to entryCount × $100 (COST_BASIS_PER_ENTRY).
14378
+ * 1 entry = $100, 2 entries = $200, etc.
14379
+ *
14380
+ * Returns null if no pending signal exists.
14381
+ *
14382
+ * @param backtest - Whether running in backtest mode
14383
+ * @param symbol - Trading pair symbol
14384
+ * @param context - Execution context with strategyName, exchangeName, frameName
14385
+ * @returns Promise resolving to total invested cost in dollars or null
14386
+ */
14335
14387
  this.getPositionInvestedCost = async (backtest, symbol, context) => {
14336
14388
  this.loggerService.log("strategyCoreService getPositionInvestedCost", {
14337
14389
  symbol,
@@ -14340,6 +14392,20 @@ class StrategyCoreService {
14340
14392
  await this.validate(context);
14341
14393
  return await this.strategyConnectionService.getPositionInvestedCost(backtest, symbol, context);
14342
14394
  };
14395
+ /**
14396
+ * Returns the unrealized PNL percentage for the current pending signal at currentPrice.
14397
+ *
14398
+ * Accounts for partial closes, DCA entries, slippage and fees
14399
+ * (delegates to toProfitLossDto).
14400
+ *
14401
+ * Returns null if no pending signal exists.
14402
+ *
14403
+ * @param backtest - Whether running in backtest mode
14404
+ * @param symbol - Trading pair symbol
14405
+ * @param currentPrice - Current market price
14406
+ * @param context - Execution context with strategyName, exchangeName, frameName
14407
+ * @returns Promise resolving to pnlPercentage or null
14408
+ */
14343
14409
  this.getPositionPnlPercent = async (backtest, symbol, currentPrice, context) => {
14344
14410
  this.loggerService.log("strategyCoreService getPositionPnlPercent", {
14345
14411
  symbol,
@@ -14349,6 +14415,20 @@ class StrategyCoreService {
14349
14415
  await this.validate(context);
14350
14416
  return await this.strategyConnectionService.getPositionPnlPercent(backtest, symbol, currentPrice, context);
14351
14417
  };
14418
+ /**
14419
+ * Returns the unrealized PNL in dollars for the current pending signal at currentPrice.
14420
+ *
14421
+ * Calculated as: pnlPercentage / 100 × totalInvestedCost
14422
+ * Accounts for partial closes, DCA entries, slippage and fees.
14423
+ *
14424
+ * Returns null if no pending signal exists.
14425
+ *
14426
+ * @param backtest - Whether running in backtest mode
14427
+ * @param symbol - Trading pair symbol
14428
+ * @param currentPrice - Current market price
14429
+ * @param context - Execution context with strategyName, exchangeName, frameName
14430
+ * @returns Promise resolving to pnl in dollars or null
14431
+ */
14352
14432
  this.getPositionPnlCost = async (backtest, symbol, currentPrice, context) => {
14353
14433
  this.loggerService.log("strategyCoreService getPositionPnlCost", {
14354
14434
  symbol,
@@ -14358,6 +14438,27 @@ class StrategyCoreService {
14358
14438
  await this.validate(context);
14359
14439
  return await this.strategyConnectionService.getPositionPnlCost(backtest, symbol, currentPrice, context);
14360
14440
  };
14441
+ /**
14442
+ * Returns the list of DCA entry prices for the current pending signal.
14443
+ *
14444
+ * The first element is always the original priceOpen (initial entry).
14445
+ * Each subsequent element is a price added by commitAverageBuy().
14446
+ *
14447
+ * Returns null if no pending signal exists.
14448
+ * Returns a single-element array [priceOpen] if no DCA entries were made.
14449
+ *
14450
+ * @param backtest - Whether running in backtest mode
14451
+ * @param symbol - Trading pair symbol
14452
+ * @param context - Execution context with strategyName, exchangeName, frameName
14453
+ * @returns Promise resolving to array of entry prices or null
14454
+ *
14455
+ * @example
14456
+ * ```typescript
14457
+ * // No DCA: [43000]
14458
+ * // One DCA: [43000, 42000]
14459
+ * // Two DCA: [43000, 42000, 41500]
14460
+ * ```
14461
+ */
14361
14462
  this.getPositionLevels = async (backtest, symbol, context) => {
14362
14463
  this.loggerService.log("strategyCoreService getPositionLevels", {
14363
14464
  symbol,
@@ -14366,6 +14467,20 @@ class StrategyCoreService {
14366
14467
  await this.validate(context);
14367
14468
  return await this.strategyConnectionService.getPositionLevels(backtest, symbol, context);
14368
14469
  };
14470
+ /**
14471
+ * Returns the list of partial closes for the current pending signal.
14472
+ *
14473
+ * Each entry records a partial profit or loss close event with its type,
14474
+ * percent closed, price at close, cost basis snapshot, and entry count at close.
14475
+ *
14476
+ * Returns null if no pending signal exists.
14477
+ * Returns an empty array if no partial closes have been executed.
14478
+ *
14479
+ * @param backtest - Whether running in backtest mode
14480
+ * @param symbol - Trading pair symbol
14481
+ * @param context - Execution context with strategyName, exchangeName, frameName
14482
+ * @returns Promise resolving to array of partial close records or null
14483
+ */
14369
14484
  this.getPositionPartials = async (backtest, symbol, context) => {
14370
14485
  this.loggerService.log("strategyCoreService getPositionPartials", {
14371
14486
  symbol,
@@ -14374,6 +14489,27 @@ class StrategyCoreService {
14374
14489
  await this.validate(context);
14375
14490
  return await this.strategyConnectionService.getPositionPartials(backtest, symbol, context);
14376
14491
  };
14492
+ /**
14493
+ * Returns the list of DCA entry prices and costs for the current pending signal.
14494
+ *
14495
+ * Each entry records the price and cost of a single position entry.
14496
+ * The first element is always the original priceOpen (initial entry).
14497
+ * Each subsequent element is an entry added by averageBuy().
14498
+ *
14499
+ * Returns null if no pending signal exists.
14500
+ * Returns a single-element array [{ price: priceOpen, cost }] if no DCA entries were made.
14501
+ *
14502
+ * @param backtest - Whether running in backtest mode
14503
+ * @param symbol - Trading pair symbol
14504
+ * @param context - Execution context with strategyName, exchangeName, frameName
14505
+ * @returns Promise resolving to array of entry records or null
14506
+ *
14507
+ * @example
14508
+ * ```typescript
14509
+ * // No DCA: [{ price: 43000, cost: 100 }]
14510
+ * // One DCA: [{ price: 43000, cost: 100 }, { price: 42000, cost: 100 }]
14511
+ * ```
14512
+ */
14377
14513
  this.getPositionEntries = async (backtest, symbol, context) => {
14378
14514
  this.loggerService.log("strategyCoreService getPositionEntries", {
14379
14515
  symbol,
@@ -14755,6 +14891,28 @@ class StrategyCoreService {
14755
14891
  await this.validate(context);
14756
14892
  return await this.strategyConnectionService.partialLoss(backtest, symbol, percentToClose, currentPrice, context);
14757
14893
  };
14894
+ /**
14895
+ * Checks whether `trailingStop` would succeed without executing it.
14896
+ * Validates context, then delegates to StrategyConnectionService.validateTrailingStop().
14897
+ *
14898
+ * @param backtest - Whether running in backtest mode
14899
+ * @param symbol - Trading pair symbol
14900
+ * @param percentShift - Percentage shift of ORIGINAL SL distance [-100, 100], excluding 0
14901
+ * @param currentPrice - Current market price to validate against
14902
+ * @param context - Execution context with strategyName, exchangeName, frameName
14903
+ * @returns Promise<boolean> - true if `trailingStop` would execute, false otherwise
14904
+ */
14905
+ this.validateTrailingStop = async (backtest, symbol, percentShift, currentPrice, context) => {
14906
+ this.loggerService.log("strategyCoreService validateTrailingStop", {
14907
+ symbol,
14908
+ percentShift,
14909
+ currentPrice,
14910
+ context,
14911
+ backtest,
14912
+ });
14913
+ await this.validate(context);
14914
+ return await this.strategyConnectionService.validateTrailingStop(backtest, symbol, percentShift, currentPrice, context);
14915
+ };
14758
14916
  /**
14759
14917
  * Adjusts the trailing stop-loss distance for an active pending signal.
14760
14918
  *
@@ -14768,7 +14926,7 @@ class StrategyCoreService {
14768
14926
  * @param percentShift - Percentage adjustment to SL distance (-100 to 100)
14769
14927
  * @param currentPrice - Current market price to check for intrusion
14770
14928
  * @param context - Execution context with strategyName, exchangeName, frameName
14771
- * @returns Promise that resolves when trailing SL is updated
14929
+ * @returns Promise<boolean> - true if trailing SL was updated, false otherwise
14772
14930
  *
14773
14931
  * @example
14774
14932
  * ```typescript
@@ -14783,8 +14941,8 @@ class StrategyCoreService {
14783
14941
  * );
14784
14942
  * ```
14785
14943
  */
14786
- this.validateTrailingStop = async (backtest, symbol, percentShift, currentPrice, context) => {
14787
- this.loggerService.log("strategyCoreService validateTrailingStop", {
14944
+ this.trailingStop = async (backtest, symbol, percentShift, currentPrice, context) => {
14945
+ this.loggerService.log("strategyCoreService trailingStop", {
14788
14946
  symbol,
14789
14947
  percentShift,
14790
14948
  currentPrice,
@@ -14792,21 +14950,21 @@ class StrategyCoreService {
14792
14950
  backtest,
14793
14951
  });
14794
14952
  await this.validate(context);
14795
- return await this.strategyConnectionService.validateTrailingStop(backtest, symbol, percentShift, currentPrice, context);
14953
+ return await this.strategyConnectionService.trailingStop(backtest, symbol, percentShift, currentPrice, context);
14796
14954
  };
14797
14955
  /**
14798
- * Checks whether `trailingStop` would succeed without executing it.
14799
- * Validates context, then delegates to StrategyConnectionService.validateTrailingStop().
14956
+ * Checks whether `trailingTake` would succeed without executing it.
14957
+ * Validates context, then delegates to StrategyConnectionService.validateTrailingTake().
14800
14958
  *
14801
14959
  * @param backtest - Whether running in backtest mode
14802
14960
  * @param symbol - Trading pair symbol
14803
- * @param percentShift - Percentage shift of ORIGINAL SL distance [-100, 100], excluding 0
14961
+ * @param percentShift - Percentage adjustment to ORIGINAL TP distance [-100, 100], excluding 0
14804
14962
  * @param currentPrice - Current market price to validate against
14805
14963
  * @param context - Execution context with strategyName, exchangeName, frameName
14806
- * @returns Promise<boolean> - true if `trailingStop` would execute, false otherwise
14964
+ * @returns Promise<boolean> - true if `trailingTake` would execute, false otherwise
14807
14965
  */
14808
- this.trailingStop = async (backtest, symbol, percentShift, currentPrice, context) => {
14809
- this.loggerService.log("strategyCoreService trailingStop", {
14966
+ this.validateTrailingTake = async (backtest, symbol, percentShift, currentPrice, context) => {
14967
+ this.loggerService.log("strategyCoreService validateTrailingTake", {
14810
14968
  symbol,
14811
14969
  percentShift,
14812
14970
  currentPrice,
@@ -14814,7 +14972,7 @@ class StrategyCoreService {
14814
14972
  backtest,
14815
14973
  });
14816
14974
  await this.validate(context);
14817
- return await this.strategyConnectionService.trailingStop(backtest, symbol, percentShift, currentPrice, context);
14975
+ return await this.strategyConnectionService.validateTrailingTake(backtest, symbol, percentShift, currentPrice, context);
14818
14976
  };
14819
14977
  /**
14820
14978
  * Adjusts the trailing take-profit distance for an active pending signal.
@@ -14825,7 +14983,7 @@ class StrategyCoreService {
14825
14983
  * @param percentShift - Percentage adjustment to TP distance (-100 to 100)
14826
14984
  * @param currentPrice - Current market price to check for intrusion
14827
14985
  * @param context - Strategy context with strategyName, exchangeName, frameName
14828
- * @returns Promise that resolves when trailing TP is updated
14986
+ * @returns Promise<boolean> - true if trailing TP was updated, false otherwise
14829
14987
  *
14830
14988
  * @example
14831
14989
  * ```typescript
@@ -14840,8 +14998,8 @@ class StrategyCoreService {
14840
14998
  * );
14841
14999
  * ```
14842
15000
  */
14843
- this.validateTrailingTake = async (backtest, symbol, percentShift, currentPrice, context) => {
14844
- this.loggerService.log("strategyCoreService validateTrailingTake", {
15001
+ this.trailingTake = async (backtest, symbol, percentShift, currentPrice, context) => {
15002
+ this.loggerService.log("strategyCoreService trailingTake", {
14845
15003
  symbol,
14846
15004
  percentShift,
14847
15005
  currentPrice,
@@ -14849,29 +15007,27 @@ class StrategyCoreService {
14849
15007
  backtest,
14850
15008
  });
14851
15009
  await this.validate(context);
14852
- return await this.strategyConnectionService.validateTrailingTake(backtest, symbol, percentShift, currentPrice, context);
15010
+ return await this.strategyConnectionService.trailingTake(backtest, symbol, percentShift, currentPrice, context);
14853
15011
  };
14854
15012
  /**
14855
- * Checks whether `trailingTake` would succeed without executing it.
14856
- * Validates context, then delegates to StrategyConnectionService.validateTrailingTake().
15013
+ * Checks whether `breakeven` would succeed without executing it.
15014
+ * Validates context, then delegates to StrategyConnectionService.validateBreakeven().
14857
15015
  *
14858
15016
  * @param backtest - Whether running in backtest mode
14859
15017
  * @param symbol - Trading pair symbol
14860
- * @param percentShift - Percentage adjustment to ORIGINAL TP distance [-100, 100], excluding 0
14861
15018
  * @param currentPrice - Current market price to validate against
14862
15019
  * @param context - Execution context with strategyName, exchangeName, frameName
14863
- * @returns Promise<boolean> - true if `trailingTake` would execute, false otherwise
15020
+ * @returns Promise<boolean> - true if `breakeven` would execute, false otherwise
14864
15021
  */
14865
- this.trailingTake = async (backtest, symbol, percentShift, currentPrice, context) => {
14866
- this.loggerService.log("strategyCoreService trailingTake", {
15022
+ this.validateBreakeven = async (backtest, symbol, currentPrice, context) => {
15023
+ this.loggerService.log("strategyCoreService validateBreakeven", {
14867
15024
  symbol,
14868
- percentShift,
14869
15025
  currentPrice,
14870
15026
  context,
14871
15027
  backtest,
14872
15028
  });
14873
15029
  await this.validate(context);
14874
- return await this.strategyConnectionService.trailingTake(backtest, symbol, percentShift, currentPrice, context);
15030
+ return await this.strategyConnectionService.validateBreakeven(backtest, symbol, currentPrice, context);
14875
15031
  };
14876
15032
  /**
14877
15033
  * Moves stop-loss to breakeven when price reaches threshold.
@@ -14893,26 +15049,6 @@ class StrategyCoreService {
14893
15049
  * );
14894
15050
  * ```
14895
15051
  */
14896
- this.validateBreakeven = async (backtest, symbol, currentPrice, context) => {
14897
- this.loggerService.log("strategyCoreService validateBreakeven", {
14898
- symbol,
14899
- currentPrice,
14900
- context,
14901
- backtest,
14902
- });
14903
- await this.validate(context);
14904
- return await this.strategyConnectionService.validateBreakeven(backtest, symbol, currentPrice, context);
14905
- };
14906
- /**
14907
- * Checks whether `breakeven` would succeed without executing it.
14908
- * Validates context, then delegates to StrategyConnectionService.validateBreakeven().
14909
- *
14910
- * @param backtest - Whether running in backtest mode
14911
- * @param symbol - Trading pair symbol
14912
- * @param currentPrice - Current market price to validate against
14913
- * @param context - Execution context with strategyName, exchangeName, frameName
14914
- * @returns Promise<boolean> - true if `breakeven` would execute, false otherwise
14915
- */
14916
15052
  this.breakeven = async (backtest, symbol, currentPrice, context) => {
14917
15053
  this.loggerService.log("strategyCoreService breakeven", {
14918
15054
  symbol,
@@ -14957,16 +15093,14 @@ class StrategyCoreService {
14957
15093
  return await this.strategyConnectionService.activateScheduled(backtest, symbol, context, activateId);
14958
15094
  };
14959
15095
  /**
14960
- * Adds a new DCA entry to the active pending signal.
14961
- *
14962
- * Validates strategy existence and delegates to connection service
14963
- * to add a new averaging entry to the position.
15096
+ * Checks whether `averageBuy` would succeed without executing it.
15097
+ * Validates context, then delegates to StrategyConnectionService.validateAverageBuy().
14964
15098
  *
14965
15099
  * @param backtest - Whether running in backtest mode
14966
15100
  * @param symbol - Trading pair symbol
14967
- * @param currentPrice - New entry price to add to the averaging history
15101
+ * @param currentPrice - New entry price to validate
14968
15102
  * @param context - Execution context with strategyName, exchangeName, frameName
14969
- * @returns Promise<boolean> - true if entry added, false if rejected
15103
+ * @returns Promise<boolean> - true if `averageBuy` would execute, false otherwise
14970
15104
  */
14971
15105
  this.validateAverageBuy = async (backtest, symbol, currentPrice, context) => {
14972
15106
  this.loggerService.log("strategyCoreService validateAverageBuy", {
@@ -14979,14 +15113,17 @@ class StrategyCoreService {
14979
15113
  return await this.strategyConnectionService.validateAverageBuy(backtest, symbol, currentPrice, context);
14980
15114
  };
14981
15115
  /**
14982
- * Checks whether `averageBuy` would succeed without executing it.
14983
- * Validates context, then delegates to StrategyConnectionService.validateAverageBuy().
15116
+ * Adds a new DCA entry to the active pending signal.
15117
+ *
15118
+ * Validates strategy existence and delegates to connection service
15119
+ * to add a new averaging entry to the position.
14984
15120
  *
14985
15121
  * @param backtest - Whether running in backtest mode
14986
15122
  * @param symbol - Trading pair symbol
14987
- * @param currentPrice - New entry price to validate
15123
+ * @param currentPrice - New entry price to add to the averaging history
15124
+ * @param cost - Cost basis for this entry in dollars
14988
15125
  * @param context - Execution context with strategyName, exchangeName, frameName
14989
- * @returns Promise<boolean> - true if `averageBuy` would execute, false otherwise
15126
+ * @returns Promise<boolean> - true if entry added, false if rejected
14990
15127
  */
14991
15128
  this.averageBuy = async (backtest, symbol, currentPrice, context, cost) => {
14992
15129
  this.loggerService.log("strategyCoreService averageBuy", {
@@ -47941,6 +48078,13 @@ class StoragePersistBacktestUtils {
47941
48078
  await this.waitForInit();
47942
48079
  return Array.from(this._signals.values());
47943
48080
  };
48081
+ /**
48082
+ * Handles active ping event for an opened signal.
48083
+ * Updates the signal's PnL and timestamp if the event is newer than the stored state.
48084
+ * Persists updated state to disk.
48085
+ *
48086
+ * @param event - Active ping contract with signal data and current price
48087
+ */
47944
48088
  this.handleActivePing = async (event) => {
47945
48089
  bt.loggerService.info(STORAGE_BACKTEST_METHOD_NAME_HANDLE_ACTIVE_PING, {
47946
48090
  signalId: event.data.id,
@@ -47964,6 +48108,13 @@ class StoragePersistBacktestUtils {
47964
48108
  });
47965
48109
  await this._updateStorage();
47966
48110
  };
48111
+ /**
48112
+ * Handles schedule ping event for a scheduled signal.
48113
+ * Updates the signal's data and timestamp if the event is newer than the stored state.
48114
+ * Persists updated state to disk.
48115
+ *
48116
+ * @param event - Schedule ping contract with signal data and current price
48117
+ */
47967
48118
  this.handleSchedulePing = async (event) => {
47968
48119
  bt.loggerService.info(STORAGE_BACKTEST_METHOD_NAME_HANDLE_SCHEDULE_PING, {
47969
48120
  signalId: event.data.id,
@@ -48135,6 +48286,13 @@ class StorageMemoryBacktestUtils {
48135
48286
  bt.loggerService.info(STORAGE_MEMORY_BACKTEST_METHOD_NAME_LIST);
48136
48287
  return Array.from(this._signals.values());
48137
48288
  };
48289
+ /**
48290
+ * Handles active ping event for an opened signal.
48291
+ * Updates the signal's PnL and timestamp if the event is newer than the stored state.
48292
+ * In-memory only — no disk persistence.
48293
+ *
48294
+ * @param event - Active ping contract with signal data and current price
48295
+ */
48138
48296
  this.handleActivePing = async (event) => {
48139
48297
  bt.loggerService.info(STORAGE_MEMORY_BACKTEST_METHOD_NAME_HANDLE_ACTIVE_PING, {
48140
48298
  signalId: event.data.id,
@@ -48156,6 +48314,13 @@ class StorageMemoryBacktestUtils {
48156
48314
  updatedAt: event.timestamp,
48157
48315
  });
48158
48316
  };
48317
+ /**
48318
+ * Handles schedule ping event for a scheduled signal.
48319
+ * Updates the signal's data and timestamp if the event is newer than the stored state.
48320
+ * In-memory only — no disk persistence.
48321
+ *
48322
+ * @param event - Schedule ping contract with signal data and current price
48323
+ */
48159
48324
  this.handleSchedulePing = async (event) => {
48160
48325
  bt.loggerService.info(STORAGE_MEMORY_BACKTEST_METHOD_NAME_HANDLE_SCHEDULE_PING, {
48161
48326
  signalId: event.data.id,
@@ -48235,8 +48400,14 @@ class StorageDummyBacktestUtils {
48235
48400
  this.list = async () => {
48236
48401
  return [];
48237
48402
  };
48403
+ /**
48404
+ * No-op handler for active ping events (dummy adapter discards all writes).
48405
+ */
48238
48406
  this.handleActivePing = async () => {
48239
48407
  };
48408
+ /**
48409
+ * No-op handler for schedule ping events (dummy adapter discards all writes).
48410
+ */
48240
48411
  this.handleSchedulePing = async () => {
48241
48412
  };
48242
48413
  }
@@ -48383,6 +48554,13 @@ class StoragePersistLiveUtils {
48383
48554
  await this.waitForInit();
48384
48555
  return Array.from(this._signals.values());
48385
48556
  };
48557
+ /**
48558
+ * Handles active ping event for an opened signal.
48559
+ * Updates the signal's PnL and timestamp if the event is newer than the stored state.
48560
+ * Persists updated state to disk.
48561
+ *
48562
+ * @param event - Active ping contract with signal data and current price
48563
+ */
48386
48564
  this.handleActivePing = async (event) => {
48387
48565
  bt.loggerService.info(STORAGE_LIVE_METHOD_NAME_HANDLE_ACTIVE_PING, {
48388
48566
  signalId: event.data.id,
@@ -48406,6 +48584,13 @@ class StoragePersistLiveUtils {
48406
48584
  });
48407
48585
  await this._updateStorage();
48408
48586
  };
48587
+ /**
48588
+ * Handles schedule ping event for a scheduled signal.
48589
+ * Updates the signal's data and timestamp if the event is newer than the stored state.
48590
+ * Persists updated state to disk.
48591
+ *
48592
+ * @param event - Schedule ping contract with signal data and current price
48593
+ */
48409
48594
  this.handleSchedulePing = async (event) => {
48410
48595
  bt.loggerService.info(STORAGE_LIVE_METHOD_NAME_HANDLE_SCHEDULE_PING, {
48411
48596
  signalId: event.data.id,
@@ -48577,6 +48762,13 @@ class StorageMemoryLiveUtils {
48577
48762
  bt.loggerService.info(STORAGE_MEMORY_LIVE_METHOD_NAME_LIST);
48578
48763
  return Array.from(this._signals.values());
48579
48764
  };
48765
+ /**
48766
+ * Handles active ping event for an opened signal.
48767
+ * Updates the signal's PnL and timestamp if the event is newer than the stored state.
48768
+ * In-memory only — no disk persistence.
48769
+ *
48770
+ * @param event - Active ping contract with signal data and current price
48771
+ */
48580
48772
  this.handleActivePing = async (event) => {
48581
48773
  bt.loggerService.info(STORAGE_MEMORY_LIVE_METHOD_NAME_HANDLE_ACTIVE_PING, {
48582
48774
  signalId: event.data.id,
@@ -48598,6 +48790,13 @@ class StorageMemoryLiveUtils {
48598
48790
  updatedAt: event.timestamp,
48599
48791
  });
48600
48792
  };
48793
+ /**
48794
+ * Handles schedule ping event for a scheduled signal.
48795
+ * Updates the signal's data and timestamp if the event is newer than the stored state.
48796
+ * In-memory only — no disk persistence.
48797
+ *
48798
+ * @param event - Schedule ping contract with signal data and current price
48799
+ */
48601
48800
  this.handleSchedulePing = async (event) => {
48602
48801
  bt.loggerService.info(STORAGE_MEMORY_LIVE_METHOD_NAME_HANDLE_SCHEDULE_PING, {
48603
48802
  signalId: event.data.id,
@@ -48677,8 +48876,14 @@ class StorageDummyLiveUtils {
48677
48876
  this.list = async () => {
48678
48877
  return [];
48679
48878
  };
48879
+ /**
48880
+ * No-op handler for active ping events (dummy adapter discards all writes).
48881
+ */
48680
48882
  this.handleActivePing = async () => {
48681
48883
  };
48884
+ /**
48885
+ * No-op handler for schedule ping events (dummy adapter discards all writes).
48886
+ */
48682
48887
  this.handleSchedulePing = async () => {
48683
48888
  };
48684
48889
  }