AlgoPaper
A paper-trading agent. An XGBoost model reads live crypto prices, labels the market regime each hour and trades a virtual $100k account, with every decision on a public dashboard.
- Year
- 2026
- Role
- Solo. Design, build, release
- Stack
- Python, XGBoost, pandas, Next.js, Supabase, Recharts
- Ships as
- Python agent plus a public Next.js dashboard
The problem
Most trading-bot demos are a backtest chart and a promise.
I wanted the whole loop running for real on live data: features, a model, a broker with honest fills and risk limits, and a dashboard that shows why each decision was made. Paper money only, built on free tiers.
What I built
A streaming agent, a model that retrains itself, and a dashboard that reads the same database.
The agent streams 1-minute bars for BTC, ETH, SOL and DOGE from the Binance.US public WebSocket, rolls them up into hourly bars, computes 51 features and asks the model for a regime. A router turns the regime into buy, close or hold, and a paper broker fills it. Bars, signals, trades and equity go to Supabase, and the dashboard updates over Realtime.
- featuresReturns, volatility, RSI, MACD, ADX, Bollinger and Donchian position, VWAP distance, the crypto Fear and Greed index and trading-session flags.
- modelXGBoost regime classifier. Retrained every Sunday by a GitHub Actions cron; each prediction logs the model version.
- brokerATR-based sizing, 2% risk per trade, at most 25% in one coin, next-bar fills with slippage, and a halt after a 5% daily loss.
- dashboardNext.js pages for the overview, trade log, bot reasoning and model, with Recharts for equity and P&L.
Five regimes, three actions
Training labels each hourly bar by what price did over the next 12 hours. Live, the router maps the predicted label to one action.
| Regime | How training labels it | What the agent does |
|---|---|---|
BULL_TREND | Price reaches +1.5 ATR before it falls 1.5 ATR | Buy |
BEAR_TREND | Price falls 1.5 ATR first | Close if holding, otherwise stay in cash |
BREAKOUT | A Bollinger squeeze, then the band width grows by half | Buy |
RANGE | Every close stays inside the Bollinger bands | Hold |
FLAT | None of the above | Hold |
Hard decisions
The calls that shaped it.
Label by the trade, not the chart
Labels use the triple-barrier method: which of a profit target or a stop, both 1.5 ATR away, price hits first within 12 hours. The model learns outcomes a trade would actually have had, instead of a fixed return threshold.
Let the model act
The first version routed each regime to a hand-written strategy: momentum, breakout, VWAP scalping. The last commit deleted all three and maps the label straight to an action. Fewer knobs to tune, and the behaviour now rests entirely on the model.
Train hourly, stream by the minute
The model was trained on hourly bars but the feed sends minute bars, so every indicator was off scale and the agent never placed a trade. The fix resamples the live buffer to hourly before features and prediction.
Keep the future out
Labels peek ahead, so they exist only in training. The validation split is chronological with no shuffle, and the broker fills at the next bar's open with slippage, never at the price that triggered the signal.
Where it is now
Paper trading only. Not investment advice.
- Public dashboardOverview, trade log, bot reasoning and model pages
- Weekly retrainGitHub Actions cron every Sunday
- 22 testsBroker sizing and limits, feature engineering
- 46 commitsOn GitHub