Allow roll add-ons while position-limit freeze is active.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2862,9 +2862,11 @@ def precheck_risk(conn, symbol, direction):
|
||||
return False, risk_reason
|
||||
if not trading_day_reset_allows_new_open(now):
|
||||
return False, f"北京时间 {TRADING_DAY_RESET_HOUR}:00 前不允许持仓"
|
||||
active_count = get_active_position_count(conn)
|
||||
if active_count >= MAX_ACTIVE_POSITIONS:
|
||||
return False, f"已达最大持仓数({active_count}/{MAX_ACTIVE_POSITIONS})"
|
||||
from account_risk_lib import position_limit_reached
|
||||
|
||||
reached, active_count, mx = position_limit_reached(conn, max_active_positions=MAX_ACTIVE_POSITIONS)
|
||||
if reached:
|
||||
return False, f"已达最大持仓数({active_count}/{mx})"
|
||||
ok_daily, daily_reason, _opens = check_daily_open_hard_limit(
|
||||
conn, get_trading_day(now), DAILY_OPEN_HARD_LIMIT, TRADING_DAY_RESET_HOUR
|
||||
)
|
||||
@@ -6795,11 +6797,14 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
records = []
|
||||
total = miss_count = rate = occupied_miss_total = 0
|
||||
active_count = len(order_list)
|
||||
from strategy_trade_labels import count_position_limit_active_monitors
|
||||
|
||||
position_limit_count = count_position_limit_active_monitors(conn)
|
||||
opens_today = count_opens_for_trading_day(conn, trading_day)
|
||||
risk_status = hub_account_risk_status(conn)
|
||||
can_trade = can_trade_new_open(
|
||||
time_allows=trading_day_reset_allows_new_open(now),
|
||||
active_count=active_count,
|
||||
active_count=position_limit_count,
|
||||
max_active_positions=MAX_ACTIVE_POSITIONS,
|
||||
opens_today=opens_today,
|
||||
hard_limit=DAILY_OPEN_HARD_LIMIT,
|
||||
@@ -6862,7 +6867,7 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
transfer_amount_fmt=format_usdt(AUTO_TRANSFER_AMOUNT),
|
||||
full_margin_buffer_ratio=FULL_MARGIN_BUFFER_RATIO,
|
||||
price_refresh_seconds=PRICE_REFRESH_SECONDS,
|
||||
active_count=active_count,
|
||||
active_count=position_limit_count,
|
||||
can_trade=can_trade,
|
||||
opens_today=opens_today,
|
||||
daily_open_hard_limit=DAILY_OPEN_HARD_LIMIT,
|
||||
@@ -6971,13 +6976,15 @@ def api_account_snapshot():
|
||||
funding_usdt = round(funding_capital, 2) if funding_capital is not None else None
|
||||
current_capital = round(trading_capital, 2) if trading_capital is not None else round(local_current_capital, 2)
|
||||
recommended_capital = round(float(get_recommended_capital(current_capital)), 2)
|
||||
active_count = get_active_position_count(conn)
|
||||
from strategy_trade_labels import count_position_limit_active_monitors
|
||||
|
||||
position_limit_count = count_position_limit_active_monitors(conn)
|
||||
opens_today = count_opens_for_trading_day(conn, trading_day)
|
||||
risk_status = hub_account_risk_status(conn)
|
||||
conn.close()
|
||||
can_trade = can_trade_new_open(
|
||||
time_allows=trading_day_reset_allows_new_open(now),
|
||||
active_count=active_count,
|
||||
active_count=position_limit_count,
|
||||
max_active_positions=MAX_ACTIVE_POSITIONS,
|
||||
opens_today=opens_today,
|
||||
hard_limit=DAILY_OPEN_HARD_LIMIT,
|
||||
@@ -6989,7 +6996,7 @@ def api_account_snapshot():
|
||||
"current_capital": current_capital,
|
||||
"available_trading_usdt": round(available_trading_usdt, 2) if available_trading_usdt is not None else None,
|
||||
"recommended_capital": recommended_capital,
|
||||
"active_count": active_count,
|
||||
"active_count": position_limit_count,
|
||||
"max_active_positions": MAX_ACTIVE_POSITIONS,
|
||||
"can_trade": can_trade,
|
||||
"opens_today": opens_today,
|
||||
|
||||
Reference in New Issue
Block a user