fix: Handle entry_price formatting with error handling

This commit is contained in:
Bobby (aider) 2025-02-13 08:50:05 -08:00
parent 9ef81fb589
commit 0c30213688

View File

@ -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())