Skip to content

haifaafridi/copybot-gateio-binance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CopyBot — Gate.io → Binance Futures Copy Trading Bot

Automatically mirrors trades from Gate.io's top leaderboard traders directly to your Binance Futures account in real time.

Python https://github.com/haifaafridi/copybot-gateio-binance/blob/main/LICENSE Status


What It Does

CopyBot monitors a Gate.io copy trading leaderboard trader via WebSocket and replays every trade signal (open/close/size/direction) on your own Binance Futures account — in demo or live mode.

You pick a trader ID from the Gate.io leaderboard. CopyBot handles the rest.


Features

  • Real-time signal detection via Gate.io WebSocket stream
  • Proportional position sizing — scales the trader's size to your account balance
  • Demo mode — full dry-run with fake money, no real orders placed
  • Live mode — executes real Binance Futures orders
  • Hot-swap traders — switch lead trader mid-session without restarting
  • Performance stats — live P&L, win rate, trade count on demand
  • Auto browser login — handles Gate.io session auth automatically; CAPTCHA only required once
  • Graceful shutdown — closes open positions and exits cleanly

Tech Stack

Layer Technology
Exchange connectivity CCXT (Binance Futures)
Signal feed Gate.io WebSocket (real-time leaderboard stream)
Session auth Playwright + playwright-stealth
Async runtime Python asyncio + aiohttp
Config management python-dotenv

Architecture

Gate.io Leaderboard
        │
        ▼
 [gateio_auth.py]          Browser login → session cookie
        │
        ▼
 [gateio_ws.py]            WebSocket listener → raw trade events
        │
        ▼
 [trader_monitor.py]       Filter signals for target trader ID
        │
        ▼
 [signal_engine.py]        Parse signal → calculate position size
        │
        ▼
 [binance_client.py]       Execute order on Binance Futures
        │
        ▼
 [bot.py / logger.py]      Orchestration, stats, graceful shutdown

Requirements

  • Python 3.10+
  • A Binance account with Futures enabled and API keys generated
  • A Gate.io account (free — used only to access the public leaderboard)

Setup

1. Clone the repo

git clone https://github.com/YOUR_USERNAME/copybot-gateio-binance.git
cd copybot-gateio-binance

2. Create a virtual environment and install dependencies

python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # Mac/Linux

pip install -r requirements.txt
python -m playwright install chromium

3. Configure your credentials

# Copy the example env file
copy .env.example config\.env      # Windows
# cp .env.example config/.env      # Mac/Linux

Open config/.env and fill in:

BINANCE_API_KEY=your_binance_api_key
BINANCE_API_SECRET=your_binance_api_secret
GATEIO_EMAIL=your_gateio_email
GATEIO_PASSWORD=your_gateio_password

Never commit your .env file. It is listed in .gitignore and will not be tracked by git.


Usage

# Demo mode — no real money, recommended for testing first
python main.py --trader 1851 --mode demo

# Live mode — real Binance Futures orders
python main.py --trader 1851 --mode live

Replace 1851 with any trader ID from the Gate.io Copy Trading leaderboard.

First Run

On first launch, a browser window opens automatically, logs into Gate.io, and saves your session. You may need to solve a CAPTCHA once. After that, the bot runs fully headlessly for 23 hours before the session expires.

Commands (type while bot is running)

Command Action
trader <id> Switch to a different lead trader instantly
stats Show full performance report (P&L, win rate, trades)
stop Graceful shutdown — closes open positions cleanly

Project Structure

copybot/
├── main.py                  # Entry point — CLI args, startup
├── core/
│   ├── bot.py               # Main orchestrator loop
│   ├── signal_engine.py     # Signal parsing & position sizing logic
│   └── logger.py            # Structured logging
├── exchange/
│   ├── binance_client.py    # Binance Futures order execution (CCXT)
│   ├── gateio_ws.py         # Gate.io WebSocket listener
│   ├── gateio_auth.py       # Playwright browser login & session mgmt
│   └── trader_monitor.py    # Filters & routes signals by trader ID
├── config/
│   ├── settings.py          # Config loader (reads from .env)
│   └── .env.example         # Template — copy to .env and fill in keys
├── tests/                   # Test scripts for each module
├── logs/                    # Auto-created; log files excluded from git
├── requirements.txt
└── .gitignore

Notes & Limitations

  • Uses Gate.io's public leaderboard WebSocket endpoint, which is not part of their official documented API. The bot may require updates if Gate.io changes their site structure.
  • This project is for educational and personal automation purposes. Always review Gate.io's Terms of Service before use.
  • Start with demo mode. Verify signals are being mirrored correctly before switching to live.

Disclaimer

This software is provided for educational purposes only. Crypto futures trading carries significant financial risk. This project does not constitute financial advice. You are solely responsible for any trades placed by this bot on your account. Always test in demo mode first and never risk money you cannot afford to lose.


Author

Haifa Khan Afridi 📧 haifaafridi8@gmail.com


License

MIT License — see https://github.com/haifaafridi/copybot-gateio-binance/blob/main/LICENSE for details.

About

Automated copy trading bot that mirrors Gate.io leaderboard traders to Binance Futures in real time | Python, CCXT, WebSocket, Playwright

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages