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.1.1.tar.gz (27.4 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for nanoback-0.1.1.tar.gz
Algorithm Hash digest
SHA256 91bee90a7bbf101f674ff6b1c8ba2ec120fb4a2b91baeb3bfa1f1a7863a82b8d
MD5 8c3e576eaf3741aa684e5af5e91a01eb
BLAKE2b-256 891e72a66de398f8e01ecfc776619bb5a7b0d4f6c35a9a225b7277760b695b4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanoback-0.1.1.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