fix: 统计日历服务端内嵌 bootstrap,首屏显示盈亏与笔数
与月统计同源 initial_calendar 写入页面,API 失败时仍渲染;四所日历路由独立注册并传入 get_db_fn。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1861,6 +1861,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,
|
||||
@@ -1869,6 +1875,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,
|
||||
}
|
||||
|
||||
|
||||
@@ -8998,7 +9005,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,
|
||||
@@ -9018,15 +9025,22 @@ try:
|
||||
render_main_page_fn=render_main_page,
|
||||
login_required_fn=login_required,
|
||||
)
|
||||
except Exception as _hub_err:
|
||||
print(f"[hub_bridge] okx: {_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] okx: {_hub_err}")
|
||||
except Exception as _cal_err:
|
||||
print(f"[stats calendar] okx: {_cal_err}")
|
||||
|
||||
|
||||
@app.route("/strategy")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<script src="/static/instance_theme.js?v=36"></script>
|
||||
<script src="/static/instance_theme.js?v=46"></script>
|
||||
<link rel="stylesheet" href="/static/instance_theme_early.css?v=4">
|
||||
<link rel="stylesheet" href="/static/account_risk_badge.css?v=4">
|
||||
<script src="/static/account_risk_badge.js?v=4"></script>
|
||||
@@ -243,8 +243,8 @@
|
||||
.stats-period-block h3{font-size:1rem;color:#dbe4ff;margin-bottom:4px}
|
||||
.stats-period-block .sub{font-size:.78rem;color:#8892b0;margin-bottom:10px;line-height:1.4}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=38">
|
||||
<link rel="stylesheet" href="/static/trade_stats_calendar.css?v=3">
|
||||
<link rel="stylesheet" href="/static/instance_theme.css?v=48">
|
||||
<link rel="stylesheet" href="/static/trade_stats_calendar.css?v=4">
|
||||
|
||||
</head>
|
||||
<body
|
||||
@@ -803,6 +803,9 @@
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{% if stats_bundle.initial_calendar %}
|
||||
<script type="application/json" id="stats-calendar-bootstrap">{{ stats_bundle.initial_calendar | tojson }}</script>
|
||||
{% endif %}
|
||||
<div id="stats-calendar-wrap" class="trade-cal-wrap stats-calendar-wrap">
|
||||
<div class="trade-cal-head">
|
||||
<button type="button" id="stats-cal-prev" class="btn" title="上一月">‹</button>
|
||||
@@ -840,14 +843,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/instance_ui.js?v=3"></script>
|
||||
<script src="/static/instance_ui.js?v=4"></script>
|
||||
<script src="/static/instance_records_mobile.js?v=2"></script>
|
||||
<script src="/static/time_close_ui.js?v=2"></script>
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/trade_stats_calendar.js?v=3"></script>
|
||||
<script src="/static/trade_stats_calendar.js?v=4"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
Reference in New Issue
Block a user