fix: Correct portfolio value calculation with current market prices
This commit is contained in:
parent
ab218a3065
commit
a1a91291f3
@ -247,14 +247,17 @@ def trading_journal_page():
|
|||||||
for summary in open_summary:
|
for summary in open_summary:
|
||||||
ticker = summary['ticker']
|
ticker = summary['ticker']
|
||||||
current_price = current_prices.get(ticker, 0)
|
current_price = current_prices.get(ticker, 0)
|
||||||
shares = summary['total_shares']
|
shares = float(summary['total_shares'])
|
||||||
avg_entry = summary['avg_entry_price']
|
avg_entry = float(summary['avg_entry_price'])
|
||||||
|
|
||||||
# Calculate current position value and P/L
|
# Calculate current position value using current market price
|
||||||
position_value = current_price * shares
|
position_value = current_price * shares
|
||||||
total_invested_value += position_value
|
total_invested_value += position_value
|
||||||
total_paper_pl += (current_price - avg_entry) * shares
|
total_paper_pl += (current_price - avg_entry) * shares
|
||||||
|
|
||||||
|
print(f"Debug - Total Invested: ${total_invested_value:.2f}") # Debug line
|
||||||
|
print(f"Debug - Cash Balance: ${cash_balance:.2f}") # Debug line
|
||||||
|
|
||||||
# Calculate total portfolio value (cash + invested value)
|
# Calculate total portfolio value (cash + invested value)
|
||||||
total_portfolio_value = cash_balance + total_invested_value
|
total_portfolio_value = cash_balance + total_invested_value
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user