Files
trader-ml/config/risk_limits.example.yaml
Tika da30ef19ed Initial commit — Trading AI Secure project complet
Architecture Docker (8 services), FastAPI, TimescaleDB, Redis, Streamlit.
Stratégies : scalping, intraday, swing. MLEngine + RegimeDetector (HMM).
BacktestEngine + WalkForwardAnalyzer + Optuna optimizer.
Routes API complètes dont /optimize async.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08 17:38:09 +00:00

265 lines
11 KiB
YAML

# Configuration Risk Management - Trading AI Secure
# Copier ce fichier vers risk_limits.yaml et ajuster selon votre profil de risque
# ============================================================================
# LIMITES GLOBALES DU PORTFOLIO
# ============================================================================
global_limits:
# Capital et Exposition
max_portfolio_risk: 0.02 # 2% du capital total en risque simultané
max_position_size: 0.05 # 5% du capital par position maximum
max_total_exposure: 1.0 # 100% du capital (pas de levier)
min_cash_reserve: 0.10 # 10% du capital en réserve
# Drawdown et Pertes
max_drawdown: 0.10 # 10% drawdown maximum avant halt
max_daily_loss: 0.03 # 3% perte journalière maximum
max_weekly_loss: 0.07 # 7% perte hebdomadaire maximum
max_monthly_loss: 0.15 # 15% perte mensuelle maximum
# Corrélation et Diversification
max_correlation: 0.7 # Corrélation maximum entre positions
min_diversification: 3 # Minimum 3 positions non-corrélées
max_same_strategy_positions: 5 # Maximum 5 positions par stratégie
# Liquidité
min_daily_volume: 1000000 # 1M$ volume quotidien minimum
max_position_vs_volume: 0.01 # Maximum 1% du volume quotidien
min_spread_pct: 0.001 # 0.1% spread maximum acceptable
# Concentration
max_sector_exposure: 0.30 # 30% maximum par secteur
max_asset_class_exposure: 0.50 # 50% maximum par classe d'actif
max_currency_exposure: 0.40 # 40% maximum par devise
# ============================================================================
# LIMITES PAR STRATÉGIE
# ============================================================================
strategy_limits:
# Stratégie Scalping (Court Terme)
scalping:
enabled: true
max_trades_per_day: 50 # Maximum 50 trades par jour
max_trades_per_hour: 10 # Maximum 10 trades par heure
risk_per_trade: 0.005 # 0.5% du capital par trade
max_holding_time: 1800 # 30 minutes maximum
max_slippage: 0.001 # 0.1% slippage maximum acceptable
min_profit_target: 0.003 # 0.3% profit minimum visé
max_consecutive_losses: 3 # Pause après 3 pertes consécutives
# Paramètres adaptatifs
adaptive_params:
min_confidence: 0.65 # Confiance minimum pour trade
bb_period: 20 # Période Bollinger Bands
bb_std: 2.0 # Écart-type Bollinger
rsi_period: 14 # Période RSI
rsi_oversold: 30 # Seuil oversold
rsi_overbought: 70 # Seuil overbought
volume_threshold: 1.5 # Ratio volume vs moyenne
# Stratégie Intraday (Moyen Terme)
intraday:
enabled: true
max_trades_per_day: 10 # Maximum 10 trades par jour
max_trades_per_hour: 3 # Maximum 3 trades par heure
risk_per_trade: 0.015 # 1.5% du capital par trade
max_holding_time: 86400 # 1 jour maximum
max_slippage: 0.002 # 0.2% slippage maximum
min_profit_target: 0.01 # 1% profit minimum visé
max_consecutive_losses: 3 # Pause après 3 pertes
# Paramètres adaptatifs
adaptive_params:
min_confidence: 0.60 # Confiance minimum
ema_fast: 9 # EMA rapide
ema_slow: 21 # EMA lente
ema_trend: 50 # EMA tendance
atr_multiplier: 2.5 # Multiplicateur ATR pour stops
volume_confirmation: 1.2 # Confirmation volume
min_adx: 25 # ADX minimum (force tendance)
# Stratégie Swing (Long Terme)
swing:
enabled: true
max_trades_per_week: 5 # Maximum 5 trades par semaine
max_trades_per_day: 2 # Maximum 2 trades par jour
risk_per_trade: 0.025 # 2.5% du capital par trade
max_holding_time: 432000 # 5 jours maximum
max_slippage: 0.003 # 0.3% slippage maximum
min_profit_target: 0.03 # 3% profit minimum visé
max_consecutive_losses: 2 # Pause après 2 pertes
# Paramètres adaptatifs
adaptive_params:
min_confidence: 0.55 # Confiance minimum
sma_short: 20 # SMA courte
sma_long: 50 # SMA longue
rsi_period: 14 # Période RSI
macd_fast: 12 # MACD rapide
macd_slow: 26 # MACD lente
macd_signal: 9 # Signal MACD
# ============================================================================
# LIMITES DYNAMIQUES (Ajustées selon conditions)
# ============================================================================
dynamic_limits:
# Ajustements selon volatilité
volatility_adjustments:
enabled: true
low_volatility_threshold: 0.01 # < 1% volatilité quotidienne
high_volatility_threshold: 0.03 # > 3% volatilité quotidienne
# Réductions en haute volatilité
high_vol_position_size_mult: 0.5 # Réduire taille positions de 50%
high_vol_risk_mult: 0.7 # Réduire risque total de 30%
high_vol_trades_mult: 0.5 # Réduire nombre trades de 50%
# Ajustements selon drawdown
drawdown_adjustments:
enabled: true
# Paliers de drawdown
mild_drawdown: 0.05 # 5% drawdown
moderate_drawdown: 0.08 # 8% drawdown
severe_drawdown: 0.10 # 10% drawdown (halt)
# Réductions selon palier
mild_position_size_mult: 0.8 # -20% taille positions
moderate_position_size_mult: 0.5 # -50% taille positions
# Ajustements selon losing streak
losing_streak_adjustments:
enabled: true
# Paliers de pertes consécutives
minor_streak: 3 # 3 pertes consécutives
major_streak: 5 # 5 pertes consécutives
critical_streak: 7 # 7 pertes (pause trading)
# Réductions
minor_trades_mult: 0.7 # -30% nombre trades
minor_risk_mult: 0.5 # -50% risque par trade
major_trades_mult: 0.5 # -50% nombre trades
major_risk_mult: 0.3 # -70% risque par trade
# ============================================================================
# CIRCUIT BREAKERS (Arrêts Automatiques)
# ============================================================================
circuit_breakers:
# Drawdown excessif
max_drawdown_breaker:
enabled: true
threshold: 0.10 # 10% drawdown
action: "halt_trading" # Arrêter trading
notification: ["telegram", "email", "sms"]
# Perte journalière
daily_loss_breaker:
enabled: true
threshold: 0.03 # 3% perte journalière
action: "halt_trading"
notification: ["telegram", "email"]
# Volatilité extrême
volatility_spike_breaker:
enabled: true
threshold_multiplier: 3.0 # 3x volatilité normale
action: "reduce_exposure" # Réduire exposition
notification: ["telegram"]
# Flash crash
flash_crash_breaker:
enabled: true
price_move_threshold: 0.05 # 5% mouvement en 1 minute
action: "halt_trading"
notification: ["telegram", "sms"]
# API failure
api_failure_breaker:
enabled: true
max_consecutive_failures: 3 # 3 échecs consécutifs
action: "close_positions" # Fermer positions
notification: ["telegram", "email", "sms"]
# Corrélation excessive
correlation_breaker:
enabled: true
threshold: 0.85 # 85% corrélation
action: "block_new_trades" # Bloquer nouveaux trades
notification: ["telegram"]
# ============================================================================
# ALERTES ET NOTIFICATIONS
# ============================================================================
alerts:
# Seuils d'alerte (avant circuit breakers)
warning_thresholds:
drawdown_warning: 0.08 # Alerte à 8% drawdown
daily_loss_warning: 0.025 # Alerte à 2.5% perte journalière
position_size_warning: 0.04 # Alerte si position > 4%
correlation_warning: 0.6 # Alerte si corrélation > 60%
# Canaux de notification
notification_channels:
telegram:
enabled: true
priority: "high"
bot_token: "" # À configurer
chat_id: "" # À configurer
email:
enabled: true
priority: "medium"
smtp_server: "smtp.gmail.com"
smtp_port: 587
from_email: "" # À configurer
to_email: "" # À configurer
password: "" # À configurer
sms:
enabled: false # Coûteux, urgences uniquement
priority: "critical"
provider: "twilio"
account_sid: "" # À configurer
auth_token: "" # À configurer
from_number: "" # À configurer
to_number: "" # À configurer
# ============================================================================
# PARAMÈTRES AVANCÉS
# ============================================================================
advanced:
# Kelly Criterion
kelly_criterion:
enabled: true
fraction: 0.25 # Utiliser 25% du Kelly (conservateur)
min_trades_for_calculation: 30 # Minimum 30 trades pour calcul
# Value at Risk (VaR)
var_calculation:
enabled: true
confidence_level: 0.95 # 95% confiance
time_horizon_days: 1 # Horizon 1 jour
method: "historical" # historical, parametric, monte_carlo
# Position Sizing
position_sizing:
method: "kelly_adaptive" # kelly_adaptive, fixed_fractional, volatility_based
min_position_size: 0.01 # 1% minimum
max_position_size: 0.05 # 5% maximum
# Rebalancing
portfolio_rebalancing:
enabled: true
frequency: "daily" # daily, weekly, monthly
threshold: 0.05 # Rebalancer si drift > 5%
# ============================================================================
# NOTES
# ============================================================================
# 1. Ces limites sont CONSERVATRICES par défaut
# 2. Ajuster selon votre tolérance au risque
# 3. JAMAIS désactiver circuit breakers en production
# 4. Tester changements en paper trading d'abord
# 5. Documenter toute modification