Spaces:
Paused
Paused
zt p commited on
Commit ·
49efd8b
1
Parent(s): f03326d
新增 ENABLE_FUTURES 全局开关(默认关),彻底拦截 /fapi 与强平流调用,规避 US 451
Browse files41 unmodified lines424344454647544 unmodified lines592593594595596597598142 unmodified lines741742743744745746747267 unmodified lines10151016101710181019102041 unmodified linesFAPI_BASE = os.getenv("BINANCE_FAPI_BASE", "https://fapi.binance.com")FSTREAM_BASE = os.getenv("BINANCE_FSTREAM_BASE", "wss://fstream.binance.com/ws")# 配置持久化文件CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))CONFIG_FILE = os.path.join(CURRENT_DIR, "crypto_config.json")544 unmodified linesout["liq_severe_usdt"] = round(out["liq_5m_usdt"] * 4)# 7) 资金费率:历史费率分位(仅合约启用时)if coin_cfg.get("enable_futures"):fr = api._get(FAPI_BASE, "/fapi/v1/fundingRate",{"symbol": coin_cfg["futures_symbol"], "limit": 500})if fr:142 unmodified linesself._check_rsi(cfg, sym, head, add)# 12) 合约类if cfg.get("enable_futures"):self._check_futures(cfg, head, add)snapshot = {267 unmodified linesself.logs.appendleft(entry)def _futures_symbols(self):return [c["futures_symbol"] for c in self.config["coins"].values()if c.get("enable_futures")]41 unmodified lines424344454647484950515253544 unmodified lines598599600601602603604142 unmodified lines747748749750751752753267 unmodified lines1021102210231024102510261027102841 unmodified linesFAPI_BASE = os.getenv("BINANCE_FAPI_BASE", "https://fapi.binance.com")FSTREAM_BASE = os.getenv("BINANCE_FSTREAM_BASE", "wss://fstream.binance.com/ws")# 合约功能全局开关(默认关闭)。币安合约接口/强平流对 US 区域返回 451,# 而 HuggingFace Space 运行在 US。此开关优先级高于每个币种的 enable_futures:# 关闭时一律不调用 /fapi 与强平 websocket,避免 451 刷屏。# 若自带可访问合约接口的代理,设置环境变量 ENABLE_FUTURES=true 即可整体开启。FUTURES_ENABLED = os.getenv("ENABLE_FUTURES", "false").strip().lower() in ("1", "true", "yes", "on")# 配置持久化文件CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))CONFIG_FILE = os.path.join(CURRENT_DIR, "crypto_config.json")544 unmodified linesout["liq_severe_usdt"] = round(out["liq_5m_usdt"] * 4)# 7) 资金费率:历史费率分位(仅合约启用时)if FUTURES_ENABLED and coin_cfg.get("enable_futures"):fr = api._get(FAPI_BASE, "/fapi/v1/fundingRate",{"symbol": coin_cfg["futures_symbol"], "limit": 500})if fr:142 unmodified linesself._check_rsi(cfg, sym, head, add)# 12) 合约类if FUTURES_ENABLED and cfg.get("enable_futures"):self._check_futures(cfg, head, add)snapshot = {267 unmodified linesself.logs.appendleft(entry)def _futures_symbols(self):if not FUTURES_ENABLED:return []return [c["futures_symbol"] for c in self.config["coins"].values()if c.get("enable_futures")]
coinpush.py+10-2