refactor: 移除四所统计分析页交易日历
删除日历 UI、bootstrap 与 /api/stats/calendar 注册;保留日/周/月统计表。内照明心档案日历不受影响。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1857,7 +1857,7 @@ def _compute_period_metrics(trades):
|
||||
}
|
||||
|
||||
|
||||
def compute_stats_bundle(conn, trading_day, now_dt=None, *, with_calendar=False):
|
||||
def compute_stats_bundle(conn, trading_day, now_dt=None):
|
||||
"""日 / 周 / 月 统计:平仓按北京时间交易日(默认 8:00 切日)计入。"""
|
||||
now_dt = now_dt or app_now()
|
||||
pnls = _load_completed_trade_pnls(conn)
|
||||
@@ -1888,15 +1888,6 @@ def compute_stats_bundle(conn, trading_day, now_dt=None, *, with_calendar=False)
|
||||
|
||||
dm, wm, mm = slice_metrics("all")
|
||||
|
||||
initial_calendar = None
|
||||
calendar_bootstrap_json = None
|
||||
if with_calendar:
|
||||
from trade_stats_calendar_lib import build_stats_calendar_bootstrap
|
||||
|
||||
initial_calendar, calendar_bootstrap_json = build_stats_calendar_bootstrap(
|
||||
pnls, now_dt, _pnl_row_matches_segment, reset_hour=TRADING_DAY_RESET_HOUR
|
||||
)
|
||||
|
||||
return {
|
||||
"trading_day": trading_day,
|
||||
"total_opens_all": total_opens_all,
|
||||
@@ -1905,8 +1896,6 @@ def compute_stats_bundle(conn, trading_day, now_dt=None, *, with_calendar=False)
|
||||
"month": mm,
|
||||
"segments": segments,
|
||||
"stats_reset_hour": TRADING_DAY_RESET_HOUR,
|
||||
"initial_calendar": initial_calendar,
|
||||
"calendar_bootstrap_json": calendar_bootstrap_json,
|
||||
}
|
||||
|
||||
|
||||
@@ -7044,7 +7033,7 @@ def render_main_page(page="trade", embed_mode=None):
|
||||
else []
|
||||
)
|
||||
stats_bundle = (
|
||||
compute_stats_bundle(conn, trading_day, now, with_calendar=(page == "stats"))
|
||||
compute_stats_bundle(conn, trading_day, now)
|
||||
if plan.stats_bundle
|
||||
else minimal_stats_bundle(TRADING_DAY_RESET_HOUR)
|
||||
)
|
||||
@@ -9651,20 +9640,6 @@ try:
|
||||
except Exception as _hub_err:
|
||||
print(f"[hub_bridge] binance: {_hub_err}")
|
||||
|
||||
try:
|
||||
from hub_bridge import register_trade_stats_calendar_route
|
||||
|
||||
register_trade_stats_calendar_route(
|
||||
app,
|
||||
login_required_fn=login_required,
|
||||
load_pnls_fn=_load_completed_trade_pnls,
|
||||
row_matches_segment_fn=_pnl_row_matches_segment,
|
||||
reset_hour=TRADING_DAY_RESET_HOUR,
|
||||
get_db_fn=get_db,
|
||||
)
|
||||
except Exception as _cal_err:
|
||||
print(f"[stats calendar] binance: {_cal_err}")
|
||||
|
||||
|
||||
@app.route("/strategy")
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user