""" Configuration du bot Polymarket. Toutes les constantes et paramètres ajustables. """ import os from dataclasses import dataclass, field from typing import Optional # ══════════════════════════════════════════════════════════════════ # ENDPOINTS # ══════════════════════════════════════════════════════════════════ CLOB_API_URL = "https://clob.polymarket.com" GAMMA_API_URL = "https://gamma-api.polymarket.com" WS_URL = "wss://ws-subscriptions-clob.polymarket.com/ws/market" POLYGON_RPC = os.getenv("POLYGON_RPC_URL", "https://polygon-rpc.com") # ══════════════════════════════════════════════════════════════════ # ON-CHAIN CONTRACTS (Polygon) # ══════════════════════════════════════════════════════════════════ CTF_EXCHANGE_ADDRESS = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045" NEGRISK_EXCHANGE_ADDRESS = "0xC5d563A36AE78145C45a50134d48A1D45eD1D83e" USDC_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" POLYGON_CHAIN_ID = 137 @dataclass class BotConfig: """Configuration principale du bot.""" # ── Credentials ────────────────────────────────────────────── private_key: str = os.getenv("POLYMARKET_PRIVATE_KEY", "") polygon_rpc_url: str = os.getenv("POLYGON_RPC_URL", POLYGON_RPC) # ── Stratégie: Arbitrage ───────────────────────────────────── arb_min_spread: float = 0.02 # Minimum YES+NO < 1 - spread arb_profit_threshold: float = 0.05 # Min profit per dollar pour trader arb_max_position_usd: float = 500.0 # Max par trade en USD arb_min_position_usd: float = 5.0 # Min par trade en USD arb_max_price_filter: float = 0.95 # Ignorer si un token > 0.95 # ── Stratégie: Value Bet (LLM-assisted) ────────────────────── value_bet_confidence_threshold: float = 0.65 value_bet_min_edge: float = 0.05 # Edge minimum vs prix du marché value_bet_max_position_usd: float = 200.0 # ── Stratégie: Leader-Follower ─────────────────────────────── lf_similarity_threshold: float = 0.85 lf_max_position_usd: float = 300.0 # ── Gestion des risques ────────────────────────────────────── max_total_exposure_usd: float = 5000.0 max_single_market_exposure_pct: float = 0.10 # 10% du portefeuille max kelly_fraction: float = 0.25 # 1/4 Kelly (conservateur) max_daily_loss_usd: float = 500.0 max_concurrent_positions: int = 20 # ── Polling ────────────────────────────────────────────────── poll_interval_seconds: float = 2.0 market_refresh_interval_seconds: float = 300.0 # 5 min # ── Filtres de marché ──────────────────────────────────────── min_market_volume: float = 10000.0 # Min $10K volume min_liquidity_depth: float = 100.0 # Min $100 dans le carnet excluded_tags: list = field(default_factory=lambda: ["Crypto"]) # Crypto catastrophique selon PolyBench max_days_to_resolution: int = 90 # ── Mode ───────────────────────────────────────────────────── dry_run: bool = True # Paper trading par défaut log_level: str = "INFO" strategies: list = field(default_factory=lambda: ["arbitrage", "value_bet", "leader_follower"]) @dataclass class AlertThresholds: """Seuils pour les alertes de monitoring.""" daily_loss_warn_pct: float = 0.50 # Alerte si 50% du max daily loss atteint drawdown_warn_pct: float = 0.10 # Alerte si drawdown > 10% win_rate_warn: float = 0.40 # Alerte si win rate < 40% arb_opportunity_min_log: float = 0.03 # Logger les opportunités > 3%