Can be used as a sidecar for other applications to create distinct application surfaces for model running, or can be built out into a fully integrated product. Supports:
- Apple Neural Engine Private API (ANE repo) (Apple M-Series)
- Unreal matrix solving
- 3800x faster than base runtime (pytorch/tensorflow) in small test
- CoreML fallback (Apple M-Series)
- 39x faster than base runtime in small test
- regular runtime for final fallback / default for non-MacOS
A sophisticated cryptocurrency automated trading application powered by ensemble AI analysis, implementing 10 cutting-edge machine learning models for superior trading performance. This system is designed for real-money trading with enterprise-grade security, comprehensive risk management, and advanced AI ensemble techniques.
- Microservices Architecture: Scalable, fault-tolerant design with independent components
- Security-First: Enterprise-grade security protocols throughout the system
- AI Ensemble Approach: Dynamic weighted-majority algorithm with utility-based weighting
- Real-Time Processing: Sub-100ms latency for trading decisions and execution
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Data Pipeline β β AI Ensemble β β Trading Engine β
β β β β β β
β β’ Market Data βββββΆβ β’ 10 ML Models βββββΆβ β’ Risk Manager β
β β’ Sentiment β β β’ Dynamic Weightsβ β β’ Position Sizerβ
β β’ On-chain β β β’ Orchestrator β β β’ Order Router β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Security β β Monitoring β β Compliance β
β β β β β β
β β’ Auth/AuthZ β β β’ Performance β β β’ Audit Logs β
β β’ Encryption β β β’ Health Checks β β β’ Risk Reports β
β β’ Key Rotation β β β’ Alerting β β β’ Regulatory β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Executive-Auxiliary Agent Dual Architecture: Hierarchical RL addressing sparse rewards (6.3%+ improvement)
- Cross-Modal Temporal Fusion: Transformer architecture with 20% improvement through multimodal integration
- Progressive Denoising VAE: Three-stage denoising for financial signal preservation
- Functional Data-Driven Quantile Ensemble: Mathematically proven optimal VaR prediction
- CryptoBERT-Enhanced Sentiment Fusion: Advanced NLP for crypto-specific sentiment analysis
- Temporal Fusion Transformer: Multi-scale attention for regime-aware predictions
- CNN-GAN-Autoencoder Ensemble: Pattern generation and anomaly detection
- Generalized Random Forest VaR: Research-validated risk prediction during instability
- Dynamic Portfolio Optimization: Statistical arbitrage with CNN-MHA architecture
- Multi-Modal Volatility Prediction: Chaos theory integration achieving 19.29% improvement
- Annual ROI: 25-50% (conservative backtesting estimate)
- Sharpe Ratio: >1.5 (crypto-adjusted)
- Maximum Drawdown: <15% (95% confidence)
- System Uptime: >99.5%
- Trade Execution: <50ms latency
- Multi-Factor Authentication: 2FA for all system access
- Encrypted Credential Storage: Fernet symmetric encryption with key rotation
- Comprehensive Audit Logging: All trading decisions and system access logged
- Network Security: TLS 1.3, VPN access, firewall protection
- Automated Security Monitoring: Real-time threat detection and response
- Helius RPC ($50/month): Optimized Solana blockchain data access
- TradingView Premium: Advanced technical analysis and market data
- Exchange APIs: Coinbase One & Kraken Pro integration
- Free Data Sources: CoinGecko, Alpha Vantage, social media APIs
- Kelly Criterion with ensemble confidence weighting
- Maximum 2% risk per trade
- Portfolio heat limit: 10%
- Dynamic volatility adjustment
- Real-time P&L monitoring
- Circuit breakers for extreme conditions
- Automated position reduction
- Emergency stop-loss mechanisms
Python 3.9+
PostgreSQL 13+
Redis 6+
Gitgit clone <repository-url>
cd crypto-ai-trading-system
pip install -r requirements.txt
python setup.py install- Copy
config/config.example.yamltoconfig/config.yaml - Configure API credentials (see Security section)
- Set up database connections
- Initialize the system:
python scripts/initialize_system.py
# Start data pipeline
python -m src.data.market_data_service
# Start AI ensemble
python -m src.ai_models.ensemble_orchestrator
# Start trading engine
python -m src.trading.trading_engine
# Monitor system
python -m src.utils.system_monitor
# HTTP prediction bridge for external agents
# (set ENSEMBLE_STUB=true to use the lightweight stub)
ENSEMBLE_STUB=true API_PORT=8288 python -m src.api.fastapi_serverproject/src/api/fastapi_server.py wraps the ensemble orchestrator in a
lightweight FastAPI service so external agents (Rust trader, MCP tools, etc.)
can call /predict over HTTP.
- Default host/port:
0.0.0.0:8288(override withAPI_HOST/API_PORT). - Request body example:
{ "token": "BONK", "features": { "momentum": 0.42, "volume": 1.8 }, "model": "ensemble" // optional override } - Response includes
prediction,confidence,expected_return,latency_ms, and the raw result structure. /healthreturns model counts + telemetry;/telemetryexposes aggregate call counts and average latency for dashboards.- WebSocket guidance stream: connect to
/ws/guidanceto receive low-latency guidance events (and optionally publish viaPOST /guidance/publish).curl -fsS -X POST http://localhost:8288/guidance/publish \ -H 'Content-Type: application/json' \ --data '{"symbol":"SOL/USDC","confidence":0.77,"score":0.66,"notes":"manual-publish"}'
From the project/ directory, the easiest way to bring the FastAPI sidecar up is:
# Creates/uses .venv and installs requirements via uv (pip fallback)
scripts/sidecar_run.sh
# Full ensemble mode (heavier deps, slower startup)
ENSEMBLE_STUB=false scripts/sidecar_run.sh
# Override bind address/port
API_HOST=127.0.0.1 API_PORT=8288 scripts/sidecar_run.shUse scripts/sidecar_smoke.sh to confirm the bridge is online and returning
predictions before pointing external agents at it:
# From project root
scripts/sidecar_smoke.sh
# Override the target endpoint if needed
SIDECAR_URL=http://localhost:8288 scripts/sidecar_smoke.shThe script pings /health, prints the current mode (stub vs full), and sends
a sample /predict payload so you can catch regressions quickly.
The sidecar can now orchestrate predictive-model refreshes for
/Users/sheawinkler/Documents/Projects/algotraderv2_rust without reimplementing
the Rust repo's trainer logic.
Endpoints:
GET /trainer/healthGET /trainer/statusGET /trainer/historyPOST /trainer/runPOST /trainer/promote/{run_id}GET /trainer/active-modelGET /trainer/candidate-model/{run_id}
Default behavior:
- scheduler disabled unless
SIDECAR_PREDICTIVE_TRAINER_ENABLED=true - cadence defaults to
600seconds when enabled - training uses the Rust repo's shadow firehose corpus as the primary dataset
- candidate models promote only when they improve row counts without materially degrading positive share or calibration
- relaunches happen only when
algotraderv2_rustis on clean syncedmainand there are0open positions
Key env vars:
SIDECAR_PREDICTIVE_TRAINER_ALGO_REPO_DIRSIDECAR_PREDICTIVE_TRAINER_DATA_DIRSIDECAR_PREDICTIVE_TRAINER_ENABLEDSIDECAR_PREDICTIVE_TRAINER_INTERVAL_SECSSIDECAR_PREDICTIVE_TRAINER_AUTO_PROMOTESIDECAR_PREDICTIVE_TRAINER_RELAUNCH_ENABLEDSIDECAR_PREDICTIVE_TRAINER_TIMEOUT_SECS(default200000;0disables the timeout)
python -m tests.backtesting.comprehensive_backtest --start-date 2022-01-01 --end-date 2024-01-01python -m src.trading.paper_trading --duration 30dpytest tests/unit/ -v --cov=src --cov-report=html- Technical Architecture
- AI Model Documentation
- Security Implementation
- Risk Management
- API Documentation
- Deployment Guide
src/
βββ ai_models/ # AI ensemble models and orchestrator
βββ data/ # Data ingestion and processing
βββ trading/ # Trading execution and order management
βββ risk/ # Risk management and monitoring
βββ security/ # Authentication and encryption
βββ utils/ # Shared utilities and helpers
tests/
βββ unit/ # Unit tests for individual components
βββ integration/ # Integration tests
βββ backtesting/ # Comprehensive backtesting framework
config/ # Configuration files
docs/ # Documentation
scripts/ # Deployment and utility scripts
logs/ # System logs
data/ # Historical and cache data
- Create feature branch from
main - Implement changes with comprehensive tests
- Run security audit:
python scripts/security_audit.py - Submit pull request with performance validation
- Code review and automated testing
- Deploy to staging for validation
- Production deployment after approval
- Trading performance (P&L, Sharpe ratio, drawdown)
- System health (uptime, latency, errors)
- Model performance (accuracy, confidence, drift)
- Risk metrics (VaR, portfolio heat, correlation)
- Slack integration for system alerts
- Email notifications for performance issues
- SMS alerts for critical system failures
- Dashboard visualizations with Grafana
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run the full test suite
- Submit a pull request
This repository is licensed under the Apache License, Version 2.0.
See LICENSE for the full terms.
- Active sidecar runtime surface remains in:
src/api/scripts/sidecar_run.shscripts/sidecar_smoke.shtests/sidecar/
- Legacy implementation artifacts were moved to
archive/legacy_2026q2/. - A long-lived preservation branch is kept at
dev/fastapi_sidecar_legacy_lab.
This software is designed for sophisticated users who understand the risks of algorithmic trading. Cryptocurrency trading involves substantial risk of loss. Past performance does not guarantee future results. Use at your own risk.
For technical support and questions:
- Email: sheawinkler@gmail.com
- Documentation: Technical Docs
- Issue Tracker: GitHub Issues
Built with π₯ for serious crypto traders