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>
This commit is contained in:
Tika
2026-03-08 17:38:09 +00:00
commit da30ef19ed
111 changed files with 31723 additions and 0 deletions

View File

@@ -0,0 +1,434 @@
# Configuration Sources de Données - Trading AI Secure
# Copier ce fichier vers data_sources.yaml
# ============================================================================
# SOURCES DE DONNÉES GRATUITES (Phase Développement)
# ============================================================================
# Yahoo Finance (Gratuit, Illimité)
yahoo_finance:
enabled: true
priority: 1 # Priorité 1 = source principale
description: "Yahoo Finance - Données EOD + intraday limitées"
capabilities:
historical_data: true
intraday_data: true # Limité à 7 jours
real_time: false
fundamental_data: true
limits:
rate_limit: null # Pas de limite officielle
max_requests_per_minute: 60 # Limite recommandée
max_symbols_per_request: 1
timeframes:
- "1m"
- "5m"
- "15m"
- "30m"
- "1h"
- "1d"
- "1wk"
- "1mo"
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# Alpha Vantage (Gratuit, 500 calls/jour)
alpha_vantage:
enabled: true
priority: 2
description: "Alpha Vantage - Données temps réel et historiques"
api_key: "YOUR_API_KEY_HERE" # Obtenir sur https://www.alphavantage.co/support/#api-key
capabilities:
historical_data: true
intraday_data: true
real_time: true
fundamental_data: true
technical_indicators: true
limits:
rate_limit: 500 # 500 calls par jour
max_requests_per_minute: 5
max_symbols_per_request: 1
timeframes:
- "1min"
- "5min"
- "15min"
- "30min"
- "60min"
- "daily"
- "weekly"
- "monthly"
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# Twelve Data (Gratuit, 800 calls/jour)
twelve_data:
enabled: false # Activer si besoin
priority: 3
description: "Twelve Data - Alternative robuste"
api_key: "YOUR_API_KEY_HERE" # Obtenir sur https://twelvedata.com/
capabilities:
historical_data: true
intraday_data: true
real_time: true
fundamental_data: true
technical_indicators: true
limits:
rate_limit: 800 # 800 calls par jour
max_requests_per_minute: 8
max_symbols_per_request: 1
timeframes:
- "1min"
- "5min"
- "15min"
- "30min"
- "1h"
- "1day"
- "1week"
- "1month"
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# Polygon.io (Gratuit, 5 calls/minute)
polygon_io:
enabled: false
priority: 4
description: "Polygon.io - Données US premium"
api_key: "YOUR_API_KEY_HERE" # Obtenir sur https://polygon.io/
capabilities:
historical_data: true
intraday_data: true
real_time: true
fundamental_data: false
limits:
rate_limit: 5 # 5 calls par minute (gratuit)
max_requests_per_minute: 5
max_symbols_per_request: 1
timeframes:
- "1min"
- "5min"
- "15min"
- "1hour"
- "1day"
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# FRED API (Réserve Fédérale - Données Macro)
fred_api:
enabled: true
priority: 5
description: "FRED - Données macroéconomiques"
api_key: "YOUR_API_KEY_HERE" # Obtenir sur https://fred.stlouisfed.org/docs/api/api_key.html
capabilities:
economic_indicators: true
interest_rates: true
inflation_data: true
limits:
rate_limit: null # Pas de limite
max_requests_per_minute: 120
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# ============================================================================
# SOURCES CRYPTO (Pour Tests)
# ============================================================================
# Binance Public API
binance:
enabled: false # Activer pour tests crypto
priority: 6
description: "Binance - Données crypto gratuites"
capabilities:
historical_data: true
intraday_data: true
real_time: true
orderbook: true
limits:
rate_limit: null # Illimité (public API)
max_requests_per_minute: 1200
weight_limit: 1200 # Weight-based rate limiting
timeframes:
- "1m"
- "5m"
- "15m"
- "30m"
- "1h"
- "4h"
- "1d"
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# CoinGecko API
coingecko:
enabled: false
priority: 7
description: "CoinGecko - Backup crypto"
capabilities:
historical_data: true
market_data: true
fundamental_data: true
limits:
rate_limit: 50 # 50 calls par minute
max_requests_per_minute: 50
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# ============================================================================
# IG MARKETS (Production)
# ============================================================================
ig_markets:
enabled: false # Activer en Phase 5
priority: 0 # Priorité 0 = source principale en prod
description: "IG Markets - Trading réel"
# Environnements
environments:
demo:
api_url: "https://demo-api.ig.com/gateway/deal"
lightstreamer_url: "https://demo-apd.marketdatasys.com"
api_key: "" # À configurer
username: ""
password: ""
account_id: ""
live:
api_url: "https://api.ig.com/gateway/deal"
lightstreamer_url: "https://apd.marketdatasys.com"
api_key: "" # À configurer
username: ""
password: ""
account_id: ""
capabilities:
historical_data: true
real_time_streaming: true
order_execution: true
account_management: true
limits:
rate_limit: 60 # 60 requêtes par minute
max_requests_per_minute: 60
max_positions: 200
retry_policy:
max_retries: 3
backoff_factor: 2
timeout: 30
# ============================================================================
# CONFIGURATION CACHE
# ============================================================================
cache:
enabled: true
description: "Cache local pour réduire appels API"
# Backend cache
backend: "redis" # redis, memory, disk
# Redis configuration (si backend = redis)
redis:
host: "localhost"
port: 6379
db: 0
password: null
# TTL par type de données
ttl:
intraday_1min: 60 # 1 minute
intraday_5min: 300 # 5 minutes
intraday_15min: 900 # 15 minutes
intraday_1hour: 3600 # 1 heure
daily: 86400 # 1 jour
weekly: 604800 # 1 semaine
fundamental: 2592000 # 30 jours
# Politique de cache
policy:
max_size_mb: 1000 # 1 GB max
eviction_policy: "lru" # lru, lfu, fifo
compression: true
# ============================================================================
# FAILOVER ET REDONDANCE
# ============================================================================
failover:
enabled: true
description: "Basculement automatique si source principale échoue"
# Stratégie de failover
strategy: "priority" # priority, round_robin, random
# Conditions de failover
triggers:
consecutive_failures: 3 # 3 échecs consécutifs
timeout_threshold: 30 # 30 secondes timeout
error_rate_threshold: 0.5 # 50% taux d'erreur
# Cooldown avant retry source principale
cooldown_seconds: 300 # 5 minutes
# ============================================================================
# MONITORING ET LOGGING
# ============================================================================
monitoring:
enabled: true
# Métriques à tracker
metrics:
- "api_calls_count"
- "api_calls_success_rate"
- "api_response_time"
- "cache_hit_rate"
- "data_freshness"
- "failover_events"
# Alertes
alerts:
high_error_rate:
threshold: 0.3 # 30% taux d'erreur
notification: ["telegram"]
rate_limit_approaching:
threshold: 0.9 # 90% de la limite
notification: ["telegram"]
source_unavailable:
duration_seconds: 300 # 5 minutes indisponible
notification: ["telegram", "email"]
logging:
enabled: true
level: "INFO" # DEBUG, INFO, WARNING, ERROR
# Logs par source
log_api_calls: true
log_cache_operations: true
log_failover_events: true
# Rotation logs
rotation:
max_size_mb: 100
backup_count: 10
# ============================================================================
# SYMBOLES ET MARCHÉS
# ============================================================================
symbols:
# Forex
forex:
- symbol: "EURUSD"
name: "Euro / US Dollar"
enabled: true
sources: ["yahoo_finance", "alpha_vantage", "ig_markets"]
- symbol: "GBPUSD"
name: "British Pound / US Dollar"
enabled: true
sources: ["yahoo_finance", "alpha_vantage", "ig_markets"]
- symbol: "USDJPY"
name: "US Dollar / Japanese Yen"
enabled: true
sources: ["yahoo_finance", "alpha_vantage", "ig_markets"]
# Indices
indices:
- symbol: "^GSPC" # S&P 500
name: "S&P 500"
enabled: true
sources: ["yahoo_finance", "alpha_vantage"]
- symbol: "^DJI" # Dow Jones
name: "Dow Jones Industrial Average"
enabled: true
sources: ["yahoo_finance", "alpha_vantage"]
# Crypto (tests uniquement)
crypto:
- symbol: "BTCUSD"
name: "Bitcoin / US Dollar"
enabled: false
sources: ["binance", "coingecko"]
- symbol: "ETHUSD"
name: "Ethereum / US Dollar"
enabled: false
sources: ["binance", "coingecko"]
# ============================================================================
# VALIDATION DONNÉES
# ============================================================================
data_validation:
enabled: true
# Checks de qualité
quality_checks:
check_missing_values: true
max_missing_pct: 0.05 # 5% max valeurs manquantes
check_outliers: true
outlier_std_threshold: 5 # 5 écarts-types
check_duplicates: true
check_chronological_order: true
check_price_consistency: true # High >= Low, etc.
# Actions si validation échoue
on_validation_failure:
action: "skip" # skip, interpolate, use_cache
notify: true
# ============================================================================
# NOTES
# ============================================================================
# 1. Obtenir clés API gratuites avant utilisation
# 2. Respecter rate limits pour éviter bans
# 3. Activer cache pour réduire appels API
# 4. Tester failover régulièrement
# 5. Monitor consommation API quotidienne

View File

@@ -0,0 +1,264 @@
# 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

View File

@@ -0,0 +1,477 @@
# Configuration Paramètres Stratégies - Trading AI Secure
# Copier ce fichier vers strategy_params.yaml
# ============================================================================
# CONFIGURATION GLOBALE STRATÉGIES
# ============================================================================
global_strategy_config:
# Capital allocation par stratégie (doit totaliser 1.0)
allocation:
scalping: 0.30 # 30% du capital
intraday: 0.50 # 50% du capital
swing: 0.20 # 20% du capital
# Ajustement allocation selon régime de marché
regime_based_allocation:
enabled: true
bull_market:
scalping: 0.20
intraday: 0.50
swing: 0.30 # Favoriser swing en bull
bear_market:
scalping: 0.40 # Favoriser scalping en bear
intraday: 0.40
swing: 0.10
short_bias: 0.10 # Activer short bias
sideways_market:
scalping: 0.50 # Favoriser scalping en sideways
intraday: 0.30
swing: 0.20
# ============================================================================
# STRATÉGIE SCALPING
# ============================================================================
scalping_strategy:
# Informations générales
name: "Scalping Mean Reversion"
description: "Stratégie scalping basée sur retour à la moyenne"
timeframe: "1min" # 1, 5 minutes
enabled: true
# Indicateurs techniques
indicators:
bollinger_bands:
period: 20
std_dev: 2.0
adaptive: true # Ajuster selon volatilité
rsi:
period: 14
oversold: 30
overbought: 70
adaptive: true # Ajuster seuils dynamiquement
macd:
fast_period: 12
slow_period: 26
signal_period: 9
volume:
ma_period: 20
threshold_multiplier: 1.5 # Volume > 1.5x moyenne
atr:
period: 14
multiplier_stop: 2.0 # Stop-loss à 2 ATR
multiplier_target: 3.0 # Take-profit à 3 ATR
# Conditions d'entrée
entry_conditions:
long:
- "bb_position < 0.2" # Prix proche BB lower
- "rsi < rsi_oversold" # RSI oversold
- "macd_hist > 0" # MACD histogram positif
- "volume_ratio > volume_threshold" # Volume confirmation
- "confidence >= min_confidence" # Confiance suffisante
short:
- "bb_position > 0.8" # Prix proche BB upper
- "rsi > rsi_overbought" # RSI overbought
- "macd_hist < 0" # MACD histogram négatif
- "volume_ratio > volume_threshold"
- "confidence >= min_confidence"
# Gestion de position
position_management:
entry_type: "market" # market, limit
exit_type: "market" # market, limit
use_trailing_stop: true
trailing_stop_activation: 0.005 # Activer à +0.5%
trailing_stop_distance: 0.003 # Distance 0.3%
partial_take_profit: true
partial_tp_levels:
- level: 0.003 # 0.3%
size: 0.5 # Fermer 50%
- level: 0.005 # 0.5%
size: 0.3 # Fermer 30%
# Filtres
filters:
time_filter:
enabled: true
trading_hours:
- start: "08:00"
end: "17:00"
timezone: "Europe/London"
spread_filter:
enabled: true
max_spread_pct: 0.001 # 0.1% spread maximum
volatility_filter:
enabled: true
min_volatility: 0.005 # 0.5% minimum
max_volatility: 0.03 # 3% maximum
# Optimisation adaptative
adaptive_optimization:
enabled: true
optimization_frequency: "daily" # daily, weekly
method: "bayesian" # bayesian, grid, random
parameters_to_optimize:
- "bb_period"
- "bb_std"
- "rsi_period"
- "rsi_oversold"
- "rsi_overbought"
- "volume_threshold"
- "min_confidence"
constraints:
bb_period: [10, 30]
bb_std: [1.5, 3.0]
rsi_period: [10, 20]
rsi_oversold: [20, 35]
rsi_overbought: [65, 80]
volume_threshold: [1.2, 2.0]
min_confidence: [0.5, 0.8]
# ============================================================================
# STRATÉGIE INTRADAY
# ============================================================================
intraday_strategy:
# Informations générales
name: "Intraday Trend Following"
description: "Stratégie intraday suivant les tendances"
timeframe: "15min" # 15, 30, 60 minutes
enabled: true
# Indicateurs techniques
indicators:
ema:
fast_period: 9
slow_period: 21
trend_period: 50
adaptive: true
adx:
period: 14
threshold: 25 # ADX > 25 = tendance forte
atr:
period: 14
multiplier_stop: 2.5
multiplier_target: 5.0 # R:R 2:1
volume:
ma_period: 20
confirmation_threshold: 1.2
pivot_points:
type: "standard" # standard, fibonacci, camarilla
lookback_period: 1 # 1 jour
# Conditions d'entrée
entry_conditions:
long:
- "ema_fast > ema_slow" # EMA fast au-dessus slow
- "ema_fast_prev <= ema_slow_prev" # Crossover récent
- "close > ema_trend" # Prix au-dessus tendance
- "adx > adx_threshold" # Tendance forte
- "volume_ratio > volume_confirmation"
- "confidence >= min_confidence"
short:
- "ema_fast < ema_slow"
- "ema_fast_prev >= ema_slow_prev"
- "close < ema_trend"
- "adx > adx_threshold"
- "volume_ratio > volume_confirmation"
- "confidence >= min_confidence"
# Gestion de position
position_management:
entry_type: "market"
exit_type: "market"
use_trailing_stop: true
trailing_stop_activation: 0.01 # Activer à +1%
trailing_stop_distance: 0.005 # Distance 0.5%
partial_take_profit: true
partial_tp_levels:
- level: 0.01 # 1%
size: 0.4 # Fermer 40%
- level: 0.015 # 1.5%
size: 0.3 # Fermer 30%
# Breakeven
move_to_breakeven: true
breakeven_trigger: 0.008 # À +0.8%
breakeven_offset: 0.002 # +0.2% au-dessus entry
# Filtres
filters:
time_filter:
enabled: true
avoid_news_times: true # Éviter annonces économiques
trading_sessions:
- name: "London"
start: "08:00"
end: "16:30"
- name: "New York"
start: "13:30"
end: "20:00"
trend_filter:
enabled: true
min_trend_strength: 0.6 # ADX normalisé
support_resistance_filter:
enabled: true
min_distance_from_sr: 0.005 # 0.5% distance minimum
# Optimisation adaptative
adaptive_optimization:
enabled: true
optimization_frequency: "weekly"
method: "bayesian"
parameters_to_optimize:
- "ema_fast"
- "ema_slow"
- "ema_trend"
- "adx_threshold"
- "atr_multiplier_stop"
- "atr_multiplier_target"
- "min_confidence"
constraints:
ema_fast: [5, 15]
ema_slow: [15, 30]
ema_trend: [40, 60]
adx_threshold: [20, 30]
atr_multiplier_stop: [2.0, 3.5]
atr_multiplier_target: [4.0, 6.0]
min_confidence: [0.5, 0.75]
# ============================================================================
# STRATÉGIE SWING
# ============================================================================
swing_strategy:
# Informations générales
name: "Swing Multi-Timeframe"
description: "Stratégie swing avec analyse multi-timeframe"
timeframe: "4h" # 4h, 1D
enabled: true
# Indicateurs techniques
indicators:
sma:
short_period: 20
long_period: 50
adaptive: true
rsi:
period: 14
neutral_zone: [40, 60] # Zone neutre pour swing
macd:
fast_period: 12
slow_period: 26
signal_period: 9
fibonacci:
lookback_period: 50 # 50 barres pour high/low
key_levels: [0.236, 0.382, 0.5, 0.618, 0.786]
atr:
period: 14
multiplier_stop: 3.0
multiplier_target: 6.0 # R:R 2:1
# Multi-timeframe analysis
multi_timeframe:
enabled: true
higher_timeframe: "1D" # Timeframe supérieur
confirm_trend: true # Confirmer tendance HTF
htf_indicators:
- "sma_50"
- "sma_200"
- "trend_direction"
# Conditions d'entrée
entry_conditions:
long:
- "sma_short > sma_long" # SMA short au-dessus long
- "rsi >= 40 and rsi <= 60" # RSI zone neutre
- "macd > macd_signal" # MACD bullish
- "close_near_fib_support" # Prix près support Fibonacci
- "htf_trend == 'UP'" # Tendance HTF haussière
- "confidence >= min_confidence"
short:
- "sma_short < sma_long"
- "rsi >= 40 and rsi <= 60"
- "macd < macd_signal"
- "close_near_fib_resistance"
- "htf_trend == 'DOWN'"
- "confidence >= min_confidence"
# Gestion de position
position_management:
entry_type: "limit" # Limit orders pour meilleur prix
entry_offset: 0.002 # 0.2% offset
exit_type: "market"
use_trailing_stop: true
trailing_stop_activation: 0.02 # Activer à +2%
trailing_stop_distance: 0.01 # Distance 1%
partial_take_profit: true
partial_tp_levels:
- level: 0.03 # 3%
size: 0.33 # Fermer 33%
- level: 0.05 # 5%
size: 0.33 # Fermer 33%
# Scale in
scale_in: true
scale_in_levels:
- trigger: 0.01 # À +1%
size: 0.5 # Ajouter 50% position initiale
# Filtres
filters:
fundamental_filter:
enabled: true
avoid_earnings: true # Éviter publications résultats
avoid_major_news: true # Éviter news majeures
seasonal_filter:
enabled: false # Optionnel
favorable_months: [1, 2, 3, 10, 11, 12] # Mois favorables
correlation_filter:
enabled: true
max_correlation_with_existing: 0.7
# Optimisation adaptative
adaptive_optimization:
enabled: true
optimization_frequency: "monthly"
method: "bayesian"
parameters_to_optimize:
- "sma_short"
- "sma_long"
- "rsi_period"
- "fibonacci_lookback"
- "atr_multiplier_stop"
- "min_confidence"
constraints:
sma_short: [15, 25]
sma_long: [40, 60]
rsi_period: [10, 20]
fibonacci_lookback: [30, 70]
atr_multiplier_stop: [2.5, 4.0]
min_confidence: [0.5, 0.7]
# ============================================================================
# MACHINE LEARNING CONFIGURATION
# ============================================================================
ml_config:
# Modèles utilisés
models:
- name: "xgboost"
enabled: true
priority: 1
hyperparameters:
n_estimators: 100
max_depth: 6
learning_rate: 0.1
- name: "lightgbm"
enabled: true
priority: 2
hyperparameters:
n_estimators: 100
max_depth: 6
learning_rate: 0.1
- name: "random_forest"
enabled: false
priority: 3
hyperparameters:
n_estimators: 100
max_depth: 10
# Features engineering
features:
technical_indicators: true
price_patterns: true
volume_profile: true
market_microstructure: false # Avancé
sentiment_analysis: false # Nécessite API news
# Training
training:
train_test_split: 0.7 # 70% train, 30% test
validation_method: "walk_forward" # walk_forward, k_fold
retraining_frequency: "weekly" # daily, weekly, monthly
min_samples: 1000 # Minimum échantillons
# Ensemble
ensemble:
enabled: true
method: "stacking" # stacking, voting, blending
meta_learner: "logistic_regression"
# ============================================================================
# BACKTESTING CONFIGURATION
# ============================================================================
backtesting_config:
# Données
data:
start_date: "2020-01-01"
end_date: "2024-01-01"
symbols: ["EURUSD", "GBPUSD", "USDJPY"]
# Coûts de transaction
transaction_costs:
commission_pct: 0.0001 # 0.01% commission
slippage_pct: 0.0005 # 0.05% slippage
spread_pct: 0.0002 # 0.02% spread
# Validation
validation:
walk_forward:
enabled: true
train_window: 252 # 1 an
test_window: 63 # 3 mois
step_size: 21 # 1 mois
monte_carlo:
enabled: true
n_simulations: 10000
confidence_level: 0.95
out_of_sample:
enabled: true
oos_ratio: 0.30 # 30% out-of-sample
# Métriques
metrics:
required:
sharpe_ratio: 1.5
max_drawdown: 0.10
win_rate: 0.55
profit_factor: 1.3
calmar_ratio: 0.5
# ============================================================================
# NOTES
# ============================================================================
# 1. Tous les paramètres sont ADAPTATIFS par défaut
# 2. L'IA ajustera ces valeurs quotidiennement/hebdomadairement
# 3. Les contraintes définissent les limites d'optimisation
# 4. Tester changements en backtest avant paper trading