Allow roll add-ons while position-limit freeze is active.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-1
@@ -93,6 +93,19 @@ def max_active_positions_from_env(default: int = 1) -> int:
|
||||
return max(1, default)
|
||||
|
||||
|
||||
def position_limit_reached(
|
||||
conn,
|
||||
*,
|
||||
max_active_positions: Optional[int] = None,
|
||||
) -> tuple[bool, int, int]:
|
||||
"""(已达上限, 计入上限的活跃数, 上限值)。"""
|
||||
from strategy_trade_labels import count_position_limit_active_monitors
|
||||
|
||||
mx = max(1, int(max_active_positions if max_active_positions is not None else max_active_positions_from_env()))
|
||||
ac = count_position_limit_active_monitors(conn)
|
||||
return ac >= mx, ac, mx
|
||||
|
||||
|
||||
def mood_issues_daily_freeze_enabled() -> bool:
|
||||
return _env_bool("RISK_MOOD_ISSUES_DAILY_FREEZE", True)
|
||||
|
||||
@@ -721,12 +734,14 @@ def apply_position_limit_risk(
|
||||
out["status"] = STATUS_FREEZE_POSITION
|
||||
out["status_label"] = STATUS_LABELS[STATUS_FREEZE_POSITION]
|
||||
out["can_trade"] = False
|
||||
out["reason"] = f"已达最大持仓数({ac}/{mx},不含趋势回调/顺势加仓),平仓前不可新开"
|
||||
out["can_roll"] = True
|
||||
out["reason"] = f"已达最大持仓数({ac}/{mx}),新开仓已冻结,顺势加仓仍可用"
|
||||
out["position_limit_frozen"] = True
|
||||
out["freeze_until_ms"] = None
|
||||
out["freeze_remaining_sec"] = 0
|
||||
else:
|
||||
out["position_limit_frozen"] = False
|
||||
out["can_roll"] = True
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user