Harden LIVE opens with slot claim and exchange reconcile.
Prevent duplicate opens by atomically claiming an opening slot, verifying exchange perp is flat before live orders, setting leverage from ledger, and preferring exchange position size when closing perps. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,7 +23,7 @@ from .pricing import (
|
||||
|
||||
# 禁止新开仓的本地仓位状态(实盘防卡)
|
||||
BLOCKING_STATUSES = frozenset(
|
||||
{"open", "half_open", "option_closed_perp_pending"}
|
||||
{"open", "half_open", "option_closed_perp_pending", "opening"}
|
||||
)
|
||||
|
||||
|
||||
@@ -72,11 +72,13 @@ class Matcher:
|
||||
return dict(row)
|
||||
|
||||
def has_open_position(self) -> bool:
|
||||
"""是否禁止新开:含 open / half_open / option_closed_perp_pending。"""
|
||||
"""是否禁止新开:含 open / half_open / option_closed_perp_pending / opening。"""
|
||||
pos = self.current_position()
|
||||
st = str(pos.get("status") or "")
|
||||
if st not in BLOCKING_STATUSES:
|
||||
return False
|
||||
if st == "opening":
|
||||
return True
|
||||
return bool(pos.get("group_id") or pos.get("option_inst_id"))
|
||||
|
||||
def position_status(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user