bsp_monitor: fetcher limit=1000, engine/main tweaks
This commit is contained in:
@@ -17,16 +17,21 @@ FETCH_LIMIT = 1000
|
||||
_symbols_cache: Optional[List[str]] = None
|
||||
|
||||
|
||||
# 只推送 BTC,其他币对暂不监控
|
||||
_SYMBOL_WHITELIST = {"BTC/USDT:USDT", "ETH/USDT:USDT", "SOL/USDT:USDT"}
|
||||
|
||||
|
||||
def get_symbols() -> list[str]:
|
||||
"""从 data_provider /health 获取所有可用币对(缓存)。"""
|
||||
"""获取要监控的币对列表(目前只监控 BTC)。"""
|
||||
global _symbols_cache
|
||||
if _symbols_cache is not None:
|
||||
return _symbols_cache
|
||||
try:
|
||||
resp = requests.get(f"{PROVIDER_URL}/health", timeout=10)
|
||||
resp.raise_for_status()
|
||||
_symbols_cache = resp.json().get("symbols", [])
|
||||
logger.info(f"获取到 {len(_symbols_cache)} 个币对")
|
||||
all_symbols = resp.json().get("symbols", [])
|
||||
_symbols_cache = [s for s in all_symbols if s in _SYMBOL_WHITELIST]
|
||||
logger.info(f"获取到 {len(all_symbols)} 个币对,过滤后监控 {len(_symbols_cache)} 个: {_symbols_cache}")
|
||||
except Exception as e:
|
||||
logger.error(f"获取币对列表失败: {e}")
|
||||
_symbols_cache = ["BTC/USDT:USDT"]
|
||||
|
||||
Reference in New Issue
Block a user