diff --git a/src/pages/trading/trading_system_page.py b/src/pages/trading/trading_system_page.py index 3f51533..7e64ff5 100644 --- a/src/pages/trading/trading_system_page.py +++ b/src/pages/trading/trading_system_page.py @@ -1,5 +1,5 @@ import streamlit as st -from trading.journal import get_latest_portfolio_value, get_open_trades_summary, get_open_trades +from trading.journal import get_latest_portfolio_value, get_open_trades_summary from trading.position_calculator import PositionCalculator from utils.data_utils import get_current_prices @@ -12,22 +12,20 @@ def trading_system_page(): cash_balance = portfolio_data['cash_balance'] if portfolio_data else 0 # Calculate total portfolio value including open positions - open_trades = get_open_trades() + open_summary = get_open_trades_summary() # Change to use summary instead of raw trades total_position_value = 0 - if open_trades: + if open_summary: # Get current prices for all open positions - tickers = list(set(trade['ticker'] for trade in open_trades)) + tickers = list(set(summary['ticker'] for summary in open_summary)) current_prices = get_current_prices(tickers) # Calculate total value of open positions - position_values = {} - for trade in open_trades: - ticker = trade['ticker'] + for summary in open_summary: + ticker = summary['ticker'] current_price = current_prices.get(ticker, 0) - shares = trade['shares'] + shares = summary['total_shares'] position_value = current_price * shares - position_values[ticker] = position_values.get(ticker, 0) + position_value total_position_value += position_value total_portfolio_value = cash_balance + total_position_value