Find where your alpha breaks.
Lacuna audits a signal or a backtest for leakage, overfitting, weak statistics and unrealistic costs. What the evidence cannot establish is reported as unknown, never as a pass.
Best of 200 simulated backtests
None of them has an edge
Deflated Sharpe
Probability 0.51
Reads the frames your research already produces.
- Polars
- pandas
- NumPy
- Apache Arrow
- any backtester
One call runs every check, and tells you which ones it could not run.
An audit scores the evidence a study actually supplied. Turn on the two pieces this one left out and watch the gaps close.
import lacuna as lc study = lc.SignalStudy( signal=signal, prices=prices, horizons=("5D", "10D", "20D"), signal_observed_at="close", entry="next_close", price_adjustment="total_return_adjusted",) report = study.audit( bootstrap_resamples=2_000, seed=42,)Evidence this study left out
Robustness score
72/ 100
- Evidence coverage
- 78%
- Findings
- 7pass1warn0fail4unknown1n/a
- Earned
- Half credit
- No evidence
- Excluded
The IC time series contains a defined aggregate correlation.
- code
- IC_DEFINED
- category
- Statistical validity
- severity
- high
- weight
- 12 of 100, rule v2
- mean_ic
- 0.0226
- inference_horizon
- 5D
IC is supported by at least 60 defined periods.
- code
- IC_PERIOD_SUPPORT
- category
- Statistical validity
- severity
- high
- weight
- 12 of 100, rule v2
- n_periods
- 751
- warn_threshold
- 20
- pass_threshold
- 60
- inference_horizon
- 5D
The bootstrap confidence interval includes zero.
−0.0100.010.020.030.04- code
- BOOTSTRAP_INTERVAL
- category
- Statistical validity
- severity
- high
- weight
- 12 of 100, rule v2
- observed
- 0.0156
- confidence_lower
- −0.0016
- confidence_upper
- 0.0314
- n_resampled
- 151
- minimum_sample
- 30
- inference_horizon
- 5D
- sampling
- non_overlapping_label_intervals
Average quantile returns are strongly ordered with signal rank.
−15.2
Q1
−5.0
Q2
1.1
Q3
12.4
Q4
4.4
Q5
- code
- QUANTILE_MONOTONICITY
- category
- Statistical validity
- severity
- medium
- weight
- 10 of 100, rule v1
- spearman_monotonicity
- 0.9000
- warn_threshold
- 0.4000
- pass_threshold
- 0.7000
Signal decay is evaluated across at least three horizons with defined IC.
- code
- HORIZON_DECAY_COVERAGE
- category
- Robustness
- severity
- medium
- weight
- 10 of 100, rule v2
- n_horizons
- 3
- n_defined_horizons
- 3
- undefined_horizons
- none
Forward labels include explicit sample, entry, and exit timing.
- code
- LABEL_INTERVALS_PRESENT
- category
- Temporal integrity
- severity
- critical
- weight
- 10 of 100, rule v1
- n_labels
- 178,640
required 'split' analysis evidence was not supplied
- code
- PURGED_VALIDATION_SUPPLIED
- category
- Temporal integrity
- severity
- high
- weight
- 10 of 100, rule v1
historical-universe or survivorship evidence was not supplied
- code
- SURVIVORSHIP_HANDLING_DECLARED
- category
- Temporal integrity
- severity
- high
- weight
- 2 of 100, rule v1
Price adjustment semantics are explicitly declared.
- code
- PRICE_ADJUSTMENT_DECLARED
- category
- Data integrity
- severity
- high
- weight
- 8 of 100, rule v1
- price_adjustment
- total_return_adjusted
Delisting-return handling was not supplied.
- code
- DELISTING_HANDLING_DECLARED
- category
- Data integrity
- severity
- high
- weight
- 8 of 100, rule v1
Rank turnover is measured and available for execution review.
- code
- TURNOVER_MEASURED
- category
- Costs and capacity
- severity
- medium
- weight
- 4 of 100, rule v1
- mean_rank_turnover
- 0.1019
the check requires trades or a portfolio simulation, not a signal-only study
- code
- TRANSACTION_COST_EVIDENCE
- category
- Costs and capacity
- severity
- high
- weight
- 4 of 100, rule v1
experiment trial history was not supplied
- code
- TRIAL_HISTORY_AVAILABLE
- category
- Experiment integrity
- severity
- high
- weight
- 2 of 100, rule v1
Overlapping labels make a weak signal look certain.
A five-session return, measured daily, shares four sessions with its neighbour. Resample those periods as if they were independent and the interval tightens around nothing.
Bootstrap of the mean 5-session IC
Label intervals, first 30 sessions
Kept labels are disjoint, so each return is counted once.
2,000 resampled means and their 95% interval
Mean IC
- Periods resampled
- 151
- Mean IC
- 0.0156
- 95% interval
- −0.0016 to 0.0314
- Zero
- Inside the interval
- The audit rule would read
- WARNThe same signal with each return counted once. Lacuna reports this one.
Purging removes what the test fold can see.
Drag the fold. A training label is purged when its interval overlaps a test label, and the sessions after the fold are embargoed. Intervals are half-open, [start, end), so boundaries never double-count.
One test fold over 60 sessions of five-session labels
- Train
- 36
- Test
- 12
- Purged
- 8
- Embargoed
- 4
Test [24, 36). Purged [20, 24) and [36, 40), embargoed [40, 44).
Six ways research goes wrong, and what Lacuna measures for each.
Every method returns the same structured result: metrics, tables, findings and provenance. Optional families install as extras, so the core depends only on NumPy and Polars.
- Weak signals
- Group-aware IC, flexible buckets, neutralization, decay, multi-lag turnover and diagnostic portfolio projections.
- lacuna.signal
- Leakage and bad timing
- Availability-safe joins, explicit label boundaries, purged and combinatorial splits, revisions, membership history and future-data checks.
- lacuna.biaslacuna.cvlacuna.labels
- Overfitting
- Bootstrap and permutation inference, PBO with CSCV, probabilistic and deflated Sharpe, Reality Check, SPA and multiple-testing correction.
- lacuna.validation
- Fragile conclusions
- Parameter surfaces, perturbations, subperiods, regimes, universe transitions and append-only trial history.
- lacuna.robustnesslacuna.regimelacuna.experiment
- Unrealistic trading assumptions
- Commission, spread, slippage, impact and borrow models, cost stress, break-even solving, liquidity and capacity curves.
- lacuna.costs
- Unreproducible research
- Immutable results, standardized audits, deterministic JSON and HTML, and verifiable archives.
- lacuna.auditlacuna.bundle
An audit you can hand to someone else.
report.bundle() writes a deterministic archive of the evidence, configuration and environment behind every number. Anyone can verify it without running your code.
Terminal
$ lacuna bundle verify study.lacuna
- Bundle
- study.lacuna
- Format
- lacuna.reproducibility-bundle v1
- Artifacts
- 11
- Total bytes
- 3688576
- SHA-256
- 3ebc81e10f425f7b89dbf354155cd1ed177df10da3b1e7fc5981db0642a9d9a43ebc81e10f42…42a9d9a4
- Integrity
- verified
- Authenticity
- not verified (use signed release/provenance channels separately)
study.lacuna11 artifacts
evidence/
- bootstrap.json2.0 kBd5c63f7e907d
- decay.json553.3 kB86407623d5d8
- ic.json215.1 kB4dabda80ce3f
- labels.json2.3 kB2a7c5a2540d2
- quantiles.json2.1 MBf91fe739e4f8
- turnover.json811.8 kBc30b19ddc3b5
metadata/
- configuration.json90 B07d47efcfbc1
- environment.json239 Bf2640789c543
report/
- audit.html8.5 kB1f40a0de1fcf
- audit.json5.9 kBa4c8881e85ad
- audit.md5.2 kB6e5ea55187d6
Rust where it measured faster. Python everywhere else.
Sixteen hot paths were benchmarked for a native rewrite in v0.14. Two cleared the gate. The rest got faster without Rust or stayed as they were, and each decision is recorded with its measurements.
- Rust kernel
- Python, Polars or NumPy
| Operation | Compared with | Before | After | Speed-up | Runs in | Before | After |
|---|---|---|---|---|---|---|---|
| Event response | v0.13 | 746.68 ms | 18.60 ms | 40.1× | Python | 746.68 ms | 18.60 ms |
| Portfolio projection | v0.13 | 880.93 ms | 37.64 ms | 23.4× | Polars | 880.93 ms | 37.64 ms |
| Grouped rank IC | optimized NumPy | 11.935 s | 2.076 s | 5.75× | Rust | 11.935 s | 2.076 s |
| PBO with CSCV | optimized NumPy | 405.55 ms | 85.71 ms | 4.73× | Rust | 405.55 ms | 85.71 ms |
| Prior-only regime quantiles | v0.13 | 5.28 s | 1.74 s | 3.04× | Polars | 5.28 s | 1.74 s |
| Event windows | v0.13 | 182.93 ms | 61.94 ms | 2.95× | Polars | 182.93 ms | 61.94 ms |
| Permutation reduction | v0.13 | 83.83 ms | 31.14 ms | 2.69× | NumPy | 83.83 ms | 31.14 ms |
| Purged and CPCV assembly | v0.13 | 420.52 ms | 184.60 ms | 2.28× | NumPy | 420.52 ms | 184.60 ms |
| A Rust kernel reached 159.42 ms, 1.16× faster than this. The gate is 1.5×, so it was removed. | |||||||
Bring a signal.
Leave with evidence.
Lacuna is MIT licensed and pre-1.0. It needs Python 3.11 or newer; wheels ship for Linux, macOS on Apple silicon and Windows.