C++20 event-driven multi-asset backtesting engine with Python APIs for analytics, WFO/Monte Carlo validation, corporate actions, tick replay, and execution realism.
Project description
BACKTESTER (nanoback)
BACKTESTER is a C++20 event-driven multi-asset backtesting engine with Python bindings, packaged as nanoback.
It focuses on realistic execution simulation, data correctness, and statistically valid research workflows.
Highlights (v0.5.x)
- Fast C++ core with Python APIs
- Bar-mode and tick-mode simulation paths
- Corporate actions support: split, dividend, spinoff, delisting
- Smart execution realism primitives:
- multi-venue routing model (fees, volume share, fill curves)
- signal/order/fill latency modeling + adverse selection penalties
- Derivatives primitives:
- instrument model for equity, options, futures, FX forwards
- option expiry settlement, futures roll events, margin liquidation path
- Research validity stack:
- analytics (Sharpe, Sortino, CAGR, drawdown, attribution)
- parameter sweeps and heatmaps
- walk-forward optimization
- Monte Carlo shuffle/block-bootstrap stress tests
- Deterministic audit ledger and snapshot/resume support
Repository Layout
include/nanoback: C++ public headerscpp: core engine and Python bindingspython/nanoback: Python API, loaders, analytics, research modulesbenchmarks: performance and regression checksexamples: runnable usage examplestests: regression and functional test suite
Quickstart
cd C:\Users\TAPESH\Documents\BACKTESTEER
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .[dev]
python -m pytest
Core Usage
Basic Bar Backtest
import numpy as np
import nanoback as nb
result = nb.run_backtest(
timestamps=np.array([1, 2, 3, 4], dtype=np.int64),
prices=np.array([100.0, 101.0, 99.0, 102.0], dtype=np.float64),
signals=np.array([1, 1, 0, -1], dtype=np.int64),
config=nb.BacktestConfig(max_position=2),
)
print(result.summary())
Tick Replay
import nanoback as nb
config = nb.BacktestConfig()
config.data_mode = nb.DataMode.TICK
result = nb.run_backtest_ticks(
timestamp_ns=timestamp_ns,
asset=asset_idx,
price=price,
size=size,
side=side, # TickSide.BID / ASK / TRADE
target_positions=targets,
cols=n_assets,
config=config,
symbols=symbols,
)
Corporate Actions
import nanoback as nb
config = nb.BacktestConfig()
config.corporate_actions = nb.load_corporate_actions_csv("corp_actions.csv", symbol_to_asset)
Statistical Validation
import nanoback as nb
sweep = nb.Sweep(data)
grid = nb.ParamGrid({"lookback": [5, 10, 20], "max_position": [1, 2]})
res = sweep.run(strategy, grid, n_jobs=1, compiled=True)
wfo = nb.WalkForward(n_splits=6, train_frac=0.7, anchored=True)
wfo_res = wfo.run(data, strategy, grid, compiled=True)
mc = nb.MonteCarlo.from_backtest(result)
mc_res = mc.run(n_sims=5000, method="block_bootstrap", block_size=20)
Data Loaders
load_csv,load_parquetfor bar dataload_ticks_parquetfor tick event replayload_corporate_actions_csvfor corporate action ingestionload_yahoo_adjustedfor adjusted prices + suspicious jump warning checks
Benchmarks
Latency benchmark (CI-style):
.\.venv\Scripts\python.exe benchmarks\benchmark_engine.py --max-seconds 0.50 --min-fills 1000 --ci-mode
Stress benchmark (large shapes):
.\.venv\Scripts\python.exe benchmarks\benchmark_engine.py --mode stress --profile xlarge
Useful benchmark flags:
--baseline/--update-baseline--regression-factor--stage-regression-factor--pnl-tolerance--fill-count-tolerance--memory-guard-gb--record-history --history-file ...
Notes
- This is a research and simulation platform, not a production OMS/EMS.
- Performance and determinism are prioritized, but you should still validate strategy-specific assumptions before live deployment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file nanoback-0.5.3.tar.gz.
File metadata
- Download URL: nanoback-0.5.3.tar.gz
- Upload date:
- Size: 57.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d77d1ab29238fb87016c0ca6e87da2dfb1d8aaa749152c448b93751e7f9dc2a
|
|
| MD5 |
920df31f240bbff741aeec8e000d5cff
|
|
| BLAKE2b-256 |
a277499b6dec5ba53fb5601430f68d5091d7cbf167b4889dc8ee0f8859e39df8
|
Provenance
The following attestation bundles were made for nanoback-0.5.3.tar.gz:
Publisher:
publish.yml on td-02/BACKTESTER
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nanoback-0.5.3.tar.gz -
Subject digest:
4d77d1ab29238fb87016c0ca6e87da2dfb1d8aaa749152c448b93751e7f9dc2a - Sigstore transparency entry: 1441879842
- Sigstore integration time:
-
Permalink:
td-02/BACKTESTER@7e344f6b10890bc853e7d27916114c5a97280b17 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/td-02
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7e344f6b10890bc853e7d27916114c5a97280b17 -
Trigger Event:
push
-
Statement type: