From 0b07861265a919ab0f535ccb00df04df025082c6 Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Thu, 13 Feb 2025 08:40:44 -0800 Subject: [PATCH] fix: Convert trade prices and shares to float to prevent type errors --- src/pages/journal/trading_journal_page.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index 74e98e8..e16280e 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -27,7 +27,12 @@ def plot_trade_history(trades): for trade in trades: if trade['exit_price']: - trade_pnl = (trade['exit_price'] - trade['entry_price']) * trade['shares'] + # Convert prices to float if they're strings + exit_price = float(trade['exit_price']) + entry_price = float(trade['entry_price']) + shares = float(trade['shares']) + + trade_pnl = (exit_price - entry_price) * shares cumulative_pnl += trade_pnl dates.append(trade['exit_date']) pnl.append(cumulative_pnl)