diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index 2859e5b..e87fcd6 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -283,12 +283,20 @@ def trading_journal_page(): f"{weekly_pl_pct:.2f}% | {weekly_metrics['weekly_trade_count']} trades") with col3: - # Overall P/L metrics (from trade history) - total_pl = sum(trade.get('position_pl', 0) for trade in trade_history) if trade_history else 0 - total_pl_pct = (total_pl / total_portfolio_value * 100) if total_portfolio_value > 0 else 0 + # Overall P/L metrics (combining realized P/L from history and current paper P/L) + realized_pl = 0 + if trade_history: + for position_id in set(trade['position_id'] for trade in trade_history): + position_trades = [t for t in trade_history if t['position_id'] == position_id] + performance = calculate_position_performance(position_trades) + realized_pl += performance['realized_pl'] + + overall_pl = realized_pl + total_paper_pl + overall_pl_pct = (overall_pl / total_portfolio_value * 100) if total_portfolio_value > 0 else 0 + st.metric("Overall P/L", - f"${total_pl:,.2f}", - f"{total_pl_pct:.2f}% since inception") + f"${overall_pl:,.2f}", + f"{overall_pl_pct:.2f}% since inception") total_paper_pl = 0 invested_value = 0