Files
dekun a1abe159fa Initial standalone crypto_okx with one-click deploy.
Add deploy/manage.sh bootstrap for git.bz121.com/dekun/crypto_okx and point docs at this repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 20:00:59 +08:00

153 lines
8.2 KiB
HTML

{# Hub iframe tab fragment — shared via embed_templates #}
{% macro period_stats_pane(period_key, s) %}
{% set win_pct = s.win_rate_pct if s.win_rate_pct is not none else 0 %}
{% set profit_sum = (s.net_pnl_u + s.loss_sum_u) if s.closed_count else 0 %}
{% set loss_sum = s.loss_sum_u %}
{% set pnl_total = profit_sum + loss_sum %}
{% set profit_bar_w = (profit_sum / pnl_total * 100) if pnl_total > 0 else 0 %}
{% set loss_bar_w = (loss_sum / pnl_total * 100) if pnl_total > 0 else 0 %}
{% set net_cls = 'pos-pnl-profit' if s.net_pnl_u > 0 else ('pos-pnl-loss' if s.net_pnl_u < 0 else '') %}
<div class="stats-period-pane" data-stats-period="{{ period_key }}" role="tabpanel"{% if period_key != 'day' %} hidden{% endif %}>
<div class="stats-period-range">{{ s.range_label }}</div>
<div class="inst-stats-viz">
{% if s.closed_count %}
<div class="inst-stats-kpis">
<div class="inst-stats-kpi inst-stats-kpi--pnl">
<span class="inst-stats-kpi-val {{ net_cls }}">{% if s.net_pnl_u > 0 %}+{% endif %}{{ funds_fmt(s.net_pnl_u) }}U</span>
<span class="inst-stats-kpi-lbl">净盈亏</span>
</div>
<div class="inst-stats-kpi inst-stats-kpi--win">
<div class="inst-stats-ring" style="--win-pct: {{ win_pct }}">
<span class="inst-stats-ring-label">{% if s.win_rate_pct is not none %}{{ win_pct|round(0)|int }}%{% else %}—{% endif %}</span>
</div>
<span class="inst-stats-kpi-lbl">{{ s.win_count }}胜 {{ s.loss_count }}负</span>
</div>
<div class="inst-stats-kpi inst-stats-kpi--trades">
<span class="inst-stats-kpi-val">{{ s.opens_count }} / {{ s.closed_count }}</span>
<span class="inst-stats-kpi-lbl">开单 / 平仓</span>
</div>
</div>
<div class="inst-stats-block">
<div class="inst-stats-block-title">盈亏构成</div>
<div class="inst-stats-stacked-bar">
<div class="inst-stats-stacked-fill inst-stats-stacked-fill--profit" style="width: {{ '%.1f'|format(profit_bar_w) }}%"></div>
<div class="inst-stats-stacked-fill inst-stats-stacked-fill--loss" style="width: {{ '%.1f'|format(loss_bar_w) }}%"></div>
</div>
<div class="inst-stats-bar-labels">
<span class="pos-pnl-profit">盈利 {{ funds_fmt(profit_sum) }}U</span>
<span class="pos-pnl-loss">亏损 {{ funds_fmt(loss_sum) }}U</span>
</div>
</div>
<div class="inst-stats-block inst-stats-block--risk">
<div class="inst-stats-risk-grid">
<div class="inst-stats-risk-item">
<span class="k">最大回撤</span>
<span class="v pos-pnl-loss">{{ funds_fmt(s.max_drawdown_u) }}U</span>
</div>
<div class="inst-stats-risk-item">
<span class="k">连续亏损</span>
<span class="v">{{ s.consecutive_losses }} 笔</span>
</div>
<div class="inst-stats-risk-item">
<span class="k">最长连亏日</span>
<span class="v">{{ s.max_loss_streak_days }} 天</span>
</div>
<div class="inst-stats-risk-item">
<span class="k">最大亏损日</span>
<span class="v">{% if s.worst_day %}{{ s.worst_day }} ({{ funds_fmt(s.worst_day_pnl) }}U){% else %}—{% endif %}</span>
</div>
</div>
</div>
{% else %}
<p class="inst-stats-empty">当前区间暂无平仓数据</p>
{% endif %}
</div>
<details class="inst-stats-details" open>
<summary>详细指标</summary>
<div class="stats-detail">
<div class="stat-item"><div class="label">开单次数</div><div class="value">{{ s.opens_count }}</div></div>
<div class="stat-item"><div class="label">平仓笔数</div><div class="value">{{ s.closed_count }}</div></div>
<div class="stat-item"><div class="label">胜率</div><div class="value">{% if s.win_rate_pct is not none %}{{ s.win_rate_pct }}%{% else %}-{% endif %}</div></div>
<div class="stat-item"><div class="label">净盈亏(U)</div><div class="value">{{ funds_fmt(s.net_pnl_u) }}</div></div>
<div class="stat-item"><div class="label">亏损额合计(U)</div><div class="value">{{ funds_fmt(s.loss_sum_u) }}</div></div>
<div class="stat-item"><div class="label">单笔最大亏损(U)</div><div class="value">{% if s.max_single_loss is not none %}{{ funds_fmt(s.max_single_loss) }}{% else %}-{% endif %}</div></div>
<div class="stat-item"><div class="label">单笔最大盈利(U)</div><div class="value">{% if s.max_single_profit is not none %}{{ funds_fmt(s.max_single_profit) }}{% else %}-{% endif %}</div></div>
<div class="stat-item"><div class="label">最大回撤(U)</div><div class="value">{{ funds_fmt(s.max_drawdown_u) }}</div></div>
<div class="stat-item"><div class="label">当前连续亏损笔数</div><div class="value">{{ s.consecutive_losses }}</div></div>
<div class="stat-item"><div class="label">最长连续亏损(交易日)</div><div class="value">{{ s.max_loss_streak_days }} 天</div></div>
<div class="stat-item"><div class="label">期内最大亏损日</div><div class="value">{% if s.worst_day %}{{ s.worst_day }}({{ funds_fmt(s.worst_day_pnl) }}U){% else %}-{% endif %}</div></div>
</div>
</details>
{% if period_key == 'all' %}
<div class="inst-stats-block inst-stats-monthly" style="margin-top:14px">
<div class="inst-stats-block-title">按月统计</div>
{% if s.monthly_rows %}
<div class="inst-stats-month-table-wrap">
<table class="inst-stats-month-table">
<thead>
<tr>
<th>月份</th>
<th>开单</th>
<th>平仓</th>
<th>胜率</th>
<th>净盈亏</th>
<th>最大回撤</th>
</tr>
</thead>
<tbody>
{% for m in s.monthly_rows %}
{% set m_net_cls = 'pos-pnl-profit' if m.net_pnl_u > 0 else ('pos-pnl-loss' if m.net_pnl_u < 0 else '') %}
<tr>
<td>{{ m.month_key }}</td>
<td>{{ m.opens_count }}</td>
<td>{{ m.closed_count }}</td>
<td>{% if m.win_rate_pct is not none %}{{ m.win_rate_pct }}%{% else %}—{% endif %}</td>
<td class="{{ m_net_cls }}">{% if m.net_pnl_u > 0 %}+{% endif %}{{ funds_fmt(m.net_pnl_u) }}</td>
<td class="pos-pnl-loss">{{ funds_fmt(m.max_drawdown_u) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="inst-stats-empty" style="margin-top:0">暂无按月平仓数据</p>
{% endif %}
</div>
{% endif %}
</div>
{% endmacro %}
<div class="grid">
{% if page == 'dashboard' %}
{% include 'dashboard_panel.html' %}
{% elif page == 'account_ledger' %}
{% include 'account_ledger_panel.html' %}
{% elif page == 'key_monitor' %}
{% include 'key_monitor_panel.html' %}
{% elif page == 'options' %}
{% include 'options_panel.html' %}
{% elif page == 'options_review' %}
{% include 'options_review_panel.html' %}
{% elif page == 'hedge_plan' %}
{% include 'hedge_plan_panel.html' %}
{% endif %}
{% if page == 'env_config' %}
{% include 'env_config_panel.html' %}
{% endif %}
{% if page == 'risk_policy' %}
{% include 'risk_policy_panel.html' %}
{% endif %}
{% if page == 'system_guide' %}
{% include 'system_guide_panel.html' %}
{% endif %}
{% if page == 'settings' %}
{% include 'settings_panel.html' %}
{% endif %}