← projectsquanthack
trading competition / jun 2026 / 85th of 440

From hourly trade signals to automated execution. A rules-based trading system built for Model to Market: The Quantitative Hack, reaching the top 100 finalists.

python / pandas / pydantic / metatrader 5 / mql5

starting with manual execution

I entered Model to Market to explore my interest in quantitative trading. Participants traded with $1 million in simulated capital, with rankings accounting for returns, drawdown and risk. I started with a system that suggested trades every hour and placed the orders myself.

Its decisions came from momentum and mean-reversion rules: following recent price direction or trading against a sufficiently large move away from the recent average. After observing the calls and becoming comfortable using them, I connected the system to MetaTrader 5 for automated execution.

accounting for positions already open

Automation needed to account for what was already in the account. A signal to hold three lots should produce an order for one additional lot if two are already held. Repeating the full three-lot order would keep increasing exposure.

MetaTrader exports market data and current positions. Python calculates target positions, subtracts the existing holdings and writes only the required adjustments. An MQL5 Expert Advisor submits those orders, and subsequent account snapshots inform the next cycle.

The sizing calculation also converts dollar exposure into each instrument's contract units and rounds down to its permitted trading increment. Offline tests cover those conversions, position reductions and cases where no adjustment is needed.

knowing whether an order arrived

The file-based connection kept Python research code separate from MetaTrader execution, but introduced a timing problem. An order could be submitted before the next position snapshot reflected it, leaving Python with an outdated view of the account.

The bridge includes checks for repeated signals and unchanged order files. Later acknowledgement logic attempted to track outstanding adjustments, but a subsequent test exposed a gap: an unresolved order could be forgotten when its waiting period expired.

The next engineering priority is to retain each order's status until it can be reconciled with a confirmed fill or rejection. That would give the system stronger evidence of what happened than a submitted file and a later net position.

the result

I placed 85th out of 440 participants, qualifying among the top 100 invited to the in-person final. The competition gave me experience taking a rules-based strategy through manual use and into automated execution, where account state, sizing and order delivery all had to be handled explicitly.