From 0c302136885cee930c736cc9d3818ca185437d5a Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Thu, 13 Feb 2025 08:50:05 -0800 Subject: [PATCH] fix: Handle entry_price formatting with error handling --- src/pages/journal/trading_journal_page.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/journal/trading_journal_page.py b/src/pages/journal/trading_journal_page.py index b936ebf..409e2e9 100644 --- a/src/pages/journal/trading_journal_page.py +++ b/src/pages/journal/trading_journal_page.py @@ -316,10 +316,15 @@ def trading_journal_page(): col1, col2 = st.columns(2) with col1: - if trade['direction'] == 'sell': - st.metric("Exit Price", f"${trade['entry_price']:.2f}") - else: - st.metric("Entry Price", f"${trade['entry_price']:.2f}") + try: + entry_price = float(trade['entry_price']) + if trade['direction'] == 'sell': + st.metric("Exit Price", f"${entry_price:.2f}") + else: + st.metric("Entry Price", f"${entry_price:.2f}") + except (ValueError, TypeError): + price_label = "Exit Price" if trade['direction'] == 'sell' else "Entry Price" + st.metric(price_label, "N/A") st.metric("Shares", trade['shares']) direction = trade.get('direction', 'buy') st.metric("Type", direction.capitalize())