feat: expand header stats with total funds and profit-loss ratio

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 02:14:18 +08:00
parent 659c0969fe
commit 814fe67a21
10 changed files with 138 additions and 10 deletions
+10
View File
@@ -6471,6 +6471,8 @@ def render_main_page(page="trade", embed_mode=None):
from lib.instance.instance_embed_context_lib import (
embed_render_plan,
minimal_stats_bundle,
profit_loss_ratio_from_trades,
total_funds_usdt,
trade_records_summary,
)
@@ -6530,14 +6532,17 @@ def render_main_page(page="trade", embed_mode=None):
total = len(records)
win = count_winning_trades(records)
rate = round(win / total * 100, 2) if total else 0
profit_loss_ratio = profit_loss_ratio_from_trades(records)
elif plan.records_summary:
summary = trade_records_summary(conn, start_bj, end_bj, tr_ts)
records = summary["records"]
total = summary["total"]
rate = summary["rate"]
profit_loss_ratio = summary.get("profit_loss_ratio")
else:
records = []
total = rate = 0
profit_loss_ratio = None
active_count = len(order_list)
from lib.strategy.strategy_trade_labels import count_position_limit_active_monitors
@@ -6594,6 +6599,8 @@ def render_main_page(page="trade", embed_mode=None):
record=records,
total=total,
rate=rate,
profit_loss_ratio=profit_loss_ratio,
total_funds=total_funds_usdt(funding_usdt, current_capital),
trading_day=trading_day,
daily_start_capital=DAILY_START_CAPITAL,
current_capital=current_capital,
@@ -6764,6 +6771,8 @@ def api_account_snapshot():
extra_blocks=not risk_status.get("can_trade", True),
)
available_trading_usdt = get_available_trading_usdt()
from lib.instance.instance_embed_context_lib import total_funds_usdt
unrealized_pnl = None
if exchange_private_api_configured():
from lib.instance.instance_live_pnl_lib import resolve_instance_unrealized_pnl
@@ -6783,6 +6792,7 @@ def api_account_snapshot():
return jsonify({
"funding_usdt": funding_usdt,
"current_capital": current_capital,
"total_funds": total_funds_usdt(funding_usdt, current_capital),
"available_trading_usdt": round(available_trading_usdt, FUNDS_DECIMALS) if available_trading_usdt is not None else None,
"unrealized_pnl": unrealized_pnl,
"recommended_capital": recommended_capital,