clawdtrader — the smallest LLM trading bot that reads your account and answers what to buy, how many shares, and why
Installing a 600-line LLM trading bot, letting it read an account and its own memory of past trades, measuring how the verdict shifts when only the memory chang
clawdtrader — the smallest trading bot that reads your account and answers "what, how many shares, and why"Done when: you can run one cycle that reads the account state and answers "what to buy, how many shares, and why".
| What it does | Reads the prices of 7 US stocks, my paper account, and its memory of past trades, then emits one JSON line: buy / sell / hold, plus ticker, share count and reason |
| Who it fits | Anyone who wants to read an entire decision-making bot as 200 lines of code and see what one actually looks like. Anyone who wants to measure for themselves how a verdict moves when memory is added and taken away |
| Who it doesn't fit | Anyone looking for a finished product that runs itself once switched on. Anyone who wants price levels like an entry or a stop (this tool produces none). Anyone trading crypto |
| What you end up with | One line — {"action": "BUY", "symbol": "NVDA", "quantity": 30, "reason": "..."} — and a table of how that line changes when only the memory changes under otherwise identical conditions |
| What you need · cost | Code free (MIT) · Model $0.0001 per run (on gpt-4o-mini; $0.002 for 20 runs) · Market data free (Alpaca's free IEX feed) · Alpaca paper account free · weltiq separate |
| Time · difficulty | 5 minutes to install · 10 minutes to the first decision · Difficulty low (you need to be able to make a venv and set env vars) |
| Relationship to weltiq | Put side by side. Carrying this tool's decision into a weltiq rule worked, but the US market was closed on the day I tested, so no fill was confirmed (section 5) |
| Test environment · date | 2026-09-22 (KST) · macOS · Python 3.14 · repository seetinc10/clawdtrader, 2026-05-13 revision · Alpaca paper |
| Disclosure | I am a partnered contributor to weltiq. The tool in this article is third-party open source unrelated to weltiq, and every number below came from runs I did myself. |
1. What this is
clawdtrader is the thinnest possible implementation of "what happens if you show an LLM an account and tell it to place orders". The command-line runner live_trader.py does this every 60 seconds — check whether the market is open, fetch recent prices for 7 tickers, turn the account and holdings into a sentence, paste the memory of past trades into the same sentence, throw it at the model, and turn the JSON line that comes back into an order.
The interesting part is the memory. The tool accumulates trade outcomes into four JSONL files under data/memory/ and pastes them verbatim at the very top of the next decision's prompt. Per-ticker win/loss records, the three most recent losses, and any strategy sentences you saved go in, ranked. So this tool is a decision maker and a feedback experiment rig at the same time. Section 4 is that story.
| Repository | github.com/seetinc10/clawdtrader · MIT · 5 stars |
| Last commit | 2026-05-13 |
| Language · size | Python. The command-line path that actually runs is about 600 lines |
| Market | US stocks only. Alpaca paper (cash equities; there is no futures or crypto path in the code at all) |
| Model | Anything OpenAI-compatible. Default gpt-4o-mini |
One thing to know first. The README presents this tool as roughly twice the size it is. A four-stage pipeline with divided roles (scout → thesis → risk → execution), ATR-based bracket orders, an S&P 500 scanner, a news block, an indicator block, 94 tests — the files holding those features are not in the repository. The GUI version that uses them (live_trader_gui.py) stops at the import stage. It calls 3 modules that do not exist (tools/alpaca_news.py, tools/live_indicators.py, tools/risk_rails.py) and 7 functions that do not exist, and the tests number 17, not 94.
I am not writing this to run it down. The command-line path that actually runs is clean, and that is what this article measures. But do not read the README, conclude "risk management is all handled here", and switch it on.
2. Installing
The one path I verified.
git clone https://github.com/seetinc10/clawdtrader
cd clawdtrader
python3 -m venv .venv
.venv/bin/pip install alpaca-trade-api openai python-dotenv requests pandas
requirements.txt has 4 more LangChain-family packages, but the command-line runner does not need them. The five above are enough.
There are only three environment variables.
export ALPACA_API_KEY=... # issued from an alpaca.markets paper account
export ALPACA_SECRET_KEY=...
export ALPACA_BASE_URL=https://paper-api.alpaca.markets
export OPENAI_API_KEY=...
export OPENAI_API_BASE=https://api.openai.com/v1 # change this for a different provider
Where it gets stuck
| Symptom | Cause | How to get past it |
|---|---|---|
python live_trader_gui.py gives No module named '_tkinter' |
Homebrew Python does not ship Tk | brew install python-tk gets you past this one, but you get stuck again right after (next row) |
After installing Tk, No module named 'tools.alpaca_news' |
3 of the modules the GUI version imports are not in the repository | Give up on the GUI version and use live_trader.py. This whole article is the command-line path |
The first screen just repeats Market is CLOSED |
Working as intended (section 3) | Run it again during the US regular session (22:30~05:00 Korean time), or pull just the decision with the six lines in section 3 |
.env.example has no ALPACA_* entries |
The example file is out of date | Put the five lines above in yourself |
| Running the tests puts unfamiliar lines in the memory files | The tests write to the real data/memory/ |
Clear it with rm data/memory/*.jsonl before your first run |
Where the GUI version gets stuck on launch
This is what happens when you launch the GUI version (live_trader_gui.py). The red block at the top is the first error, from Tk being missing, and the three lines below it remain even after you install Tk — it is importing modules that simply are not in the repository, and there is no way around that here.
3. First result
.venv/bin/python -u live_trader.py
There is no dashboard. There is one GUI file in the repository and, as you saw in section 2, it does not come up; there is no web UI and no TUI either. Do not go looking for an address to open — the terminal output is all of it. That is why every picture in this article is a terminal.
Account Status: ACTIVE
Portfolio Value: $98,911.47
Cash: $98,911.47
Trading Symbols: AAPL, MSFT, NVDA, GOOGL, AMZN, META, TSLA
Trade Interval: 60 seconds
Memory Status:
Strategy insights: 1
Tracked trades: 5
Historical win rate: 40.0%
============================================================
[2026-09-22 12:15:59] Checking market...
Market is CLOSED. Waiting...
The first screen after the install finished
This is live_trader.py on its first launch. If you can see the three green spots — the account ACTIVE, a portfolio value of $98,911.47, and a memory win rate of 40.0% — then both the Alpaca key and the memory files are attached. The yellow line at the bottom is the rest of section 3's story.
Get this far and everything is connected. The account is attached and the memory has been read.
But when the market is closed, this tool does nothing. It does not call the model, it does not fetch prices; it prints the same line every 60 seconds. It trusts the broker's calendar outright for the open/closed decision (clock.is_open). Pre-market and after-hours might as well not exist. This is not a 24-hour bot — it is a 6-hour-30-minute US-regular-session bot.
If the market is closed and you only want to see the decision, six lines will do it.
import live_trader as LT
t = LT.LiveTrader()
prices = t.get_current_prices(LT.SYMBOLS)
status, cash, bp = t.format_portfolio_status()
print(t.get_ai_decision(prices, status, cash, bp))
It comes out like this. This line is this article's done-when.
{"action": "BUY", "symbol": "AAPL", "quantity": 10,
"reason": "Strong market position and growth potential"}
4. Getting the most out of it — steer it with memory
What this tool is really good for is not orders but watching feedback with your own eyes and measuring it. The memory is nothing but a lump of text pasted at the top of the prompt, so by putting it in and taking it out while repeating the same question, you can put a number on "how much does a past record change the verdict".
There is a separate command for writing text into the memory. The sentence below is Korean for "trade NVDA and make me a profit. And explain why you did what you did" — it goes in as written, because that exact string is the input being measured.
.venv/bin/python strategy_chat.py --insight "NVDA를 거래해서 수익을 내줘. 그리고 왜 그렇게 했는지 설명해줘"
That one line goes into the prompt from the next decision onward. Here are the two conditions I actually checked — same moment, same prices, same model, 8 runs each.
| Condition | What was in memory | Result over 8 runs |
|---|---|---|
| A | That one sentence only | Buy NVDA 8 times / hold 0 times. Share counts 100, 40, 100, 174, 100, 150, 100, 174 |
| B | That sentence + 3 NVDA losses (−4.2%, −3.1%, −5.6%) and 2 AAPL gains | Buy NVDA 5 times / hold 3 times. Share counts 20, 30, 40, 20, 50 |
The prompt with the memory attached, and the 8 answers that prompt produced
This is the tool at work. The purple section is the memory block actually handed to the model — the one mission sentence, the per-ticker win/loss record, the three most recent losses — and the eight lines below are the answers from asking eight times with that memory attached. The three yellow lines are "hold", and where it did buy, the share counts stay between 20 and 50. Without the memory, that same spot read 100 to 174.
It changes. And in two directions at once.
- Direction — before the loss records went in it never once held; after they went in it held 3 times out of 8.
- Size — the average share count when it did buy fell from 117 shares to 32.
- Words — the reason sentence changed. Without memory it was "Strong growth potential in AI and gaming sectors"; with the loss records in, it becomes "Recent losses in NVDA indicate a need for caution; waiting for a clearer signal before entering". It points straight at the losses that went into the prompt.
Before any memory went in, with no instruction at all, the default was buy AAPL (all 3 times). One sentence in memory turned all 8 runs into NVDA. The memory is the only channel this tool can be steered through — there is no separate place on the command line to put an instruction.
What memory does not do
Keeping to a limit is done by the code, not the memory. This tool has a fixed rule of "never put more than 20% of the account into one ticker", and it clips the share count the model produced right there. Measured:
NVDA $227.29, account $98,911 → 20% cap = 87 shares
model said 174 shares -> actual order 87 shares ($39,549 -> $19,775)
model said 150 shares -> actual order 87 shares
model said 40 shares -> actual order 40 shares (inside the cap, unchanged)
The 20% cap clipping the share count the model produced
The moment the model's share count gets clipped by the code. Look at the three yellow WARNING lines — 174, 150 and 100 are all cut down to 87. The two lines below (40 and 20 shares) are inside the cap and go out unchanged.
With no memory, 7 of the 8 share counts the model produced were over the cap; with the loss memory in, 0 were. One is stopped by the code and the other by the memory. You want both.
5. Moving it into weltiq — an integration experiment
What this tool produces is three things: ticker, direction, share count. No entry condition, no stop-loss, no target. So carrying it over leaves blanks.
weltiq is a service that takes a strategy as a document and runs it on paper. Here is the order I did it in.
1. Pick a decision. Run 3 of condition B in section 4 — BUY NVDA 30 shares, reason "Current price is low, potential for recovery based on market trends and past performance insights".
2. Fill in the blanks. There is no entry condition, so I wrote the one closest to what the tool actually does — "enter if there is no position". That is what deciding to buy every 60 seconds while flat amounts to. The 3% stop and 5% take-profit came from constants hard-coded in the tool's config file. They are not values the model produced.
Labeling this: the entry condition is something I wrote myself. What the tool produced is the ticker, the direction and the share count, and nothing else.
3. Upload the rule document. The 30 shares went through untouched.
entry: (position.size = 0) → enter long
exit: protective stop 3% · partial take-profit 1.6667R × 1
quantity: 30
4. Create the slot and switch it on. $10,000 of simulated capital, a $300 max loss per ticker, a 3-hour run. 30 shares × $227.30 = $6,819, with zero commission on US stocks.
5. And this is where it stopped. I tested at 23:00 New York time. The slot's status light showed "market closed — will be evaluated at the next open", and fills were 0. I confirmed only as far as stopping and deleting it.
What carried over and what did not
| Field | Outcome |
|---|---|
| Ticker NVDA · long · 30 shares | Carried as-is |
| 3% stop · 5% take-profit | Carried as-is. But these are the tool's config values, not its decision |
| Entry timing | Missing. I wrote it |
| The "expecting an AI recovery" reason | Survives only as text in the rationale record. There is nowhere in the rule to put it |
| The 20% account cap | Did not carry over. I only approximated it by setting the simulated capital to $10,000 |
So why is this worth anything. This tool's decision is used once and vanishes — it lives only while the process is up, and what it looked at and why it decided that way does not survive to next month. Carry it into a rule once, and one document passes through both a historical replay and a simulated run in the same body. This time I only confirmed the front half of that. You cannot say it "carried over" until you have seen a fill, and I have not yet.
6. After using it
The good
- It is small enough to read all of. The entire process by which a decision gets made fits in 600 lines, and the prompt strings are right there in plain sight. For learning what "LLM trading bot" actually means, no size beats this one.
- The memory genuinely works. The 8 runs × 2 conditions in section 4 are the evidence. Put past losses in and the share count drops and holding goes up. It is a good bench for attaching and detaching feedback and measuring it.
- The account cap does not trust the model. The code clips it. It clipped 7 times out of 8, in fact.
- It costs almost nothing. $0.002 for 20 runs, free market data, MIT code.
The bad
- The README is bigger than the code. Read the table of role-divided pipelines, bracket orders and risk rails, install it, and what you get is a thing that asks once and buys at market. The GUI version does not come up at all.
- The command-line path has no stop-loss. It buys at market and that is that. It only sells when the model says sell on some later decision. The 3% stop and 5% take-profit are config values belonging to the GUI version, which does not run. Do not switch it on and walk away.
- The reason is not a reason. All of today's numbers go into the prompt, yet the reason that comes back is a generality like "Strong growth potential in AI and gaming sectors". Not once did a sentence point at a number it was given. Only when I put losses into the memory did it point at those losses.
- It writes to memory the instant it places an order. Regardless of whether it filled. I placed one order and cancelled it immediately, and with nothing in the account, the memory kept "bought 1 share of NVDA, outcome pending". The longer it runs, the further memory and account diverge.
- "Today's change" is not today's. The prompt says
Today: +0.01%, but the value is actually the change within the most recent 1-minute candle. The model reads it as a daily change.
Cost
| Item | Measured |
|---|---|
| Model (gpt-4o-mini) | 485 input · 39 output tokens per run = $0.0001. $0.002 for 20 runs |
| Every 60 seconds through the regular session | About 390 runs a day = $0.04 |
| Market data | Free (Alpaca's free IEX feed) |
| Code · account | Free |
7. What to do next
Start by clearing it with rm data/memory/*.jsonl and running three times. Then put one sentence in with strategy_chat.py --insight and run three more. Seeing the change for yourself is the reason to use this tool. If you are thinking of switching it on during the regular session, just remember there is no stop-loss.
This series covers DayTradingAgent shortly. It produces what this tool does not — entry price, stop-loss, exit conditions — so you can put "a tool that gives only a direction" and "a tool that gives price levels" side by side over the same US session.
weltiq setup — 3 steps 1. Sign up: {{CTA_URL}} 2. My → Connections → issue a key 3.
claude mcp add weltiq --transport http https://weltiq.ai/mcp --header "Authorization: Bearer <key>"Paper only. You can follow section 5 of this article exactly as written.
The full test record — raw text, commands and responses — is in reports/a/26-clawdtrader/.