# LLM TRADER BOT

> Source: <https://dev.to/qrak/llm-trader-bot-3625>
> Published: 2026-07-29 23:13:41+00:00

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.

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.

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.

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.

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.

``` python
@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
```

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.

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.

Optiver found LLMs can explain expected value but can't execute it. My EV Framework computes:

The LLM provides the reasoning. The EV Framework provides the math. If the LLM says "strong buy" but EV comes back negative — HOLD.

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.

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.

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:

`main`

133 commits since the agent system was introduced. Every one tested. Every one documented.

Every AI response passes through:

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.

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).

Month-to-month cost: **0 zł**. Not "almost free." Free.

```
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
```

Dashboard at `localhost:8000`

. Windows users: `scripts/experimental_branch.ps1`

.

**What this bot IS:**

**What it's NOT:**

*Built in Wrocław, Poland. No degree. No bootcamp. Just Python, asyncio, and thousands of hours after warehouse shifts.*

**☕ Support:** [buymeacoffee.com/qrak](https://www.buymeacoffee.com/qrak) — every coffee = real API calls

**📊 Live:** [semanticsignal.qrak.org](https://semanticsignal.qrak.org) — watch it trade in real time

**📚 More:** [qrak.org](https://qrak.org) — research, articles, free resources (AdSense-supported)
