refactor: Simplify technical scanner results display with summary table and download option

This commit is contained in:
Bobby (aider) 2025-02-12 20:45:26 -08:00
parent 83159566e3
commit a24605e839

View File

@ -64,17 +64,19 @@ def technical_scanner_page():
)
if signals:
st.success(f"Found {len(signals)} signals")
for signal in signals:
with st.expander(f"{signal['ticker']} - ${signal['entry_price']:.2f}"):
col1, col2 = st.columns(2)
with col1:
st.metric("Entry Price", f"${signal['entry_price']:.2f}")
st.metric("Target", f"${signal['target_price']:.2f}")
st.metric("Stop Loss", f"${signal['stop_loss']:.2f}")
with col2:
st.metric("Shares", signal['shares'])
st.metric("Position Size", f"${signal['position_size']:.2f}")
st.metric("Risk Amount", f"${abs(signal['risk_amount']):.2f}")
# Create a summary table
summary_df = pd.DataFrame(signals)[['ticker', 'entry_price', 'target_price', 'stop_loss']]
summary_df = summary_df.round(2) # Round numeric columns to 2 decimal places
st.dataframe(summary_df)
# Add a download button for the full results
full_df = pd.DataFrame(signals)
st.download_button(
label="Download Full Results",
data=full_df.to_csv(index=False),
file_name="scanner_results.csv",
mime='text/csv'
)
else:
st.info("No signals found")
except Exception as e: