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:
434
config/data_sources.example.yaml
Normal file
434
config/data_sources.example.yaml
Normal 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
|
||||
Reference in New Issue
Block a user