-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.py
More file actions
41 lines (33 loc) · 1.11 KB
/
dashboard.py
File metadata and controls
41 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pandas as pd
import streamlit as st
import os
# CSV log file path
CSV_FILE = "crossed_events.csv"
st.title("📈 Stock Cross Alert Log")
# Check if the CSV file exists
if os.path.exists(CSV_FILE):
df = pd.read_csv(CSV_FILE)
df = df.sort_values("Timestamp", ascending=False)
# Show full log
st.subheader("📋 Event Log")
st.dataframe(df)
# Filter dropdown
symbols = df["Symbol"].unique()
selected = st.multiselect("🔍 Filter by Symbol", symbols)
filtered_df = df[df["Symbol"].isin(selected)] if selected else df
# Show line chart
st.subheader("📊 Price Chart")
if not filtered_df.empty:
for symbol in filtered_df["Symbol"].unique():
chart_data = filtered_df[filtered_df["Symbol"] == symbol]
st.line_chart(
chart_data.set_index("Timestamp")["Price"],
height=200,
use_container_width=True,
)
else:
st.info("No data to display for selected symbol(s).")
if st.button("🔄 Refresh"):
st.experimental_rerun()
else:
st.warning("⚠️ No data logged yet.")