From 6c9825284f36d933113e67867259a74be2a0cc60 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 20 Aug 2026 13:28:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=81=E6=9C=AC=E4=BD=8D=E5=BC=80=E4=BB=93?= =?UTF-8?q?=E9=81=87=E4=BF=9D=E8=AF=81=E9=87=91=E4=B8=8D=E8=B6=B3=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=87=8F=E5=8D=8A=E5=BC=A0=E6=95=B0=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/options/options_coin_open_lib.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/options/options_coin_open_lib.py b/lib/options/options_coin_open_lib.py index a14f310..f9923a9 100644 --- a/lib/options/options_coin_open_lib.py +++ b/lib/options/options_coin_open_lib.py @@ -202,6 +202,32 @@ def open_coin_option_buy_full( tick_sz=tick_sz, ord_type="ioc", ) + # 51008 时自动减半张数再试一次(买币已到位,避免整笔回滚) + if (not order.get("ok")) and sheets > 1: + msg_l = str(order.get("msg") or "").lower() + if "51008" in str(order.get("raw") or "").lower() or "不足" in str(order.get("msg") or ""): + sheets2 = max(1, sheets // 2) + if sheets2 < sheets: + order2 = cfg["place_option_limit_order"]( + ex, + inst_id=inst_id, + side="buy", + sheets=sheets2, + price=float(ask), + td_mode=td_mode_for_option_buy(cfg.get("td_mode")), + tick_sz=tick_sz, + ord_type="ioc", + ) + if order2.get("ok"): + order = order2 + sheets = sheets2 + sizing = { + "ok": True, + "sheets": sheets, + "eth_amount": round(sheets * ct_mult, 8), + "coin_premium": round(sheets * float(ask) * ct_mult, 8), + "retried_half": True, + } if not order.get("ok"): rb = rollback_bought_coin_to_usdt( conn, ex, bridge_id=bridge_id, underlying=underlying, reason=order.get("msg") or "下单失败"