fix: Handle potential type conversion errors for exit price in trading journal

This commit is contained in:
Bobby (aider) 2025-02-13 08:45:50 -08:00
parent 287dd32485
commit b8a561f37c

View File

@ -334,8 +334,13 @@ def trading_journal_page():
if trade.get('stop_loss'):
st.metric("Stop Loss", f"${trade['stop_loss']:.2f}")
if trade.get('exit_price'):
st.metric("Exit Price", f"${trade['exit_price']:.2f}")
st.metric("Exit Date", format_datetime(trade['exit_date']))
try:
exit_price = float(trade['exit_price'])
st.metric("Exit Price", f"${exit_price:.2f}")
st.metric("Exit Date", format_datetime(trade['exit_date']))
except (ValueError, TypeError):
st.metric("Exit Price", "N/A")
st.metric("Exit Date", format_datetime(trade['exit_date']))
if trade.get('strategy'):
st.text(f"Strategy: {trade['strategy']}")