Skip to Content

Introduction

Lacuna audits a signal or a backtest for leakage, overfitting, weak statistics and unrealistic costs, and reports what the evidence cannot establish as unknown.

Lacuna is a Python library for auditing quantitative trading research: an alpha signal scored across a universe of instruments, or the returns of a backtested strategy. Give it a signal and prices, or a backtest’s results, and it tells you where the result is fragile: labels that see the future, intervals that overlap, a Sharpe ratio picked from many trials, costs that erase the edge, a universe that only holds survivors.

It does not generate signals, source data, simulate fills or route orders. It reads the artifacts your research already produces, as Polars, pandas or Arrow tables, and returns structured evidence.

import lacuna as lc

study = lc.SignalStudy(
    signal=signal,  # time, instrument, signal
    prices=prices,  # time, instrument, close
    horizons=("1D", "5D", "20D"),
    signal_observed_at="open",
    entry="current_close",
    price_adjustment="total_return_adjusted",
)
report = study.audit(seed=42)
report.write("audit.html")

The quickstart runs this workflow end to end on data it builds itself.

What you get back

Every analysis returns an AnalysisResult, or a typed result that carries one: metrics, named tables, findings, warnings and the provenance needed to reproduce it. Results are immutable and serialize to canonical JSON.

Audits turn that evidence into findings, and every finding has one of five states:

StateMeaning
PASSThe evidence supports the claim.
WARNThe evidence supports it weakly, or with a caveat you should read. A safeguard you declared as not in place also warns.
FAILThe evidence contradicts it.
UNKNOWNThe question matters, but the evidence to answer it was not supplied.
NOT_APPLICABLEThe question does not apply to this kind of study.

UNKNOWN is the important one. If you do not declare how delistings were handled, or never supply a purged validation split, Lacuna does not assume the best. The check stays UNKNOWN, earns no credit, and shows up in the report. Signal timing is the exception: when the signal became known and when you could trade are parameters you should always set, because leaving them out raises no finding. The quickstart shows how.

What it checks

Where to start

Pre-1.0

Lacuna is MIT licensed and pre-1.0. Minor releases may change APIs, and patch releases can change audit results; the changelog describes each change. Record the exact version you audited with. These docs describe lacuna-quant 0.14.3.