diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index 522a599..35bda09 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -21,9 +21,10 @@ def calculate_position_performance(trades): shares = float(trade['shares']) price = float(trade['entry_price']) - # Check if this is a buy or sell based on order type and direction + # Check order_type to determine if it's a buy or sell + # since direction field is corrupted with datetime is_buy = True - if isinstance(trade.get('direction'), str) and trade['direction'].lower() == 'sell': + if trade.get('order_type', '').lower() == 'sell': is_buy = False if is_buy: @@ -401,10 +402,7 @@ def trading_journal_page(): # Show buy trades st.subheader("Buy Orders") for trade in trades: - # Convert direction to lowercase and strip whitespace - direction = str(trade.get('direction', '')).lower().strip() - - if isinstance(trade.get('direction'), str) and trade['direction'].lower() == 'buy': + if trade.get('order_type', '').lower() != 'sell': # If not sell, assume buy col1, col2, col3 = st.columns(3) with col1: st.text(f"Date: {format_datetime(trade['entry_date'])}") @@ -424,10 +422,7 @@ def trading_journal_page(): # Show sell trades st.subheader("Sell Orders") for trade in trades: - # Convert direction to lowercase and strip whitespace - direction = str(trade.get('direction', '')).lower().strip() - - if isinstance(trade.get('direction'), str) and trade['direction'].lower() == 'sell': + if trade.get('order_type', '').lower() == 'sell': col1, col2 = st.columns(2) with col1: st.text(f"Date: {format_datetime(trade['entry_date'])}")