42Cummer commited on
Commit
5fbcdf7
·
verified ·
1 Parent(s): df8bacb

Upload monitor.py

Browse files
Files changed (1) hide show
  1. monitor.py +16 -7
monitor.py CHANGED
@@ -72,6 +72,9 @@ if 'dropping_streak' not in st.session_state:
72
  st.session_state.dropping_streak = 0
73
  if 'logs' not in st.session_state:
74
  st.session_state.logs = []
 
 
 
75
 
76
  # --- 3. VISUALIZATION HELPER ---
77
  def plot_quantum_cloud(real_window, futures):
@@ -139,7 +142,7 @@ def plot_quantum_cloud(real_window, futures):
139
  def main():
140
  # Header
141
  c1, c2 = st.columns([4, 1])
142
- with c1: st.title("⚛️ QUANTUM SENTINEL | VFV.TO")
143
  with c2:
144
  if st.button("Stop Engine"): st.stop()
145
 
@@ -147,9 +150,11 @@ def main():
147
 
148
  # Layout Containers (To hold live updates)
149
  status_area = st.empty()
150
- metrics_area = st.container()
151
  chart_area = st.empty()
152
  log_area = st.expander("Live Signal Log", expanded=True)
 
 
153
 
154
  # --- THE LIVE LOOP ---
155
  while True:
@@ -209,6 +214,11 @@ def main():
209
  # Current Eastern Time (handles EST/EDT automatically)
210
  est_now = datetime.now(ZoneInfo("America/New_York"))
211
  est_stamp = est_now.strftime("%Y-%m-%d %H:%M:%S %Z")
 
 
 
 
 
212
 
213
  # 1. Status Box
214
  status_area.markdown(f"""
@@ -219,8 +229,7 @@ def main():
219
  """, unsafe_allow_html=True)
220
 
221
  # 2. Metrics Grid
222
- with metrics_area:
223
- # We use st.empty() inside columns to overwrite numbers cleanly
224
  c1, c2, c3, c4 = st.columns(4)
225
  c1.metric("Quantum Trend", f"{trend:.4f}")
226
  c2.metric("Instant Signal", instant_signal)
@@ -236,9 +245,9 @@ def main():
236
  log_entry = f"[{ts}] {instant_signal:<8} | Trend: {trend:+.4f} | Score: {critic_score:.4f}"
237
  st.session_state.logs.insert(0, log_entry)
238
  if len(st.session_state.logs) > 8: st.session_state.logs.pop()
239
-
240
- with log_area:
241
- st.text("\n".join(st.session_state.logs))
242
 
243
  # Loop delay is handled by sync_market_clock(), but we add a tiny safety sleep
244
  time.sleep(1)
 
72
  st.session_state.dropping_streak = 0
73
  if 'logs' not in st.session_state:
74
  st.session_state.logs = []
75
+ if 'log_reset_at' not in st.session_state:
76
+ # Used to clear the log every hour (ET)
77
+ st.session_state.log_reset_at = datetime.now(ZoneInfo("America/New_York"))
78
 
79
  # --- 3. VISUALIZATION HELPER ---
80
  def plot_quantum_cloud(real_window, futures):
 
142
  def main():
143
  # Header
144
  c1, c2 = st.columns([4, 1])
145
+ with c1: st.title("Quantum Market Monitor for VFV.TO")
146
  with c2:
147
  if st.button("Stop Engine"): st.stop()
148
 
 
150
 
151
  # Layout Containers (To hold live updates)
152
  status_area = st.empty()
153
+ metrics_area = st.empty()
154
  chart_area = st.empty()
155
  log_area = st.expander("Live Signal Log", expanded=True)
156
+ with log_area:
157
+ log_text_area = st.empty()
158
 
159
  # --- THE LIVE LOOP ---
160
  while True:
 
214
  # Current Eastern Time (handles EST/EDT automatically)
215
  est_now = datetime.now(ZoneInfo("America/New_York"))
216
  est_stamp = est_now.strftime("%Y-%m-%d %H:%M:%S %Z")
217
+
218
+ # Clear log every hour to prevent unbounded growth
219
+ if (est_now - st.session_state.log_reset_at).total_seconds() >= 3600:
220
+ st.session_state.logs = []
221
+ st.session_state.log_reset_at = est_now
222
 
223
  # 1. Status Box
224
  status_area.markdown(f"""
 
229
  """, unsafe_allow_html=True)
230
 
231
  # 2. Metrics Grid
232
+ with metrics_area.container():
 
233
  c1, c2, c3, c4 = st.columns(4)
234
  c1.metric("Quantum Trend", f"{trend:.4f}")
235
  c2.metric("Instant Signal", instant_signal)
 
245
  log_entry = f"[{ts}] {instant_signal:<8} | Trend: {trend:+.4f} | Score: {critic_score:.4f}"
246
  st.session_state.logs.insert(0, log_entry)
247
  if len(st.session_state.logs) > 8: st.session_state.logs.pop()
248
+
249
+ # Replace log contents (don't stack)
250
+ log_text_area.text("\n".join(st.session_state.logs))
251
 
252
  # Loop delay is handled by sync_market_clock(), but we add a tiny safety sleep
253
  time.sleep(1)