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.

Read the docs

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.

study.py
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

Signal auditaudit.v0_1

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.

    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.

    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
Output of lacuna-quant 0.14.1 on a seeded synthetic panel of 80 instruments over 756 sessions, with 2,000 bootstrap resamples and seed 42. The switches swap in the audit that was run with that evidence supplied; nothing is recalculated in the page.

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

051015202530

Kept labels are disjoint, so each return is counted once.

2,000 resampled means and their 95% interval

−0.0100.010.020.030.040.05

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.
Both intervals are lacuna.validation.bootstrap with the percentile method on the audited panel, seed 42: once over every daily IC (n = 751), once over the periods the audit keeps (n = 151). Lacuna 0.14.1 made the second one the default.

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

Embargo
Test fold
01224364860
Train
36
Test
12
Purged
8
Embargoed
4

Test [24, 36). Purged [20, 24) and [36, 40), embargoed [40, 44).

Each bar is one label, drawn from the session it is observed to the session it stops earning. The roles are computed in the page and tested against lacuna.cv.PurgedKFold for every fold and embargo shown. Arrow keys move the fold one session.

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
The archive of the audit above, verified with the command shown. Integrity is a SHA-256 check of every member. Size bars are on a log scale. Authenticity is reported as not verified because a hash cannot establish who made the file.

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
OperationCompared withBeforeAfterSpeed-upRuns inBeforeAfter
Event responsev0.13746.68 ms18.60 ms40.1×Python746.68 ms18.60 ms
Portfolio projectionv0.13880.93 ms37.64 ms23.4×Polars880.93 ms37.64 ms
Grouped rank ICoptimized NumPy11.935 s2.076 s5.75×Rust11.935 s2.076 s
PBO with CSCVoptimized NumPy405.55 ms85.71 ms4.73×Rust405.55 ms85.71 ms
Prior-only regime quantilesv0.135.28 s1.74 s3.04×Polars5.28 s1.74 s
Event windowsv0.13182.93 ms61.94 ms2.95×Polars182.93 ms61.94 ms
Permutation reductionv0.1383.83 ms31.14 ms2.69×NumPy83.83 ms31.14 ms
Purged and CPCV assemblyv0.13420.52 ms184.60 ms2.28×NumPy420.52 ms184.60 ms
A Rust kernel reached 159.42 ms, 1.16× faster than this. The gate is 1.5×, so it was removed.
Eight of the sixteen candidates, from the v0.14 native decision ledger. Bars are on a log scale. Native rows are measured against an already optimized NumPy reference on a pinned runner; the rest against the v0.13 implementation. Native execution is single-threaded.

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.

View on GitHub