Skip to main content

sharpebench (Python)

Is my Sharpe real, or an artifact of luck and multiple testing?

Python distribution of SharpeBench's honest-backtest statistics, a pyo3 binding over the same deterministic Rust kernel the SharpeBench CLI and the @general-liquidity/sharpebench npm package use. Bring your own return series; everything takes plain numeric sequences (lists, tuples, numpy arrays, df["ret"].to_numpy()) and returns plain floats, lists and dicts.

import numpy as np
from sharpebench import is_my_sharpe_real, bootstrap_dsr_ci

returns = df["strategy_ret"].to_numpy()          # per-period, NOT annualized

# n_trials is the honest one: how many variants did you try before keeping this?
v = is_my_sharpe_real(returns, n_trials=200)
print(v["sharpe"], v["deflated_sharpe"], v["verdict"], v["explanation"])

ci = bootstrap_dsr_ci(returns, n_trials=200)
print(ci["lower"], ci["point"], ci["upper"])

Surface

Function Answers
sharpe_ratio(returns) observed per-period Sharpe
moments(returns, target=0.0) mean / std / skew / kurtosis / downside deviation / Sortino
probabilistic_sharpe_ratio(returns, sr_benchmark=0.0) P(true Sharpe > benchmark) (PSR)
deflated_sharpe_ratio(returns, n_trials, trials_sr_std=0.5) PSR deflated for the size of the search (DSR)
expected_max_sharpe(trials_sr_std, n_trials) the Sharpe the best of n_trials shows with zero skill
min_track_record_length(returns, ...) periods needed before the Sharpe is believable
bootstrap_dsr_ci(returns, n_trials, ...) {point, se, lower, upper} on the DSR itself
bootstrap_pvalue(excess, ...) stationary-bootstrap p-value for one series
is_my_sharpe_real(returns, n_trials=1, ...) LITE verdict dict: pass | borderline | fail + explanation
is_my_sharpe_real_full(field, ...) FULL verdict over a whole candidate field (LITE + snooping family + PBO + HLZ)
reality_check_pvalue(field, ...) White's Reality Check over the field
spa_pvalue / spa_consistent_pvalue(field, ...) Hansen's SPA (liberal / consistent)
step_down_significant(field, ..., alpha=0.05) Romano-Wolf step-down, per candidate, FWER-controlled
probability_of_backtest_overfitting(perf_matrix, s=16) CSCV PBO
benjamini_hochberg(p_values, q=0.05) / fdr_verdict(...) BH-FDR rejections and the operator summary
hlz_gate(t_stat, t_threshold=None) the Harvey-Liu-Zhu |t| >= 3.0 factor bar
selection_robustness(candidates, n_trials, ...) best vs median DSR: is the headline a lucky pick?
runs_for_power(effect, alpha, power) how many runs to detect an effect
pass_k(passed_per_run, mode="all", n=None) pass^k reliability: won on every run, not on average
budget_curve(...) DSR by search budget, marginal DSR, and overfit-onset diagnostics
rank_board(submissions, config_json="") / score_one(...) Full composite scoring over the CLI-compatible JSON contract
rank_returns(field, config_json="") Build and rank a board from agent IDs and per-run return arrays
default_score_config() Serialize the default scoring configuration
never_catastrophic_config() Serialize the preset that asks only whether every run avoids catastrophe
relative_to_benchmark_config(id) Serialize the benchmark-relative pass preset

Matrix orientation

Two conventions, deliberately unchanged from the papers they come from:

  • the data-snooping family (reality_check_pvalue, spa_*, step_down_significant, is_my_sharpe_real_full) takes a field: N rows (strategies) x T cols (time);
  • probability_of_backtest_overfitting takes the transpose: T rows (time) x N cols (strategies).

Determinism

No I/O, no clock, no ambient randomness. The bootstraps take an explicit seed (defaulted to a fixed constant, so a result is reproducible unless you ask for otherwise). The Python suite matches the public example board to the committed Rust golden on Ubuntu CI. Rust CI separately checks two committed golden fields on Linux, macOS, and Windows; neither check covers every possible input or host.

Relationship to sharpearena

sharpearena is the environment: a point-in-time market API where a trading agent produces a track, scored end-to-end by its score_run helper. It does not provide process containment. sharpebench is the judge for a track you already have: your own backtest, live P&L, or a field of candidate strategies. They share one Rust statistics kernel, so the verdict is identical either way; this package simply does not, and will not, duplicate arena run-scoring.

Building from source

python -m pip install maturin
python -m maturin develop --manifest-path crates/sharpebench-py/Cargo.toml
python -m pytest crates/sharpebench-py/tests

MIT OR Apache-2.0.

Metadata

Release files for sharpebench 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharpebench 0.17.0
File Size Uploaded
sharpebench-0.17.0.tar.gz 248.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sharpebench 0.17.0
File
sharpebench-0.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
sharpebench-0.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
sharpebench-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
sharpebench-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details

Total release size: 2.4 MB

Release files / sharpebench-0.17.0.tar.gz

Download URL sharpebench-0.17.0.tar.gz
Size 248.9 kB
Tags Source
SHA-256 checksum
How to use checksums
570aebec761fb86d099edb46b67a1cb1db4c23f01e75ab54b95143625ed2b334
BLAKE2b-256 checksum
How to use checksums
7e504114c5579386a3be3413d4e6bb10ca7531fa6592b16e27382bfd82a64748
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / sharpebench-0.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpebench-0.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 546.6 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
00e63970811084c11874c693d7a869147264701254613bbb1661be2bf1194aa4
BLAKE2b-256 checksum
How to use checksums
66ab8cb270d1b97caf1d975fb69a187e4c409fc8af45c8d42f53f035804f6b0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / sharpebench-0.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpebench-0.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 547.4 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e0dbc539e3efba5be9243bec4acd668bcbe4ed652c60f72e6193ed3c4c5aadbd
BLAKE2b-256 checksum
How to use checksums
b55d7012ea82b54ad1011b9fd10f5df80cea1f90b1563aaf484d0104345a8da5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / sharpebench-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpebench-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 551.0 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
707fc386e1baf6ef6c6f54aa9ff89ccebfc84aaa0b183775b3e91b841f973e5f
BLAKE2b-256 checksum
How to use checksums
2381cebfb1dfdf72c6b52798dfad2efc432afa3a040cfb49ac3c1d8297c3d6d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / sharpebench-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpebench-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 551.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
04861fd8f4b55a0c96443847c6d8350f0cd2d8b4d0b070749557b7d8571092d9
BLAKE2b-256 checksum
How to use checksums
6bc4775b2dd01fb701c024ec4617b9d06dbdc2d9b2eaadf0ee7dbaf32e52395c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page