Metadata-Version: 2.4
Name: quantproof
Version: 0.1.3
Summary: Proof-test your trading strategy before you trust it with money: deflated Sharpe, luck curves, and a canary harness that catches backtesters that lie.
Author: Quantproof
License: MIT License
        
        Copyright (c) 2026 Quantproof
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Quantproof Pro (paid tier), https://quantproof.gumroad.com/l/quantproof-pro
Project-URL: All Quantproof tools, https://quantproof.gumroad.com
Keywords: backtesting,overfitting,deflated sharpe,quant,trading,validation
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22
Dynamic: license-file

# Quantproof

**Proof-test your strategy before you trust it with money.**

Every backtest produces a number. Two questions decide whether that
number means anything:

1. **Is it luck?** Test enough strategies and one of them will look
   good by pure chance. Run 200 random strategies over ten years of
   daily data and the best one will show a Sharpe near 0.9, with no
   edge anywhere in the pile. So if your winner came out of a long
   search, it has to beat that bar, not zero.
2. **Can you trust your backtester?** A sign error in the cost model,
   or data misaligned by one day, will quietly inflate every result it
   prints. Bugs like that don't crash. They just make bad numbers look
   good.

Quantproof is three small instruments that answer both.

## The instruments

### `quantproof.canary`: test the tester

Feed your own pipeline three things whose true value is known by
construction, and grade the report card:

- a **crystal ball** that knows tomorrow's return. It must report an
  absurd Sharpe. If it doesn't, your pipeline is destroying signal and
  cannot see your edge either.
- a **dead strategy** that never trades. It must report roughly zero.
  Anything else means your pipeline manufactures performance from
  nothing.
- a **coin-flip mine**: N random strategies on signal-free synthetic
  prices. The best will look good. The harness shows it against the
  luck curve so you see what selection alone buys on your equipment.

```python
from quantproof import run_canary

def my_pipeline(prices, positions):
    # wrap your backtester: return the annualized Sharpe it reports
    ...

print(run_canary(my_pipeline).summary())
```

### `quantproof.deflate`: what is your Sharpe worth after honesty?

Probabilistic and Deflated Sharpe Ratios (Bailey & López de Prado).
PSR prices track length and fat tails; DSR additionally charges you
for every configuration you looked at before keeping this one.

```python
from quantproof import deflated_sharpe

verdict = deflated_sharpe(daily_returns, n_trials=140)
print(verdict["deflated_sharpe_probability"], verdict["passes_95"])
```

### `quantproof.luck`: the price of persistence

The luck curve: the expected best Sharpe from N skill-less trials.
And `trials_to_explain(your_sharpe, n_obs)`: how many coin flips it
would take for luck alone to match a track record.

## What you need to bring

The suite degrades gracefully down a ladder of what you actually have:

| You have | What works |
|---|---|
| Nothing but a backtester | The canary. It generates its own synthetic data; you bring only your pipeline. |
| One return series + an honest count of what you tried | The deflated Sharpe and the luck margin: the core verdict. |
| Just a claimed Sharpe, a track length, and a trial count (say, a vendor's ad) | The luck curve and `trials_to_explain`: enough to price whether the claim is even interesting. |
| Every trial kept | The full picture, including overfitting analysis (PBO, in the paid tier). |

Two honest notes. Short tracks widen every error bar, and the tools say
so: below 60 observations `deflated_sharpe` reports
`sufficient_evidence: False` and refuses to pass the track, because
"not enough data yet" is a real answer. And the more trial records you
keep, the more the suite can do: keep every trial, not just the winner.

## What Quantproof does NOT do

Honesty about the tools themselves:

- The canary validates your **pipeline**, not your **data**. Splits,
  survivorship, and stale quotes pass through it untouched.
- DSR assumes you report `n_trials` honestly, meaning every variant
  you *looked at*, not just the ones you kept. Undercounting buys
  false comfort.
- The default deflation hurdle uses the independent zero-skill special
  case (sigma = sqrt(1/T)). If the Sharpe dispersion across your real
  trials is wider, that default understates the hurdle; pass
  `trial_sr_std` measured from your trials whenever you have them.
- The math assumes returns stationary enough for sample moments to
  mean something; below 60 observations the verdict is withheld as
  insufficient evidence rather than reported.
- A passing grade means "not provably broken in these ways". That is
  necessary, never sufficient. Nothing here predicts returns, and
  nothing here is investment advice.

## Install

```
pip install quantproof
```

Depends on numpy only. Python 3.9+.

## The pro tier

The free core answers: is this number luck, and would my backtester even know?
Quantproof Pro adds the two instruments serious review demands:

- PBO: the probability of backtest overfitting, computed by combinatorially
  symmetric cross-validation over your full trial matrix.
- The proof certificate: a single self-contained HTML page of your deflated
  verdict, luck curve, and limits, safe to share with anyone.

One-time license: https://quantproof.gumroad.com/l/quantproof-pro

## The Quantproof line

Part of the Quantproof line. All tools: https://quantproof.gumroad.com
Free core: https://pypi.org/project/quantproof/ (pip install quantproof)
