Let me tell you a story about failure.
Late 2024. I'm sitting in my Wrocław apartment after an 8-hour warehouse shift. My back hurts. I've been trying to make a trading bot work for two weeks. Every night, same result: the LLM generates beautiful-sounding analysis. Confident. Articulate. Completely wrong.
"RSI is 28, oversold. BUY."
Next morning: -4.2%.
The problem wasn't the LLM being stupid. It was me being lazy. I was dumping numbers into a prompt and hoping for magic — the exact thing every "LLM trading bot" tutorial on YouTube tells you to do.
I had three options: give up, buy a course, or do what nobody else was doing — read the actual research papers. I chose option three. 77 papers later, I understood the real problem. And I built something that fixes it.
1. Chart Vision — The LLM Reads Candlestick Images
Every cycle, the bot generates a 4K PNG candlestick chart with 5 overlay indicators (SMA, RSI, Volume, CMF, OBV). This image goes directly to Google Gemini 3.6 Flash. Not as bytes. Not as a data URL. As a visual inference.
I spent two weeks coding pattern detection algorithms — head and shoulders, wedges, trendlines. Then I compared the AI's visual reads against my code. The AI was better. By a lot. I deleted 900 lines of pattern detection code. Never looked back.
2. 50+ Indicators, JIT-Compiled Locally
No pandas-ta. No TA-Lib. I built the entire indicator engine from scratch Let me tell you a story about failure.
Late 2024. I'm sitting in my Wrocław apartment after an 8-hour warehouse shift. My back hurts. I've been trying to make a trading bot work for two weeks. Every night, same result: the LLM generates beautiful-sounding analysis. Confident. Articulate. Completely wrong.
"RSI is 28, oversold. BUY."
Next morning: -4.2%.
The problem wasn't the LLM being stupid. It was me being lazy. I was dumping numbers into a prompt and hoping for magic — the exact thing every "LLM trading bot" tutorial on YouTube tells you to do.
I had three options: give up, buy a course, or do what nobody else was doing — read the actual research papers. I chose option three. 77 papers later, I understood the real problem. And I built something that fixes it.
1. Chart Vision — The LLM Reads Candlestick Images
Every cycle, the bot generates a 4K PNG candlestick chart with 5 overlay indicators (SMA, RSI, Volume, CMF, OBV). This image goes directly to Google Gemini 3.6 Flash. Not as bytes. Not as a data URL. As a visual inference.
I spent two weeks coding pattern detection algorithms — head and shoulders, wedges, trendlines. Then I compared the AI's visual reads against my code. The AI was better. By a lot. I deleted 900 lines of pattern detection code. Never looked back.
2. 50+ Indicators, JIT-Compiled Locally
No pandas-ta. No TA-Lib. I built the entire indicator engine from scratch using NumPy and Numba. Every EMA, SMA, MACD, ADX, Stochastic, Bollinger Band, TTM Squeeze, Ichimoku, and 11 moving average variants compiles to machine code on first call and caches the result.
@njit(cache=True)
def _ema_numba(prices, period):
alpha = 2.0 / (period + 1)
result = np.empty_like(prices)
result[0] = prices[0]
for i in range(1, len(prices)):
result[i] = alpha * prices[i] + (1 - alpha) * result[i - 1]
return result
Enter fullscreen mode Exit fullscreen mode
50 indicators. All custom. All JIT-compiled. All running in microseconds on a CPU. No CUDA. No cloud. Just a Ryzen 5700G on my desk.
3. Bull vs Bear Debate — One Prompt, Two Sides
TradingAgents spawns separate agents for bull and bear analysis. Smart, but each one costs an API call. My bot gives the LLM a single instruction: argue the bullish case first (with evidence), then argue the bearish case (with the same rigor). Then decide.
One prompt. Both perspectives. Zero extra tokens. The model holds both arguments in context simultaneously — it can't "forget" the counter-argument halfway through.
4. EV Framework — What Optiver Said LLMs Can't Do
Optiver found LLMs can explain expected value but can't execute it. My EV Framework computes:
- Win rate from trade history, filtered by similarity to current setup
- Average win size vs average loss size
- Expected P&L = (win_rate × avg_win) - ((1 - win_rate) × avg_loss)
- Kelly fraction sizing based on account equity
- Risk/reward validation before signal acceptance
The LLM provides the reasoning. The EV Framework provides the math. If the LLM says "strong buy" but EV comes back negative — HOLD.
5. Falsification Check — Name the Price That Proves You Wrong
Before any signal is accepted, the LLM must write one sentence:
"This signal would be proven wrong if [specific price level or indicator condition] occurs."
If it can't name one — rejected. If the named condition triggers — position closed early. If the condition is vague — rejected, try again. This single prompt addition improved signal quality more than any other change.
6. Vector Memory — The Bot Remembers Its Mistakes
Every closed trade gets embedded as a vector with 15+ metadata fields: symbol, direction, entry price, exit price, P&L percentage, max adverse excursion, timeframe, ADX at entry, trend strength, RSI, volume trend, pattern detected, news sentiment score, surprise ratio, and closed timestamp.
On every new analysis cycle, the bot queries ChromaDB (now on BAAI/bge-base-en-v1.5 768D embeddings): "Find me the 5 most similar trades to this current setup." These 5 trades are injected into the LLM prompt with their outcomes. Time-decay ensures recent trades carry 3x more weight than old ones.
7. Eight AI Agents Maintaining the Codebase
In the .ai/ directory, eight specialized agent prompts — one Supervisor plus seven workers. Each has a dedicated scope, journal, and personality. They've produced real commits:
- Supervisor — Routes work, scans codebase via vector search
- Bolt — Performance: found a sync file read in an async loop (40ms fix)
- Palette — UX: ARIA labels, toast notifications, collapsible panels
- Sentinel — Security: rate limiting, CSP headers, API key isolation
- Refactor — Clean code: killed 27 isinstance chains, enforced DI pattern
- Concise — Code reduction: cut 380 lines across the prompt builder
-
Bugfixer — Regressions: caught 3 bugs before they hit
main - Smoke Tests — Pre-flight: syntax, import scan, ruff lint before every commit
133 commits since the agent system was introduced. Every one tested. Every one documented.
8. Validation Pipeline — Never Trust Raw LLM Output
Every AI response passes through:
- TrendValidator — cross-checks LLM-reported trend against actual ADX calculations
- PatternQualityScorer — deterministic score from real detection, not self-reporting
- Falsification Check — reject signals that can't name their failure condition
- 6 Risk Guards — symbol whitelist, max position, cooldown, min R:R, SL/TP validity
9. Zero-Cost Sentiment — No API Keys
Reddit JSON (free, no auth), X/Twitter via Nitter (public feeds), RSS from CoinDesk, CoinTelegraph, Decrypt, CryptoSlate — enriched via Crawl4AI. All processed through a RAG engine built on ChromaDB. No monthly bills. No API rate limits.
The Test Suite
1,324 tests. Fully mocked — no network, no ChromaDB, no LLM API. They run in about 60 seconds on any machine. Codacy CLI v2 + ruff for automated quality gates. AST-based codebase vector search for semantic navigation.
Coverage includes: LLM output corruption, async race conditions, rate limiting with exponential backoff, vector DB boundaries, friction reporting for all 6 guard types, closed-loop feedback injection, ticker retry with network timeout handling.
When Optiver says LLMs "fail to incorporate new information after acting" — my tests verify the bot doesn't do that. When the arXiv survey says reproducibility is the bottleneck — my tests are deterministic.
☕ This project is 100% self-funded. No company. No investors. Just a warehouse worker paying for servers and API keys. If this gave you an idea or saved you time — Buy Me a Coffee helps keep it running. qrak.org has more free content (AdSense-supported — every visit helps).
What It Costs
- Google Gemini 3.6 Flash: free tier (1,500 requests/day)
- Technical indicators: CPU only (Numba JIT, microseconds)
- News + Sentiment: free (Reddit JSON, Nitter, RSS + Crawl4AI enrichment)
- Vector database: local ChromaDB, BAAI/bge-base-en-v1.5 768D embeddings
- Hosting: home server (Ryzen 5700G, 32 GB RAM)
- Dashboard: Cloudflare Tunnel (free tier)
Month-to-month cost: 0 zł. Not "almost free." Free.
Quick Start
git clone https://github.com/qrak/LLM_trader.git
cd LLM_trader
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp keys.env.example keys.env
python start.py
Enter fullscreen mode Exit fullscreen mode
Dashboard at localhost:8000. Windows users: scripts/experimental_branch.ps1.
Honest Limitations
What this bot IS:
- A research-grade, open-source LLM trading engine
- Paper trading only (real execution via separate CCXT service)
- Fully transparent — every prompt, response, and trade log is inspectable
- Self-improving through reflection engine
What it's NOT:
- A get-rich-quick scheme
- A production trading system (yet)
- Something you should trust with real money without extensive testing
Links
- Source: github.com/qrak/LLM_trader
- Live Dashboard: semanticsignal.qrak.org
- Landing Page: qrak.org
- Buy Me a Coffee: buymeacoffee.com/qrak
- Email: [email protected]
Built in Wrocław, Poland. No degree. No bootcamp. Just Python, asyncio, and thousands of hours after warehouse shifts.
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.