This is a comprehensive crypto trading bot with a React dashboard for monitoring and control. The system includes:
- Trading Bot: Python-based algorithmic trading system
- React Dashboard: Modern web interface for monitoring and control
- REST API: FastAPI server connecting the dashboard to the bot
- Comprehensive Testing: Full test suite with 3,497+ lines of test code
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ React │ │ FastAPI │ │ Trading Bot │
│ Dashboard │◄──►│ API Server │◄──►│ Core System │
│ (Port 3000) │ │ (Port 8000) │ │ (Background) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
# Make setup script executable
chmod +x setup_ubuntu.sh
# Run automated setup
./setup_ubuntu.shThis script will:
- ✅ Update system packages
- ✅ Install Python 3.11+, Node.js, and dependencies
- ✅ Create virtual environment
- ✅ Install all Python and Node.js packages
- ✅ Create configuration files
- ✅ Set up systemd service
- ✅ Create startup scripts
- ✅ Run basic tests
If you prefer manual setup, follow the detailed guide in UBUNTU_SETUP_GUIDE.md.
# Edit environment file
nano .env
# Add your Binance API credentials:
BINANCE_API_KEY=your_actual_api_key
BINANCE_API_SECRET=your_actual_api_secret
TESTNET=true # Keep true for testingTerminal 1 - API Server:
./start_api.sh
# API available at: http://localhost:8000
# Documentation at: http://localhost:8000/docsTerminal 2 - Dashboard:
./start_dashboard.sh
# Dashboard available at: http://localhost:3000Terminal 3 - Trading Bot (Optional):
./start_bot.sh
# Bot runs in backgroundOpen your browser and navigate to: http://localhost:3000
- Real-time portfolio value and P&L
- Active positions summary
- Recent trades and performance metrics
- System health indicators
- Position tracking with real-time P&L
- Asset allocation visualization
- Performance analytics and charts
- Risk metrics and drawdown analysis
- Enable/disable trading strategies
- Strategy performance comparison
- Parameter adjustment interface
- Backtesting results
- Start/stop trading with one click
- Paper trading vs live trading modes
- Emergency stop functionality
- Real-time market signals
- API key management
- Risk management parameters
- Notification preferences
- System configuration
- Real-time log monitoring
- Filter by component and log level
- Download logs functionality
- Error tracking and alerts
# Activate virtual environment
source venv/bin/activate
# Run comprehensive test suite
python3 run_tests.py
# Run specific component tests
python3 run_tests.py --component strategies
python3 run_tests.py --component technical
python3 run_tests.py --component managers
# Run with coverage analysis
python3 run_tests.py --coverage- 3,497+ lines of test code
- Unit tests for all components
- Integration tests for workflows
- End-to-end tests for complete scenarios
- Mock data generators for realistic testing
symbols:
- BTCUSDT
- ETHUSDT
- ADAUSDT
strategies:
liquidity:
enabled: true
weight: 1.0
momentum:
enabled: true
weight: 1.2
risk_management:
max_position_size: 0.02 # 2% per trade
daily_loss_limit: 0.05 # 5% daily limit
max_drawdown: 0.15 # 15% max drawdown# API Configuration
BINANCE_API_KEY=your_api_key
BINANCE_API_SECRET=your_api_secret
TESTNET=true
# Trading Configuration
TRADING_ENABLED=false
DRY_RUN=true
LOG_LEVEL=INFO# Set proper file permissions
chmod 600 .env
chmod 600 config/bot_config.yaml
# Use environment variables
export BINANCE_API_KEY="your_key"
export BINANCE_API_SECRET="your_secret"# Allow dashboard access (optional)
sudo ufw allow 3000/tcp
# Allow API access (only if needed externally)
sudo ufw allow 8000/tcp# Enable auto-start
sudo systemctl enable crypto-trading-bot
# Start/stop service
sudo systemctl start crypto-trading-bot
sudo systemctl stop crypto-trading-bot
# Check status
sudo systemctl status crypto-trading-bot# View real-time logs
tail -f logs/bot.log
# Check API server logs
tail -f logs/api.log
# Monitor system resources
htop# Check API health
curl http://localhost:8000/health
# Check bot status
curl http://localhost:8000/status
# View portfolio
curl http://localhost:8000/portfoliocrypto-trading-bot/
├── crypto_trading_bot/ # Core trading bot
│ ├── strategies/ # Trading strategies
│ ├── managers/ # Component managers
│ ├── models/ # Data models
│ ├── utils/ # Utilities
│ └── api/ # API clients
├── dashboard/ # React dashboard
│ ├── src/ # Source code
│ ├── public/ # Static files
│ └── package.json # Dependencies
├── tests/ # Test suite
│ ├── test_strategies.py # Strategy tests
│ ├── test_technical_analysis.py # TA tests
│ └── test_managers.py # Manager tests
├── config/ # Configuration files
├── logs/ # Log files
└── api_server.py # FastAPI server
-
New Strategy:
# Create strategy file touch crypto_trading_bot/strategies/my_strategy.py # Add tests # Update configuration # Test thoroughly
-
Dashboard Component:
# Create React component touch dashboard/src/components/MyComponent.tsx # Add to routing # Style with Tailwind CSS # Connect to API
-
Port Already in Use:
# Kill process using port sudo lsof -t -i:8000 | xargs kill -9 sudo lsof -t -i:3000 | xargs kill -9
-
Python Module Not Found:
# Ensure virtual environment is activated source venv/bin/activate # Add to Python path export PYTHONPATH="${PYTHONPATH}:$(pwd)"
-
API Connection Issues:
# Check if API server is running curl http://localhost:8000/health # Restart API server pkill -f api_server.py python3 api_server.py
-
Dashboard Build Issues:
# Clear npm cache cd dashboard npm cache clean --force rm -rf node_modules package-lock.json npm install
- Check logs:
tail -f logs/bot.log - Test components:
python3 run_tests.py - API documentation:
http://localhost:8000/docs - Dashboard:
http://localhost:3000
- Ubuntu Setup Guide:
UBUNTU_SETUP_GUIDE.md - API Documentation: Available at
http://localhost:8000/docs - Test Results: Run
python3 test_summary.py
- Always start with
TESTNET=true - Use
DRY_RUN=truefor paper trading - Test thoroughly before live trading
- Never share your API keys
- Monitor your positions regularly
- Set appropriate risk limits
✅ API Server: http://localhost:8000/health returns "healthy"
✅ Dashboard: http://localhost:3000 loads successfully
✅ Tests: python3 test_basic.py passes all tests
✅ Configuration: API keys configured and testnet enabled
✅ Logs: System logs show no critical errors
🚀 You're now ready to start algorithmic crypto trading with a professional dashboard!
Remember to start with paper trading and gradually move to live trading as you gain confidence in the system.