openprophet.io | learn | github
Trading with AI: How LLM Agents Trade Stocks
AI trading agents use large language models — Claude, GPT, Gemini — to autonomously research markets, make trading decisions, and execute orders. Unlike traditional bots that follow hardcoded rules, these agents reason about market conditions in natural language, read news, and adapt strategies in real time.
How It Works
- Wake up — Agent activates on a schedule (heartbeat). In OpenProphet, intervals vary by market phase — every 2 minutes at open, every 10 minutes midday, every hour when closed.
- Gather information — Calls tools to check portfolio, read news, get quotes, scan options chains.
- Analyze and reason — LLM processes all data. Reads headlines, interprets RSI/MACD, checks past trades for similar setups, evaluates risk.
- Decide — Buy, sell, hold, or do nothing. Logs reasoning for every decision.
- Execute — Places orders through the brokerage API.
- Sleep — Dormant until next heartbeat.
How This Differs from Algorithmic Trading
Traditional algo bots (like Freqtrade) execute predefined rules: "if RSI < 30 and MACD crosses up, buy." The developer codes the rules. The bot cannot adapt to unanticipated situations.
LLM agents are different:
- They read news. An AI agent can read that the Fed raised rates and factor it in. A rule-based bot cannot.
- They reason about context. "Stock down 8% today, but it's sector rotation, not company news. Options chain shows heavy put selling at support. Buying opportunity." No hardcoded rule captures this.
- They learn from experience. With vector memory, the agent searches past trades for similar setups and checks outcomes.
- They explain themselves. Every decision includes written reasoning you can review.
The Risk
AI trading agents carry unique risks:
- Hallucination — LLMs generate plausible but incorrect analysis. Agent might misinterpret a headline or miscalculate position size.
- Instruction non-compliance — Even with strict rules, LLMs sometimes ignore constraints.
- Non-determinism — Same conditions can produce different decisions on different runs.
This is why paper trading first. Alpaca provides free paper trading with real market data and simulated execution.
Models Used
- Claude Sonnet 4 (Anthropic) — Strong reasoning, good at following complex trading rules. Default in OpenProphet. $3/$15 per MTok.
- Claude Opus 4 (Anthropic) — Highest reasoning. Better for complex multi-leg options. $5/$25 per MTok.
- GPT-4o (OpenAI) — Fast, capable tool use. Available via OpenRouter.
- Gemini 2.5 Pro (Google) — Strong at data analysis. Also used internally for news cleaning.
Getting Started
- Create a free paper trading account at Alpaca
- Set up OpenProphet — clone from GitHub or use the Premium Setup Guide
- Configure your LLM provider
- Start with a conservative strategy on paper money
- Review decisions in the dashboard and daily logs
See Also
OpenProphet is experimental software. AI agents can hallucinate and result in total loss of an account. We never recommend connecting real money. This is not investment advice.
CC BY-NC 4.0 · Jake Nesler · Source on GitHub