yida-bot: Trading Bot

Dec 2026 – present · Personal project

Project page · Code on GitHub · Commit history

Yida's Chart, the yida-bot dashboard

The idea

yida-bot is a trading bot that reads market data, asks a strategy what to do, and only acts if a separate risk guard agrees. It started on Coinbase with crypto, and it’s built so stocks, prediction markets and sentiment from Reddit and YouTube can plug in later without rewriting the core.

Strategy modes

Every strategy is a “mode”: one small class with a decide() method that returns buy, sell or hold, a confidence and a reason. There are six so far:

  • risk: momentum, with trades sized down as volatility rises
  • swing: a fast/slow moving-average crossover
  • yinyang: mean reversion, leaning against prices that drift too far from their average
  • random: a coin flip, and the control group every other mode has to beat
  • moon: buys near the new moon and sells near the full moon, using a computed lunar phase
  • astrology: sits out Mercury retrograde and leans in under fire signs

The last two are for fun, but they prove the point of the design: a new strategy is one file, and the rest of the bot doesn’t change.

The risk guard

This is the part I care about most. A strategy can be wrong; the guard makes sure being wrong stays cheap. Every order has to pass rules the strategy can’t override:

  • A $1/day loss limit, counted on the worst case. A buy is only allowed if today’s losses, plus every open position hitting its stop-loss, plus the new trade hitting its own, stays under $1, with fees on both sides included.
  • Per-coin rules. Volatile coins like PEPE get a wider stop (8%) and a smaller size ($10), so one stop-out still costs under $1.
  • A kill switch that blocks new buys from the terminal or the dashboard, while still letting the bot sell.
  • State saved to disk, so restarting the bot never resets the day’s losses.

There’s a test that fails if any configured coin’s worst case ever exceeds the daily limit, so a careless config edit can’t quietly break the rule.

The dashboard

“Yida’s Chart” is a Streamlit web page that runs locally: a candlestick chart with the swing mode’s moving averages, volume, balances, a table of what every mode thinks right now, the day’s risk budget, and the moon phase. It reads live data from Coinbase but can’t place trades. The screenshot above is it running on real PEPE prices.

Security

  • The Coinbase API key lives in a file outside the project folder, and the bot refuses to load one stored inside it, so it can’t be committed by accident.
  • The key can view and trade but not withdraw, and Coinbase only accepts it from my IP address.
  • Order placement stays switched off in the code until the risk guard and a dry-run mode are in place.

How I built it

I used Claude Code as a pair programmer for this project, the same way I did for Gablaxy. I decided the rules and the design, reviewed each change and ran it on my own machine against my real account before keeping it. Every feature came with tests, and GitHub Actions runs them on each push.

Tech: Python, Coinbase Advanced Trade API, Streamlit, Plotly, pytest, GitHub Actions

Not financial advice. Trading carries real risk.