Personal project · Python

yida-bot

A modular trading bot for Coinbase with pluggable strategy modes, a hard risk guard that caps losses at $1 a day, and a live web dashboard.

View on GitHub Project write-up How it works
Yida's Chart dashboard: live PEPE-USDC candlestick chart with moving averages, volume bars, what each strategy mode says right now, and today's risk budget.

“Yida's Chart”, the dashboard, running on live PEPE-USDC prices from Coinbase (read-only).

What it does

yida-bot reads live market data, asks a strategy “mode” what to do, and only acts if the risk guard agrees. Everything runs locally; API keys never leave the machine.

🧠

Pluggable modes

Six strategies behind one interface, from moving-average swing trading to a moon-cycle mode. A new one is a single class.

🛡️

Risk guard

Every order passes hard limits the strategy can't override: a $1/day worst-case loss cap, per-coin stop-losses, size caps and a kill switch.

📈

Live dashboard

Candlesticks, volume, balances, every mode's current opinion and the day's risk budget, refreshing every minute.

🔌

Coinbase connector

Talks to Coinbase Advanced Trade with an Ed25519 key that can view and trade but never withdraw.

How it works

Each stage is a separate module with one job, so a new data source, strategy or exchange slots in without touching the rest.

Sources
  • Coinbase prices
  • Reddit · planned
  • YouTube · planned
Signals
  • Price history
  • Sentiment score
  • Moon phase
Modes
  • risk · swing
  • yinyang · random
  • moon · astrology
Risk guard
  • $1/day worst case
  • Stop-loss
  • Kill switch
Exchanges
  • Coinbase
  • Paper (testing)
  • Stocks, events · planned

The modes

Some serious, some for fun. The random mode is the control group: any strategy worth keeping has to beat a coin flip.

ModeIdeaSignal
riskMomentum, sized down as volatility risesPrice trend ÷ volatility
swingFast/slow moving-average crossover, nudged by sentiment5 vs 20-period average
yinyangMean reversion: lean against prices that stray from balanceDistance from the average
randomCoin flip. The baselineDice
moonBuy near the new moon, sell near the full moonComputed lunar phase
astrologyStay out during Mercury retrograde, lean in under fire signsCalendar

The risk guard

The part I care about most. A strategy can be wrong; the guard makes sure being wrong stays cheap.

# a buy is allowed only if
today's realised loss
+ every open position hitting its stop
+ this trade hitting its stop
  (fees included on both sides)
≤ $1.00

# config/risk.toml
daily_loss_limit_usd = 1.00
[coins.PEPE]
trade_size_usd = 10.00
stop_loss_pct  = 0.08   # worst case $0.85
  • Worst case, not hindsight. The limit counts losses that could still happen, not just ones already taken.
  • Survives restarts. Today's losses and open positions are saved to disk, so restarting doesn't reset the day.
  • Selling always works. The kill switch blocks new buys but never stops the bot from getting out.
  • Per-coin rules. Volatile coins get a wider stop and a smaller size, so one stop-out still fits the budget.
  • Tested. A test fails if any configured coin's worst case ever exceeds the daily limit.

Security

Built with

Python 3.11+Coinbase Advanced Trade APIStreamlit PlotlypytestGitHub ActionsClaude Code

Try the dashboard with fake prices, no account needed:

git clone https://github.com/yida-li/yida-bot && cd yida-bot
pip install -e ".[dev]"
yida-bot dashboard --demo

Not financial advice. This is a personal project; trading carries real risk, and you can lose money.