Skip to main content

banner

tradedesk

CI Build PyPI Version

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.marketdata for market events, subscriptions, aggregation, and indicators
  • tradedesk.data_sources for external datasets such as CFTC COT history
  • tradedesk.strategy for strategy base classes and strategy-facing events
  • tradedesk.portfolio for portfolio state, sizing, and risk policies
  • tradedesk.execution for live execution adapters and order handling
  • tradedesk.execution.backtest for simulated execution and replay
  • tradedesk.recording for lifecycle events, trade records, and metrics
  • tradedesk.research for walk-forward and correlation-gate helpers
  • tradedesk.ml for optional feature engineering, labels, and walk-forward tooling

For a broader system map, see docs/architecture.md.

Runtime model

Typical flow:

  1. Market data arrives as ticks or candles.
  2. Aggregation updates candle streams.
  3. Strategies react in callbacks such as on_price_update(...) or on_candle_close(...).
  4. Strategies request orders through the execution layer.
  5. Portfolio and execution components apply gates, place or simulate orders, and emit lifecycle events.
  6. 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 history
  • run_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.

Rust crates

Beside the Python package, crates/ holds a Cargo workspace with two Rust crates:

  • tradedesk-data, the market-data layer: the Reader trait, the trading calendar, aggregation of 1-minute bars to 5m / 15m / 1h / 1d, gap detection (which reads only the 1-minute timestamps, Reader::read_1m_timestamps), an Arrow IPC bar cache, and a reader for the <root>/<SYMBOL>/<YYYY>/<MM 00-indexed>/<DD>_<bid|ask>.csv.zst cache layout.
  • tradedesk-backtest, the backtester: venue costs and financing, the ledger, metrics, indicators, the Strategy trait, parameter sweeps with an append-only trial registry, the deflated Sharpe, PBO and walk-forward, and a command line. It ships no strategy: a strategy implements the trait and registers itself in a StrategyRegistry. See its README.

The Python backtester, tradedesk.execution.backtest, remains the path on which a strategy and its portfolio run byte-identically in backtest and live. tradedesk-backtest is the research engine for parameter sweeps. A later milestone joins the two, by moving the live runtime to Rust, once a strategy has proved itself in backtesting.

The crates are not published to crates.io; build and test them from the repository root with cargo build --workspace and cargo test --workspace (the toolchain is pinned in rust-toolchain.toml). The tradedesk-backtest binary has three commands, sweep, report and walkforward. For the report command, replace path/to/registry.jsonl with an existing registry written by a sweep.

cargo run -p tradedesk-backtest -- --help
cargo run -p tradedesk-backtest -- report path/to/registry.jsonl   # a registry that sweep wrote

It registers no strategy, so sweep needs a binary built by a strategy crate; see the crate README's "Command line".

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_KEY
  • IG_USERNAME
  • IG_PASSWORD
  • IG_ENVIRONMENT (DEMO by default, or LIVE)
  • IG_ACCOUNT_ID for strategies that create tick-level MarketSubscription items

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:

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

Metadata

Release files for tradedesk 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradedesk 1.8.0
File Size Uploaded Provenance Actions
tradedesk-1.8.0.tar.gz 1.4 MB With provenance Details for tradedesk-1.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tradedesk 1.8.0
File Interpreter ABI Platform Actions
tradedesk-1.8.0-py3-none-any.whl Python 3 none any Details for tradedesk-1.8.0-py3-none-any.whl

Total release size: 1.6 MB

Release files / tradedesk-1.8.0.tar.gz

Download URL tradedesk-1.8.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
27cc7c08227d88aa99c168c9785b8a455197f03e8fe45661d47d09f641ebe845
BLAKE2b-256 checksum
How to use checksums
f9196b41fa6317fdeb7d8f6e47fa1a76a1592d3d197f1349f5721a06f4f48793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / tradedesk-1.8.0-py3-none-any.whl

Download URL tradedesk-1.8.0-py3-none-any.whl
Size 229.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46603ec21b05380c0f089e1e75aefa242b5e590f1ac18095c0544d7bf35c981e
BLAKE2b-256 checksum
How to use checksums
163d14d290b94c9844cf250b2a7c8e00dc1d060d4cb2a9b0a30fbed09c1d62bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for tradedesk 1.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tradedesk-1.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page