From cc1b2c33c1c12ba0e36fc25d55d7952ce37bc3c6 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Mar 2026 10:34:04 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E7=BD=91STOP=5FMARKET?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=E4=B8=BASTOP=E9=99=90=E4=BB=B7=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试网不支持STOP_MARKET/TAKE_PROFIT_MARKET order type 检测TRADE_ENV=testnet时自动降级: - STOP_MARKET → STOP + price + GTC - TAKE_PROFIT_MARKET → TAKE_PROFIT + price + GTC 实盘(mainnet)不受影响 --- backend/live_executor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/live_executor.py b/backend/live_executor.py index f57c5d0..1ca2975 100644 --- a/backend/live_executor.py +++ b/backend/live_executor.py @@ -206,6 +206,13 @@ async def place_stop_order(session: aiohttp.ClientSession, symbol: str, side: st "reduceOnly": "true", } + # 测试网不支持STOP_MARKET/TAKE_PROFIT_MARKET,降级为STOP/TAKE_PROFIT(限价单) + if TRADE_ENV == "testnet" and order_type in ("STOP_MARKET", "TAKE_PROFIT_MARKET"): + fallback_type = "STOP" if "STOP" in order_type else "TAKE_PROFIT" + params["type"] = fallback_type + params["price"] = price_str # 限价单需要price + params["timeInForce"] = "GTC" + data, status = await binance_request(session, "POST", "/fapi/v1/order", params) if status == 200: logger.info(f"[{symbol}] 📌 挂{order_type} {side} @ {price_str} qty={qty_str} | orderId={data.get('orderId')}")