Skip to content

Manas-Kenge/exness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exness — Crypto Leverage Trading Platform

Real-time crypto leverage trading platform with live Binance price feeds, position management, and PnL tracking. Built with TypeScript and Bun.

Demo

Untitled.mp4

Architecture

Binance WS ─> price_poller ─> Redis PUBLISH ─> ws server ─> frontend (live prices)
                            └> TimescaleDB (historical candles)
              Redis SUB ─> server ─> monitors open positions (TP/SL/liquidation)
Service Port Description
frontend/ 5173 React 19 + Vite + Tailwind CSS. Lightweight Charts for candlestick visualization
server/ 5000 Express 5 REST API. JWT auth, trade execution, candle queries. In-memory user/order state
ws/ 8080 WebSocket relay. Bridges Redis pub/sub to browser connections
price_poller/ Binance aggTrade streams (BTC, ETH, SOL). Publishes to Redis, batch-inserts to TimescaleDB

Infrastructure: TimescaleDB (hypertables + continuous aggregates for 1m/1d/1w candles), Redis 7.2 (pub/sub)

Quick Start

Local Development (recommended)

# 1. Start infrastructure
docker compose up -d redis db

# 2. Wait for DB to be healthy, then set up schema + candle views (one-time)
cd price_poller && bun install && bunx prisma db push && bun run seed && cd ..

# 3. Install dependencies and start all services
bun install && bun run install:all && bun run dev

Open http://localhost:5173

Docker Compose (full stack)

docker compose up --build

Open http://localhost:3000

Note: The DB runs on tmpfs — data is lost on restart. Re-run the seed step after docker compose down.

Available Scripts

Root

Command Description
bun run dev Start all 4 services concurrently
bun run install:all Install deps in all services
bun run docker:up docker compose up -d --build
bun run docker:down docker compose down

Frontend

Command Description
bun run dev Dev server with HMR
bun run build Production build
bun run lint ESLint

Price Poller

Command Description
bun run seed Create TimescaleDB hypertable + continuous aggregates
bunx prisma db push Apply Prisma schema

API Routes

All routes are prefixed with /api/v1.

Method Route Auth Description
POST /user/signup No Create account
POST /user/signin No Get JWT token
POST /user/logout Yes Logout
GET /user/balance Yes Get USD balance
POST /trade Yes Open a position
POST /trade/close Yes Close a position
GET /trades/open Yes List open trades
GET /trades Yes List closed trades
GET /candles No OHLCV candle data
GET /asset No Asset list with live prices

Trading Features

  • Assets: BTC, ETH, SOL (all paired with USDT)
  • Leverage: 1x, 5x, 10x, 20x, 100x
  • Order types: Market, Limit
  • Risk management: Take Profit, Stop Loss, auto-liquidation
  • Real-time: Live price streaming via WebSocket, auto-updating candlestick charts (1m, 1d, 1w)

Price Scaling

All prices use integer math to avoid floating-point errors:

  • PRICE_SCALE = 10000 — prices stored as integer x 10000
  • USD_SCALE = 100 — USD amounts stored as cents
  • PnL calculations use BigInt

Tech Stack

  • Runtime: Bun
  • Frontend: React 19, Vite, Tailwind CSS, Lightweight Charts
  • Backend: Express 5, Zod validation, JWT auth
  • Database: TimescaleDB (PostgreSQL) with continuous aggregates
  • Cache/Pub-Sub: Redis 7.2
  • ORM: Prisma (price_poller)
  • Containerization: Docker Compose

About

Crypto leverage trading platform with real-time Binance price feeds, position management, and PnL tracking

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages