feat: require gate reset before post-stop reentry
This commit is contained in:
@@ -20,7 +20,7 @@ from app.services.outcome_service import (
|
||||
Bar,
|
||||
evaluate_setup_against_bars,
|
||||
)
|
||||
from app.services.trade_policy import get_reentry_lockdowns
|
||||
from app.services.trade_policy import get_reentry_gate_locks
|
||||
|
||||
# Exit policy for OPEN paper trades (auto-close). Production defaults to the
|
||||
# July 2026 promoted strategy: initial stop + 3x ATR trailing stop, with a max
|
||||
@@ -319,12 +319,9 @@ async def create_trade(
|
||||
raise ValidationError("shares and entry_price must be positive")
|
||||
|
||||
ticker = await _get_ticker(db, symbol)
|
||||
remaining_sessions = (await get_reentry_lockdowns(db)).get(ticker.id)
|
||||
if remaining_sessions is not None:
|
||||
suffix = "session" if remaining_sessions == 1 else "sessions"
|
||||
if ticker.id in await get_reentry_gate_locks(db):
|
||||
raise ValidationError(
|
||||
f"{ticker.symbol} is in a post-stop re-entry lockdown: "
|
||||
f"{remaining_sessions} market {suffix} remaining"
|
||||
f"{ticker.symbol} requires a post-stop gate reset before re-entry"
|
||||
)
|
||||
trade = PaperTrade(
|
||||
user_id=user_id,
|
||||
|
||||
Reference in New Issue
Block a user