feat: add per-account daily open hard limit across all exchanges
Enforce optional DAILY_OPEN_HARD_LIMIT in precheck_risk and can_trade, keep AI alerts at DAILY_OPEN_ALERT_THRESHOLD, and document env setup for all four instances. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1484,10 +1484,18 @@ def load_trend_page_context(conn, request_obj, cfg: dict) -> dict[str, Any]:
|
||||
pass
|
||||
now = m.app_now()
|
||||
active_count = m.get_active_position_count(conn)
|
||||
can_trade_trend = (
|
||||
m.trading_day_reset_allows_new_open(now)
|
||||
and active_count < cfg["max_active_positions"]
|
||||
and trend_active == 0
|
||||
from daily_open_limit_lib import can_trade_new_open, count_opens_for_trading_day
|
||||
|
||||
trading_day = m.get_trading_day(now)
|
||||
opens_today = count_opens_for_trading_day(conn, trading_day)
|
||||
hard_limit = int(getattr(m, "DAILY_OPEN_HARD_LIMIT", 0) or 0)
|
||||
can_trade_trend = can_trade_new_open(
|
||||
time_allows=m.trading_day_reset_allows_new_open(now),
|
||||
active_count=active_count,
|
||||
max_active_positions=cfg["max_active_positions"],
|
||||
opens_today=opens_today,
|
||||
hard_limit=hard_limit,
|
||||
extra_blocks=trend_active != 0,
|
||||
)
|
||||
trend_preview = None
|
||||
trend_preview_levels = []
|
||||
|
||||
Reference in New Issue
Block a user