diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index 05ca611..0b46a4f 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -21,11 +21,12 @@ def calculate_position_performance(trades): shares = float(trade['shares']) price = float(trade['entry_price']) - # Check direction field directly - if trade.get('direction', '').lower() == 'buy': + direction = str(trade.get('direction', '')).lower() + + if direction == 'buy': total_bought += shares total_cost += shares * price - elif trade.get('direction', '').lower() == 'sell': + elif direction == 'sell': total_sold += shares total_proceeds += shares * price except (ValueError, TypeError) as e: