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.
- Coinbase prices
- Reddit · planned
- YouTube · planned
- Price history
- Sentiment score
- Moon phase
- risk · swing
- yinyang · random
- moon · astrology
- $1/day worst case
- Stop-loss
- Kill switch
- 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.
| Mode | Idea | Signal |
|---|---|---|
risk | Momentum, sized down as volatility rises | Price trend ÷ volatility |
swing | Fast/slow moving-average crossover, nudged by sentiment | 5 vs 20-period average |
yinyang | Mean reversion: lean against prices that stray from balance | Distance from the average |
random | Coin flip. The baseline | Dice |
moon | Buy near the new moon, sell near the full moon | Computed lunar phase |
astrology | Stay out during Mercury retrograde, lean in under fire signs | Calendar |
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
- Keys stay local. The Coinbase key lives in a file outside the project folder; the bot refuses to load one stored inside it.
- Least privilege. The key can view and trade, but transfers and withdrawals are disabled.
- IP-locked. Coinbase only accepts the key from a whitelisted address.
- Read-only first. Order placement stays switched off in code until the risk guard and a dry-run mode are in place.
Built with
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.