feat: show force-close badge and countdown when FORCE_CLOSE is enabled
Add shared lib/UI for midnight force-close indicator on instance and hub pages, and document Gate intraday 0-point exit alignment. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -121,6 +121,11 @@ from lib.trade.time_close_lib import (
|
||||
time_close_label,
|
||||
time_close_settings_from_row,
|
||||
)
|
||||
from lib.trade.force_close_lib import (
|
||||
apply_force_close_to_payload,
|
||||
enrich_orders_force_close,
|
||||
force_close_template_context,
|
||||
)
|
||||
from lib.trade.manual_sltp_lib import (
|
||||
normalize_open_sltp_mode,
|
||||
resolve_entrust_sltp_prices,
|
||||
@@ -6910,6 +6915,12 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
raw_order_list = conn.execute("SELECT * FROM order_monitors WHERE status='active'").fetchall()
|
||||
for o in raw_order_list:
|
||||
order_list.append(enrich_order_item(row_to_dict(o), current_capital))
|
||||
enrich_orders_force_close(
|
||||
order_list,
|
||||
FORCE_CLOSE_ENABLED,
|
||||
FORCE_CLOSE_BJ_HOUR,
|
||||
now_ms=int(app_now().timestamp() * 1000),
|
||||
)
|
||||
exchange_pnl_sync = {}
|
||||
if exchange_private_api_configured() and not request_is_hub_soft_nav() and embed_mode not in (
|
||||
"fragment",
|
||||
@@ -7062,6 +7073,11 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
kline_timeframe=KLINE_TIMEFRAME,
|
||||
exchange_pnl_sync=exchange_pnl_sync,
|
||||
**strategy_extra,
|
||||
**force_close_template_context(
|
||||
FORCE_CLOSE_ENABLED,
|
||||
FORCE_CLOSE_BJ_HOUR,
|
||||
now_ms=int(app_now().timestamp() * 1000),
|
||||
),
|
||||
**embed_context_extras("gate"),
|
||||
)
|
||||
if embed_mode == "fragment":
|
||||
@@ -7159,6 +7175,11 @@ def api_account_snapshot():
|
||||
"manual_min_planned_rr": MANUAL_MIN_PLANNED_RR,
|
||||
"trading_day": trading_day,
|
||||
"risk_status": risk_status,
|
||||
**force_close_template_context(
|
||||
FORCE_CLOSE_ENABLED,
|
||||
FORCE_CLOSE_BJ_HOUR,
|
||||
now_ms=int(now.timestamp() * 1000),
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -7425,6 +7446,11 @@ def api_price_snapshot():
|
||||
funds_decimals=FUNDS_DECIMALS,
|
||||
)
|
||||
apply_time_close_to_payload(payload, r)
|
||||
apply_force_close_to_payload(
|
||||
payload,
|
||||
enabled=FORCE_CLOSE_ENABLED,
|
||||
bj_hour=FORCE_CLOSE_BJ_HOUR,
|
||||
)
|
||||
payload["opened_at"] = r["opened_at"] if "opened_at" in r.keys() else None
|
||||
open_ms = r["opened_at_ms"] if "opened_at_ms" in r.keys() else None
|
||||
payload["opened_at_ms"] = int(open_ms) if open_ms not in (None, "") else None
|
||||
@@ -7460,6 +7486,10 @@ def api_price_snapshot():
|
||||
"order_prices": order_prices,
|
||||
"position_marks": position_marks,
|
||||
"positions_raw_count": len(all_swap_positions),
|
||||
**force_close_template_context(
|
||||
FORCE_CLOSE_ENABLED,
|
||||
FORCE_CLOSE_BJ_HOUR,
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user