Back to portfolio Ian Wu

Real-Time Crypto Trading Bot

JavaScript app using WebSockets to stream live Binance market data and compute RSI-based buy/sell signals. UI for price charts, holdings, and trade history.

Paper trading only. The bot reads Binance’s public market data and trades a simulated $10,000 balance. It needs no account or API key, places no real orders, and is not financial advice.

Connecting to Binance…
Price
—
RSI (14)
—
Latest signal
None yet
Portfolio value
—

Price and RSI · 1-minute candles

Holdings

Cash (USDT)
—
BTC held
—
Position value
—
Fees paid (0.1%)
—
Trades
0

Manual orders fill at the latest price.

Trade history

Time Side Price Amount Value Reason

No trades yet.

How it works

Strategy

  • RSI (Relative Strength Index) measures how strongly the price has been rising or falling over the last 14 candles, on a 0–100 scale, using Wilder’s smoothing.
  • Buy when RSI falls below 30 (oversold), spending 25% of the cash.
  • Sell the whole position when RSI rises above 70 (overbought).
  • Signals are only taken when a candle closes, so a signal can’t vanish after the bot has acted on it. A 0.1% fee is charged on every trade, like Binance spot trading.

Code structure

  • BinanceMarket loads recent candles over REST, then streams live candles over a WebSocket, reconnecting with back-off if the connection drops.
  • SimulatedMarket has the same interface and takes over if Binance can’t be reached.
  • RsiStrategy, PaperPortfolio and TradingBot hold the trading logic, separate from the page, and are unit-tested.
  • MarketChart draws the price and RSI on a canvas, with a hover crosshair.