feat: trading bot MVP — ICT Order Block + Liquidity Sweep strategy

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>
This commit is contained in:
2026-02-24 23:25:51 +01:00
commit 4df8d53b1a
58 changed files with 7484 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
from datetime import datetime
from typing import Optional
from sqlalchemy import Float, Integer, String, DateTime, JSON
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base
class BacktestResult(Base):
__tablename__ = "backtest_results"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
instrument: Mapped[str] = mapped_column(String(20))
granularity: Mapped[str] = mapped_column(String(10))
start_date: Mapped[datetime] = mapped_column(DateTime)
end_date: Mapped[datetime] = mapped_column(DateTime)
initial_balance: Mapped[float] = mapped_column(Float, default=10000.0)
final_balance: Mapped[float] = mapped_column(Float)
total_pnl: Mapped[float] = mapped_column(Float)
total_trades: Mapped[int] = mapped_column(Integer)
winning_trades: Mapped[int] = mapped_column(Integer)
losing_trades: Mapped[int] = mapped_column(Integer)
win_rate: Mapped[float] = mapped_column(Float)
max_drawdown: Mapped[float] = mapped_column(Float)
sharpe_ratio: Mapped[Optional[float]] = mapped_column(Float, nullable=True)
expectancy: Mapped[float] = mapped_column(Float)
# Courbe d'équité [{time, balance}] stockée en JSON
equity_curve: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
# Paramètres de la stratégie utilisés
strategy_params: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)