File size: 4,718 Bytes
3458abb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
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%