Vectorised backtesting python library

Research
Backtesting
Portfolio
A compact research library for fast, vectorised backtesting and portfolio construction with clear timing and guardrails.
Published

January 21, 2026

github repo

A small research library I wrote for fast strategy prototyping. Vectorised backtesting is not perfectly realistic, but it is a good way to quickly tell whether an idea looks promising or probably dead on arrival. I use it as a first pass tool before moving to slower event driven sims or production code.

Why I built it

  • I wanted a quick feedback loop for research: test many variations without building a full simulator each time
  • I wanted consistent assumptions across experiments: timing, execution lag, costs, and cash handling
  • I wanted something simple enough to extend while exploring new signals and portfolio rules

What it includes

Fast vectorised backtests

  • Single asset and multi asset backtests built on numpy and pandas
  • Clear timing alignment between signals, trades, and PnL, with configurable execution lag
  • Cash accounting mode that tracks equity, cash, turnover, and net performance after costs

Portfolio construction helpers

  • Turn signals into positions or weights with a clean interface
  • Optional constrained optimisation via cvxpy for basic weight and risk constraints

Guardrails for research

  • Input checks that prevent silent bad results, including enforcing positive prices
  • Safe handling of edge cases like divide by zero by producing NaN instead of misleading numbers
  • Result objects with consistent field meanings so analysis code stays simple