A comprehensive copy-trading platform that monitors top DEX traders, tracks their performance, and automatically executes copy trades with built-in risk management.
- Real-time Trader Monitoring: Tracks top 5 traders from CoinMarketCap DEX data
- Multi-Chain Support: Supports Solana and BSC (Binance Smart Chain)
- Automated Copy Trading: Executes trades automatically with configurable parameters
- Risk Management: Pauses underperforming traders automatically
- Performance Analytics: Real-time P&L tracking and portfolio management
- Blockchain Monitoring: Real-time transaction monitoring via WebSockets
- Trader Discovery Service: Fetches and monitors top traders every 30 seconds
- Blockchain Monitor Service: Real-time transaction monitoring for tracked wallets
- Copy Trading Engine: Executes copy trades with risk management logic
- Performance Analytics: Tracks P&L and portfolio performance
traders- Tracked trader information and statustrader_trades- Original trader transactionscopy_trades- Our executed copy tradesportfolio_positions- Current holdings per tradertrader_performance- Aggregated performance metricssystem_metrics- Overall platform performance
- Go 1.21+
- PostgreSQL 15+
- CoinMarketCap API key (optional)
-
Clone and setup:
git clone <repository> cd copy-trade-bot make setup
-
Configure environment:
cp .env.example .env # Edit .env with your configuration -
Start database:
make db-up
-
Install dependencies and build:
make deps make build
-
Run the application:
make run
Edit the .env file with your settings:
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=copy_trader
DB_PASSWORD=your_password
DB_NAME=copy_trade_db
# API Keys
COINMARKETCAP_API_KEY=your_cmc_api_key
# Blockchain RPC URLs
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
BSC_RPC_URL=https://bsc-dataseed.binance.org/
# Trading Configuration
MAX_POSITION_SIZE=10.0 # USDC per trade
MAX_SLIPPAGE=0.05 # 5% max slippage
TRADER_FETCH_INTERVAL=30 # seconds- Condition: Trader status = ACTIVE AND avg performance > 50%
- Amount: Fixed 10 USDC per trade
- Risk: Pause trader if avg portfolio performance drops below 50%
- Condition: Always copy (regardless of trader status)
- Amount: Proportional to our current holdings
- Execution: Immediate copy when detected
The platform continuously monitors:
- Trader Performance: Win rate, P&L, volume metrics
- Portfolio Values: Real-time position tracking and P&L
- Risk Metrics: Automatic trader pausing based on performance
- System Health: Database connectivity and service status
- Performance-based pausing: Traders paused if avg performance < 50%
- Position limits: Max 10 USDC per trade, configurable per trader
- Slippage protection: Configurable maximum slippage (default 5%)
- Gas management: Dynamic gas estimation for optimal execution
- Pause/resume individual traders
- Adjust position sizes and risk parameters
- Emergency stop functionality
make help # Show all available commands
make deps # Download dependencies
make build # Build the application
make run # Run the application
make dev # Run with hot reload
make test # Run tests
make test-coverage # Run tests with coverage
make check # Run fmt, vet, and lint
make clean # Clean build artifactsInstall recommended tools:
make install-toolsThis installs:
air- Hot reload for developmentgolangci-lint- Code linting
make db-up # Start PostgreSQL container
make db-down # Stop PostgreSQL containercopy-trade-bot/
βββ cmd/ # Application entry points
β βββ main.go
βββ internal/ # Private application code
β βββ config/ # Configuration management
β βββ db/ # Database connection and migrations
β βββ models/ # Database models
β βββ services/ # Business logic services
βββ pkg/ # Public library code
β βββ dex/ # DEX client implementations
β βββ utils/ # Utility functions
βββ scripts/ # Database scripts and utilities
βββ docs/ # Documentation
βββ .env.example # Environment configuration template
βββ Makefile # Build and development commands
βββ README.md # This file
- Private Keys: Store securely, consider hardware wallets for production
- API Keys: Rotate regularly and use environment variables
- Database: Use SSL connections and proper access controls
- Monitoring: Implement proper logging and alerting
- Total P&L across all traders
- Success rate percentage
- Average copy delay time
- Volume traded per day
- Individual trader P&L
- Win/loss ratios
- Average hold times
- Risk scores
- Token performance across traders
- Best/worst performing assets
- Portfolio allocation
The platform includes:
- Health check endpoints
- Database connectivity monitoring
- Service status tracking
- Error logging and reporting
- High Risk: Copy trading involves significant financial risk
- No Guarantees: Past performance does not guarantee future results
- Due Diligence: Always verify trader performance before copying
- Compliance: Ensure compliance with local trading regulations
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and quality checks:
make check test - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and feature requests, please open an issue on GitHub.