From df28e6dfb8a073c846271961dedf1e7ff009a050 Mon Sep 17 00:00:00 2001 From: dekun Date: Sat, 4 Jul 2026 22:21:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ccxt=20Gate=20=E7=B1=BB=E5=90=8D=20gatei?= =?UTF-8?q?o=20=E6=94=B9=E4=B8=BA=E5=85=BC=E5=AE=B9=20gate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- crypto_monitor_gate/app.py | 4 +++- lib/exchange/gate_ccxt_lib.py | 9 +++++++++ manual_trading_hub/agent.py | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 lib/exchange/gate_ccxt_lib.py diff --git a/crypto_monitor_gate/app.py b/crypto_monitor_gate/app.py index 1fc39ce..1ed39c8 100644 --- a/crypto_monitor_gate/app.py +++ b/crypto_monitor_gate/app.py @@ -394,8 +394,10 @@ os.makedirs(UPLOAD_FOLDER, exist_ok=True) os.makedirs(ORDER_CHART_DIR, exist_ok=True) app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER +from lib.exchange.gate_ccxt_lib import gate_ccxt_class + # Gate.io USDT 永续(swap) -exchange = ccxt.gateio({ +exchange = gate_ccxt_class()({ "enableRateLimit": True, "options": { "defaultType": "swap", diff --git a/lib/exchange/gate_ccxt_lib.py b/lib/exchange/gate_ccxt_lib.py new file mode 100644 index 0000000..daf2bbd --- /dev/null +++ b/lib/exchange/gate_ccxt_lib.py @@ -0,0 +1,9 @@ +"""Gate.io ccxt 构造(ccxt 4.x 起类名由 gateio 改为 gate)。""" +from __future__ import annotations + +import ccxt + + +def gate_ccxt_class(): + """返回 ccxt Gate 交易所类(兼容旧版 gateio 名称)。""" + return getattr(ccxt, "gate", None) or ccxt.gateio diff --git a/manual_trading_hub/agent.py b/manual_trading_hub/agent.py index ce620b9..1e37dce 100644 --- a/manual_trading_hub/agent.py +++ b/manual_trading_hub/agent.py @@ -158,7 +158,9 @@ def _make_exchange() -> Any: secret = (os.getenv("GATE_API_SECRET") or "").strip() if not key or not secret: raise RuntimeError("缺少 GATE_API_KEY / GATE_API_SECRET") - ex = ccxt.gateio( + from lib.exchange.gate_ccxt_lib import gate_ccxt_class + + ex = gate_ccxt_class()( { "apiKey": key, "secret": secret,