backtest-kit 11.5.0 → 11.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backtest-kit",
3
- "version": "11.5.0",
3
+ "version": "11.6.0",
4
4
  "description": "A TypeScript library for trading system backtest",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -4636,6 +4636,18 @@ interface BacktestStatisticsModel {
4636
4636
  recoveryFactor: number | null;
4637
4637
  /** Per-trade Expectancy (winProb*avgWin + lossProb*avgLoss), null if unsafe. Higher is better. */
4638
4638
  expectancy: number | null;
4639
+ /** Average trade duration in minutes ((closeTimestamp - pendingAt) / 60_000), null if unsafe. */
4640
+ avgDuration: number | null;
4641
+ /** Median pnlPercentage — robust to outliers; reveals distribution skew when paired with avgPnl. */
4642
+ medianPnl: number | null;
4643
+ /** Average sum of pnlPercentage across consecutive winning streaks. Null if no win streak. */
4644
+ avgConsecutiveWinPnl: number | null;
4645
+ /** Average sum of pnlPercentage across consecutive losing streaks. Null if no loss streak. Closer to 0 is better. */
4646
+ avgConsecutiveLossPnl: number | null;
4647
+ /** Average duration in minutes of winning trades. */
4648
+ avgWinDuration: number | null;
4649
+ /** Average duration in minutes of losing trades. */
4650
+ avgLossDuration: number | null;
4639
4651
  }
4640
4652
 
4641
4653
  /**
@@ -10727,12 +10739,36 @@ interface IHeatmapRow {
10727
10739
  avgPeakPnl: number | null;
10728
10740
  /** Average fall PNL percentage across all trades (_fall.pnlPercentage). Closer to 0 is better. */
10729
10741
  avgFallPnl: number | null;
10742
+ /** Maximum peak PNL percentage observed across all trades (best best-case). Higher is better. */
10743
+ peakProfitPnl: number | null;
10744
+ /** Minimum fall PNL percentage observed across all trades (worst worst-case). Closer to 0 is better. */
10745
+ maxDrawdownPnl: number | null;
10746
+ /** Average trade duration in minutes ((closeTimestamp - pendingAt) / 60_000). */
10747
+ avgDuration: number | null;
10748
+ /** Median pnlPercentage — robust to outliers; reveals distribution skew when paired with avgPnl. */
10749
+ medianPnl: number | null;
10750
+ /** Average sum of pnlPercentage across consecutive winning streaks. Null if no win streak. */
10751
+ avgConsecutiveWinPnl: number | null;
10752
+ /** Average sum of pnlPercentage across consecutive losing streaks. Null if no loss streak. Closer to 0 is better. */
10753
+ avgConsecutiveLossPnl: number | null;
10754
+ /** Average duration in minutes of winning trades. */
10755
+ avgWinDuration: number | null;
10756
+ /** Average duration in minutes of losing trades. */
10757
+ avgLossDuration: number | null;
10730
10758
  /** Sortino Ratio (avgPnl / downside deviation — RMS of losing trades only). Higher is better. */
10731
10759
  sortinoRatio: number | null;
10732
10760
  /** Calmar Ratio (totalPnl / maxDrawdown). Higher is better. */
10733
10761
  calmarRatio: number | null;
10734
10762
  /** Recovery Factor (totalPnl / maxDrawdown). Higher is better. */
10735
10763
  recoveryFactor: number | null;
10764
+ /** Annualized Sharpe Ratio (sharpeRatio × √tradesPerYear). Higher is better. */
10765
+ annualizedSharpeRatio: number | null;
10766
+ /** Certainty Ratio (avgWin / |avgLoss|). Higher is better. */
10767
+ certaintyRatio: number | null;
10768
+ /** Expected yearly returns (geometric, capped at ±MAX_EXPECTED_YEARLY_RETURNS). Higher is better. */
10769
+ expectedYearlyReturns: number | null;
10770
+ /** Observed trade frequency extrapolated to one year (signals × 365 / calendarSpanDays). */
10771
+ tradesPerYear: number | null;
10736
10772
  }
10737
10773
 
10738
10774
  /**
@@ -12613,6 +12649,18 @@ interface LiveStatisticsModel {
12613
12649
  recoveryFactor: number | null;
12614
12650
  /** Per-trade Expectancy (winProb*avgWin + lossProb*avgLoss), null if unsafe. Higher is better. */
12615
12651
  expectancy: number | null;
12652
+ /** Average trade duration in minutes ((timestamp - pendingAt) / 60_000), null if unsafe. */
12653
+ avgDuration: number | null;
12654
+ /** Median pnl — robust to outliers; reveals distribution skew when paired with avgPnl. */
12655
+ medianPnl: number | null;
12656
+ /** Average sum of pnl across consecutive winning streaks. Null if no win streak. */
12657
+ avgConsecutiveWinPnl: number | null;
12658
+ /** Average sum of pnl across consecutive losing streaks. Null if no loss streak. Closer to 0 is better. */
12659
+ avgConsecutiveLossPnl: number | null;
12660
+ /** Average duration in minutes of winning trades. */
12661
+ avgWinDuration: number | null;
12662
+ /** Average duration in minutes of losing trades. */
12663
+ avgLossDuration: number | null;
12616
12664
  }
12617
12665
 
12618
12666
  /**
@@ -12634,6 +12682,22 @@ interface HeatmapStatisticsModel {
12634
12682
  portfolioAvgPeakPnl: number | null;
12635
12683
  /** Trade-count-weighted average fall PNL across all symbols. Closer to 0 is better. */
12636
12684
  portfolioAvgFallPnl: number | null;
12685
+ /** Maximum peak PNL across all trades of all symbols (best best-case). Higher is better. */
12686
+ portfolioPeakProfitPnl: number | null;
12687
+ /** Minimum fall PNL across all trades of all symbols (worst worst-case). Closer to 0 is better. */
12688
+ portfolioMaxDrawdownPnl: number | null;
12689
+ /** Pooled average trade duration in minutes across all trades of all symbols. */
12690
+ portfolioAvgDuration: number | null;
12691
+ /** Pooled median pnlPercentage across all trades of all symbols. */
12692
+ portfolioMedianPnl: number | null;
12693
+ /** Trade-count-weighted mean of per-symbol avgConsecutiveWinPnl. Null if no symbol has a win streak. */
12694
+ portfolioAvgConsecutiveWinPnl: number | null;
12695
+ /** Trade-count-weighted mean of per-symbol avgConsecutiveLossPnl. Null if no symbol has a loss streak. */
12696
+ portfolioAvgConsecutiveLossPnl: number | null;
12697
+ /** Pooled average duration in minutes of winning trades. */
12698
+ portfolioAvgWinDuration: number | null;
12699
+ /** Pooled average duration in minutes of losing trades. */
12700
+ portfolioAvgLossDuration: number | null;
12637
12701
  /** Pooled sample standard deviation of returns across all symbols. */
12638
12702
  portfolioStdDev: number | null;
12639
12703
  /** Pooled Sortino Ratio over all trades. Same canonical formula as per-symbol. */
@@ -12644,6 +12708,14 @@ interface HeatmapStatisticsModel {
12644
12708
  portfolioRecoveryFactor: number | null;
12645
12709
  /** Pooled Expectancy: winProb*avgWin + lossProb*avgLoss (per-trade expected %). */
12646
12710
  portfolioExpectancy: number | null;
12711
+ /** Pooled Annualized Sharpe Ratio (portfolioSharpeRatio × √portfolioTradesPerYear). Higher is better. */
12712
+ portfolioAnnualizedSharpeRatio: number | null;
12713
+ /** Pooled Certainty Ratio (pooledAvgWin / |pooledAvgLoss|). Higher is better. */
12714
+ portfolioCertaintyRatio: number | null;
12715
+ /** Pooled expected yearly returns (geometric annualization of pooled equity, capped at ±MAX_EXPECTED_YEARLY_RETURNS). */
12716
+ portfolioExpectedYearlyReturns: number | null;
12717
+ /** Pooled observed trade frequency extrapolated to one year. */
12718
+ portfolioTradesPerYear: number | null;
12647
12719
  }
12648
12720
 
12649
12721
  /**