修复机构落地页构建失败并恢复 Polymarket 市场扫描
InstitutionalLandingPage.tsx 补充 "use client" 指令以通过 Next.js 15 构建。 polymarket_readonly.py 集成 WebSocket 报价缓存加速价格获取。 city_payloads.py 复用 Polymarket 层构建真实市场扫描数据替代空返回。 Constraint: 市场扫描需在无 Polymarket 价格 UI 的前提下提供数据 Tested: npm run build 通过
This commit is contained in:
@@ -4,6 +4,7 @@ Polymarket read-only market layer.
|
||||
P0 scope:
|
||||
- Market discovery from Gamma REST
|
||||
- Price / midpoint / spread / orderbook read from CLOB REST
|
||||
- Optional WebSocket quote acceleration via PolymarketWsQuoteCache
|
||||
- No signing, no order placement
|
||||
"""
|
||||
|
||||
@@ -23,6 +24,7 @@ import httpx
|
||||
from loguru import logger
|
||||
|
||||
from src.data_collection.city_registry import ALIASES, CITY_REGISTRY
|
||||
from src.data_collection.polymarket_ws_cache import PolymarketWsQuoteCache
|
||||
|
||||
|
||||
def _safe_float(value: Any) -> Optional[float]:
|
||||
@@ -448,6 +450,9 @@ class PolymarketReadOnlyLayer:
|
||||
self._price_cache: Dict[str, Dict[str, Any]] = {}
|
||||
self._lock = threading.Lock()
|
||||
|
||||
self._ws_cache = PolymarketWsQuoteCache.from_env()
|
||||
self._ws_cache.start()
|
||||
|
||||
def _market_scan_debug_enabled(self) -> bool:
|
||||
return (
|
||||
str(os.getenv("POLYMARKET_MARKET_SCAN_DEBUG", "false")).strip().lower()
|
||||
@@ -1769,6 +1774,14 @@ class PolymarketReadOnlyLayer:
|
||||
if cached and now - cached.get("t", 0) < self.price_cache_ttl:
|
||||
return cached.get("data", {})
|
||||
|
||||
ws_data = self._ws_cache.get_market_data(token_id)
|
||||
if ws_data:
|
||||
with self._lock:
|
||||
self._price_cache[token_id] = {"data": ws_data, "t": now}
|
||||
return ws_data
|
||||
|
||||
self._ws_cache.subscribe([token_id])
|
||||
|
||||
data = self._fetch_token_market_data(token_id)
|
||||
|
||||
with self._lock:
|
||||
|
||||
Reference in New Issue
Block a user