Refactor: Remove overall P/L metrics from portfolio overview

This commit is contained in:
Bobby (aider) 2025-02-19 20:43:59 -08:00
parent 6b13abe8ea
commit 744d717938

View File

@ -237,7 +237,7 @@ def trading_journal_page():
# Portfolio overview section
st.subheader("Portfolio Overview")
col1, col2, col3 = st.columns(3)
col1, col2 = st.columns(2)
# Get cash balance
latest_portfolio = get_latest_portfolio_value()
@ -286,35 +286,6 @@ def trading_journal_page():
st.metric("Week P/L",
f"${weekly_metrics['weekly_pl']:,.2f}",
f"{weekly_pl_pct:.2f}% | {weekly_metrics['weekly_trade_count']} trades")
with col3:
# Calculate realized P/L from closed trades
realized_pl = 0
if trade_history:
for trade in trade_history:
if trade.get('exit_price'): # Only count closed trades
entry_price = float(trade['entry_price'])
exit_price = float(trade['exit_price'])
shares = float(trade['shares'])
realized_pl += (exit_price - entry_price) * shares
# Calculate paper P/L from open positions
paper_pl = 0
if open_summary:
for summary in open_summary:
ticker = summary['ticker']
current_price = current_prices.get(ticker, 0)
shares = summary['total_shares']
avg_entry = summary['avg_entry_price']
paper_pl += (current_price - avg_entry) * shares
# Calculate overall P/L
overall_pl = realized_pl + paper_pl
overall_pl_pct = (overall_pl / total_portfolio_value * 100) if total_portfolio_value > 0 else 0
st.metric("Overall P/L",
f"${overall_pl:,.2f}",
f"{overall_pl_pct:.2f}% (R: ${realized_pl:,.2f} | U: ${paper_pl:,.2f})")
total_paper_pl = 0
invested_value = 0