backtest-kit 7.2.0 → 7.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
@@ -6653,17 +6653,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6653
6653
  let percentTp = 0;
6654
6654
  let percentSl = 0;
6655
6655
  const currentTime = self.params.execution.context.when.getTime();
6656
- await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6657
6656
  // Calculate percentage of path to TP/SL for partial fill/loss callbacks
6658
6657
  {
6659
6658
  const effectivePriceOpen = getEffectivePriceOpen(signal);
6660
6659
  if (signal.position === "long") {
6661
6660
  // For long: calculate progress towards TP or SL
6662
6661
  const currentDistance = currentPrice - effectivePriceOpen;
6663
- if (currentDistance > 0) {
6664
- // Check if breakeven should be triggered
6665
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6666
- }
6667
6662
  if (currentDistance > 0) {
6668
6663
  // Moving towards TP (use trailing TP if set)
6669
6664
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -6679,6 +6674,9 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6679
6674
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6680
6675
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6681
6676
  }
6677
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6678
+ // Check if breakeven should be triggered
6679
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6682
6680
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentTp, currentTime, self.params.execution.context.backtest);
6683
6681
  }
6684
6682
  else if (currentDistance < 0) {
@@ -6696,16 +6694,16 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6696
6694
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6697
6695
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6698
6696
  }
6697
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6699
6698
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentSl, currentTime, self.params.execution.context.backtest);
6700
6699
  }
6700
+ else {
6701
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6702
+ }
6701
6703
  }
6702
6704
  else if (signal.position === "short") {
6703
6705
  // For short: calculate progress towards TP or SL
6704
6706
  const currentDistance = effectivePriceOpen - currentPrice;
6705
- if (currentDistance > 0) {
6706
- // Check if breakeven should be triggered
6707
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6708
- }
6709
6707
  if (currentDistance > 0) {
6710
6708
  // Moving towards TP (use trailing TP if set)
6711
6709
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -6721,9 +6719,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6721
6719
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6722
6720
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6723
6721
  }
6722
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6723
+ // Check if breakeven should be triggered
6724
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6724
6725
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentTp, currentTime, self.params.execution.context.backtest);
6725
6726
  }
6726
- if (currentDistance < 0) {
6727
+ else if (currentDistance < 0) {
6727
6728
  // Moving towards SL (use trailing SL if set)
6728
6729
  const effectiveStopLoss = signal._trailingPriceStopLoss ?? signal.priceStopLoss;
6729
6730
  const slDistance = effectiveStopLoss - effectivePriceOpen;
@@ -6738,8 +6739,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6738
6739
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6739
6740
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6740
6741
  }
6742
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6741
6743
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentSl, currentTime, self.params.execution.context.backtest);
6742
6744
  }
6745
+ else {
6746
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6747
+ }
6743
6748
  }
6744
6749
  }
6745
6750
  const publicSignal = TO_PUBLIC_SIGNAL("pending", signal, currentPrice);
@@ -7212,7 +7217,6 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7212
7217
  if (self._closedSignal) {
7213
7218
  return await CLOSE_USER_PENDING_SIGNAL_IN_BACKTEST_FN(self, self._closedSignal, averagePrice, currentCandleTimestamp);
7214
7219
  }
7215
- await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7216
7220
  let shouldClose = false;
7217
7221
  let closeReason;
7218
7222
  // Check time expiration FIRST (КРИТИЧНО!)
@@ -7271,10 +7275,6 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7271
7275
  if (signal.position === "long") {
7272
7276
  // For long: calculate progress towards TP or SL
7273
7277
  const currentDistance = averagePrice - effectivePriceOpen;
7274
- if (currentDistance > 0) {
7275
- // Check if breakeven should be triggered
7276
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7277
- }
7278
7278
  if (currentDistance > 0) {
7279
7279
  // Moving towards TP (use trailing TP if set)
7280
7280
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -7288,6 +7288,8 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7288
7288
  }
7289
7289
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7290
7290
  }
7291
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7292
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7291
7293
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7292
7294
  }
7293
7295
  else if (currentDistance < 0) {
@@ -7303,16 +7305,16 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7303
7305
  }
7304
7306
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7305
7307
  }
7308
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7306
7309
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7307
7310
  }
7311
+ else {
7312
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7313
+ }
7308
7314
  }
7309
7315
  else if (signal.position === "short") {
7310
7316
  // For short: calculate progress towards TP or SL
7311
7317
  const currentDistance = effectivePriceOpen - averagePrice;
7312
- if (currentDistance > 0) {
7313
- // Check if breakeven should be triggered
7314
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7315
- }
7316
7318
  if (currentDistance > 0) {
7317
7319
  // Moving towards TP (use trailing TP if set)
7318
7320
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -7326,9 +7328,11 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7326
7328
  }
7327
7329
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7328
7330
  }
7331
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7332
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7329
7333
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7330
7334
  }
7331
- if (currentDistance < 0) {
7335
+ else if (currentDistance < 0) {
7332
7336
  // Moving towards SL (use trailing SL if set)
7333
7337
  const effectiveStopLoss = signal._trailingPriceStopLoss ?? signal.priceStopLoss;
7334
7338
  const slDistance = effectiveStopLoss - effectivePriceOpen;
@@ -7341,8 +7345,12 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7341
7345
  }
7342
7346
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7343
7347
  }
7348
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7344
7349
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7345
7350
  }
7351
+ else {
7352
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7353
+ }
7346
7354
  }
7347
7355
  }
7348
7356
  // Process queued commit events with candle timestamp
package/build/index.mjs CHANGED
@@ -6633,17 +6633,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6633
6633
  let percentTp = 0;
6634
6634
  let percentSl = 0;
6635
6635
  const currentTime = self.params.execution.context.when.getTime();
6636
- await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6637
6636
  // Calculate percentage of path to TP/SL for partial fill/loss callbacks
6638
6637
  {
6639
6638
  const effectivePriceOpen = getEffectivePriceOpen(signal);
6640
6639
  if (signal.position === "long") {
6641
6640
  // For long: calculate progress towards TP or SL
6642
6641
  const currentDistance = currentPrice - effectivePriceOpen;
6643
- if (currentDistance > 0) {
6644
- // Check if breakeven should be triggered
6645
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6646
- }
6647
6642
  if (currentDistance > 0) {
6648
6643
  // Moving towards TP (use trailing TP if set)
6649
6644
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -6659,6 +6654,9 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6659
6654
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6660
6655
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6661
6656
  }
6657
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6658
+ // Check if breakeven should be triggered
6659
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6662
6660
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentTp, currentTime, self.params.execution.context.backtest);
6663
6661
  }
6664
6662
  else if (currentDistance < 0) {
@@ -6676,16 +6674,16 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6676
6674
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6677
6675
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6678
6676
  }
6677
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6679
6678
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentSl, currentTime, self.params.execution.context.backtest);
6680
6679
  }
6680
+ else {
6681
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6682
+ }
6681
6683
  }
6682
6684
  else if (signal.position === "short") {
6683
6685
  // For short: calculate progress towards TP or SL
6684
6686
  const currentDistance = effectivePriceOpen - currentPrice;
6685
- if (currentDistance > 0) {
6686
- // Check if breakeven should be triggered
6687
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6688
- }
6689
6687
  if (currentDistance > 0) {
6690
6688
  // Moving towards TP (use trailing TP if set)
6691
6689
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -6701,9 +6699,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6701
6699
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6702
6700
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6703
6701
  }
6702
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6703
+ // Check if breakeven should be triggered
6704
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, currentPrice, currentTime, self.params.execution.context.backtest);
6704
6705
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentTp, currentTime, self.params.execution.context.backtest);
6705
6706
  }
6706
- if (currentDistance < 0) {
6707
+ else if (currentDistance < 0) {
6707
6708
  // Moving towards SL (use trailing SL if set)
6708
6709
  const effectiveStopLoss = signal._trailingPriceStopLoss ?? signal.priceStopLoss;
6709
6710
  const slDistance = effectiveStopLoss - effectivePriceOpen;
@@ -6718,8 +6719,12 @@ const RETURN_PENDING_SIGNAL_ACTIVE_FN = async (self, signal, currentPrice, backt
6718
6719
  !backtest && await PersistSignalAdapter.writeSignalData(signal, self.params.execution.context.symbol, self.params.strategyName, self.params.exchangeName);
6719
6720
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, currentPrice), currentPrice, currentTime);
6720
6721
  }
6722
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6721
6723
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentPrice, percentSl, currentTime, self.params.execution.context.backtest);
6722
6724
  }
6725
+ else {
6726
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentTime, self.params.execution.context.backtest, currentPrice);
6727
+ }
6723
6728
  }
6724
6729
  }
6725
6730
  const publicSignal = TO_PUBLIC_SIGNAL("pending", signal, currentPrice);
@@ -7192,7 +7197,6 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7192
7197
  if (self._closedSignal) {
7193
7198
  return await CLOSE_USER_PENDING_SIGNAL_IN_BACKTEST_FN(self, self._closedSignal, averagePrice, currentCandleTimestamp);
7194
7199
  }
7195
- await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7196
7200
  let shouldClose = false;
7197
7201
  let closeReason;
7198
7202
  // Check time expiration FIRST (КРИТИЧНО!)
@@ -7251,10 +7255,6 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7251
7255
  if (signal.position === "long") {
7252
7256
  // For long: calculate progress towards TP or SL
7253
7257
  const currentDistance = averagePrice - effectivePriceOpen;
7254
- if (currentDistance > 0) {
7255
- // Check if breakeven should be triggered
7256
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7257
- }
7258
7258
  if (currentDistance > 0) {
7259
7259
  // Moving towards TP (use trailing TP if set)
7260
7260
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -7268,6 +7268,8 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7268
7268
  }
7269
7269
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7270
7270
  }
7271
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7272
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7271
7273
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7272
7274
  }
7273
7275
  else if (currentDistance < 0) {
@@ -7283,16 +7285,16 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7283
7285
  }
7284
7286
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7285
7287
  }
7288
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7286
7289
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7287
7290
  }
7291
+ else {
7292
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7293
+ }
7288
7294
  }
7289
7295
  else if (signal.position === "short") {
7290
7296
  // For short: calculate progress towards TP or SL
7291
7297
  const currentDistance = effectivePriceOpen - averagePrice;
7292
- if (currentDistance > 0) {
7293
- // Check if breakeven should be triggered
7294
- await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7295
- }
7296
7298
  if (currentDistance > 0) {
7297
7299
  // Moving towards TP (use trailing TP if set)
7298
7300
  const effectiveTakeProfit = signal._trailingPriceTakeProfit ?? signal.priceTakeProfit;
@@ -7306,9 +7308,11 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7306
7308
  }
7307
7309
  await self.params.onHighestProfit(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7308
7310
  }
7311
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7312
+ await CALL_BREAKEVEN_CHECK_FN(self, self.params.execution.context.symbol, signal, averagePrice, currentCandleTimestamp, self.params.execution.context.backtest);
7309
7313
  await CALL_PARTIAL_PROFIT_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7310
7314
  }
7311
- if (currentDistance < 0) {
7315
+ else if (currentDistance < 0) {
7312
7316
  // Moving towards SL (use trailing SL if set)
7313
7317
  const effectiveStopLoss = signal._trailingPriceStopLoss ?? signal.priceStopLoss;
7314
7318
  const slDistance = effectiveStopLoss - effectivePriceOpen;
@@ -7321,8 +7325,12 @@ const PROCESS_PENDING_SIGNAL_CANDLES_FN = async (self, signal, candles, frameEnd
7321
7325
  }
7322
7326
  await self.params.onMaxDrawdown(TO_PUBLIC_SIGNAL("pending", signal, averagePrice), averagePrice, currentCandleTimestamp);
7323
7327
  }
7328
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7324
7329
  await CALL_PARTIAL_LOSS_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, averagePrice, Math.min(progressPercent, 100), currentCandleTimestamp, self.params.execution.context.backtest);
7325
7330
  }
7331
+ else {
7332
+ await CALL_ACTIVE_PING_CALLBACKS_FN(self, self.params.execution.context.symbol, signal, currentCandleTimestamp, true, averagePrice);
7333
+ }
7326
7334
  }
7327
7335
  }
7328
7336
  // Process queued commit events with candle timestamp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",