Crypto Trading Bot with MEXC API Integration
This is an AI-powered cryptocurrency trading bot that can run in both simulation (demo) mode and live trading mode using the MEXC exchange API.
Features
- Deep Reinforcement Learning agent for trading decisions
- Technical indicators and price prediction
- Live trading integration with MEXC exchange via mexc-api
- Demo mode for testing without real trades
- Real-time data streaming via websockets
- Performance tracking and visualization
Setup
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the root directory with your MEXC API keys:MEXC_API_KEY=your_api_key_here MEXC_SECRET_KEY=your_secret_key_here
Usage
The bot can be run in three different modes:
Training Mode
Train the agent on historical data:
python main.py --mode train --episodes 100
Evaluation Mode
Evaluate the trained agent on historical data:
python main.py --mode evaluate
Live Trading Mode
Run the bot in live trading mode:
python main.py --mode live
To run in demo mode (no real trades):
python main.py --mode live --demo
Live Trading Implementation
The bot uses the mexc-api package to execute trades on the MEXC exchange. The implementation includes:
- Market order execution for opening and closing positions
- Stop loss and take profit orders
- Real-time balance updates
- Trade history tracking
Configuration
You can adjust the following parameters in main.py
:
INITIAL_BALANCE
: Starting balance for simulationMAX_LEVERAGE
: Leverage to use for tradingSTOP_LOSS_PERCENT
: Default stop loss percentageTAKE_PROFIT_PERCENT
: Default take profit percentage
Architecture
main.py
: Main entry point and trading logicmexc_trading.py
: MEXC API integration for live trading using mexc-apimodels/
: Directory for saved model weights
Warning
Trading cryptocurrencies involves significant risk. This bot is provided for educational purposes only. Use at your own risk.
License
MIT