From f4b6c2f07eb957b8d749c728bbf3566fb56700be Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Mon, 17 Feb 2025 16:57:20 -0800 Subject: [PATCH] fix: Improve prefill data handling in trading system page input fields --- src/pages/trading/trading_system_page.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pages/trading/trading_system_page.py b/src/pages/trading/trading_system_page.py index c11d524..3a67dee 100644 --- a/src/pages/trading/trading_system_page.py +++ b/src/pages/trading/trading_system_page.py @@ -241,26 +241,33 @@ def trading_system_page(): # Use prefilled data if available prefill = st.session_state.prefill_watchlist or {} + # Debug output to verify prefill data + if prefill: + st.write("Debug - Prefill data:", prefill) + col1, col2 = st.columns(2) with col1: - ticker = st.text_input("Ticker", value=prefill.get('ticker', '')) + ticker = st.text_input("Ticker", value=str(prefill.get('ticker', ''))) entry_price = st.number_input("Entry Price", - value=float(prefill.get('entry_price', 0.0)), + value=prefill.get('entry_price', 0.0), min_value=0.0, - step=0.01) + step=0.01, + format="%.2f") shares = st.number_input("Shares", - value=int(prefill.get('shares', 0)), + value=prefill.get('shares', 0), min_value=0, step=1) with col2: target_price = st.number_input("Target Price", - value=float(prefill.get('target_price', 0.0)), + value=prefill.get('target_price', 0.0), min_value=0.0, - step=0.01) + step=0.01, + format="%.2f") stop_loss = st.number_input("Stop Loss", - value=float(prefill.get('stop_loss', 0.0)), + value=prefill.get('stop_loss', 0.0), min_value=0.0, - step=0.01) + step=0.01, + format="%.2f") notes = st.text_area("Notes")