币本位开仓:张数留手续费缓冲,延长买币落账等待并修正51008文案

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 13:24:54 +08:00
parent ed3f4898dd
commit 9f3360e968
3 changed files with 20 additions and 5 deletions
+7 -1
View File
@@ -126,7 +126,13 @@ def open_coin_option_buy_full(
message="已买币,待开期权",
)
# 等余额落账
time.sleep(0.6)
time.sleep(1.5)
try:
from lib.exchange.okx_options_lib import invalidate_options_balance_cache
invalidate_options_balance_cache()
except Exception:
pass
coin_after = fetch_trading_coin_available(ex, underlying)
if coin_after is None:
rb = rollback_bought_coin_to_usdt(
+3 -1
View File
@@ -143,12 +143,14 @@ def calc_sheets_from_coin_balance(
mult = float(ct_mult or 0.01)
need = max(1, int(min_sz or 1))
coin = max(0.0, float(coin_available or 0))
# 留一点手续费/精度缓冲,避免算满张后下单 51008
coin_eff = coin * 0.97
if ask <= 0 or mult <= 0:
return {"ok": False, "msg": "卖一价无效", "sheets": 0, "coin_premium": 0.0}
per_sheet = ask * mult
if per_sheet <= 0:
return {"ok": False, "msg": "无法计算单张权利金(币)", "sheets": 0, "coin_premium": 0.0}
sheets = int(math.floor((coin / per_sheet) + 1e-12))
sheets = int(math.floor((coin_eff / per_sheet) + 1e-12))
if sheets < need:
return {
"ok": False,