Full-stack trading bot with: - FastAPI backend with ICT strategy (Order Block + Liquidity Sweep detection) - Backtester engine with rolling window, spread simulation, and performance metrics - Hybrid market data service (yfinance + TwelveData with rate limiting + SQLite cache) - Simulated exchange for paper trading - React/TypeScript frontend with TradingView lightweight-charts v5 - Live dashboard with candlestick chart, OHLC legend, trade markers - Backtest page with configurable parameters, equity curve, and trade table - WebSocket support for real-time updates - Bot runner with asyncio loop for automated trading Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
83 lines
2.4 KiB
Python
83 lines
2.4 KiB
Python
"""
|
|
Constantes de mapping entre les noms canoniques du projet
|
|
et les symboles/intervalles propres à chaque source de données.
|
|
"""
|
|
|
|
# ── Limites yfinance (jours de données disponibles par granularité) ──────────
|
|
YF_MAX_DAYS: dict[str, int] = {
|
|
"M1": 7,
|
|
"M5": 60,
|
|
"M15": 60,
|
|
"M30": 60,
|
|
"H1": 730,
|
|
"H4": 730,
|
|
"D": 9999,
|
|
}
|
|
|
|
# ── Durée d'une bougie en minutes ─────────────────────────────────────────────
|
|
GRANULARITY_MINUTES: dict[str, int] = {
|
|
"M1": 1,
|
|
"M5": 5,
|
|
"M15": 15,
|
|
"M30": 30,
|
|
"H1": 60,
|
|
"H4": 240,
|
|
"D": 1440,
|
|
}
|
|
|
|
# ── Mapping vers les intervalles yfinance ─────────────────────────────────────
|
|
GRANULARITY_TO_YF: dict[str, str] = {
|
|
"M1": "1m",
|
|
"M5": "5m",
|
|
"M15": "15m",
|
|
"M30": "30m",
|
|
"H1": "1h",
|
|
"H4": "4h",
|
|
"D": "1d",
|
|
}
|
|
|
|
# ── Mapping vers les intervalles TwelveData ───────────────────────────────────
|
|
GRANULARITY_TO_TD: dict[str, str] = {
|
|
"M1": "1min",
|
|
"M5": "5min",
|
|
"M15": "15min",
|
|
"M30": "30min",
|
|
"H1": "1h",
|
|
"H4": "4h",
|
|
"D": "1day",
|
|
}
|
|
|
|
# ── Mapping instrument → symbole yfinance ─────────────────────────────────────
|
|
INSTRUMENT_TO_YF: dict[str, str] = {
|
|
"EUR_USD": "EURUSD=X",
|
|
"GBP_USD": "GBPUSD=X",
|
|
"USD_JPY": "USDJPY=X",
|
|
"USD_CHF": "USDCHF=X",
|
|
"AUD_USD": "AUDUSD=X",
|
|
"USD_CAD": "USDCAD=X",
|
|
"GBP_JPY": "GBPJPY=X",
|
|
"EUR_JPY": "EURJPY=X",
|
|
"EUR_GBP": "EURGBP=X",
|
|
"SPX500_USD": "^GSPC",
|
|
"NAS100_USD": "^NDX",
|
|
"XAU_USD": "GC=F",
|
|
"US30_USD": "YM=F",
|
|
}
|
|
|
|
# ── Mapping instrument → symbole TwelveData ───────────────────────────────────
|
|
INSTRUMENT_TO_TD: dict[str, str] = {
|
|
"EUR_USD": "EUR/USD",
|
|
"GBP_USD": "GBP/USD",
|
|
"USD_JPY": "USD/JPY",
|
|
"USD_CHF": "USD/CHF",
|
|
"AUD_USD": "AUD/USD",
|
|
"USD_CAD": "USD/CAD",
|
|
"GBP_JPY": "GBP/JPY",
|
|
"EUR_JPY": "EUR/JPY",
|
|
"EUR_GBP": "EUR/GBP",
|
|
"SPX500_USD": "SPY",
|
|
"NAS100_USD": "QQQ",
|
|
"XAU_USD": "XAU/USD",
|
|
"US30_USD": "DJI",
|
|
}
|