File size: 1,957 Bytes
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
5afc99d
fc81fa3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Autonomous Trading Agents

Autonomous Trading Agents is a multi-agent AI system where four independent AI traders β€” each modelled on a legendary investor β€” autonomously research financial news, make portfolio decisions, and execute real stock trades every hour. Built with the OpenAI Agents SDK, MCP (Model Context Protocol), and Gemini 2.5 Flash.

## What It Does

Four agents run concurrently using Python asyncio. Each agent reads its current portfolio, calls a Researcher sub-agent to search the web for relevant financial news, checks live stock prices via Polygon.io, and executes buy or sell trades. Every decision and trade is logged to a SQLite database and displayed in a live Gradio dashboard.

The trading is simulated β€” each agent starts with $10,000 β€” but the stock prices are real, sourced from Polygon.io.

## The Four Traders

Each agent has a distinct strategy inspired by its namesake investor. Warren follows value investing β€” patient, long-term, focused on fundamentals. George is a macro trader β€” bold and contrarian. Ray is systematic and risk-balanced across asset classes. Cathie focuses on disruptive innovation and crypto ETFs. Agents can also rewrite their own strategy over time using a dedicated tool.

## What Makes It Interesting

The system uses a three-tier agent hierarchy β€” an orchestrator coordinates four trader agents, each of which spins up a Researcher sub-agent on demand. MCP servers handle tool access for web search, market data, memory persistence, and push notifications. A custom TracingProcessor hooks into the SDK's internal observability pipeline to surface real-time agent activity in the dashboard. Agents alternate between a trade mode (find new opportunities) and a rebalance mode (review existing holdings) on successive runs, keeping each LLM call focused.

## Tech Stack

Python, OpenAI Agents SDK, Gemini 2.5 Flash, MCP, Polygon.io, Tavily, SQLite, LibSQL, Gradio, Plotly, Pydantic.