Skip to content
Back to projects
// Case study2026

AMD Backtester

Automated backtesting engine for an institutional price-action strategy on XAU/USD.

Equity curve of AMD strategy backtest
Lines of Python
~11.9k
Strategy modules
26
Sample run expectancy
+0.50R
License
MIT
Role

Solo engineer

Stack
  • Python
  • PostgreSQL
  • MetaTrader 5
  • Git

Problem

Price-action traders need a reproducible way to validate an Accumulation / Manipulation / Distribution hypothesis on gold, with realistic execution costs and session filters — not a toy notebook.

Approach

26-module Python engine: MT5 data ingestion, PostgreSQL cold storage, SMC confluence (FVG + order blocks), session filters, Monte-Carlo validation, and a pytest-backed core. Reports generate equity curves, trade funnels, cost breakdowns and monthly P&L.

Outcome

11.9k LOC, MIT-licensed, fully reproducible runs. Ships backtest artefacts as PNG + txt so results can be audited outside the repo.

Strategy thesis

The AMD pattern frames a day in three institutional phases: accumulation (tight range, liquidity builds), manipulation (a fake breakout that sweeps stops), and distribution (the real leg). Entries come on retest of the broken level with rejection confirmation, filtered by session and confluence with fair-value gaps / order blocks.

Engineering choices

Ingestion runs through the official MT5 terminal API; raw ticks and minute bars land in PostgreSQL so runs are reproducible. Strategy logic is split into 26 pure-function modules (indicators, consolidation detector, manipulation detector, distribution detector, entry, risk, filters) so each can be unit-tested. A Monte-Carlo layer resamples trade sequences to stress-test expectancy.

Why it matters for a portfolio

This is the piece that proves I can own a system end-to-end: data layer, strategy layer, risk layer, reporting layer, tests, and reproducible artefacts. No notebooks hiding bugs.

// Artefacts
Equity curve with drawdown
Equity curve with running drawdown shading.
Distribution of trade R-multiples
Per-trade R-multiple distribution.
Monthly profit and loss heatmap
Monthly P&L heatmap across the backtest window.
Cost breakdown bar chart
Execution-cost breakdown (spread / slippage / commission).
Pattern-filtering funnel analysis
Pattern funnel — how many candidates survive each filter.