tradedesk is an event-driven trading framework for building, running, and evaluating systematic trading strategies across both backtesting and live broker environments.
It provides:
- Event-based strategy execution
- Unified backtest and live broker runtime model
- Market data aggregation and indicator framework
- Portfolio orchestration and risk management
- Trade recording, metrics, and reporting
The framework is designed so that strategies react to events --- not broker implementations --- enabling the same strategy code to run unchanged in both backtest and live environments.
All major subsystems communicate via events:
- Market data events (ticks, candles)
- Strategy events (signals)
- Execution events (orders, fills)
- Portfolio events (position updates)
- Recording events (trade lifecycle)
As a user, you primarily:
- Implement a strategy that reacts to candle updates
- Optionally subscribe to events for custom analytics or logging
A strategy derives from the base strategy class and implements candle handling logic.
Typical flow:
- Market data arrives (tick or candle)
- Aggregation produces candles
- Strategy receives
on_candle_update - Strategy emits order requests
- Execution layer processes orders
- Portfolio updates positions
- Recording captures trade lifecycle
Backtesting uses the same event model as live trading.
High-level flow:
- CSV or historical provider feeds market data
- Backtest runner drives event loop
- Strategy executes normally
- Portfolio and recording operate identically to live mode
See docs/backtesting_guide.md for detailed usage.
The IG execution module provides:
- REST client for order management
- Streaming price integration
- Position synchronization
- Retry and resilience handling
Your strategy remains unchanged --- only the execution configuration differs.
The portfolio subsystem:
- Tracks positions
- Applies risk policies
- Reconciles fills
- Emits portfolio events
Risk controls can reject or modify orders before execution.
The recording subsystem:
- Tracks trades and equity curves
- Computes excursions and performance metrics
- Generates structured reports
Users can subscribe to recording events for custom reporting pipelines.
my_strategy/
strategy.py
run_backtest.py
config.py
Install using your preferred environment manager. Ensure Python 3.11+.
See the docs/ directory for:
- Backtesting guide
- Strategy guide
- Portfolio guide
- Indicator guide
- Aggregation guide
- Risk management guide
- Metrics guide
Licensed under the Apache License, Version 2.0. See: https://www.apache.org/licenses/LICENSE-2.0
Copyright 2026 Radius Red Ltd.