From 3d4ab83bdbd8424bd4f26daea0b01949856efef5 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Mon, 25 May 2026 19:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20CLAUDE.md=EF=BC=9AWS-only?= =?UTF-8?q?=20=E4=BB=B7=E6=A0=BC=E7=AE=A1=E7=BA=BF=E3=80=81skip=5Fpolymark?= =?UTF-8?q?et=E3=80=81=E5=81=8F=E5=B7=AE=E4=BF=AE=E6=AD=A3=E3=80=81WAL=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 8f8365c8..f47817a8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,7 +26,7 @@ cd frontend npm run dev # dev server :3000 npm run build # production build npm run typecheck # tsc --noEmit -npm run test:business # 21 business state tests +npm run test:business # 19 business state tests # Backend uvicorn web.app:app --reload --host 0.0.0.0 --port 8000 @@ -75,10 +75,8 @@ Users → Next.js (Vercel) → FastAPI :8000 (VPS) - `CityRegionList` — city list panel (left top) - `CityContractDetail` — contract table panel (left bottom) - `LiveTemperatureThresholdChart` — temperature trend + market thresholds (right) -- `TrainingDashboard` — DEB + Mu accuracy charts (sidebar tab) -- `MarketOverviewView` — regional heat + top opportunities (sidebar tab) -- `GroupedMarketTable` — contract comparison table -- `continent-grouping.ts` — 7 trading regions, city-to-region mapping, timezone detection +- `TrainingDashboard` — DEB + Mu accuracy charts (sidebar "训练数据" tab) +- `continent-grouping.ts` — 7 trading regions (`TRADING_REGIONS`), city-to-region fallback (`CITY_REGION_FALLBACK`), timezone detection (`detectLocalRegion`) ### Account Module @@ -113,20 +111,38 @@ Local dev bypass: set `NEXT_PUBLIC_POLYWEATHER_LOCAL_FULL_ACCESS=false` to test ## Polymarket Integration -Price pipeline: +Price pipeline (WS-only, no REST fallback): ``` -Gamma API (slug discovery) → CLOB REST + WS cache → market_scan → terminal rows +Gamma API (slug discovery) → WS subscribe + cache → market_scan → terminal rows ``` -- `resolve_city_clob_tokens()` — timezone-aware market discovery -- `collect_all_clob_token_ids()` — all YES/NO tokens for WS subscription -- `PolymarketWsQuoteCache` — WebSocket quote cache (daemon thread) -- Prices flow to terminal via `**row` spread in `_build_terminal_row` +- `PolymarketWsQuoteCache` — daemon thread connects `wss://ws-subscriptions-clob.polymarket.com/ws/market` +- `_batch_get_token_market_data()` — subscribes all missing tokens, waits 0.6s for WS quotes, returns from cache +- `_get_token_market_data()` — WS-only, returns `{}` on miss (no REST fallback) +- Gamma market fallback used when WS prices unavailable (bestBid/bestAsk from event payload) +- Enable with `POLYMARKET_WS_PRICE_ENABLED=true` (default: true) +- `skip_polymarket=true` query param skips price fetching entirely for fast city/weather loads ## Trading Regions 7 regions: east_asia, southeast_asia, central_asia, west_asia, europe_africa, south_america, north_america. Mappings in `continent-grouping.ts` (`CITY_REGION_FALLBACK` — all 50 cities hardcoded) and `scan_terminal_filters.py` (`market_region_from_tz_offset`). Default region auto-detected from browser timezone. +## Scan Terminal Performance + +- **Region lazy-loading**: `region=east_asia` filters cities server-side before scanning (see `_market_region_from_tz_offset`) +- **skip_polymarket mode**: `skip_polymarket=true` returns 1 row/city instantly (Live/DEB only, no market prices); full contract prices load on second pass after WS warmup +- **DB**: SQLite WAL mode + `busy_timeout=5000` enabled in `db_manager.py` (fixes "database is locked" with parallel workers) +- **VPS env**: `POLYWEATHER_SCAN_TERMINAL_MAX_WORKERS=2`, `POLYWEATHER_SCAN_TERMINAL_BUILD_TIMEOUT_SEC=180` +- **Caching**: `_cache` is `LRUDict(256)` with `_CACHE_LOCK`; `_SUMMARY_CACHE` is `LRUDict(128)`; weather caches trimmed every 200 writes + +## Intraday Bias Correction + +`analysis_service.py:_analyze()` applies intraday correction after probability generation: +- Compares current observed temp vs model hourly forecast for current hour +- Time-of-day weight: 0.15↗0.35 pre-peak, 0.40↗0.75 during peak, 0.80 post-peak +- Also checks if max-so-far already exceeds DEB prediction (strong upward nudge) +- Correction capped at ±5°F / ±3°C, applied to both `deb_val` and `mu` + ## Code Style - No `\uXXXX` escapes — write characters directly in UTF-8