Skip to content

A full-stack Binance USDT-M Futures trading bot with an interactive React dashboard and a Flask API backend. The system supports market, limit, stop-limit, OCO, TWAP, and grid trading strategies, along with real-time candlestick charts, order book visualization, and WebSocket-based price updates.

Notifications You must be signed in to change notification settings

Dinesh-Sharma2004/Trading-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance Futures Trading Bot

An interactive trading application for Binance USDT-M Futures with live chart visualization and Flask API backend.

Features

Core Order Types (Mandatory)

  • Market Orders: Execute immediately at the best available price
  • Limit Orders: Execute at a specified price or better

Advanced Order Types (Bonus)

  • Stop-Limit Orders: Trigger a limit order when a stop price is hit
  • OCO (One-Cancels-the-Other): Place take-profit and stop-loss simultaneously
  • TWAP (Time-Weighted Average Price): Split large orders into smaller chunks over time
  • Grid Orders: Automated buy-low/sell-high within a price range

Additional Features

  • Live candlestick charts with TradingView-style visualization
  • Real-time order book display
  • WebSocket price updates
  • Comprehensive validation and logging
  • Dark theme optimized for trading

Project Structure

├── app.py                  # Flask API server
├── src/
│   ├── config.py          # Configuration settings
│   ├── logger.py          # Structured logging
│   ├── validator.py       # Input validation
│   ├── market_orders.py   # Market order logic
│   ├── limit_orders.py    # Limit order logic
│   └── advanced/
│       ├── stop_limit.py  # Stop-limit order logic
│       ├── oco.py         # OCO order logic
│       ├── twap.py        # TWAP strategy
│       └── grid.py        # Grid trading strategy
├── client/                 # React frontend
├── bot.log                # Logs (API calls, errors, executions)
└── README.md              # This file

Setup

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • Binance API credentials (optional for simulation mode)

Environment Variables

Set the following environment variables (optional - app works in simulation mode without them):

BINANCE_API_KEY=your_api_key
BINANCE_API_SECRET=your_api_secret
BINANCE_TESTNET=true  # Use testnet (recommended for testing)

Installation

  1. Install Python dependencies:
pip install flask flask-cors flask-socketio python-binance requests python-dotenv gunicorn eventlet
  1. Install frontend dependencies:
cd client
npm install

Running the Application

  1. Start the Flask backend:
python app.py
  1. Start the React frontend (in development):
cd client
npm run dev

The application will be available at http://localhost:5000

API Endpoints

Market Data

  • GET /api/symbols - List supported trading symbols
  • GET /api/prices - Get current prices for all symbols
  • GET /api/price/<symbol> - Get price for specific symbol
  • GET /api/klines/<symbol> - Get candlestick data
  • GET /api/orderbook/<symbol> - Get order book data

Orders

  • POST /api/orders/market - Place market order
  • POST /api/orders/limit - Place limit order
  • POST /api/orders/stop-limit - Place stop-limit order
  • POST /api/orders/oco - Place OCO order
  • POST /api/orders/twap - Place TWAP order
  • POST /api/orders/grid - Create grid trading strategy
  • GET /api/orders/pending - Get all pending orders
  • DELETE /api/orders/<order_id> - Cancel order

Logging

All actions are logged to bot.log with structured format including:

  • Timestamps
  • Order placements
  • API calls
  • Validation results
  • Error traces

Supported Symbols

  • BTCUSDT, ETHUSDT, BNBUSDT, XRPUSDT, ADAUSDT
  • DOGEUSDT, SOLUSDT, DOTUSDT, MATICUSDT, LTCUSDT

Notes

  • The application runs in simulation mode without Binance API credentials
  • Use Binance Testnet for safe testing with real API
  • All orders are validated before placement
  • Comprehensive error handling and logging

Resources

About

A full-stack Binance USDT-M Futures trading bot with an interactive React dashboard and a Flask API backend. The system supports market, limit, stop-limit, OCO, TWAP, and grid trading strategies, along with real-time candlestick charts, order book visualization, and WebSocket-based price updates.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published