修复期权币本位高危缺陷:开仓估量、卖回封顶、握库超时与条件单嵌套锁。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-07 12:00:08 +08:00
parent ea3e029eb9
commit 77fe0fa679
16 changed files with 724 additions and 201 deletions
+10 -3
View File
@@ -468,16 +468,23 @@ def _patch_spot_bridge_lib() -> None:
try:
if _GET_DB is not None and is_sim_mode(_GET_DB):
coin = (underlying or "ETH").strip().upper() or "ETH"
_ = coin_amount
avail = fetch_trading_coin_available(ex, coin)
if avail is None or float(avail) <= 0:
return {"ok": False, "msg": f"交易账户无可用 {coin}"}
from lib.options.options_spot_bridge_lib import is_sellable_spot_coin, spot_min_sell_sz
if not is_sellable_spot_coin(ex, coin, avail):
amt = float(avail)
if coin_amount is not None:
try:
lim = float(coin_amount)
except (TypeError, ValueError):
lim = 0.0
if lim > 0:
amt = min(amt, lim)
if not is_sellable_spot_coin(ex, coin, amt):
min_sz = spot_min_sell_sz(ex, coin)
return {"ok": False, "msg": f"{coin} 可卖数量过小(低于现货最小 {min_sz:g})"}
sell_sz = max(0.0, float(avail) * 0.999)
sell_sz = max(0.0, float(amt) * 0.999)
if sell_sz <= 0 or not is_sellable_spot_coin(ex, coin, sell_sz):
return {"ok": False, "msg": f"{coin} 可卖数量过小"}
pub = _sim_public_exchange(ex)