betting_combat.strategies.stats
stats — what every strategy’s backtest reports, López’s way (AFML; Sam 2026-11-15):
sharpe the per-card Sharpe (mean / sd of the cards' P&L) and annualised (x sqrt(cards a year))psr the probabilistic Sharpe ratio (ch. 14): the chance the true Sharpe beats ``sr_star``, given the sample's length, skew and kurtosisexpected_max_sr the Sharpe the best of ``trials`` worthless variants would show by luck (ch. 14)dsr the deflated Sharpe: ``psr`` against that luckcpcv combinatorial purged cross-validation over cards (ch. 12): every split and the backtest paths it makes (k / N x C(N, k) of them), so a strategy gets a spread of out-of-sample Sharpes, not oneprecision the hit rate a binary bet needs (ch. 15): to break even, and for a target annual SharpeFunctions
cpcv
cpcv(n_groups: int, k_test: int) -> tuple[list[tuple[int, ...]], dict[int, list[tuple[int, int]]]]The splits (each a tuple of test groups) and the paths: path j -> [(group, split index)] - each group’s j-th appearance in a test set goes to path j (AFML ch. 12). There are k / N x C(N, k) paths.
dsr
dsr(card_pnl: Sequence[float], var_sr: float, trials: int) -> floatThe deflated Sharpe ratio: psr against the luck of the best of trials.
expected_max_sr
expected_max_sr(var_sr: float, trials: int) -> floatThe expected best Sharpe among trials variants with true Sharpe 0 and this variance (AFML ch. 14).
precision
precision(price: float, fee: float, bets_a_year: float, target_sr: float = 1.0) -> tuple[float, float](break-even hit rate, the hit rate for target_sr a year) of a $1-payout contract bought at price
with fee (AFML ch. 15: asymmetric payouts; solved by bisection).
psr
psr(card_pnl: Sequence[float], sr_star: float = 0.0) -> floatP(true per-card Sharpe > sr_star) (AFML eq. 14.4; kurtosis not excess).
sharpe
sharpe(card_pnl: Sequence[float]) -> tuple[float, float](per card, annualised).