All projects

Hobby2025

Crypto Trading Bot

A multi-indicator trading engine with live dashboard, backtesting and Telegram control.

Loop
15 s
Exchange
Binance testnet
Transport
WebSocket
Control
Web + Telegram

01Overview

An automated trading system that scans the market every 15 seconds, scores opportunities with several technical indicators, manages positions with explicit exit rules and streams every decision to a live dashboard.

It runs against the Binance testnet by default - it is an engineering and research project, not financial advice.

02Architecture

The strategy engine is isolated behind services: market access, portfolio accounting, notifications and persistence are each their own module, and the transport (WebSocket broadcast) is injected rather than imported.

Dashboard

Portfolio

Holdings, charts, history

Live activity

Streamed trades

Bot settings

Risk, target, on/off

Manual trading

Override the bot

Server

REST API

Express

WebSocket

Broadcast to clients

Auth

Passport sessions

Trading services

Strategy

Scoring & exits

Binance

Market data & orders

Portfolio

Balances & P/L

Backtest

Replay & metrics

Telegram

Commands & alerts

Data

PostgreSQL

Drizzle ORM

Tables

users · trades · portfolio · bot_settings · price_history

03Components

Strategy engine

Decides what to buy and sell

  • Scores every coin with RSI, momentum, a MACD-style signal, Bollinger position, Fibonacci levels and market structure.
  • Exits on profit targets, stop losses and overbought RSI; stops itself when the user's target balance is reached.

Backtesting

Validates a strategy before it trades

  • Replays generated historical prices through the same entry and exit logic.
  • Reports win rate, number of trades and profit factor.

Real-time layer

Makes the bot observable

  • Every trade and balance change is broadcast over WebSocket to the dashboard.
  • Telegram commands and alerts give control from a phone.

04How it works

  1. 1

    Tick

    Every 15 s the engine checks the bot is active for the user.

  2. 2

    Guard

    If total balance reached the target, sell everything and stop.

  3. 3

    Score

    Fetch market data and rank opportunities by the combined indicator score.

  4. 4

    Act

    Close positions that hit exit rules, open the best new ones within risk limits.

  5. 5

    Report

    Persist trades, broadcast over WebSocket and notify Telegram.

05Technical deep dives

Measuring a strategy

Backtests use the same take-profit (+8%) and stop-loss (−5%) rules as live trading. The key metric is the profit factor - gross profit divided by gross loss - where anything above 1 means the strategy made more than it lost.

06Design decisions

Testnet by default

The Binance client starts in testnet mode, so the full pipeline can run without real funds.

Injected broadcast

The strategy receives a broadcast function instead of importing the WebSocket server, keeping it testable in isolation.

One schema for all state

Trades, holdings, settings and price history share a typed Drizzle schema with Zod validation.

07Tech stack

Frontend
ReactTypeScriptViteRechartsChart.jsshadcn/ui
Backend
Node.jsExpresswsPassportbinance-api-nodenode-telegram-bot-api
Data
PostgreSQLDrizzle ORMZod

Next case study

Vacancy Scraper Bot

A Telegram bot that collects jobs and internships from Azerbaijani job sites and publishes them to channels.