fix: Handle None values for numeric trade fields in trading journal

This commit is contained in:
Bobby (aider) 2025-02-13 07:58:35 -08:00
parent 7764821ec9
commit 3a962fb685

View File

@ -223,12 +223,12 @@ def trading_journal_page():
col1, col2 = st.columns(2)
with col1:
new_shares = st.number_input("Shares", value=trade['shares'])
new_entry = st.number_input("Entry Price", value=float(trade['entry_price']))
new_target = st.number_input("Target Price", value=float(trade['target_price']))
new_shares = st.number_input("Shares", value=trade['shares'] if trade['shares'] is not None else 0)
new_entry = st.number_input("Entry Price", value=float(trade['entry_price']) if trade['entry_price'] is not None else 0.0)
new_target = st.number_input("Target Price", value=float(trade['target_price']) if trade['target_price'] is not None else 0.0)
with col2:
new_stop = st.number_input("Stop Loss", value=float(trade['stop_loss']))
new_stop = st.number_input("Stop Loss", value=float(trade['stop_loss']) if trade['stop_loss'] is not None else 0.0)
new_strategy = st.text_input("Strategy", value=trade['strategy'])
new_order_type = st.selectbox("Order Type", ["Market", "Limit"],
index=0 if trade['order_type'] == "Market" else 1,