I bolted a self-improving loop onto a free gold RL model. Now it paper-trades XAUUSD live and retrains itself every week while I sleep.

By Gencay

Published: 2026-07-15

URL: https://www.learnwithmeai.com/p/i-built-a-gold-predicting-trading


Two days ago, I caught a headline.

Gold had dropped to its lowest level in months.

The same metal that printed an all-time high of $5,591 back in January was now sitting near $4,040.

It made me curious because I have been testing trading bots all year.

I built a Polymarket bot that made 2.1x in 18 days, a copy-trading bot that copies millionaires on Hyperliquid, and a crypto bot that hit a 77.8% win rate.

But I had never pointed any of this at gold.

One of the oldest currencies on earth, and I had no bot for it.

I am not a finance expert, so I did what I always do.

I went looking for someone who already cracked it.

I found a guy who trained a reinforcement learning model on 23 years of gold data. The same family of methods is used to train our LLMs.

He reports around 60% out-of-sample returns, and he gave away the code.

The prediction brain is his. I added the part he never built. Every week, NotebookLM grades the bot’s trades against trading books, and Claude retrains the model on the findings.

A dashboard shows me the live position.

Claude x Gold champion dashboard on Hermes showing paper portfolio metrics, LONG signal at $4,065, equity curve, and the self-improving loop steps trade, log, autopsy via NotebookLM, retrain, promote, repeat.

\Champion view running on Hermes, the six-step loop from trade to autopsy to retrain to promote, all while you sleep.\

The Gold Bot I’ve Built with Claude Code and Hermes

Let me first show you the dashboard, live.

\The full live dashboard, one window showing the champion, the signal, the equity curve, the six-step self-improving loop, and the trade stream.\

At the top left, you see the portfolio. It started at $10,000.

Paper portfolio metrics panel showing equity $10,555.53, total return +5.56%, win rate 54.2%, profit factor 1.36, Sharpe-like 5.1, max drawdown -3.74% over 131 trades.

\Paper portfolio scorecard: +5.56% return, 54.2% win rate, 1.36 profit factor, 5.1 Sharpe-like, -3.74% max drawdown.\

In the middle, you see the current signal. It comes from the RL model, trained on 23 years of gold data.

Current signal panel reading LONG, an RL deterministic decision on gold (GC=F) at $4,066.10.

\The current signal comes straight from the RL model, a deterministic LONG call on gold.\

On the right, the equity curve shows how the portfolio changes over time.

Equity curve panel showing the gold bot paper portfolio rising over time, low $10,259.84 and high $10,555.53.

\The equity curve: paper portfolio climbing from a $10,259 low to a $10,555 high.\

And below it, the gold price itself.

Live XAU/USD candlestick chart on the bot dashboard showing gold trading near $4,058 with high $4,215 and low $4,054.

\Live gold price on the dashboard, XAU/USD candlesticks feeding the RL model every minute.\

Every minute, the trained model reads the latest gold bars and decides. Long, Short, or sit this one out.

Every decision and every fill gets logged.

Live trade log table streaming timestamped paper trades with LONG side labels and per-trade P&L in green and red, marked paper trading for research and education.

\The live trade log streams every fill, each paper trade logged with side and P&L.\

The dashboard is one window. The other is Telegram, where the bot reports its position every two hours.

\Every two hours the bot reports its position to Telegram, signal, equity, win rate, profit factor\

Now, let me explain to you how the gold bot works.

How the Gold Bot Works

Illustrated diagram titled How the Gold Bot Works showing three components — the bot, the Hermes agent on a Mac Mini, and the NotebookLM notebook — connected in a weekly self-improving loop.

\How the gold bot works: three pieces, the bot Claude Code wrote, the Hermes agent, and the NotebookLM notebook that retrains it.\

The whole thing runs on three pieces.

  • The bot.
  • Claude Code wrote it. Every minute, it reads the latest gold bars and takes the RL model’s call. Long, Short, or Hold.
  • The model wrote its own trading rules by running millions of simulated trades on 23 years of gold data.
  • I never touched the math.
  • The agent.
  • The bot lives on a Hermes agent on my Mac Mini.
  • Hermes runs it on schedule, sends the reports to Telegram, and keeps the trading journal, every decision and every fill.
  • The journal matters because the third piece reads it.
  • The notebook.
  • NotebookLM holds the library, trading books, and RL papers, and answers questions against them.
  • Once a week, Claude carries the journal into the notebook.
  • What comes out trains the model.

The weekly loop is the part that the other bots never had, so it gets its own section.

The Weekly Loop: It Retrains Itself with NotebookLM

Here is my NotebookLM notebook. It holds trading books and RL papers.

NotebookLM chat where the notebook analyzes the champion bot's 3.62 Sharpe and 1.24 profit factor as backtest overfitting, citing PPO and backtesting-overfit source papers.

\Weekly autopsy in action, NotebookLM flags the champion's track record as textbook backtest overfitting, citing the sources.\

I customized it for one job. Reading weekly trade journals and answering hard questions about them.

NotebookLM Configure chat screen with a custom role prompt defining a quantitative trading risk analyst reviewing a PPO reinforcement-learning gold bot grounded only in attached sources.

\NotebookLM customized for one job: a ruthless quant risk analyst grading the bot against PPO papers, FinRL, and overfitting research.\

Every week, a Claude routine runs the autopsy. No approval from me. It fires on schedule.

\The weekly autopsy fires on its own, a scheduled Claude routine every Sunday at 9AM, no approval needed.\

It carries the week’s journal into the notebook and asks the hard questions.

  • Where did the model bleed?
  • Which setups failed?
  • What do the books say the model should have done?

NotebookLM answers with three concrete changes.

Then the retrain. Claude takes those changes and retrains a second model, the challenger.

Telegram alert reading Gold RL Challenger Is Live, comparing champion seed 42 (3.83% return, Sharpe 3.62, profit factor 1.24, 129 trades) against a week-1 challenger auto-retrained on trading books via NotebookLM.

\The bot runs a weekly tournament: the champion keeps trading while a NotebookLM-retrained challenger fights to replace it.\

The changes stack week over week, so the challenger keeps evolving while the champion, the original bot, keeps trading untouched.

Setting Up the Gold Bot

You do not write any of this from scratch.

I packaged the whole thing into one folder. Five pieces. The trained RL model, the live loop, the weekly autopsy, the dashboard, and the connection skills.

Google Drive folder showing the gold RL trading bot build kit with bot folder, hermes-skill.md and SETUP.md files.

\The full gold RL bot build kit in one Google Drive folder — bot, Hermes skill, and SETUP.md.\

You point Claude Code at it and answer a few questions. Three things you set up once. One, the bot. Two, the NotebookLM CLI. Three, the weekly loop.

Here is the folder.

This folder is the bot’s full build kit. The model is already trained, so it starts paper trading on the first run. SETUP.md and LOOP.md carry the step-by-step, and the prompts below hand the work to Claude Code.

https://drive.google.com/drive/folders/1\_HyavZTWa1Um6so1zfYVZVWwWSuEqL0x?usp=sharing

1. The bot.

Drop the bot/ folder where it will run. A Mac Mini, a VPS, your laptop.

It pulls real gold data on its own. The trained model is included, so it starts trading paper on the first run.

Use this prompt:

Set up the gold RL bot from this folder. Follow SETUP.md.

- Create the py3.12 venv and install requirements.

- Run one tick now so I see a real signal and a paper trade.

- Start the live price poller and the dashboard server.
Do not flip the live-money switch. Paper only.

2. NotebookLM CLI.

This is the library the weekly autopsy reads from.

Use this prompt:

Install the NotebookLM CLI from here: https://github.com/teng-lin/notebooklm-py

Then, customize the notebook so it knows it is a gold trading advisor reading weekly autopsies against trading books. Here is the exact customization prompt.

You are a ruthless quantitative trading risk analyst reviewing a PPO reinforcement-learning
bot that paper-trades XAUUSD (gold).
Ground every answer ONLY in the attached sources (Sutton & Barto, PPO papers, SB3, FinRL,
backtest-overfitting papers) and the weekly performance data provided.
Be blunt and specific.
Cite which source supports each claim. No hedging, no generic advice.
If the data shows a problem, name it and name the fix.

3. The self-improving loop.

Open the loop folder with Claude Code and paste this:

Use this prompt:

Set up the gold autopsy + retrain loop from this folder.
Follow LOOP.md.

- Ask me where the bot’s trade journal lives (local path or SSH).

- Create a NotebookLM notebook called “Gold RL — Weekly Autopsy Log”.

- Tell me which trading-book PDFs to add myself.

- Run one autopsy now so I see real output.

- Install a weekly scheduled task for Sunday 09:00.

- Retrain the model on the autopsy, compare out-of-sample, promote only if better.
Do not touch the live-money switch. I decide what goes real.

That is the whole setup.

The skill handles the bot, the notebook, the weekly schedule, and the retrain-and-promote gate.

You add your own trading-book PDFs and pick the connection skill that matches your machine (hermes for a Mac, openclaw for a cloud box).

The full step-by-step is SETUP.md inside the folder.

Here is the folder:

https://drive.google.com/drive/folders/1\_HyavZTWa1Um6so1zfYVZVWwWSuEqL0x?usp=sharing

Disclaimer: This is not financial advice. Paper portfolio only. A build experiment, not a trading recommendation. The live-money switch ships off. Always do your own research and make your own decisions.

Next Steps

You have the folder. Here is the order.

Set up the bot first. Drop it on whatever machine stays on. Let it run a week and fill the journal.

Install the NotebookLM CLI.

Add your own trading books as PDFs. Three is enough. The loop checks every autopsy against them.

Run one autopsy by hand.

Watch the full loop fire once before you trust it on a schedule. See if the retrain actually produced a better model.

Then set the Sunday routine. Now it runs without you.

Go build your own.