diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index e16280e..8e1c358 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -26,8 +26,12 @@ def plot_trade_history(trades): cumulative_pnl = 0 for trade in trades: - if trade['exit_price']: - # Convert prices to float if they're strings + # Skip trades without numeric exit prices + if not trade['exit_price'] or not isinstance(trade['exit_price'], (int, float)): + continue + + try: + # Convert prices to float if they're strings and are numeric exit_price = float(trade['exit_price']) entry_price = float(trade['entry_price']) shares = float(trade['shares']) @@ -36,6 +40,9 @@ def plot_trade_history(trades): cumulative_pnl += trade_pnl dates.append(trade['exit_date']) pnl.append(cumulative_pnl) + except (ValueError, TypeError): + # Skip trades where conversion to float fails + continue if not dates: return None