Skip to content

Interactive 3D Backtesting Dashboard

Component Type: Dash / Plotly Web Application (Backtesting/Dashboard)
Primary Script: dashboard_3d.py
Launch Command: ./Backtesting/Dashboard/start_dashboard.sh or ./py.sh Backtesting/Dashboard/dashboard_3d.py


🟢 Part 1: Layman & Trader Guide

1. What is the 3D Backtesting Dashboard?

The 3D Backtesting Dashboard is a browser-based command center for exploring, evaluating, and launching algorithmic trading strategies.

Rather than looking at endless rows of numbers in Excel, the dashboard projects hundreds of thousands of backtested trading models ("Genomes") into an interactive 3D space. This allows you to visually identify robust clusters of profitable settings while avoiding fragile statistical flukes.

2. Main Navigation Tabs

Tab 1: 3D Explorer

  • What you see: A 3D scatter plot where every bubble represents a complete trading genome.
  • X-Axis: Win Rate (percentage of winning trades).
  • Y-Axis: Net PnL (total accumulated profit in ticks or dollars).
  • Z-Axis: Maximum Drawdown (the deepest loss experienced along the way).
  • Bubble Size & Color: Represents the Stability Score (greener and larger bubbles represent smoother, more consistent equity curves).
  • Finding Profitable Clusters: Look for dense clouds of green bubbles. If multiple nearby settings all perform well, the strategy is robust. If a lone profitable bubble is surrounded by red losers, it is an overfitted curve-fit trap.
  • Filtering Sidebar: Filter models by Engine (Engine A: Reversal vs Engine B: Options), Target, Chart dataset, and specific evaluation windows (Train, Out-of-Sample, Anchor, Lifetime).

Tab 2: Specialist Studio & Fleet Builder

  • What is a Specialist?: Some trading settings only perform well on Monday mornings, while others excel during high-volatility afternoons.
  • Building a Fleet: Specialist Studio allows you to combine multiple niche models into a single diversified "Fleet". When combined, their equity curves smooth out, and drawdowns are drastically reduced.

Tab 3: Backtest Runner

  • Paste any Genome string directly into the runner.
  • Select your target chart and date range, then click Run Backtest.
  • Instantly view the interactive Equity Curve, underwater drawdown chart, and individual trade history table.

Tab 4: Portfolio Matrix & Trade Ledger

  • Inspect the master trade ledger across all active strategies.
  • Analyze trade duration, Maximum Adverse Excursion (MAE), and exit reason distributions.

💻 Part 2: Expert & Developer Specification

1. Architecture & Component Graph

The Dashboard is engineered on top of Dash (Flask), Plotly WebGL, and Polars/DuckDB/SQLite:

graph TD
    UI[Browser Client: Dash 3D UI] <--> App[dashboard_3d.py / Flask Server]
    App <--> DL[data_loader.py: Polars / In-Memory Cache]
    DL <--> SQL1[(trades_*.db: Tick Trades)]
    DL <--> SQL2[(results.db / backtests_*.db: Genomes)]
    DL <--> SQL3[(lineage_*.db: GA Family Trees)]
    App <--> CB[Callbacks Graph: callbacks/explorer.py, runner.py, portfolio.py]
    CB <--> Sub[Subprocess Dispatcher: ./py.sh backtest.py]

2. High-Performance Data Layer & SQLite Caching

With datasets exceeding 12 GB and millions of trades, data_loader.py avoids blocking the Dash event loop: * WAL Mode & Pragmas: All SQLite connections enforce PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA cache_size = -64000;. * Zero-Copy Arrow / Polars Loading: Queries stream into Apache Arrow tables and Polars DataFrames for vector calculations. * LRU Memory Caching: Expensive aggregations (e.g., cross-validation matrices and 3D point clouds) are memoized using @lru_cache(maxsize=128) keyed on query parameter hashes.

3. State Management & Dash Callbacks

The application decomposes callback logic across modular handlers in Backtesting/Dashboard/callbacks/: * explorer.py: Handles 3D camera transforms, axis re-mapping, click-to-select point events, and color scale normalization. * runner.py: Spawns asynchronous backtest processes via subprocess.Popen, monitors stdout progress streams, and pushes dynamic updates to the client. * portfolio.py: Performs trade-level interleaving, calculating portfolio margin usage, concurrency conflicts, and combined Sharpe/Sortino ratios. * settings.py: Manages user UI persistence in browser local storage (dcc.Store(storage_type='local')).

4. Interactive Cross-Filtering Contracts

  • Selection State: Clicking any 3D bubble triggers a selectedData event passing {curveNumber, pointIndex, customdata: [genome_id, engine, score]}.
  • Global Sync: Selected genomes are broadcasted across the active session state, updating the HUD preview, the detailed trade ledger, and the lineage family tree in parallel.