backtest-kit 8.1.0 → 8.1.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/build/index.cjs +13 -17
- package/build/index.mjs +13 -17
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -21926,10 +21926,10 @@ let ReportStorage$a = class ReportStorage {
|
|
|
21926
21926
|
const fallVariance = fallReturns.reduce((sum, r) => sum + Math.pow(r, 2), 0) / totalSignals;
|
|
21927
21927
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
21928
21928
|
const sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
21929
|
-
//
|
|
21930
|
-
const
|
|
21931
|
-
const calmarRatio =
|
|
21932
|
-
const recoveryFactor =
|
|
21929
|
+
// Max absolute drawdown across all signals — used as denominator for Calmar and Recovery
|
|
21930
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
21931
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
21932
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
21933
21933
|
return {
|
|
21934
21934
|
signalList: this._signalList,
|
|
21935
21935
|
totalSignals,
|
|
@@ -22658,12 +22658,10 @@ let ReportStorage$9 = class ReportStorage {
|
|
|
22658
22658
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
22659
22659
|
sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
22660
22660
|
}
|
|
22661
|
-
//
|
|
22662
|
-
const
|
|
22663
|
-
|
|
22664
|
-
|
|
22665
|
-
const calmarRatio = avgAbsFall > 0 ? expectedYearlyReturns / avgAbsFall : 0;
|
|
22666
|
-
const recoveryFactor = avgAbsFall > 0 ? totalPnl / avgAbsFall : 0;
|
|
22661
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
22662
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
22663
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
22664
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
22667
22665
|
return {
|
|
22668
22666
|
eventList: this._eventList,
|
|
22669
22667
|
totalEvents: this._eventList.length,
|
|
@@ -24657,15 +24655,13 @@ class HeatmapStorage {
|
|
|
24657
24655
|
sortinoRatio = avgPnl / fallDeviation;
|
|
24658
24656
|
}
|
|
24659
24657
|
}
|
|
24660
|
-
//
|
|
24661
|
-
const
|
|
24662
|
-
? fallReturns.reduce((acc, r) => acc + Math.abs(r), 0) / signals.length
|
|
24663
|
-
: 0;
|
|
24658
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
24659
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
24664
24660
|
let calmarRatio = null;
|
|
24665
24661
|
let recoveryFactor = null;
|
|
24666
|
-
if (
|
|
24667
|
-
calmarRatio = totalPnl /
|
|
24668
|
-
recoveryFactor = totalPnl /
|
|
24662
|
+
if (maxAbsFall > 0 && totalPnl !== null) {
|
|
24663
|
+
calmarRatio = totalPnl / maxAbsFall;
|
|
24664
|
+
recoveryFactor = totalPnl / maxAbsFall;
|
|
24669
24665
|
}
|
|
24670
24666
|
// Apply safe math checks
|
|
24671
24667
|
if (isUnsafe(winRate))
|
package/build/index.mjs
CHANGED
|
@@ -21906,10 +21906,10 @@ let ReportStorage$a = class ReportStorage {
|
|
|
21906
21906
|
const fallVariance = fallReturns.reduce((sum, r) => sum + Math.pow(r, 2), 0) / totalSignals;
|
|
21907
21907
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
21908
21908
|
const sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
21909
|
-
//
|
|
21910
|
-
const
|
|
21911
|
-
const calmarRatio =
|
|
21912
|
-
const recoveryFactor =
|
|
21909
|
+
// Max absolute drawdown across all signals — used as denominator for Calmar and Recovery
|
|
21910
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
21911
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
21912
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
21913
21913
|
return {
|
|
21914
21914
|
signalList: this._signalList,
|
|
21915
21915
|
totalSignals,
|
|
@@ -22638,12 +22638,10 @@ let ReportStorage$9 = class ReportStorage {
|
|
|
22638
22638
|
const fallDeviation = Math.sqrt(fallVariance);
|
|
22639
22639
|
sortinoRatio = fallDeviation > 0 ? avgPnl / fallDeviation : 0;
|
|
22640
22640
|
}
|
|
22641
|
-
//
|
|
22642
|
-
const
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
const calmarRatio = avgAbsFall > 0 ? expectedYearlyReturns / avgAbsFall : 0;
|
|
22646
|
-
const recoveryFactor = avgAbsFall > 0 ? totalPnl / avgAbsFall : 0;
|
|
22641
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
22642
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
22643
|
+
const calmarRatio = maxAbsFall > 0 ? expectedYearlyReturns / maxAbsFall : 0;
|
|
22644
|
+
const recoveryFactor = maxAbsFall > 0 ? totalPnl / maxAbsFall : 0;
|
|
22647
22645
|
return {
|
|
22648
22646
|
eventList: this._eventList,
|
|
22649
22647
|
totalEvents: this._eventList.length,
|
|
@@ -24637,15 +24635,13 @@ class HeatmapStorage {
|
|
|
24637
24635
|
sortinoRatio = avgPnl / fallDeviation;
|
|
24638
24636
|
}
|
|
24639
24637
|
}
|
|
24640
|
-
//
|
|
24641
|
-
const
|
|
24642
|
-
? fallReturns.reduce((acc, r) => acc + Math.abs(r), 0) / signals.length
|
|
24643
|
-
: 0;
|
|
24638
|
+
// Max absolute drawdown across all signals — denominator for Calmar and Recovery
|
|
24639
|
+
const maxAbsFall = fallReturns.reduce((max, r) => Math.max(max, Math.abs(r)), 0);
|
|
24644
24640
|
let calmarRatio = null;
|
|
24645
24641
|
let recoveryFactor = null;
|
|
24646
|
-
if (
|
|
24647
|
-
calmarRatio = totalPnl /
|
|
24648
|
-
recoveryFactor = totalPnl /
|
|
24642
|
+
if (maxAbsFall > 0 && totalPnl !== null) {
|
|
24643
|
+
calmarRatio = totalPnl / maxAbsFall;
|
|
24644
|
+
recoveryFactor = totalPnl / maxAbsFall;
|
|
24649
24645
|
}
|
|
24650
24646
|
// Apply safe math checks
|
|
24651
24647
|
if (isUnsafe(winRate))
|