fix: 统计日历服务端内嵌 bootstrap,首屏显示盈亏与笔数
与月统计同源 initial_calendar 写入页面,API 失败时仍渲染;四所日历路由独立注册并传入 get_db_fn。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1888,6 +1888,12 @@ def compute_stats_bundle(conn, trading_day, now_dt=None):
|
||||
|
||||
dm, wm, mm = slice_metrics("all")
|
||||
|
||||
from trade_stats_calendar_lib import build_initial_stats_calendar
|
||||
|
||||
initial_calendar = build_initial_stats_calendar(
|
||||
pnls, now_dt, _pnl_row_matches_segment, reset_hour=TRADING_DAY_RESET_HOUR
|
||||
)
|
||||
|
||||
return {
|
||||
"trading_day": trading_day,
|
||||
"total_opens_all": total_opens_all,
|
||||
@@ -1896,6 +1902,7 @@ def compute_stats_bundle(conn, trading_day, now_dt=None):
|
||||
"month": mm,
|
||||
"segments": segments,
|
||||
"stats_reset_hour": TRADING_DAY_RESET_HOUR,
|
||||
"initial_calendar": initial_calendar,
|
||||
}
|
||||
|
||||
|
||||
@@ -9617,7 +9624,7 @@ try:
|
||||
_repo_root = Path(__file__).resolve().parent.parent
|
||||
if str(_repo_root) not in sys.path:
|
||||
sys.path.insert(0, str(_repo_root))
|
||||
from hub_bridge import install_on_app, register_trade_stats_calendar_route
|
||||
from hub_bridge import install_on_app
|
||||
|
||||
install_on_app(
|
||||
app,
|
||||
@@ -9637,15 +9644,22 @@ try:
|
||||
render_main_page_fn=render_main_page,
|
||||
login_required_fn=login_required,
|
||||
)
|
||||
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 _hub_err:
|
||||
print(f"[hub_bridge] binance: {_hub_err}")
|
||||
except Exception as _cal_err:
|
||||
print(f"[stats calendar] binance: {_cal_err}")
|
||||
|
||||
|
||||
@app.route("/strategy")
|
||||
|
||||
Reference in New Issue
Block a user