Trading infrastructure library with backtesting
Project description
tradedesk
tradedesk is an event-driven trading framework for building, running, and
evaluating systematic strategies across backtesting and live broker
environments.
What it provides
- Event-driven strategy execution
- Shared strategy model across backtest and live runs
- Market data aggregation and indicators
- External market datasets and parsers
- Portfolio orchestration and risk controls
- Trade recording, metrics, and reporting
- Research helpers for walk-forward validation and correlation checks
- Optional machine-learning helpers in
tradedesk.ml
The design goal is portability: strategies react to framework events rather than broker-specific implementations, so the same strategy code can move between backtest and live execution with minimal runtime wiring changes.
Installation
Python 3.11+ is required.
Install the published package:
pip install tradedesk
Install the optional machine-learning dependencies:
pip install 'tradedesk[ml]'
For local development:
pip install -e '.[dev]'
Architecture at a glance
The public package is organized into a small set of domains:
tradedesk.marketdatafor market events, subscriptions, aggregation, and indicatorstradedesk.data_sourcesfor external datasets such as CFTC COT historytradedesk.strategyfor strategy base classes and strategy-facing eventstradedesk.portfoliofor portfolio state, sizing, and risk policiestradedesk.executionfor live execution adapters and order handlingtradedesk.execution.backtestfor simulated execution and replaytradedesk.recordingfor lifecycle events, trade records, and metricstradedesk.researchfor walk-forward and correlation-gate helperstradedesk.mlfor optional feature engineering, labels, and walk-forward tooling
For a broader system map, see docs/architecture.md.
Runtime model
Typical flow:
- Market data arrives as ticks or candles.
- Aggregation updates candle streams.
- Strategies react in callbacks such as
on_price_update(...)oron_candle_close(...). - Strategies request orders through the execution layer.
- Portfolio and execution components apply gates, place or simulate orders, and emit lifecycle events.
- Recording subscribers capture fills, positions, equity, and metrics.
Backtesting
Backtests use the same event model as live sessions.
BacktestClient.from_dukascopy_cache(...)loads Dukascopy-backed historyrun_backtest(...)runs the event loop and recording pipeline- Strategy, portfolio, and recording components behave the same way they do in live sessions
See docs/backtesting_guide.md for the current cache-backed workflow.
Live trading with IG
The IG integration provides REST-backed order execution, price streaming, and position synchronisation while keeping strategy code unchanged.
Live runs use these environment variables:
IG_API_KEYIG_USERNAMEIG_PASSWORDIG_ENVIRONMENT(DEMOby default, orLIVE)IG_ACCOUNT_IDfor strategies that create tick-levelMarketSubscriptionitems
Example:
IG_API_KEY=... \
IG_USERNAME=... \
IG_PASSWORD=... \
IG_ENVIRONMENT=DEMO \
IG_ACCOUNT_ID=... \
python your_live_runner.py
tradedesk handles the short-lived IG session headers (CST and
X-SECURITY-TOKEN) during authentication. They are not configured manually.
When live sessions request historical candles from IG, account-level historical-data limits are surfaced as a dedicated failure mode so embedding runtimes can back off or alert explicitly.
Machine learning support
tradedesk.ml is optional and installs behind the [ml] extra. It provides:
- Feature engineering over OHLC(V) and optional bid/ask data
- Label generation helpers
- Walk-forward cross-validation utilities
- Model wrappers and strategy integration points
See docs/ml_guide.md for the ML overview and docs/ml_labels_guide.md for label-specific details.
External data sources
tradedesk.data_sources exposes loaders and parsers for datasets that sit
outside the live IG / Dukascopy execution paths.
Three free, no-auth macro feeds are supported:
- FRED — US rates (DFF, DGS3MO/2/10, T10Y2Y) and VIX from the St. Louis Fed
- ECB — EUR €STR, AAA government yield curve (3M–10Y) and Euribor from the ECB Data Portal
- CFTC COT — Commitment-of-Traders positioning for metals, energy, indices, 10Y notes and CME EUR/JPY/GBP currency futures, including the TFF dealer, asset-manager and leveraged-funds buckets
Series are materialized to a Parquet lake under the existing market-data root
and loaded uniformly via load_macro_series / load_macro_frame:
from tradedesk.data_sources import load_macro_series, load_macro_frame
rates = load_macro_frame("FRED", ["DGS2", "DGS10", "VIXCLS"])
estr = load_macro_series("ECB", "EUR_ESTR")
eur_cot = load_macro_series("CFTC", "EURUSD")
A python -m tradedesk.data_sources.ingest CLI refreshes the lake on demand or
on a weekly cron (idempotent; per-series failures are non-fatal).
See docs/data_sources_guide.md for the full series
catalogue, the look-ahead semantics for CFTC release dates, and the lower-level
CFTC COT API (CFTC_CONTRACTS, load_contract_history, download_cot_zip,
iter_cot_rows, cot_release_date).
Documentation
Start with:
- docs/strategy_guide.md
- docs/backtesting_guide.md
- docs/portfolio_guide.md
- docs/risk_management.md
- docs/indicator_guide.md
- docs/aggregation_guide.md
- docs/metrics_guide.md
- docs/settings.md
- docs/operational_resilience.md
- docs/crash-recovery.md
- docs/data_sources_guide.md
- docs/ml_guide.md
Contributing
See CONTRIBUTING.md for development setup, quality gates, and PR expectations.
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-1.6.2.tar.gz.
File metadata
- Download URL: tradedesk-1.6.2.tar.gz
- Upload date:
- Size: 815.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7465a785b89ea06f960f88cbd2d3737213ef7f443d89b08bb4434feb8d04e9bb
|
|
| MD5 |
0373deecf1fd06a9e9ae5b13bd5e1190
|
|
| BLAKE2b-256 |
5074c4d6a1264f9b3eeb6295392abb1e68246c668db625a2ac589f9ca90a8359
|
Provenance
The following attestation bundles were made for tradedesk-1.6.2.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-1.6.2.tar.gz -
Subject digest:
7465a785b89ea06f960f88cbd2d3737213ef7f443d89b08bb4434feb8d04e9bb - Sigstore transparency entry: 1748079902
- Sigstore integration time:
-
Permalink:
radiusred/tradedesk@d73faa46020fff9510f8afae1f909e539634f9f8 -
Branch / Tag:
refs/tags/v1.6.2 - Owner: https://github.com/radiusred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d73faa46020fff9510f8afae1f909e539634f9f8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tradedesk-1.6.2-py3-none-any.whl.
File metadata
- Download URL: tradedesk-1.6.2-py3-none-any.whl
- Upload date:
- Size: 228.1 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 |
bee3ac1db573345e542e69286dbd6e6cd60d8ed5c571808d2218f8cb8bf2570c
|
|
| MD5 |
542794c2eba667dcae4109752dd830da
|
|
| BLAKE2b-256 |
5292af0bdc9d5093c865029f8bbc79b55576c26c7646e5805167bac6587e726d
|
Provenance
The following attestation bundles were made for tradedesk-1.6.2-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-1.6.2-py3-none-any.whl -
Subject digest:
bee3ac1db573345e542e69286dbd6e6cd60d8ed5c571808d2218f8cb8bf2570c - Sigstore transparency entry: 1748080058
- Sigstore integration time:
-
Permalink:
radiusred/tradedesk@d73faa46020fff9510f8afae1f909e539634f9f8 -
Branch / Tag:
refs/tags/v1.6.2 - Owner: https://github.com/radiusred
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d73faa46020fff9510f8afae1f909e539634f9f8 -
Trigger Event:
release
-
Statement type: