# HK Weather Prediction Market # Configuration and constants import os from pathlib import Path from dotenv import load_dotenv load_dotenv() PROJECT_ROOT = Path(__file__).parent DATA_DIR = PROJECT_ROOT / "data" WEIGHTS_DIR = DATA_DIR / "weights" FORECAST_DIR = DATA_DIR / "forecasts" for d in [DATA_DIR, WEIGHTS_DIR, FORECAST_DIR]: d.mkdir(parents=True, exist_ok=True) # === HK Region Bounding Box === HK_BBOX = { "lat_min": 22.0, "lat_max": 22.6, "lon_min": 113.8, "lon_max": 114.5, } HK_COORDS = { "hko_headquarters": (22.302, 114.174), # Tsim Sha Tsui "chek_lap_kok": (22.308, 113.918), # Airport "sheung_shui": (22.505, 114.128), # New Territories "stanley": (22.218, 114.218), # South side "cheung_chau": (22.201, 114.028), # Outlying island } # === API Keys === OPENMETEO_API_KEY = os.getenv("OPENMETEO_API_KEY", "") POLYMARKET_PRIVATE_KEY = os.getenv("POLYMARKET_PRIVATE_KEY", "") POLYMARKET_FUNDER = os.getenv("POLYMARKET_FUNDER", "") HKO_OPEN_DATA_KEY = os.getenv("HKO_OPEN_DATA_KEY", "") CDSAPI_KEY = os.getenv("CDSAPI_KEY", "") CDSAPI_URL = os.getenv("CDSAPI_URL", "https://cds.climate.copernicus.eu/api") # === Polymarket === POLYMARKET_GAMMA_API = "https://gamma-api.polymarket.com" POLYMARKET_CLOB_API = "https://clob.polymarket.com" POLYMARKET_SOCKET = "wss://ws-subscriptions-clob.polymarket.com/ws" # === WeatherNext Model === MODEL_CONFIGS = { "mini": { "name": "WeatherNextCyclones_Mini_<2024", "weights_file": "WeatherNextCyclones_Mini_<2024.npz", "resolution": "1°", "gcs_path": "gs://dm_graphcast/WeatherNextCyclones_Mini_<2024.npz", "vram_required_gb": 8, }, "operational": { "name": "WeatherNext2_<2025", "resolution": "0.25°", "gcs_path": "gs://dm_graphcast/WeatherNext2_<2025_model*.npz", "vram_required_gb": 40, }, } MODEL_CONFIG = MODEL_CONFIGS["mini"] # === Forecast Parameters === FORECAST_LEAD_TIMES = [0, 6, 12, 18, 24, 36, 48, 72, 96, 120] # hours # === Weather Variables of Interest === WEATHER_VARIABLES = [ "temperature_2m", "relative_humidity_2m", "wind_speed_10m", "wind_gusts_10m", "precipitation", "total_cloud_cover", "surface_pressure", ] # === Polymarket Market Conditions === # Weather conditions we can create markets for MARKET_CONDITIONS = { "rain_tomorrow": { "description": "Will it rain in Hong Kong tomorrow?", "threshold": lambda forecast: forecast.get("precipitation_probability", 0) > 50, "market_type": "binary", }, "temp_above_30": { "description": "Will the temperature in Hong Kong exceed 30°C tomorrow?", "threshold": lambda forecast: forecast.get("temperature_2m_max", 0) > 30.0, "market_type": "binary", }, "t8_signal": { "description": "Will the T8 typhoon signal be hoisted in the next 7 days?", "threshold": None, "market_type": "binary", }, "rainfall_amount": { "description": "Total rainfall (mm) in Hong Kong tomorrow", "threshold": None, "market_type": "scalar", }, } # === Trading Strategy === MIN_EDGE_BPS = 200 # Minimum edge in basis points to trade MAX_POSITION_USDC = 500.0 # Maximum position per market in USDC KELLY_FRACTION = 0.25 # Fraction of full Kelly to use MIN_LIQUIDITY_USDC = 100.0 # Minimum market liquidity to trade