AI & research · 2025–2026
Agentic Quant — master’s thesis
A multi-agent platform on which AI agents design quantitative trading strategies, test them in backtests and discard or improve them. My master’s thesis in Applied Artificial Intelligence, graded 1.0 (the top grade).
- Status
- Completed
- Period
- 2025–2026
- Area
- AI & research
- Role
- Master’s thesis, sole developer
The question
Rule-based trading strategies hit their limits quickly, and developing new ones is tedious manual work: idea, implementation, backtest, evaluation, next idea. The thesis examines how far this loop can be automated with language-model agents — and above all, how to validate their results reliably.
Features
The images come from the thesis; click to enlarge.
Studies
A study is the frame of an experiment: it ties a dataset to a workspace for the code. Its description is the hypothesis the agents start from; below it are all agent threads with their status.

Agents at work
Every thread shows its steps in order: which node of the graph is running, which tool a model calls and what comes back. “Copy All” hands the context of a step to a language model in one go when something needs debugging.

Sandboxes
The agents’ code runs in isolated Docker containers with a terminal, a Jupyter kernel and background tasks. The workspace is mounted at /workspace. Git is deliberately missing from the container; commits go through the server’s own tools.

Workspaces with history
Every workspace is a Git repository on the server, and each thread works on its own branch. Every change an agent makes can be traced as a commit with a diff.

Knowledge base
Documents, transcripts and notes from earlier research are stored as embeddings in Qdrant. The search also works with different wording: “moving average” finds an entry about an SMA strategy.

Metrics of a run
After every backtest, metrics such as result, maximum drawdown, win rate, profit factor and Sharpe ratio are available. The review decides on that basis: rework, research again or move on to the holdout.

The platform
- Agents in Python with LangChain and LangGraph. I implemented every tool they use myself, from fetching data to evaluating a backtest.
- Backtesting on a framework of my own with its own Python library, so agents can test strategies reproducibly and comparably.
- Execution in Go: order and portfolio management, state in PostgreSQL with type-safe queries (sqlc), exposed over Connect RPC.
- Contracts first: all services talk via Protocol Buffers; the schema is the single source of truth for Go, Python and TypeScript.
- Market data is read live from my market_server; nothing is copied locally.
- UI in SvelteKit to follow sessions, agents and results.
The agents in depth
In the thesis the agents’ workflow is called Graph Flow 3. It is the third version: earlier prototypes failed too often on broken tool calls and on the models’ error loops. The diagrams are from the thesis.
A graph with ways back
A classic pipeline runs every step exactly once. Strategies, however, come about in rounds: the review finds weaknesses, the implementation fixes them. That is why the workflow is a graph in LangGraph whose edges may also lead back.

What the model decides and what the code decides
The ground rule: whatever can run deterministically is a fixed node or a fixed edge, such as scaffolding commands, schema checks and the routing between phases. Language models only come in where the task is genuinely open: research, formulating the strategy, writing the code and judging the metrics. That way every phase change appears in the log as a distinct status value, and the token cost of a thread stays bounded.

Research, implementation and review have fixed limits: at most 15 research rounds, five implementation attempts, five rework rounds and a single new research round after the review. Without them, a model stuck on a structural problem could produce any number of tool calls, and costs with them. A trading bot only counts as implemented once the commands aq-smoketest and aq-register pass. Grok 4 Fast handles research, implementation and review, Claude Sonnet 4.6 the planning and the parameter variants.
The review sets just one field
The review produces up to ten parameter variants that run in parallel as backtests on the training data. The model then only receives aggregated metrics and log excerpts, not the raw event stream, and decides between research, coding and pass. Which edge follows is decided by a router function in code. Only pass releases the holdout, which runs as the final node without feedback to the model.


Waiting without blocking a worker
Backtests run asynchronously in the Go backend. Instead of tying up a worker all that time, the graph interrupts itself: its state is stored as a checkpoint in the backend and the worker is released. When the backend reports the run as finished, a worker loads the checkpoint and resumes the graph exactly where it stopped, even if it is a different worker.

What the evaluation shows
Twelve strategy ideas, each run five times, gave 60 threads on data for AAPL, SPY and NVDA.
- The pipeline is reliable: all 60 threads passed smoke test, registration and holdout backtest. 43 implementations were accepted without rework, the other 17 after a single round.
- Precise instructions are implemented: for the specific prompts, all required rules were in the code in 28 of 30 threads.
- Results vary widely: the same prompt led to strategies with a different time frame, a different number of trades and markedly different returns. A single run says little about the character of an idea.
- Overfitting remains visible: 17 threads showed the typical pattern of a good training and a weak holdout result, and almost a quarter had fewer than 20 trades in the holdout. That is exactly why the split between training and holdout is built into the graph.
What I take away
Agents quickly produce many strategies that look good in a backtest. The real value of the platform lies in the validation that weeds out such lucky hits.