恢复中控快照买一/流动性,与实例同步;未附带 preview 时不再误标残档。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,6 +57,13 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
|
||||
if not isinstance(p, dict):
|
||||
continue
|
||||
preview = p.get("close_preview") if isinstance(p.get("close_preview"), dict) else {}
|
||||
# 仅在实例已附带 close_preview 时判定残档;缺字段=未同步,勿假装「无买一/残档」
|
||||
preview_present = bool(preview) and (
|
||||
"bid_invalid" in preview
|
||||
or "levels" in preview
|
||||
or "covered_sheets" in preview
|
||||
or "liquidity_ok" in preview
|
||||
)
|
||||
levels = preview.get("levels") if isinstance(preview.get("levels"), list) else []
|
||||
top = levels[0] if levels and isinstance(levels[0], dict) else {}
|
||||
bid_px = top.get("px")
|
||||
@@ -64,22 +71,28 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
|
||||
bid_px = preview.get("raw_bid_px")
|
||||
bid_sz = top.get("available_sheets")
|
||||
try:
|
||||
uncovered = int(float(preview.get("uncovered_sheets") or 0))
|
||||
uncovered = int(float(preview.get("uncovered_sheets") or 0)) if preview_present else 0
|
||||
except (TypeError, ValueError):
|
||||
uncovered = 0
|
||||
try:
|
||||
covered = int(float(preview.get("covered_sheets") or 0))
|
||||
covered = int(float(preview.get("covered_sheets") or 0)) if preview_present else 0
|
||||
except (TypeError, ValueError):
|
||||
covered = 0
|
||||
bid_invalid = bool(preview.get("bid_invalid"))
|
||||
# 残档/无效买一,或买一深度盖不住持仓 → 流动性不足
|
||||
liq_ok = (not bid_invalid) and uncovered <= 0 and (
|
||||
preview.get("liquidity_ok") is not False
|
||||
)
|
||||
if not levels and not bid_invalid and covered <= 0:
|
||||
# 无买一档
|
||||
liq_ok = False
|
||||
bid_invalid = True
|
||||
bid_invalid = bool(preview.get("bid_invalid")) if preview_present else False
|
||||
bid_invalid_reason = preview.get("bid_invalid_reason") if preview_present else None
|
||||
# 残档/无效买一,或买一深度盖不住持仓 → 流动性不足;未同步时不标黄残档
|
||||
if not preview_present:
|
||||
liq_ok = None
|
||||
else:
|
||||
liq_ok = (not bid_invalid) and uncovered <= 0 and (
|
||||
preview.get("liquidity_ok") is not False
|
||||
)
|
||||
if not levels and not bid_invalid and covered <= 0:
|
||||
# 已拉盘口但无可用买一档
|
||||
liq_ok = False
|
||||
bid_invalid = True
|
||||
if not bid_invalid_reason:
|
||||
bid_invalid_reason = "无买一"
|
||||
pnl_usdt = p.get("display_pnl_usdt")
|
||||
if pnl_usdt is None:
|
||||
try:
|
||||
@@ -132,10 +145,10 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
|
||||
"target_monitor_text": p.get("target_monitor_text"),
|
||||
"bid_px": bid_px,
|
||||
"bid_sz": bid_sz,
|
||||
"covered_sheets": covered,
|
||||
"uncovered_sheets": uncovered,
|
||||
"covered_sheets": covered if preview_present else None,
|
||||
"uncovered_sheets": uncovered if preview_present else None,
|
||||
"bid_invalid": bid_invalid,
|
||||
"bid_invalid_reason": preview.get("bid_invalid_reason"),
|
||||
"bid_invalid_reason": bid_invalid_reason,
|
||||
"liquidity_ok": liq_ok,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user