A comprehensive trading bot system with web dashboard, backtesting, live trading capabilities, and Machine Learning Trading Optimization.
trade/
βββ app.py # FastAPI backend server (Docker deployment)
βββ docker-compose.yml # Docker Compose deployment configuration
βββ Dockerfile # Backend Docker container configuration
βββ frontend/ # Next.js React/TypeScript frontend
βββ README.md # This file
β
βββ archive/ # Archived unused code (see archive/README.md)
β βββ vanilla_js_dashboard/ # Previously used vanilla JS dashboard
β
βββ config/ # Configuration files
β βββ pyproject.toml # Python project configuration
β βββ requirements.txt # Python dependencies
β βββ uv.lock # UV lock file
β βββ package.json # Node.js dependencies
β βββ package-lock.json # Node.js lock file
β βββ playwright.config.ts # Playwright configuration
β βββ vector-db-config.yaml # Vector database configuration
β
βββ src/ # Source code
β βββ trade_bot/ # Main application package
β βββ core/ # Core functionality
β βββ data/ # Data handling and providers
β βββ database/ # Database management
β βββ trading/ # Trading strategies and execution
β βββ ml/ # Machine Learning components
β βββ web/ # Web dashboard and API
β
βββ tests/ # Test suite
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ e2e/ # End-to-end tests
β
βββ data/ # Data storage
β βββ databases/ # SQLite databases
β βββ outputs/ # Generated output files
β βββ cache/ # Cached data and node_modules
β
βββ docs/ # Documentation
β βββ examples/ # Example code and tutorials
β βββ CHANGELOG.md # Version history
β βββ PROJECT_OVERVIEW.md # Project overview
β βββ spec.md # Technical specifications
β βββ TEST_RESULTS.md # Test results
β βββ TYPESCRIPT_TRANSITION.md # React/TypeScript transition documentation
β βββ WEBSOCKET_SUBSCRIPTIONS.md # WebSocket documentation
β βββ ML_TRADING_OPTIMIZATION.md # ML system documentation
β
βββ rules/ # Development rules and guidelines
βββ 01-core.md
βββ 02-request.md
βββ ... (other rule files)
- One Command Setup:
docker-compose upstarts everything - Automatic Service Management: Vector database and ML services start automatically
- Seamless Trading Integration: ML predictions available for simulated and live trading
- Real-time ML Dashboard: Built-in ML management interface at
http://localhost:3000 - Health Monitoring: Automatic service health checks and status monitoring
- Graceful Shutdown: Proper cleanup when stopping the system
- Microservices Design: Modular, scalable component architecture
- Async/Await: High-performance asynchronous Python
- Vector Database: Qdrant for ML pattern matching and similarity search
- Caching Layer: Redis for high-performance data caching
- WebSocket Integration: Real-time data streaming
- RESTful API: FastAPI with automatic OpenAPI documentation
- Python 3.11+
- Node.js 18+
- UV package manager
- Qdrant (for ML vector database)
- Redis (for ML caching)
# Install Python dependencies
uv sync
# Install Node.js dependencies
npm install --prefix data/cache
# Install ML dependencies
pip install scikit-learn pandas numpy joblib requestsIMPORTANT: Before running the application, you must set up your Coinbase API credentials securely.
-
Copy the environment template:
cp docs/env.example .env
-
Get your Coinbase API credentials from Coinbase Pro API Settings
-
Update your
.envfile with your actual credentials -
Configure all trading settings through the web dashboard's Live Trading tab
-
See Security Setup Guide for detailed instructions
.env file or expose your API credentials!
### Running the Application
#### Docker Compose Deployment (Recommended)
```bash
# Start all services using Docker Compose
docker-compose up
This single command starts:
- Frontend: Next.js React dashboard on
http://localhost:3000 - Backend: FastAPI server on
http://localhost:8000 - Qdrant vector database on
http://localhost:6333 - Redis cache on
localhost:6379 - PostgreSQL database on
localhost:5432 - All ML services available for trading
If you need to run services individually for development:
# Start backend only
docker-compose up backend
# Start frontend only (requires backend running)
cd frontend && npm run dev
# Start databases only
docker-compose up db redis qdrantThe previous CLI interface using main.py has been archived. If you need to restore the vanilla JavaScript dashboard for comparison or testing, see archive/README.md for restoration instructions.
- Web Dashboard: Real-time trading dashboard with candlestick charts
- Backtesting: Historical strategy testing with comprehensive metrics
- Data Providers: Coinbase Pro API integration for real market data
- Trading Strategies: Multiple built-in strategies (RSI, MACD, Bollinger Bands, etc.)
- Simulated Trading: Paper trading with realistic execution simulation
- WebSocket Integration: Real-time data streaming
- Database Storage: SQLite for persistent data storage
- π€ Machine Learning Trading Optimization:
- ML-Enhanced Order Book Strategy: Real-time ML predictions for trading signals
- Vector Database: Qdrant vector database for pattern matching and similarity search
- Ensemble Models: Random Forest, Gradient Boosting, Neural Networks
- Feature Engineering: Advanced order book feature extraction
- Model Management: Versioning, hot-swapping, and rollback capabilities
- Real-time Inference: Sub-second ML predictions during live trading
- Performance Monitoring: Comprehensive ML model performance tracking
Configuration files are located in the config/ directory:
pyproject.toml: Python project settingsrequirements.txt: Python dependenciespackage.json: Node.js dependenciesplaywright.config.ts: E2E testing configurationvector-db-config.yaml: Vector database configuration for ML system
# Run unit tests
python -m pytest tests/unit/
# Run integration tests
python -m pytest tests/integration/
# Run E2E tests
npx playwright test- Databases: Stored in
data/databases/ - Outputs: Generated files in
data/outputs/ - Cache: Temporary data in
data/cache/
Access the web dashboard at http://localhost:3000 after running:
docker-compose upFeatures:
- Real-time price charts
- Trading strategy configuration
- Backtest results visualization
- Live trading interface
- Data feed monitoring
- π€ Integrated ML Trading Optimization:
- ML model status and performance metrics
- Feature importance visualization
- Model control interface (train, update, rollback)
- Real-time ML system monitoring
- ML vs baseline strategy comparison
- Automatic ML Service Management: Vector database and ML services start automatically
- Trading Integration: ML predictions available for simulated and live trading
The ML Trading Optimization system enhances trading decisions using machine learning:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Trading Bot β β ML Optimizer β β Vector Database β
β β β β β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β Order Book β βββββΆβ β Data β βββββΆβ β Qdrant β β
β β Strategy β β β β Collector β β β β Vector DB β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β β β β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β ML Enhanced β ββββββ β Model β ββββββ β Redis β β
β β Strategy β β β β Manager β β β β Cache β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β ML Model Server β
β (FastAPI) β
βββββββββββββββββββ
- Data Collection: Extract order book signals and trade outcomes
- Feature Engineering: Transform raw data into ML-ready features
- Model Training: Ensemble models (RF, GB, NN, Linear)
- Vector Database: Qdrant for pattern matching and similarity search
- Model Management: Versioning, deployment, and rollback
- Real-time Inference: Sub-second ML predictions during trading
- Qdrant Vector DB:
http://localhost:6333- Feature vector storage - Redis Cache:
localhost:6379- High-performance caching - PostgreSQL DB:
localhost:5432- Main database - Backend API:
http://localhost:8000- FastAPI backend server - Web Dashboard:
http://localhost:3000- Next.js React dashboard
- Automatic Startup: All ML services start automatically with
docker-compose up - Health Monitoring: Built-in health checks and service status monitoring
- Graceful Shutdown: Proper cleanup when web dashboard stops
- Trading Integration: ML predictions seamlessly integrated into trading strategies
Detailed documentation is available in the docs/ directory:
- Project Overview
- Web Dashboard Guide
- WebSocket Subscriptions
- Test Results
- π€ ML Trading Optimization - Complete ML system documentation
- Vector Database Service - Integrated service management
# Check if Qdrant and Redis are installed
which qdrant
which redis-server
# Install missing services
# For macOS with Homebrew:
brew install qdrant redis
# For Ubuntu/Debian:
sudo apt-get install qdrant redis-serverIf ports 3000, 8000, 6333, 6379, or 5432 are already in use:
# Check what's using the ports
lsof -i :3000 # Frontend
lsof -i :8000 # Backend
lsof -i :6333 # Qdrant
lsof -i :6379 # Redis
lsof -i :5432 # PostgreSQL
# Stop conflicting services or modify ports in docker-compose.yml# Start the application with Docker Compose
docker-compose up
# Access the dashboard at http://localhost:3000
# Use the ML Analytics tab to start simulated trading and generate training data# Check service status
curl http://localhost:6333/health # Qdrant
redis-cli -p 6379 ping # Redis
curl http://localhost:8000/health # Backend API
curl http://localhost:3000/api/health # Frontend APIPlease read the development rules in the rules/ directory before contributing.
This project is proprietary software. All rights reserved.