Skip to main content
@kneeraazon
R&D PrototypeFinance & QuantCase Study

Built for Trading Benchmarks · Python · LangGraph · FastMCP · Alpha Vantage

Automated Trading Arena

An arena in which several language models each start with $10,000 and trade NASDAQ 100 stocks through Model Context Protocol tool servers, replayed day by day or hour by hour from historical prices. The price tool shows only what was known at the simulated moment, search results after that moment are dropped, and every order is checked and applied under a lock. A static dashboard plots each agent's portfolio. Python, LangChain, LangGraph and FastMCP.

OUTCOME.01602Automated tests passing
OUTCOME.02230 / 230Seeded bugs caught by the tests (recorded)
OUTCOME.030Known vulnerabilities in 116 packages
2D SYSTEM TOPOLOGY // END-TO-END REQUEST PIPELINE4-STAGE DATA FLOW

Agent Loop → MCP Tools → No Look-ahead → Order Ledger

FIG.01 // INTERFACE & SYSTEM CAPTURE1 / 5
The dashboard's Asset Evolution page: four summary tiles (seven active agents, the trading period October 1 to October 31 2025, the best agent and its return) above a line chart of total asset value over time for seven series.
The dashboard's Asset Evolution page: four summary tiles (seven active agents, the trading period October 1 to October 31 2025, the best agent and its return) above a line chart of total asset value over time for seven series.

Role

AI Engineer

Duration

Since April 2026

Tech Stack

Python 3.14LangChain and LangGraphFastMCP (Model Context Protocol)Alpha Vantage price datapytestRuffuvChart.js dashboard
SECTION 01 // PROBLEM STATEMENT

The Problem

Comparing language models as traders is only meaningful if the test is fair: a model must not see prices from after the moment it is trading, its account must obey real rules, and the run must be repeatable. A benchmark that leaks the future, or lets a model spend the same cash twice, measures the harness, not the model.

The repository could not even be imported (a syntax error), and three of its defects could silently change the result of a run.

SECTION 02 // SYSTEM ARCHITECTURE & EXECUTION

My Approach

  1. Agents. LangChain and LangGraph agents, one per model, that analyse, search the web and trade through MCP tools. A runner trades once a day, or at every hour that has price data, and a parallel runner starts one process per model.
  2. Tool servers. FastMCP servers for prices, search, trading and math. Each request carries an agent signature header, so a shared server books every order to the right agent and date.
  3. No look-ahead. The price tool shows only the open for the current day (or hour) and nothing later, and refuses everything if no simulated date is set. Search results published at or after the simulated moment, or with no readable date, are dropped.
  4. A checked account. An order is a whole number of shares from 1 up, at a real price, and cash can never go negative. The read, check and write of every order run under one lock per agent, so two orders cannot spend the same cash.
  5. Metrics. Returns and risk figures computed over daily or hourly histories, with the cases that used to crash (hourly runs, days with no data, huge moves) handled.
  6. Dashboard. A static page that plots each agent's portfolio and trades from the files in data/.
  7. Review. Fixes for the syntax error, an order of negative size that added cash, two orders spending the same cash, a price tool that showed future dates, undated search results, shared servers that could not tell which agent was calling, a signature that became a file path unchecked, and an API key built into a URL that an error message would print.
SECTION 03 // VERIFIED OUTCOMES

Results & Impact

Re-run on 2026-11-14 in a scratch copy: ruff check passes, 602 tests pass, and uv audit finds no known vulnerabilities in 116 packages. The project's own guards were run on a made-up price series: for a simulated date of 2025-10-15 the price tool returned the full bar for the 14th, only the open for the 15th, an error for the 16th, and refused everything when no date was set; the account accepted a valid buy and refused negative, zero, fractional, unaffordable and unheld orders. The bundled static dashboard was served locally and rendered seven series from the data directory.

Recorded in the repository's work-done.md: a mutation check that put 230 deliberate bugs back one at a time with the tests failing for every one (a run that takes about 12 minutes, not repeated on 2026-11-14).

Not verified: any real model, Alpha Vantage or search call. The agents, HTTP calls and response shapes are tested against fakes, and the prompt and the default model names were not tried on a live endpoint. The origin of the bundled run data behind the dashboard is not documented, so no return or ranking figure from it is quoted here.