Personal trading bot for β€5 users - Fast path to first paper trade with live Binance data.
A simplified, production-ready hybrid trading system combining Smart Money Concepts analysis with live market data for automated cryptocurrency paper trading.
Frontend (React 18 + TypeScript)
- Modern React UI with real-time dashboard
- Live market data from Binance WebSocket
- Paper trading visualization
Backend (Express.js + TypeScript)
- RESTful API with WebSocket connections to Binance
- Real-time market data aggregation
- Circuit breaker patterns and rate limiting
Trading Engine (Python + FastAPI)
- SMC Analysis: Order block detection, pattern recognition
- Paper Trading: Simulated execution with live prices
- Risk Management: Position sizing, stop-loss, daily limits
- Simple Heuristic: Fast decisions without ML training (ML optional later)
Key Simplifications vs Enterprise Version:
- β Kafka removed (direct REST API)
- β Multiple exchanges removed (Binance only)
- β PostgreSQL/Redis removed (SQLite)
- β Prometheus/Grafana removed (simple logging)
- β Complex ML ensemble removed (simple heuristic first, ML optional)
- β 2 processes only: TypeScript backend + Python agent
- π Live Binance Data: Real-time WebSocket price feeds
- π SMC Pattern Detection: Order block and reversal detection
- π― Simple Heuristic: Fast decisions based on SMC patterns (no ML training needed)
- π Paper Trading: Risk-free simulation with live prices
- π‘οΈ Risk Management: Position limits, stop loss, daily loss limits
- π Live Dashboard: Real-time P&L, positions, and trade history
- π Safety First: Paper mode default, risk controls enforced
- β‘ Fast Setup: < 30 minutes to first paper trade
- Node.js 18+
- Python 3.9+
- Binance API keys (read-only for paper trading)
# 1. Install dependencies
npm install
pip install -r requirements.txt
# 2. Configure API keys
cp env.example .env
nano .env # Add your BINANCE_API_KEY and BINANCE_API_SECRET
# 3. Start TypeScript backend (Terminal 1)
npm run server:dev
# 4. Start Python trading agent (Terminal 2)
python main.py
# 5. Start frontend (Terminal 3)
npm run clwx1xwxxxient:dev
# 6. Open browser
open http://localhost:5173π Detailed guide: See docs/QUICK_START.md for step-by-step instructions.
For the new V1 API that includes user authentication, encrypted API key storage, and paper trading controls, set the required secrets and run:
export AGENT66_JWT_SECRET="replace_with_long_random_string"
export AGENT66_ENCRYPTION_KEY="$(python - <<'PY'\nfrom cryptography.fernet import Fernet\nprint(Fernet.generate_key().decode())\nPY\n)"
python -m smc_trading_agent.v1.runThen visit http://localhost:9000/docs for the OpenAPI UI.
Dev convenience: if these env vars are not set, the v1 service will generate ephemeral keys at startup and log a warning (dev only).
The system includes comprehensive historical data management for strategy backtesting and ML model training.
- π 6+ Months of Data: Historical OHLCV data for top 10 trading pairs
- β‘ Fast Queries: <1s query performance for 1-month date ranges
- π Data Quality: Automated validation for gaps, duplicates, and outliers
- π₯ Export: CSV export for external analysis tools
- π€ Automation: Celery tasks for daily data updates
- ποΈ Management UI: Web interface for monitoring and control
- BTC, ETH, BNB, ADA, XRP, SOL, DOGE, MATIC, DOT, AVAX (USDT pairs)
- 1m, 5m, 15m, 1h, 4h, 1d
# 1. Initialize TimescaleDB database
python -c "
import asyncio
from historical_data.migrations import init_timescaledb
asyncio.run(init_timescaledb())
"
# 2. Start Celery worker for background tasks
celery -A historical_data.celery_app worker --loglevel=info
# 3. Trigger initial backfill (6+ months of data)
python scripts/trigger_backfill.py --sync
# 4. Access the management UI
open http://localhost:5173/historical-data
# 5. Access API documentation
open http://localhost:8000/docsπ Complete Guide: docs/historical_data_management.md
Related Documentation:
- Historical Data Backfill Guide - Step-by-step backfill instructions
- E2E Verification Guide - Verification and testing procedures
GET /health- API health checkGET /api/historical-data/{symbol}/{timeframe}- Query OHLCV data with date rangePOST /api/historical-data/fetch- Trigger data fetch from BinanceGET /api/historical-data/status/{symbol}/{timeframe}- Get data coverage infoGET /api/historical-data/validate/{symbol}/{timeframe}- Run data quality validationGET /api/historical-data/export/{symbol}/{timeframe}- Export to CSVGET /api/historical-data/symbols- List available symbolsGET /api/historical-data/timeframes- List available timeframes
Interactive API documentation available at http://localhost:8000/docs
The system automatically connects to multiple exchanges for real-time data:
- Binance: Primary source for cryptocurrency data
- ByBit: Secondary source with failover capabilities
- OANDA: Forex and commodities (planned)
- Ticker Data: Price changes, volume, 24h statistics
- Order Book: Live bid/ask spreads with depth analysis
- Trade History: Recent trades for market sentiment analysis
- SMC Patterns: Automatic detection of order blocks and reversals
- OHLCV Candles: 6+ months of historical price data for backtesting
- Data Quality Validation: Automatic gap detection and outlier analysis
- Automated Updates: Daily data updates via Celery scheduled tasks
Development:
cp env.example .env
# Edit .env with your API keys and configurationProduction:
cp .env.production.example .env
# Edit .env with production settingsKey Environment Variables:
# Exchange API Keys
BINANCE_API_KEY=your_binance_api_key
BINANCE_API_SECRET=your_binance_secret
BYBIT_API_KEY=your_bybit_api_key
BYBIT_API_SECRET=your_bybit_secret
# Server Configuration
PORT=3002
NODE_ENV=development # or 'production'
# Security (REQUIRED for production)
ALLOWED_ORIGINS=https://yourdomain.com # Comma-separated list for production
# Trading Parameters
MAX_POSITION_SIZE=0.1
RISK_PER_TRADE=0.02
MAX_DRAWDOWN=0.05ALLOWED_ORIGINS must be set to specific domains. See Security Guide for details.
Default symbols: ['BTCUSDT', 'ETHUSDT', 'ADAUSDT', 'SOLUSDT', 'BNBUSDT']
Configure additional symbols in api/routes/trading.ts
GET /api/trading/market-data- Real-time market pricesGET /api/trading/data-health- System health and connection statusGET /api/trading/smc-patterns- Detected SMC patterns
POST /api/trading/execute-trade- Manual trade executionGET /api/trading/positions- Current positions with real-time P&LGET /api/trading/history- Trading history
GET /api/trading/risk-metrics- Real-time risk exposureGET /api/trading/performance- Trading performance statisticsGET /api/trading/system-health- Component health status
- API Call Protection: Automatic failover after 5 consecutive failures
- WebSocket Resilience: Automatic reconnection with exponential backoff
- Rate Limiting: Exchange-specific rate limit protection
- Position Limits: Automatic position size limits based on account balance
- Maximum Drawdown: 5% maximum account drawdown
- Position Sizing: Risk per trade limited to 2%
- Stop Loss: Automatic stop-loss on all positions
- Time-Based Exits: Automatic position closure after set timeframes
π Production Security Requirements:
- Set
NODE_ENV=production - Configure
ALLOWED_ORIGINSwith specific domain(s) - Use HTTPS for all production deployments
- Restrict API keys to minimum required permissions
- Never enable withdrawal permissions on exchange API keys
π For detailed security guidelines, see SECURITY_GUIDE.md
# Run frontend tests
npm test
# Run backend tests
npm run test:api
# Run Python ML tests
pytest tests/
# Run comprehensive test suite
npm run test:allGET /api/health- Basic API health checkGET /api/trading/data-health- Market data connection status- WebSocket health monitoring with automatic alerts
- Real-time P&L: Live profit/loss tracking
- Latency Monitoring: WebSocket and API response times
- Data Quality: Confidence scores and data freshness metrics
- System Performance: Memory, CPU, and connection statistics
- API Key Protection: Never commit API keys to version control
- Rate Limiting: Built-in protection against exchange API limits
- Input Validation: Comprehensive validation of all trading inputs
- Error Handling: Safe error responses that don't expose sensitive data
We welcome contributions! Please see our Contributing Guide for details on:
- Code of conduct
- Development setup
- Coding standards
- Commit guidelines
- Pull request process
Quick Start for Contributors:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following our coding standards
- Write tests for new features
- Commit with conventional commit format
- Open a Pull Request
For detailed developer information, see the Developer Guide.
- Hybrid Stack: React frontend with Python ML backend for performance
- WebSocket First: Real-time data prioritized over REST polling
- Circuit Breakers: Fault tolerance patterns throughout the system
- Microservices: Modular design for independent scaling
- Data Aggregation: Intelligent market data consolidation
- Caching: Redis caching for frequently accessed data
- Batch Processing: Efficient bulk operations for market data
- Connection Pooling: Reused connections for exchange APIs
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the troubleshooting guide
- Review API documentation
- Open an issue for bugs or feature requests
π§ Built with: React, TypeScript, Express, Python, TensorFlow, PyTorch, Rust