Cap options budget-full sizing at min(balance, trade budget) with UI hint.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 08:54:38 +08:00
parent 846f3de525
commit a2075ba73e
5 changed files with 41 additions and 4 deletions
+7 -2
View File
@@ -163,13 +163,18 @@ def _require_options_ex(cfg: dict[str, Any]):
def _budget_full_usdc(cfg: dict[str, Any], ex: Any) -> tuple[float | None, str]:
"""交易账户 USDC 可用余额(由 calc_order_size 再乘 budget_buffer 留余量)."""
"""打满可用额度 = min(交易户可用 USDC, 单笔预算);calc_order_size 再乘 budget_buffer."""
from lib.exchange.okx_options_lib import fetch_options_trading_usdc
from lib.options.options_pricing_lib import resolve_budget_full_usdc
raw = fetch_options_trading_usdc(ex)
if raw is None or float(raw) <= 0:
return None, "交易账户 USDC 可用余额不足"
return float(raw), ""
trading = float(raw)
cap = _env_float("OKX_OPTIONS_TRADE_BUDGET_USDC", float(cfg.get("trade_budget") or 10.0))
if cap <= 0:
return None, "单笔预算无效(OKX_OPTIONS_TRADE_BUDGET_USDC)"
return resolve_budget_full_usdc(trading, float(cap)), ""
def _open_premium_paid(cfg: dict[str, Any], inst_id: str) -> float | None: