Trading infrastructure library with backtesting
Project description
tradedesk
Contributing: CONTRIBUTING.md
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.
Core Concepts
Event-Driven Architecture
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
Architecture Overview
For a concise public map of the system, see ARCHITECTURE.md. tradedesk is built around an event-driven core that wires together market data, strategy logic, portfolio management, execution adapters (IG for live trading, Dukascopy-backed backtests), and a recording layer for metrics and reports. The public interfaces expose reusable building blocks (marketdata, strategy, portfolio, recording) with clear data-flow guarantees across backtest and live paths.
Basic Strategy Structure
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
Running a Backtest
Backtesting uses the same event model as live trading.
High-level flow:
- Dukascopy cache data is loaded via
BacktestClient.from_dukascopy_cache(...) run_backtest(...)drives the event loop and recording pipeline- Strategy code executes unchanged
- Portfolio and recording operate identically to live mode
See docs/backtesting_guide.md for the current cache-backed workflow.
Live Trading (IG)
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.
Portfolio & Risk
The portfolio subsystem:
- Tracks positions
- Applies risk policies
- Reconciles fills
- Emits portfolio events
Risk controls can reject or modify orders before execution.
Recording & Reporting
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.
Typical Project Structure
my_strategy/
strategy.py
run_backtest.py
config.py
Installation
Python 3.11+ is required.
Install the published package:
pip install tradedesk
For local development:
pip install -e '.[dev]'
Documentation
See the docs/ directory for:
- Backtesting guide
- Strategy guide
- Portfolio guide
- Indicator guide
- Aggregation guide
- Risk management guide
- Metrics guide
Public package entry points are grouped under:
tradedesk.marketdatatradedesk.executiontradedesk.execution.backtesttradedesk.portfoliotradedesk.recordingtradedesk.strategy
tradedesk is designed for clarity, determinism, and event-level transparency.
License
Licensed under the Apache License, Version 2.0. See: https://www.apache.org/licenses/LICENSE-2.0
Copyright 2026 Radius Red Ltd. | Contact
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tradedesk-0.9.0.tar.gz.
File metadata
- Download URL: tradedesk-0.9.0.tar.gz
- Upload date:
- Size: 455.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5073093b4f6f18c03002529176cdd11da274957754d22dd450c94b2dd2178c87
|
|
| MD5 |
aba5b30b3c8dcd1f68a3b99cf70c9049
|
|
| BLAKE2b-256 |
13d78daf7d5eb120f65f01e11cca7806e35e69c4552c19d82ddc6deb1e71f55e
|
Provenance
The following attestation bundles were made for tradedesk-0.9.0.tar.gz:
Publisher:
publish.yml on radiusred/tradedesk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradedesk-0.9.0.tar.gz -
Subject digest:
5073093b4f6f18c03002529176cdd11da274957754d22dd450c94b2dd2178c87 - Sigstore transparency entry: 1320142052
- Sigstore integration time:
-
Permalink:
radiusred/tradedesk@4c753b46bdf5d6d8b166cbadc534be019796fd84 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/radiusred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c753b46bdf5d6d8b166cbadc534be019796fd84 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tradedesk-0.9.0-py3-none-any.whl.
File metadata
- Download URL: tradedesk-0.9.0-py3-none-any.whl
- Upload date:
- Size: 125.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0174ff8883f30c154b6ae0d3b43eee1d76c0eb4b87e4c47422a49ade8df7496b
|
|
| MD5 |
1578dbc21e97b21ea60dcc510ec2a4ae
|
|
| BLAKE2b-256 |
2c10015ecb45378adbc50edc3e1d5f642ba171f2e8287381c016267bab91a91f
|
Provenance
The following attestation bundles were made for tradedesk-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on radiusred/tradedesk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradedesk-0.9.0-py3-none-any.whl -
Subject digest:
0174ff8883f30c154b6ae0d3b43eee1d76c0eb4b87e4c47422a49ade8df7496b - Sigstore transparency entry: 1320142145
- Sigstore integration time:
-
Permalink:
radiusred/tradedesk@4c753b46bdf5d6d8b166cbadc534be019796fd84 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/radiusred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c753b46bdf5d6d8b166cbadc534be019796fd84 -
Trigger Event:
release
-
Statement type: