Fix false USDC-short error while waiting for a qualified option.
Use risk-sizing preview ask/qty (same as auto-convert) instead of monitor book ask. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,7 +17,7 @@ from ..env_store import live_ready
|
||||
from .clock import can_open_new, window_key
|
||||
from .exits import check_expiry_close, check_exits, resolve_exit_target
|
||||
from .group import next_group_id
|
||||
from .open_capacity import assess_open_capacity, maybe_notify_funds_short
|
||||
from .open_capacity import maybe_notify_funds_short
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -219,9 +219,12 @@ class StrategyEngine:
|
||||
last_error = None
|
||||
allow_open = can_open_new(skip_weekends=skip_weekends)
|
||||
try:
|
||||
open_cap = assess_open_capacity(self.db)
|
||||
# 以损定仓(尤其选约杠杆):用预览名义+定仓卖一,勿用监控盘口贵卖一×账本名义虚高「需USDC」
|
||||
from .auto_usdc import preview_capacity_for_convert
|
||||
|
||||
open_cap = preview_capacity_for_convert(self.db)
|
||||
except Exception:
|
||||
logger.exception("assess_open_capacity failed")
|
||||
logger.exception("preview_capacity_for_convert failed")
|
||||
open_cap = {
|
||||
"perp_can_open": None,
|
||||
"option_can_open": None,
|
||||
@@ -1045,15 +1048,17 @@ class StrategyEngine:
|
||||
return
|
||||
if pick is None:
|
||||
try:
|
||||
from .open_capacity import assess_open_capacity, funds_gate_blocks
|
||||
from .auto_usdc import preview_capacity_for_convert
|
||||
from .open_capacity import funds_gate_blocks
|
||||
|
||||
cap = assess_open_capacity(self.db)
|
||||
# 与自动兑 USDC 同一口径(选约杠杆用隐含卖一估需),避免无合格约时用盘口贵卖一误报缺 USDC
|
||||
cap = preview_capacity_for_convert(self.db)
|
||||
blocked, why = funds_gate_blocks(cap)
|
||||
if blocked and cap.get("option_can_open") is False:
|
||||
self._set_state(
|
||||
phase="wait_funds",
|
||||
last_error=(
|
||||
"无合格期权;且交易账户 USDC 不够开仓"
|
||||
"无合格期权;且按拟定仓估算交易账户 USDC 不够开仓"
|
||||
f"(需≈{cap.get('option_need_usdc')}U / 有{cap.get('option_have_usdc')}U)。"
|
||||
"系统会在冷却后自动市价兑 USDC。"
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user