Skip to main content

C++20 event-driven trading backtester with Python bindings, snapshots, audit ledger, and microstructure-aware execution.

Project description

BACKTESTER

BACKTESTER is a low-latency, event-driven trading backtesting repo built around a C++20 execution engine and exposed through a Python package named nanoback.

What It Does

  • Multi-asset backtests over contiguous matrix inputs
  • Market and limit order simulation
  • Partial fills, queue blocking, venue caps, and bid/ask-aware execution
  • Parent/child order IDs with deterministic audit ledger output
  • Snapshot/resume support for long-running simulations
  • Risk controls for leverage, drawdown, cash, and per-asset limits
  • Financing and borrow-cost accrual
  • Compiled research policies and analytics in C++
  • Python strategy/plugin fallback
  • CSV and Parquet loaders
  • Asserted benchmarks and pytest coverage

Repo Layout

  • include/nanoback: C++ headers
  • cpp: C++ engine, policies, and Python bindings
  • python/nanoback: Python API, loaders, ledger utilities, and strategy helpers
  • examples: runnable examples
  • benchmarks: performance checks
  • tests: regression and functional coverage

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 Capabilities

Execution Engine

  • Event-driven C++20 core
  • Market and limit orders
  • Child-order slicing with delay steps
  • Cancel/replace semantics
  • Session-aware order cancellation
  • Snapshot/resume from engine state

Market Realism

  • Bid/ask execution path
  • Queue-ahead fraction and venue volume share caps
  • Slippage and participation-based impact
  • Cost calibration helpers from empirical fill data

Risk and Audit

  • Gross leverage checks
  • Drawdown kill switch
  • Cash and borrow accounting
  • Per-asset max position and notional limits
  • Deterministic ledger export to CSV/JSONL

Research Layer

  • Compiled momentum, mean reversion, and moving-average crossover policies
  • Compiled rolling volatility, cross-sectional ranking, and minimum-variance weights
  • Python strategy hooks when custom event logic is needed

Minimal Example

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,
        child_order_size=1,
        child_slice_delay_steps=1,
    ),
)

print(result.pnl)
print(len(result.ledger))

Benchmark

.\.venv\Scripts\python.exe benchmarks\benchmark_engine.py --max-seconds 0.50 --min-fills 1000

Status

The repo is strong as a research and simulation engine. It is not a full OMS/EMS, exchange adapter stack, or compliance platform.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanoback-0.2.0.tar.gz (30.8 kB view details)

Uploaded Source

File details

Details for the file nanoback-0.2.0.tar.gz.

File metadata

  • Download URL: nanoback-0.2.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nanoback-0.2.0.tar.gz
Algorithm Hash digest
SHA256 869f2aff198c00eea4b196c125493f4c908040658ff28554d4fd3d3a93dcc865
MD5 fc98c936fe98b86155ba5a68898c3a9e
BLAKE2b-256 e16a2ba60231133d6eb70bff1ead9168434895a3aef3c0d4625e6ec0b93c322e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanoback-0.2.0.tar.gz:

Publisher: publish.yml on td-02/BACKTESTER

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page