Practical Guides · knowledge base from X

A trading terminal that learns from its own rejections — Fable 5.2, seven free GitHub repos (Kronos, dspy, mem0…) and nine prompts, from the rules file to paper trading with a risk gate

A build guide to have Claude Code with Fable 5.2 write a paper-only trading terminal that downloads real bars from Kraken, splits the data into train/validation/locked test, tries two strategy families with fees from day one, runs them through a four-check risk gate, stores in mem0 the reason for every rejection and uses dspy to rewrite the prompt that proposes ideas. Nine complete prompts, a CLAUDE.md rules file and seven repos (three used, four as a source of ideas). In the author's real run, 18 candidate strategies on 560 ETH/USD bars: all blocked, nothing deployed.

✍️ ludoonchart · @ludoonchart
🔗 Read the original on X · X Article · published 10 Nov 2026
📊 108 likes · 440 bookmarks · 163k views
Summary and adaptation in English; content and results belong to the author.

Part of the manual Trading and investing — the complete manual

Claimed result

The only result is an honest negative result: in the author's run, 560 real 5-minute ETH/USD bars from Kraken (7 to 9 November 2026), the agent generated 18 candidate strategies and none of the 18 passed the risk gate: nothing was deployed and the terminal stayed on paper. The author presents it as proof the system works («a tool that approves everything is a slot machine»). There are no returns and no promises of profit.

That's why the proof level is medio-basso: the process was actually run (with screenshots in the original article), but it only proves the filter works, not that the system will ever find an edge. The launch post opens in clickbait tones («this is f*cking gold», «i pulled the full guide») but the body is unusually sober. The author has about 4,900 followers; 440 bookmarks on 108 likes point to «keep this» material.

The key idea

A trading terminal isn't one prompt: it's a chain (fetch data, write an engine, backtest, filter, store lessons, rewrite prompts, render a dashboard) where each step depends on the previous one. A model that loses the thread halfway ships a terminal that looks right and is quietly wrong. Fable 5.2 is used because it holds long chains (keeps a plan, runs its own scripts, reads the errors and fixes them) — and above all for checking, not only writing: in every prompt the rule is that it has to print the numbers from a script it ran. «You are not asking it to be right. You are making it show its work.»

The loop: bars go in → Kronos and the strategy families propose candidates → the backtest scores them → the gate blocks or allows each one → mem0 stores why → dspy rewrites the proposal prompt → next round. «Everything after the gate is the self-improving part. The gate is the part that keeps it honest.»

Step-by-step playbook

The model: what Fable 5.2 is and when it's worth the price

  • Anthropic's top public line, one tier above Opus; «Mythos class»: Fable and Mythos share the model, Fable has extra safety classifiers for biology and cybersecurity. Fable 5.2 came out on 9 November 2026; according to Anthropic it is a step above Opus 5.5 in almost all evaluated capabilities and up to 30% faster output than Fable 5.1.
  • Anthropic's demo on long tasks: a team of 1,000 Fable 5.2 agents formalized Fermat's Last Theorem in 30 hours (with 12 hours of resumption); with the same setup Opus 5.5 reached 26% in 18 hours. Not reproducible by one person, but it's the skill this build leans on.
  • A test by Felix Rieseberg: a first-person shooter made «from scratch» with one-shot prompts and no human feedback, about $550 at API pricing, about 2.7M output and 445M input tokens (heavily cached), 8 hours.
  • How to read the benchmarks: FrontierCode and FrontierSWE (agentic coding), Terminal-Bench-Science (agentic research), OSWorld (computer use) are close to what this needs; none measures trading: they're a signal about the builder, not the strategies. Fable doesn't win everything: Gemini 4 Carbon leads on AutomationBench, Opus 5.5 on the AA-Briefcase Elo.
  • Effort levels and cost: in Anthropic's FrontierCode 2.0 test, Fable 5.2 at High matched Opus 5.5 at Max for about half the cost per task; Xhigh scored the highest of any model tested; Max scored below Xhigh. Medium is the default in the apps and in Claude Code. The cost axis is logarithmic: each step up buys less than the one before.
  • Price: at the Fable 5 launch the API cost $10 per million input tokens and $50 output, twice Opus 4.8: check current pricing before budgeting (another source from the same period gives $8/$40 for Fable 5.2 [@RohOnChain#fabbrica-strategie-fable-52-quattro-cancelli-permutazione]).
  • The safety classifiers can reroute some requests to a smaller model; for data, backtests and dashboards this shouldn't happen.
  • When to use it: the plan, the first build of each module, debugging a failing backtest, reviewing its own code for look-ahead leaks. When not: renaming a variable, changing a colour, reformatting output. Switch with /model inside Claude Code.

The seven repos (about 250,000 stars in total; $0 in software, you pay only for the model)

# Repo Stars What it is Role in the terminal
1 Kronos (shiyu-coder/Kronos) 47.5k foundation model for candlesticks, decoder-only, pre-trained on K-line data from over 45 exchanges, MIT licence; mini/small/base models on Hugging Face forecasting: takes the latest OHLC bars and predicts the next ones (KronosPredictor class); the forecast is one more strategy family — long only if it beats the last close by more than fees — and goes through the same gate
2 dspy (stanfordnlp/dspy) 39k Stanford's framework for «programming» models instead of hand-writing prompts self-improvement: describe a step's input/output and a metric, dspy searches for better instructions; here the step is «propose a strategy» and the metric is how many proposals pass the gate on validation data
3 mem0 (mem0ai/mem0) 68.7k memory layer for agents memory: one short lesson per blocked candidate (e.g. «EMA crossover blocked: validation return negative»), read at the start of each round
4 RD-Agent (microsoft/RD-Agent) 15.3k Microsoft framework to automate data-driven R&D, with a quant finance version; the README reports about 2x the annual return of benchmark factor libraries with over 70% fewer factors, for under $10 reference model for the propose-test-adopt loop
5 gs-quant (goldmansachs/gs-quant) 14k Goldman Sachs' Python toolkit for quantitative finance (derivative structuring, trading, risk management, statistics), Apache-2.0 most APIs need GS credentials: a book to read (risk kept separate), not a library to install
6 magic-trace (janestreet/magic-trace) 6.4k Jane Street tool that records what a program was doing before something went wrong and shows it on a timeline (rolling buffer, snapshot on trigger), MIT; Linux on Intel CPUs source of ideas: record what happened before a failure
7 daily_stock_analysis (ZhuLinsen) 69.4k free AI analyst that runs itself with GitHub Actions (weekdays, skipping non-trading days), reads quotes, indicators and news and sends a decision report to Telegram, Discord, Slack, email; built for stocks, not crypto source of ideas for scheduled reports

Three repos become parts of the terminal (Kronos, dspy, mem0); the other four lend their best ideas. The author's comparison: a Bloomberg Terminal seat costs around $30,000 a year.

What you need

Claude Code with access to Fable 5.2; Python 3 and git; an empty folder; an evening (each prompt takes minutes, reading the output is what takes time). No exchange keys: nothing in this build places real orders.

Quick start (three commands): npm install -g @anthropic-ai/claude-code, mkdir trading-terminal && cd trading-terminal, claude.

Architecture (small files, one job each): data/bars_5m.json (real bars from Kraken), engine.py (strategies + backtest), gate.py (risk gate: ALLOW or BLOCK), memory.py (mem0: lessons from blocked ideas), optimize.py (dspy: rewrites the proposal prompt), dashboard.html (the terminal view).

Step 0 — Model and rules

In Claude Code: /model → Fable 5.2. Create a CLAUDE.md file the model follows in every session, with the hard rules written once: - Paper trading only, never real orders. - No look-ahead: a decision at bar t uses only bars ≤ t. - Fees: 2 bps per side on every trade, always. - The test window is locked: don't read it until I say «unlock test». - Every performance claim must come from a script you ran: print the numbers. - If something is uncertain, say so instead of guessing. Effort: High for the plan and the engine (where a wrong design costs most), Medium for small edits; Xhigh scored best in Anthropic's test but costs noticeably more.

Prompt 1 — Read the repos and plan (no code)

Structure: read CLAUDE.md and follow it; goal «plan a self-improving paper trading terminal for any asset»; don't write code. Step 1: clone Kronos, dspy, mem0 into ./repos and read README and docs (roles: forecasting, prompt optimization, memory of failed ideas). Step 2: write PLAN.md with (1) a short section per repo with its use and entry points to call, (2) a text diagram of the flow (bars → candidates → backtest → gate → memory → optimization → next round), (3) the file list with one line each, (4) the risks (look-ahead leaks, overfitting, API keys, cost of model calls), (5) open questions. Rules: no real orders, keys or brokers; if a README doesn't say something, write «not stated» instead of guessing. What you should see: a PLAN.md with a section per repo and the data flow. If it proposes real orders or keys, say no and have it re-read CLAUDE.md. It's the cheapest place to change direction.

Prompt 2 — Real data and a locked test window

Structure: write fetch_data.py; fetch about 2 days of 5-minute OHLC bars for ETH/USD (or any pair) from Kraken's public API (no key); save them to data/bars_5m.json with timestamp, open, high, low, close, volume; say how many bars were actually returned (Kraken returns at most 720 per call); sort by time, drop duplicate timestamps, report every gap longer than one bar; print first and last timestamp and bar count; split by time, never at random: first 60% train, next 20% validation, last 20% locked test. Check the printed range: 720 five-minute bars are about two and a half days, enough to build the pipeline and not enough to trust a result (Prompt 9 fixes that).

Prompt 3 — Strategies and an honest backtest

Structure: write engine.py with two families: (1) EMA crossover (long when the fast crosses above the slow, exit on the reverse cross), (2) z-score mean reversion (long when the z-score of price against its rolling mean drops below the entry level, exit when it returns to zero); a small parameter grid per family, stating the grid and the number of candidates. Requirements: no look-ahead (signal at bar t, fill at the open of t+1); fees of 2 bps per side from the very first backtest; backtest on train and validation only; table candidate / train return / validation return / max drawdown / trade count; two tests: one proving that shifting every signal one bar later changes the results, one proving fees are really charged. Definition of done: the table printed by a script it ran and both tests passing. Sample format (illustrative, not results): ema_9_21 +0.41% / −0.30% / 1.9% / 14; ema_12_26 +0.12% / +0.05% / 0.7% / 6; zscore_20_2.0 +0.22% / +0.10% / 0.8% / 1. If every candidate looks great, be suspicious: it usually means the backtest is peeking at the future.

Prompt 4 — The risk gate

Structure: add gate.py; a candidate passes only if all are true: (1) train return > 0 and validation return > 0; (2) the gap between them is at most 2 percentage points; (3) validation max drawdown at most 1.5%; (4) at least 2 trades in validation. Requirements: thresholds in one config block at the top of the file; a PASS or BLOCK verdict for every candidate; for every BLOCK the failed check and the numbers (e.g. BLOCK ema_9_21: validation return -0.30% <= 0); check all four rules and list every failure, not only the first; summary line (candidates, passed, blocked); the gate never reads the test window; don't loosen any threshold to get more passes: if everything is blocked, that's a valid result. Sample output: ema_9_21 BLOCK validation return <= 0, zscore_20_2.0 BLOCK validation trades 1 < 2. The gate is doing its job when the BLOCK list is long and every line has a reason (in the author's run: 18 out of 18 blocked).

Prompt 5 — Memory with mem0

Structure: add memory.py; after every gate run save one lesson per blocked candidate with name and family, the exact failed check, the numbers (train return, validation return, drawdown, trades) and the round number; at the start of every round read memory before proposing and don't propose a family or parameter set that already failed the same way. Requirements: never put API keys in code or prompts (environment variables, say which you need); if mem0 asks for a model or embedding provider, read the docs, pick a configuration and say what you chose; print the memory after each run; «strategy failed» is not enough: store the check and the numbers.

Prompt 6 — Self-improvement with dspy (with a spending cap)

Structure: add optimizer.py; define the proposal step as a dspy module (input: memory lessons and allowed families; output: list of candidates with parameters); metric: number of candidates that pass the gate on validation; optimize on train and validation only, never on the test window. Requirements: log the metric for every trial on train and validation separately; save the best prompt and the previous one to prompts/ with a version number; if the metric improves on train but not on validation, flag it as overfitting; model settings from environment variables. It's the most expensive step (dspy runs the prompt many times), so first: «print the maximum number of model calls and, if you can, a rough cost estimate; then wait for my OK. Limit it to 20 trials; if your settings would go above that, reduce them and tell me what you changed.» A prompt that improves on train and not on validation has «the same disease as an overfit strategy».

Prompt 7 — Dashboard and paper mode

Structure: one page of static HTML + JS that reads the files the pipeline writes, no server. Panels: (1) price chart with the train/validation/test windows marked, the test shown as locked; (2) candidate table with verdicts; (3) gate verdicts with the reason for every BLOCK; (4) memory feed with the latest lessons. Paper-only execution: limit orders only, a stop on every trade, a daily loss cap, a kill switch the strategy code cannot override (a separate module the strategy can't import or change), a visible banner «PAPER TRADING ONLY». No keys and no calls to any broker; kill-switch state always visible. Check: every candidate has a verdict, every BLOCK a reason, the kill switch is visible.

Prompt 8 — The full loop

Structure: run 3 rounds end to end; in each (1) read memory first and show it, (2) propose candidates with the current prompt, (3) backtest on train and validation with 2 bps, (4) gate, (5) save every blocked candidate with the reason, (6) optimize the prompt with dspy (respecting the 20-trial limit). After each round one line: candidates, passed, blocked, top reason. At the end the three rounds side by side and whether rounds two and three proposed anything different from round one. Rules: stop after 3 rounds, don't unlock the test window, don't loosen the gate between rounds. If in round one the memory read isn't wired in, ask it to show it at the start of the round.

Prompt 9 — More data before you believe anything

Structure: two days is too short; rebuild the data with a longer history (1-hour bars: Kraken returns up to 720 per call, about 30 days, or another reachable source, stated); same 60/20/20 time split, test still locked; re-run engine and gate with the same thresholds; report how many candidates still pass and compare with the two-day result (what passed before, what changed); if something passes list candidates and numbers, if nothing passes say so plainly; say what changed in the code and in the results. «A strategy that passes on two days of 5-minute bars and fails on a month of hourly bars was luck.» Only after this step do you say «unlock test».

How to check Fable's work

  • Have it re-run the backtest shifting every signal one bar later: a strategy that only works with perfect timing is probably leaking the future.
  • Ask for a list of every place the test window is touched: the answer should be «nowhere» until you unlock it.
  • Ask it to explain every BLOCK in one sentence: if you can't explain why a strategy was taken, it gets no capital.

Common mistakes

  • Skipping CLAUDE.md: without it the rules fade after the first long session.
  • Letting the agent tune on the test window: one peek and the test is no longer a test.
  • Reading a green backtest as proof: it's a hypothesis.
  • Adding fees at the end: they belong in the first backtest, so no strategy ever looks better than it is.
  • Treating one pass as a green light: it's the start of paper trading, not the end of testing.

What to do next

Run the loop on paper for a week and compare it with buy-and-hold; add a second and third asset and see whether the same rules survive; add walk-forward (fit on one window, test on the one right after, roll forward); raise fee and slippage assumptions until the surviving strategies still look decent; read RD-Agent, gs-quant and magic-trace for ideas on research loops, separate risk code and recording what happened before a failure.

Tools and costs

  • Claude Code with Fable 5.2 (price to be checked: $10/$50 per million tokens at the Fable 5 launch according to DataCamp, $8/$40 according to another source); the dspy step is the most expensive, capped at 20 trials with an estimate asked for first.
  • Python 3, git, npm to install Claude Code.
  • Kraken public API (free, no key; max 720 bars per call).
  • Free repos: Kronos (MIT), dspy, mem0 (may need a model/embedding provider, possibly paid), RD-Agent, gs-quant (Apache-2.0, GS APIs with credentials), magic-trace (MIT), daily_stock_analysis.
  • No exchange, no capital: everything on paper.

Limitations

  • No edge shown: the system found no valid strategy; it only shows that the filter blocks. It says nothing about the possibility of making money.
  • Tiny data: 560 bars over two days are, by the author's own admission, not enough; even 30 days of hourly bars are few for a single market regime.
  • Arbitrary thresholds: the four checks (2-point gap, 1.5% drawdown, 2 trades) are the author's, suited to a two-day experiment, not to a real system; the gate has no statistical test against noise (such as the permutation test in [@RohOnChain#fabbrica-strategie-fable-52-quattro-cancelli-permutazione]).
  • Optimizing the prompt on validation uses up the validation set: after many dspy rounds that data is «seen» too, and only the locked test remains as a true check.
  • Costs and dependencies: the top model is expensive and slow; mem0 may need an external provider; star counts and RD-Agent results are those in the READMEs.
  • Third-party benchmarks and demos (Fermat, the $550 shooter) are claims by Anthropic and a single developer, not trading measurements.
  • Launch tone: the promotional post («this is gold», «i pulled the full guide») doesn't match the content; it isn't clear whether the author wrote everything or gathered others' material.
  • Not financial advice: even when something passes the gate, the next step is paper trading, and trading with real capital remains risky.
← More guides in “Trading and investing (method and risk management)”