Professional

Statistical Arbitrage Strategy

· Pricesearcher

Two contrasting schematic spread lines oscillating around a mean beside paired instrument marks.

Problem

Pricesearcher wanted to test statistical arbitrage in its FX/CFD operation. A spread’s historical mean reversion may look promising, but correlation can disappear, execution can change the result, and several pair setups can compete for the same account risk.

Constraints

Both legs must be evaluated on the same completed bar. Historical ranking is not proof of a durable relationship, and backtests depend on data and execution assumptions. Live setups need separate identities, exposure limits and demo/live boundaries.

Solution

Research tools loaded and resampled bars, ranked pair candidates and ran backtests. Scheduled AWS services used the S3 bar history for signals; an on-demand service ran the same engine on historical inputs. Configurable MQL5 and Python engines handled execution, with trade-level reporting and Slack alerts feeding live review.

My Role

I built spread features, correlation and mean-reversion analysis, monthly/yearly return comparisons and data loading. I moved scheduled signals to AWS, built the historical service and MQL5 Expert Advisor, and worked on a Python bot with MT5 and offline-replay brokers. I also built an interactive comparison app, batch optimisation, hedged variants, a Monte Carlo risk simulator, trade reporting and performance alerts.

Technologies

Python, MQL5, MetaTrader 5, pandas, LightGBM, AWS (Lambda, S3), Pulumi, Slack.

Engineering Challenges

  • Candidate selection versus evidence: Pair rankings narrowed what to backtest; I did not treat correlation alone as a signal. The engine could combine z-score, half-life, correlation, Kalman-filtered hedge ratios and packaged LightGBM models, but the evaluation still depended on the historical regime.
  • Synchronous pair decisions: The MQL5 engine waits for both symbols to confirm the same closed bar, avoiding a decision based on one finished leg and one unfinished leg.
  • Account-wide interference: Per-setup identifiers, demo/live separation and controls by account, symbol and direction limited conflicting entries; drawdown simulation and live review addressed risks that parameter optimisation could hide.

Outcome

The work linked pair selection, backtesting, configurable execution and per-setup reporting, making it possible to compare research assumptions with observed trading. Pair relationships can break down; this is not a claim of returns or guaranteed risk reduction.

Relevant services

Have a Python, AI or automation problem?

Tell me what is slowing the business down, what you have tried, and what a successful outcome looks like. I'll help you identify the most sensible next step.