Skip to main content

limen.backtest

Evaluate aligned predictions as trading outcomes through either a vectorized snapshot or a sequential simulation.

Canonical docs

What this package owns

Owns Limen's two backtest modes and the assumptions they encode. Does not own signal generation, experiment logging, or raw portfolio bookkeeping beyond what it delegates to limen.trading.

Key entry points

Entry pointUse it whenNotes
backtest_snapshotYou want the fast, vectorized evaluation used across many roundsImport from limen.backtest.backtest_snapshot
BacktestSequentialYou want bar-by-bar account-state simulationImport from limen.backtest.backtest_sequential

Adjacent modules

  • limen.log uses backtest_snapshot() to summarize experiment permutations.
  • limen.trading provides the Account ledger used by the sequential path.
  • limen.experiment and limen.sfd sit upstream by producing the predictions that backtests consume.

Quick orientation

backtest/
├── backtest_snapshot.py # Vectorized snapshot evaluator
└── backtest_sequential.py # Stateful account-based simulation

Things to know

  • The package root currently does not re-export the backtest helpers, so import from the module paths directly.
  • backtest_snapshot() is the common analysis path for experiment sweeps because it is simple and fast.
  • BacktestSequential is the right tool when you need a ledger and bar-by-bar account transitions.
  • The underlying Account supports long and short bookkeeping, but the current sequential backtest loop only executes the long-side buy and sell path.
  • Snapshot outputs are reported in percent units, while fee and slippage inputs are specified in basis points.