SMC Trading Bot - Backend System

Node.js & Python backend infrastructure for trade execution and monitoring

System Architecture

Backend Architecture
1. Data Collector

MT5 API & WebSocket feeds

2. Strategy Engine

SMC pattern detection

3. Execution Layer

Order management

4. Monitoring

Performance tracking

Server Infrastructure

Data Processing

AWS EC2 c5.2xlarge instance

  • • 8 vCPUs, 16GB RAM
  • • 500GB SSD storage
  • • Dedicated MT5 bridge

Execution Server

AWS EC2 c5.xlarge instance

  • • 4 vCPUs, 8GB RAM
  • • 250GB SSD storage
  • • Low-latency networking

Monitoring

AWS EC2 t3.medium instance

  • • 2 vCPUs, 4GB RAM
  • • CloudWatch integration
  • • Telegram alerts

REST API Endpoints

1. Market Data

// Get current market structure
GET /api/market/structure?symbol=EURUSD&tf=5M
Response: {
  "bias": "Bullish",
  "protectedLow": 1.12345,
  "protectedHigh": 1.12567,
  "pivots": [1, -1, 0, 1]
}
// Stream real-time price data
WS /ws/prices?symbols=EURUSD,GBPUSD,XAUUSD
Messages: {
  "symbol": "EURUSD",
  "bid": 1.12345,
  "ask": 1.12355,
  "time": "2023-07-20T12:34:56Z"
}

2. Trade Execution

// Submit new trade
POST /api/trades
Body: {
  "symbol": "EURUSD",
  "type": "BUY",
  "entry": 1.12345,
  "sl": 1.12245,
  "tp": 1.12545,
  "riskPercent": 1.0,
  "comment": "SMC BOS setup"
}
// Get active trades
GET /api/trades?status=active
Response: [{
  "id": 12345,
  "symbol": "EURUSD",
  "type": "BUY",
  "entry": 1.12345,
  "sl": 1.12245,
  "tp": 1.12545,
  "profit": 32.50,
  "status": "open"
}]

3. System Monitoring

// Get system health
GET /api/health
Response: {
  "status": "operational",
  "lastTradeTime": "2023-07-20T12:34:56Z",
  "cpuLoad": 35.2,
  "memoryUsage": 45.8,
  "activeSymbols": ["EURUSD", "GBPUSD"]
}

Database Schema

Trades Table

CREATE TABLE trades (
  id SERIAL PRIMARY KEY,
  symbol VARCHAR(10) NOT NULL,
  direction VARCHAR(4) NOT NULL,
  entry_price DECIMAL(10,5) NOT NULL,
  sl_price DECIMAL(10,5) NOT NULL,
  tp_price DECIMAL(10,5) NOT NULL,
  lot_size DECIMAL(10,2) NOT NULL,
  risk_percent DECIMAL(5,2) NOT NULL,
  status VARCHAR(10) NOT NULL,
  open_time TIMESTAMP NOT NULL,
  close_time TIMESTAMP,
  profit DECIMAL(10,2)
);

Market Data Table

CREATE TABLE market_data (
  id SERIAL PRIMARY KEY,
  symbol VARCHAR(10) NOT NULL,
  timeframe VARCHAR(5) NOT NULL,
  timestamp TIMESTAMP NOT NULL,
  open DECIMAL(10,5) NOT NULL,
  high DECIMAL(10,5) NOT NULL,
  low DECIMAL(10,5) NOT NULL,
  close DECIMAL(10,5) NOT NULL,
  volume INTEGER NOT NULL,
  pivot_type SMALLINT
);
SMC Trading Bot

Professional backend infrastructure

© 2023 Forex AutoPilot. All rights reserved.