refactor(dashboard): optimize signal processing with groupby

Instead of repeatedly filtering the DataFrame for each symbol in a loop,
sort the DataFrame by timestamp once and use groupby(COL_SYMBOL) to
iterate over the groups. This reduces the time complexity and significantly
speeds up the signal processing loop.

Co-authored-by: maghdam <63883156+maghdam@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot]
2026-03-11 18:30:55 +00:00
parent 29fcbf0f9d
commit bf6c4846c4
+2 -6
View File
@@ -60,12 +60,8 @@ def display_recent_signals(df: pd.DataFrame):
# Optional: Show a quick mini-forecast chart per symbol
st.write("---")
st.subheader("Mini Signal Forecasts (per symbol)")
for symbol in sorted(df[COL_SYMBOL].unique()):
mini_df = (
df[df[COL_SYMBOL] == symbol]
.sort_values(COL_TIMESTAMP)
.tail(N_FORWARD)
)
for symbol, group in df.sort_values(COL_TIMESTAMP).groupby(COL_SYMBOL):
mini_df = group.tail(N_FORWARD)
# Only show if there is more than one unique value
if mini_df[COL_PREDICTION].nunique() > 1:
st.write(f"**{symbol}**")