An advanced AI-powered algorithmic trading system combining Deep Reinforcement Learning, ensemble machine learning, and sophisticated risk management.
Features โข Architecture โข Installation โข Usage โข Configuration โข Contributing
DART (Deep Adaptive Reinforcement Trader) is a sophisticated Python-based algorithmic trading platform that leverages cutting-edge AI technologies to analyze financial markets, generate trading strategies, and execute trades automatically. Built with a focus on adaptability and risk management, DART combines multiple ML paradigms to make intelligent trading decisions.
- ๐ง Hybrid AI Architecture: Combines traditional ML ensembles with Deep Reinforcement Learning
- ๐ Multi-Modal Analysis: Integrates technical indicators, price patterns, and market sentiment
- ๐ก๏ธ Institutional-Grade Risk Management: Monte Carlo VaR, Kelly Criterion, and dynamic position sizing
- ๐ฏ Uncertainty-Aware Trading: Epistemic and aleatoric uncertainty quantification for confident decisions
- ๐ Self-Adaptive Learning: Continuously improves from trade outcomes
| Feature | Description |
|---|---|
| Soft Actor-Critic (SAC) | State-of-the-art deep RL with automatic entropy tuning |
| Ensemble Stacking | Gradient Boosting + Random Forest + Logistic Regression meta-learner |
| Market Regime Detection | VAE-based detection of 7 market conditions (trending, volatile, ranging, etc.) |
| Curiosity-Driven Exploration | Intrinsic Curiosity Module (ICM) for better market exploration |
| Uncertainty Quantification | Ensemble disagreement + Monte Carlo dropout for confidence estimation |
| Feature | Description |
|---|---|
| 50+ Technical Indicators | RSI, MACD, Bollinger Bands, ATR, ADX, Stochastic, CCI, MFI, VWAP, and more |
| Market Structure Analysis | Support/resistance levels, trend direction, volatility regimes |
| Pattern Recognition | Gap detection, trend strength calculation, price pattern identification |
| Multi-Timeframe Analysis | From 1-minute scalping to daily swing trading |
| Feature | Description |
|---|---|
| Monte Carlo VaR | Value at Risk with 10,000+ simulations at 95% and 99% confidence |
| Kelly Criterion | Optimal position sizing based on expected returns |
| Dynamic Drawdown Protection | Automatic trading pause on configurable drawdown thresholds |
| Correlation-Based Limits | Portfolio diversification with correlation exposure management |
| Regime-Adjusted Sizing | Position sizes adapt to detected market conditions |
| Interface | Description |
|---|---|
| Desktop Application | Modern CustomTkinter-based GUI with real-time charts and trading controls |
| Web Dashboard | Streamlit-powered dashboard with glassmorphism design and live AI insights |
| API Integration | Full Deriv.com API support for live trading and market data |
DART/
โโโ ๐ api/ # API Integration Layer
โ โโโ deriv_client.py # Deriv API with OAuth 2.0 PKCE, trading, and account management
โ โโโ websocket_server.py # Real-time WebSocket server for live UI push updates
โ
โโโ โ๏ธ config/ # Configuration
โ โโโ dart_config.py # Pydantic v2 SOTA configuration settings and validator
โ
โโโ ๐ง ml/ # Machine Learning Core
โ โโโ deep_rl_agent.py # Soft Actor-Critic with attention & curiosity modules
โ โโโ trading_ai_v3.py # Ensemble learning (RF + GB + MLP) and strategy generation
โ โโโ feature_extractor.py # 50+ technical indicators and sentiment analysis
โ โโโ risk_manager.py # Monte Carlo VaR, Kelly criterion, position sizing
โ โโโ auto_trader.py # Multi-symbol portfolio auto-trader with background monitoring
โ โโโ backtester.py # Event-driven backtesting framework with risk integration
โ โโโ candlestick_patterns.py # 8 vectorized candlestick pattern detectors
โ โโโ evaluation_monitor.py # Trade & model evaluation, W&B integration, degradation alerts
โ โโโ llm_market_analyzer.py # LLM-powered market analysis via vLLM/OpenAI + LangChain
โ
โโโ ๐จ ui/ # User Interfaces
โ โโโ app.py # Main desktop application (1900+ lines)
โ โโโ modern_dashboard.py # Streamlit web dashboard with glassmorphism & async caching
โ โโโ chart_styles.py # Chart theming and visualization
โ โโโ ui_theme.py # Theme management (dark/light modes)
โ
โโโ ๐ง utils/ # Utilities
โ โโโ api_utils.py # Circuit breaker, retry logic, and error handling
โ โโโ logging.py # Structured logging with structlog
โ โโโ timeframe.py # Timeframe conversions
โ
โโโ ๐ models/ # Saved ML models (runtime generated)
โโโ ๐ logs/ # Trading logs and performance data
โโโ ๐ tests/ # Unit and integration tests (54 tests)
โ
โโโ ๐ main.py # Desktop app entry point
โโโ ๐ pyproject.toml # Dependencies and project metadata
graph TB
subgraph "Data Layer"
API[Deriv API Client]
FE[Feature Extractor]
CP[Candlestick Patterns]
LLM[LLM Market Analyzer]
end
subgraph "AI Core"
SAC[Soft Actor-Critic]
ENS[Ensemble Models]
MRD[Market Regime Detector]
UQ[Uncertainty Estimator]
end
subgraph "Risk Layer"
RM[Risk Manager]
PS[Position Sizer]
DP[Drawdown Protection]
end
subgraph "Execution"
AT[Auto Trader]
TL[Trade Logger]
BT[Backtester]
EM[Evaluation Monitor]
end
subgraph "UI Layer"
GUI[Desktop App]
WEB[Web Dashboard]
WS[WebSocket Server]
end
API --> FE
FE --> CP
FE --> SAC
FE --> ENS
LLM --> ENS
SAC --> MRD
ENS --> UQ
MRD --> RM
UQ --> RM
RM --> PS
PS --> AT
DP --> AT
AT --> TL
AT --> EM
AT --> API
AT --> WS
BT --> RM
GUI --> AT
WEB --> WS
- Python 3.14+ (required)
- uv - Fast Python package installer
# 1. Clone the repository
git clone https://github.com/ItzSwapnil/DART.git
cd DART
# 2. Install uv (if not already installed)
# Windows (PowerShell)
curl -LsSf https://astral.sh/uv/install.ps1 | powershell
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# 3. Create virtual environment and install dependencies
uv venv .venv
# Activate (Windows)
.venv\Scripts\activate
# Activate (macOS/Linux)
source .venv/bin/activate
# 4. Install DART
uv pip install -e .
# 5. (Optional) Install deep learning extras
uv pip install -e ".[deep-learning]"python -c "import torch; print(f'PyTorch: {torch.__version__}')"
python -c "from ml.trading_ai_v3 import TradingAIv3; print('DART AI: OK')"# Launch the main application
python main.pyQuick Guide:
- Select a market from the dropdown (e.g., Volatility 75 Index)
- Choose your timeframe (1 minute to 1 day)
- Click "Train Model" to train AI on 7 days of historical data
- Adjust the confidence threshold slider (higher = fewer but more confident trades)
- Click "Start Auto-Trading" to begin automated trading
- Monitor real-time performance in the trading dashboard
# Launch the Streamlit dashboard
streamlit run ui/modern_dashboard.pyThe web dashboard features:
- Real-time AI insights with epistemic/aleatoric uncertainty display
- Interactive candlestick charts with technical indicators
- Live performance metrics and trade history
- Non-blocking async data fetching with background caching (zero UI freeze)
- WebSocket real-time push updates from the Auto Trader
- Multi-symbol portfolio trading support
- Glassmorphism UI design with dark mode
from ml.trading_ai_v3 import TradingAIv3
from api.deriv_client import DerivClient
# Initialize components
client = DerivClient(
app_id="72212",
access_token="YOUR_ACCESS_TOKEN",
account_id="YOUR_ACCOUNT_ID"
)
ai = TradingAIv3(use_llm=True)
# Get historical data and train
data = await client.get_historical_data("R_75", 60, days=7)
ai.train(data)
# Generate strategy
current_data = await client.get_candles("R_75", 60, count=100)
strategy = ai.generate_strategy(current_data, use_llm=True)
print(f"Direction: {strategy['direction']}")
print(f"Confidence: {strategy['confidence']:.2%}")
print(f"Uncertainty: {strategy['uncertainty']:.4f}")DART v3.0+ uses secure OAuth 2.0 PKCE authentication.
- Create a Deriv.com account.
- Register an application in the Deriv Developer Portal to obtain your App ID and OAuth Client ID. Set the Redirect URI to
http://localhost:8080/callback. - Set your environment variables in
.env(located in the project root):
DERIV_APP_ID=your_app_id
DERIV_OAUTH_CLIENT_ID=your_client_id
DERIV_OAUTH_REDIRECT_URI=http://localhost:8080/callback
DERIV_ACCESS_TOKEN=your_access_token
DERIV_ACCOUNT_ID=your_account_id| Setting | Description | Default |
|---|---|---|
TRADE_AMOUNT |
Stake per trade | 1.0 |
MAX_DAILY_LOSS |
Daily loss limit | 50.0 |
CONFIDENCE_THRESHOLD |
Min confidence for trades | 0.65 |
TRAINING_DAYS |
Historical data for training | 7 |
MAX_CONSECUTIVE_LOSSES |
Losses before strategy recalc | 3 |
# config/dart_config.py
MAX_PORTFOLIO_RISK = 0.02 # 2% portfolio risk per trade
MAX_DRAWDOWN_THRESHOLD = 0.15 # 15% max drawdown
VAR_CONFIDENCE_LEVELS = [0.95, 0.99] # VaR confidence| Package | Purpose |
|---|---|
torch>=2.9.1 |
Deep learning (SAC, neural networks) |
scikit-learn>=1.8.0 |
Ensemble models, preprocessing |
pandas>=2.3.3 |
Data manipulation |
numpy>=2.4.0 |
Numerical computing |
ta>=0.11.0 |
Technical analysis indicators |
python-deriv-api>=0.1.6 |
Deriv.com API client |
customtkinter>=5.2.2 |
Modern desktop UI |
streamlit>=1.52.0 |
Web dashboard |
matplotlib>=3.10.8 |
Chart visualization |
plotly>=6.5.1 |
Interactive charts |
# Deep learning extras
uv pip install -e ".[deep-learning]"
# Development tools
uv pip install -e ".[dev]"
# Additional data sources
uv pip install -e ".[data-sources]"DART tracks comprehensive performance metrics:
- Win Rate: Percentage of profitable trades
- Sharpe Ratio: Risk-adjusted returns
- Sortino Ratio: Downside risk-adjusted returns
- Maximum Drawdown: Largest peak-to-trough decline
- Calmar Ratio: Return/drawdown ratio
- Value at Risk (VaR): 95% and 99% confidence
- Expected Shortfall (CVaR): Tail risk measure
- Deep Reinforcement Learning (Soft Actor-Critic)
- Ensemble ML with stacking meta-learner
- Advanced risk management (VaR, Kelly, drawdown)
- Market regime detection (7 regimes)
- Uncertainty quantification
- Web dashboard with Streamlit
- Multi-modal feature extraction (50+ indicators)
- Pattern recognition (8 candlestick patterns)
- Backtesting framework
- Portfolio management (multi-symbol, multi-position)
- WebSocket real-time updates
- Non-blocking async dashboard with background caching
- LLM-powered market analysis (vLLM/OpenAI)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Code formatting & linting
ruff format .
ruff check .This project is licensed under the MIT License - see the LICENSE file for details.
- Deriv API - Market data and trading infrastructure
- PyTorch - Deep learning framework
- scikit-learn - Machine learning library
- TA Library - Technical analysis
- Streamlit - Web dashboard framework
- uv - Fast Python package management
Built with โค๏ธ for the future of algorithmic trading
