Add bot source code
Browse files- polymarket_bot/config.py +79 -0
polymarket_bot/config.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Configuration du bot Polymarket.
|
| 3 |
+
Toutes les constantes et paramètres ajustables.
|
| 4 |
+
"""
|
| 5 |
+
import os
|
| 6 |
+
from dataclasses import dataclass, field
|
| 7 |
+
from typing import Optional
|
| 8 |
+
|
| 9 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
+
# ENDPOINTS
|
| 11 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
+
CLOB_API_URL = "https://clob.polymarket.com"
|
| 13 |
+
GAMMA_API_URL = "https://gamma-api.polymarket.com"
|
| 14 |
+
WS_URL = "wss://ws-subscriptions-clob.polymarket.com/ws/market"
|
| 15 |
+
POLYGON_RPC = os.getenv("POLYGON_RPC_URL", "https://polygon-rpc.com")
|
| 16 |
+
|
| 17 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 18 |
+
# ON-CHAIN CONTRACTS (Polygon)
|
| 19 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
+
CTF_EXCHANGE_ADDRESS = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
|
| 21 |
+
NEGRISK_EXCHANGE_ADDRESS = "0xC5d563A36AE78145C45a50134d48A1D45eD1D83e"
|
| 22 |
+
USDC_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
|
| 23 |
+
POLYGON_CHAIN_ID = 137
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@dataclass
|
| 27 |
+
class BotConfig:
|
| 28 |
+
"""Configuration principale du bot."""
|
| 29 |
+
|
| 30 |
+
# ββ Credentials ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 31 |
+
private_key: str = os.getenv("POLYMARKET_PRIVATE_KEY", "")
|
| 32 |
+
polygon_rpc_url: str = os.getenv("POLYGON_RPC_URL", POLYGON_RPC)
|
| 33 |
+
|
| 34 |
+
# ββ StratΓ©gie: Arbitrage βββββββββββββββββββββββββββββββββββββ
|
| 35 |
+
arb_min_spread: float = 0.02 # Minimum YES+NO < 1 - spread
|
| 36 |
+
arb_profit_threshold: float = 0.05 # Min profit per dollar pour trader
|
| 37 |
+
arb_max_position_usd: float = 500.0 # Max par trade en USD
|
| 38 |
+
arb_min_position_usd: float = 5.0 # Min par trade en USD
|
| 39 |
+
arb_max_price_filter: float = 0.95 # Ignorer si un token > 0.95
|
| 40 |
+
|
| 41 |
+
# ββ StratΓ©gie: Value Bet (LLM-assisted) ββββββββββββββββββββββ
|
| 42 |
+
value_bet_confidence_threshold: float = 0.65
|
| 43 |
+
value_bet_min_edge: float = 0.05 # Edge minimum vs prix du marchΓ©
|
| 44 |
+
value_bet_max_position_usd: float = 200.0
|
| 45 |
+
|
| 46 |
+
# ββ StratΓ©gie: Leader-Follower βββββββββββββββββββββββββββββββ
|
| 47 |
+
lf_similarity_threshold: float = 0.85
|
| 48 |
+
lf_max_position_usd: float = 300.0
|
| 49 |
+
|
| 50 |
+
# ββ Gestion des risques ββββββββββββββββββββββββββββββββββββββ
|
| 51 |
+
max_total_exposure_usd: float = 5000.0
|
| 52 |
+
max_single_market_exposure_pct: float = 0.10 # 10% du portefeuille max
|
| 53 |
+
kelly_fraction: float = 0.25 # 1/4 Kelly (conservateur)
|
| 54 |
+
max_daily_loss_usd: float = 500.0
|
| 55 |
+
max_concurrent_positions: int = 20
|
| 56 |
+
|
| 57 |
+
# ββ Polling ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 58 |
+
poll_interval_seconds: float = 2.0
|
| 59 |
+
market_refresh_interval_seconds: float = 300.0 # 5 min
|
| 60 |
+
|
| 61 |
+
# ββ Filtres de marchΓ© ββββββββββββββββββββββββββββββββββββββββ
|
| 62 |
+
min_market_volume: float = 10000.0 # Min $10K volume
|
| 63 |
+
min_liquidity_depth: float = 100.0 # Min $100 dans le carnet
|
| 64 |
+
excluded_tags: list = field(default_factory=lambda: ["Crypto"]) # Crypto catastrophique selon PolyBench
|
| 65 |
+
max_days_to_resolution: int = 90
|
| 66 |
+
|
| 67 |
+
# ββ Mode βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 68 |
+
dry_run: bool = True # Paper trading par dΓ©faut
|
| 69 |
+
log_level: str = "INFO"
|
| 70 |
+
strategies: list = field(default_factory=lambda: ["arbitrage", "value_bet", "leader_follower"])
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
@dataclass
|
| 74 |
+
class AlertThresholds:
|
| 75 |
+
"""Seuils pour les alertes de monitoring."""
|
| 76 |
+
daily_loss_warn_pct: float = 0.50 # Alerte si 50% du max daily loss atteint
|
| 77 |
+
drawdown_warn_pct: float = 0.10 # Alerte si drawdown > 10%
|
| 78 |
+
win_rate_warn: float = 0.40 # Alerte si win rate < 40%
|
| 79 |
+
arb_opportunity_min_log: float = 0.03 # Logger les opportunitΓ©s > 3%
|