Skip to main content

Trading infrastructure library with backtesting

Project description

CI Build PyPI Version

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:

  1. Market data arrives (tick or candle)
  2. Aggregation produces candles
  3. Strategy receives on_candle_update
  4. Strategy emits order requests
  5. Execution layer processes orders
  6. Portfolio updates positions
  7. 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.marketdata
  • tradedesk.execution
  • tradedesk.execution.backtest
  • tradedesk.portfolio
  • tradedesk.recording
  • tradedesk.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tradedesk-0.8.0.tar.gz (455.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tradedesk-0.8.0-py3-none-any.whl (125.4 kB view details)

Uploaded Python 3

File details

Details for the file tradedesk-0.8.0.tar.gz.

File metadata

  • Download URL: tradedesk-0.8.0.tar.gz
  • Upload date:
  • Size: 455.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tradedesk-0.8.0.tar.gz
Algorithm Hash digest
SHA256 78c95ad81df15b92900985e676f83c0f8d1f340494c089c7da47dcd70c0d8546
MD5 316e1446fce861acec56bb816fd4ee04
BLAKE2b-256 34ad08a3554c6ef10ae78caa2577e2730b6f4c6e3042d0925def2e75d4fd9566

See more details on using hashes here.

Provenance

The following attestation bundles were made for tradedesk-0.8.0.tar.gz:

Publisher: publish.yml on radiusred/tradedesk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tradedesk-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: tradedesk-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 125.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tradedesk-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79ce48d210a4c5337511470ea2094b3147fa84392d404657d554dacd6306bb19
MD5 e06ce403e84add5fe3bf9ae172246118
BLAKE2b-256 fdb0b48758ce07f2afd6f339fde3de5df775823e9cac6fd45bcb760b8a6f0415

See more details on using hashes here.

Provenance

The following attestation bundles were made for tradedesk-0.8.0-py3-none-any.whl:

Publisher: publish.yml on radiusred/tradedesk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page