Skip to content

samnmbuguah/GridBot

Repository files navigation

GridBot - MEXC BTC Grid Trading Bot

A Python-based grid trading bot for MEXC exchange with a PyQt5 GUI interface.

🎯 Features

Dynamic Trailing Grid Trading

  • Configurable grid levels (1-1000000, defaults to 5)
  • Dynamic price tracking - automatically follows current price up
  • Grid spacing - customizable distance between orders
  • Sell target - profit target above buy price
  • Automatic order management - places sell orders when buy orders fill
  • Trailing system - places new buy orders as price rises
  • Continuous grid operation - automatically replaces buy orders after completed cycles
  • Multi-instance safety - prevents duplicate orders when running multiple bot instances

Real-Time Monitoring

  • BTC price display on app launch and during operation
  • Color-coded price changes (green=up, red=down)
  • Enhanced logging - all activities visible in GUI and saved to files
  • Log download - easily download all logs as ZIP archive
  • Order tracking - monitor active orders and trade history

User Interface

  • Multi-language support (English/German)
  • Settings persistence - saves configuration between sessions
  • API key management - secure credential storage
  • Export functionality - CSV export of trade history

🚀 Quick Start

For Windows Users:

  1. Download GridBot_Windows_Updated.zip
  2. Extract the zip file
  3. Double-click GridBot.exe to run
  4. Enter your MEXC API credentials
  5. Configure your grid settings
  6. Click "Start Bot"

For Developers:

# Clone the repository
git clone <repository-url>
cd GridBot

# Install dependencies
pip install -r requirements.txt

# Run the application
python main.py

📊 How Multi-Level Grid Works

Grid Configuration Example:

Start Price: $118,985
Grid Levels: 5
Grid Spacing: $100
Sell Target: $500

Grid Levels:
1. Buy at $118,985 → Sell at $119,485
2. Buy at $118,885 → Sell at $119,385
3. Buy at $118,785 → Sell at $119,285
4. Buy at $118,685 → Sell at $119,185
5. Buy at $118,585 → Sell at $119,085

Cycle Definition:

A cycle is completed when:

  1. Buy order fills at any grid level
  2. Sell order is automatically placed at sell_target above buy price
  3. Sell order fills, completing the round trip
  4. Profit = (sell_price - buy_price) × amount

📝 Logging System

Automatic Logging:

  • All bot activities are automatically logged to files
  • Logs are saved in the logs/ directory with timestamps
  • Each session creates a new log file
  • Logs include timestamps, log levels, and detailed messages

Downloading Logs:

  • Click the "📥 Download All Logs" button in the GUI
  • Choose where to save the ZIP archive
  • Archive contains all log files with timestamps
  • Useful for debugging and support purposes

🔧 Configuration

API Setup:

  1. Create a MEXC account
  2. Generate API key and secret
  3. Enter credentials in the app
  4. Save API keys

Grid Settings:

  • Grid Levels: Number of buy orders per grid level (1-1000000)
  • Grid Spacing: Distance between buy orders ($)
  • Position Size: Amount of BTC per order
  • Sell Target: Profit target above buy price ($)
  • Dynamic Tracking: Automatically follows current price up

🛠️ Building Windows Executable

Cross-Compilation from Linux:

# Install Wine (if not already installed)
sudo apt install wine64

# Build Windows executable
python3 build_windows_cross.py

# Create distribution package
python3 create_windows_package.py

Build Output:

  • dist/GridBot.exe - Native Windows executable
  • dist/GridBot_Windows/ - Complete distribution package
  • dist/GridBot_Windows_Updated.zip - Ready for distribution

📁 Project Structure

GridBot/
├── api/                 # MEXC API integration
├── bot/                 # Trading bot logic
├── config/              # Configuration management
├── gui/                 # PyQt5 GUI components
├── utils/               # Database and utilities
├── main.py              # Application entry point
├── build_windows_cross.py  # Windows build script
├── create_windows_package.py  # Package creation script
└── requirements.txt     # Python dependencies

🔒 Security

  • API credentials are stored locally in settings.json
  • No credentials are transmitted except to MEXC API
  • All trading logic runs locally on your machine

⚠️ Disclaimer

This software is for educational and personal use only. Trading cryptocurrencies involves significant risk. Use at your own discretion and never risk more than you can afford to lose.

📝 License

This project is provided as-is for educational purposes.

🆘 Troubleshooting

Common Issues:

  1. "Insufficient funds" - Add USDT to your MEXC account
  2. API errors - Verify your API key and secret
  3. Wine crashes - Normal when testing on Linux, works fine on Windows
  4. Price not updating - Check internet connection and API status

Support:

  • Check the log area for detailed error messages
  • Verify your MEXC account has sufficient funds
  • Ensure API keys have trading permissions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published