Skip to content

Event-Driven Trading System

A causal, event-driven backtesting and paper-trading engine in Python. Market data, signals, orders, risk checks, fills and portfolio snapshots are typed, immutable events on a publish/subscribe bus. The pipeline that runs a backtest also trades an Alpaca paper account; only the execution component changes.

The goal is results you can trust: no look-ahead, correct long/short accounting, mark-to-market metrics on every bar, and deterministic, reproducible runs, each enforced by tests.

Backtest chart: price with fills, equity against buy and hold, and drawdown

Install

Python 3.11 or newer. The core needs only PyYAML; the extras add Yahoo Finance data (data) and charts (viz).

pip install "event-trading-system[all]"
trading                                   # a backtest on synthetic data

The package is event-trading-system on PyPI; in Python it is import trading.

In five lines

from trading import BacktestConfig, BacktestEngine

config = BacktestConfig().with_overrides({"strategy.type": "rsi", "simulation.n_bars": 1000})
result = BacktestEngine(config).run()
print(result.report)

Where to go next

Tutorial From the first backtest to a strategy of your own, validated and paper trading
User guide Every feature: data, orders, risk, research, paper trading, Docker
Architecture The event bus, the clock, and how causality is enforced
Configuration Every setting, its default and what it does
Examples Runnable scripts for strategies, sweeps, walk-forward and paper trading
Research A walk-forward study of every built-in strategy, after costs
API reference The public Python API
Stability What is public, versioning, and the deprecation policy