umer6016 commited on
Commit
a4a7fe2
Β·
verified Β·
1 Parent(s): e56617b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. streamlit_app.py +6 -61
streamlit_app.py CHANGED
@@ -143,54 +143,9 @@ if st.sidebar.button("πŸ”„ Refresh Data"):
143
  st.cache_data.clear() # Clear cache to force update
144
  st.rerun()
145
 
146
- # --- Debugging Status (Sidebar) ---
147
- st.sidebar.markdown("---")
148
- st.sidebar.subheader("πŸ› οΈ System Status")
149
 
150
- # Check Webhook
151
- if WEBHOOK_URL:
152
- st.sidebar.success(f"Discord Webhook: Configured (Ends in ...{WEBHOOK_URL[-4:]})")
153
- else:
154
- st.sidebar.error("Discord Webhook: Missing ❌")
155
 
156
- # Check Alpha Vantage
157
- if ALPHA_VANTAGE_KEY:
158
- st.sidebar.success("Alpha Vantage: Configured βœ…")
159
- else:
160
- st.sidebar.warning("Alpha Vantage: Missing ⚠️ (Using Mock Data)")
161
 
162
- # --- Network Diagnostics ---
163
- with st.sidebar.expander("πŸ“‘ Network Diagnostics", expanded=False):
164
- if st.button("Run Connectivity Test"):
165
- import socket
166
-
167
- # Test 1: Google DNS (General Internet)
168
- try:
169
- ip = socket.gethostbyname("google.com")
170
- st.success(f"Google DNS: OK ({ip})")
171
- except Exception as e:
172
- st.error(f"Google DNS Failed: {e}")
173
-
174
- # Test 2: Discord DNS
175
- try:
176
- ip = socket.gethostbyname("discord.com")
177
- st.success(f"Discord DNS: OK ({ip})")
178
- except Exception as e:
179
- st.error(f"Discord DNS Failed: {e}")
180
-
181
- # Test 3: HTTP Request (Requests Lib)
182
- try:
183
- r = requests.get("https://discord.com", timeout=5)
184
- st.success(f"HTTP GET discord.com: OK ({r.status_code})")
185
- except Exception as e:
186
- st.error(f"HTTP GET Failed: {e}")
187
-
188
- # Check Proxies
189
- proxies = {k: v for k, v in os.environ.items() if 'proxy' in k.lower()}
190
- if proxies:
191
- st.warning(f"Proxies detected: {proxies}")
192
- else:
193
- st.info("No Proxy Vars detected.")
194
 
195
  # --- Main Logic ---
196
 
@@ -234,31 +189,21 @@ if models:
234
  with col_pred2:
235
  st.success(f"**Target Price (Next Close):** ${pred_price:.2f}")
236
 
237
- # --- Sidebar Notification Test ---
238
  st.sidebar.markdown("---")
239
- st.sidebar.subheader("πŸ”” Notification Test")
240
- if st.sidebar.button("Send Test Notification"):
241
  # Use current data if available, else defaults
242
  current_price = data.get('price', 0.0)
243
  current_change = data.get('change', 0.0)
244
- # If models failed, we won't have 'direction', so we use a placeholder for the test
245
- test_direction = direction if 'direction' in locals() else "TEST_SIGNAL 🟑"
246
 
247
  success, status_msg = send_discord_notification(symbol, current_price, current_change, test_direction)
248
  if success:
249
- st.sidebar.success(f"Sent! {status_msg}")
250
  else:
251
  st.sidebar.error(f"Failed: {status_msg}")
252
 
253
- # Auto-send (optional - leaving disabled for now to prevent spam loop on refresh, user can click button)
254
- # if not data['is_mock']:
255
- # send_discord_notification(symbol, data['price'], data['change'], direction)
256
-
257
  # 4. Footer
258
  st.markdown("---")
259
- # Simplified View
260
- st.caption("Simplified Mode | Model: Ensemble (SVM + RF + Linear)")
261
-
262
- # Footer
263
- st.markdown("---")
264
- st.caption("Deployed via Hugging Face Spaces | Model: Ensemble (SVM + RF + Linear)")
 
143
  st.cache_data.clear() # Clear cache to force update
144
  st.rerun()
145
 
 
 
 
146
 
 
 
 
 
 
147
 
 
 
 
 
 
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
 
150
  # --- Main Logic ---
151
 
 
189
  with col_pred2:
190
  st.success(f"**Target Price (Next Close):** ${pred_price:.2f}")
191
 
192
+ # --- Sidebar Notification ---
193
  st.sidebar.markdown("---")
194
+ if st.sidebar.button("πŸ”” Send Discord Update"):
 
195
  # Use current data if available, else defaults
196
  current_price = data.get('price', 0.0)
197
  current_change = data.get('change', 0.0)
198
+ # If models failed, we won't have 'direction', so we use a placeholder checks
199
+ test_direction = direction if 'direction' in locals() else "N/A"
200
 
201
  success, status_msg = send_discord_notification(symbol, current_price, current_change, test_direction)
202
  if success:
203
+ st.sidebar.success("Sent!")
204
  else:
205
  st.sidebar.error(f"Failed: {status_msg}")
206
 
 
 
 
 
207
  # 4. Footer
208
  st.markdown("---")
209
+ st.caption("AI Stock Prediction System | Deployed on Hugging Face Spaces")