Dmitry Beresnev commited on
Commit
cfe2c87
Β·
1 Parent(s): 253cc2c

fix economic calendar

Browse files
Files changed (2) hide show
  1. app/components/news.py +20 -41
  2. app/pages/05_Dashboard.py +8 -16
app/components/news.py CHANGED
@@ -667,24 +667,12 @@ def display_economic_calendar_widget(events_df: pd.DataFrame):
667
  st.info("πŸ“… No upcoming economic events in the next 7 days")
668
  return
669
 
670
- # Widget container
671
- widget_html = """
672
- <div style="
673
- background: linear-gradient(135deg, #1E222D 0%, #131722 100%);
674
- border: 1px solid #2A2E39;
675
- border-radius: 12px;
676
- padding: 20px;
677
- margin-bottom: 20px;
678
- ">
679
- <div style="margin-bottom: 16px;">
680
- <h3 style="color: #D1D4DC; font-size: 18px; font-weight: 600; margin: 0;">
681
- πŸ“… Economic Calendar
682
- </h3>
683
- <p style="color: #787B86; font-size: 13px; margin: 4px 0 0 0;">
684
- Upcoming high-impact events
685
- </p>
686
- </div>
687
- """
688
 
689
  # Show top 10 events
690
  for idx, event in events_df.head(10).iterrows():
@@ -711,29 +699,20 @@ def display_economic_calendar_widget(events_df: pd.DataFrame):
711
  # Format forecast
712
  forecast_display = f"{forecast:.1f}" if forecast is not None else "N/A"
713
 
714
- event_html = f"""
715
- <div style="
716
- background: #0D0E13;
717
- border-left: 3px solid {'#F23645' if importance == 'high' else '#FF9800' if importance == 'medium' else '#787B86'};
718
- border-radius: 6px;
719
- padding: 12px;
720
- margin-bottom: 10px;
721
- ">
722
- <div style="display: flex; justify-content: space-between; align-items: center;">
723
- <div style="flex: 1;">
724
- <div style="color: #D1D4DC; font-size: 13px; font-weight: 500; margin-bottom: 4px;">
725
- {flag} {event_name}
726
- </div>
727
- <div style="color: #787B86; font-size: 11px;">
728
- {stars} Forecast: {forecast_display}
729
- </div>
730
- </div>
731
- <div style="color: #3861FB; font-size: 12px; font-weight: 600; white-space: nowrap; margin-left: 12px;">
732
- {time_to_event}
733
- </div>
734
- </div>
735
- </div>
736
- """
737
 
738
  widget_html += event_html
739
 
 
667
  st.info("πŸ“… No upcoming economic events in the next 7 days")
668
  return
669
 
670
+ # Build widget HTML with single-line styles (no leading whitespace)
671
+ widget_html = """<div style="background: linear-gradient(135deg, #1E222D 0%, #131722 100%); border: 1px solid #2A2E39; border-radius: 12px; padding: 20px; margin-bottom: 20px;">
672
+ <div style="margin-bottom: 16px;">
673
+ <h3 style="color: #D1D4DC; font-size: 18px; font-weight: 600; margin: 0;">πŸ“… Economic Calendar</h3>
674
+ <p style="color: #787B86; font-size: 13px; margin: 4px 0 0 0;">Upcoming high-impact events</p>
675
+ </div>"""
 
 
 
 
 
 
 
 
 
 
 
 
676
 
677
  # Show top 10 events
678
  for idx, event in events_df.head(10).iterrows():
 
699
  # Format forecast
700
  forecast_display = f"{forecast:.1f}" if forecast is not None else "N/A"
701
 
702
+ # Importance color
703
+ importance_color = '#F23645' if importance == 'high' else '#FF9800' if importance == 'medium' else '#787B86'
704
+
705
+ # Build event HTML (no leading whitespace, single-line styles)
706
+ event_html = f"""<div style="background: #0D0E13; border-left: 3px solid {importance_color}; border-radius: 6px; padding: 12px; margin-bottom: 10px;">
707
+ <div style="display: flex; justify-content: space-between; align-items: center;">
708
+ <div style="flex: 1;">
709
+ <div style="color: #D1D4DC; font-size: 13px; font-weight: 500; margin-bottom: 4px;">{flag} {event_name}</div>
710
+ <div style="color: #787B86; font-size: 11px;">{stars} Forecast: {forecast_display}</div>
711
+ </div>
712
+ <div style="color: #3861FB; font-size: 12px; font-weight: 600; white-space: nowrap; margin-left: 12px;">{time_to_event}</div>
713
+ </div>
714
+ </div>
715
+ """
 
 
 
 
 
 
 
 
 
716
 
717
  widget_html += event_html
718
 
app/pages/05_Dashboard.py CHANGED
@@ -525,22 +525,14 @@ with st.spinner("Loading news from 8 sources..."):
525
  # Clear the status message after all sources complete
526
  status_placeholder.success(f"βœ… Loaded {len(completed_sources)}/8 sources successfully")
527
 
528
- # Debug output - temporarily enabled to diagnose new sources
529
- if True: # st.session_state.get('debug_mode', False):
530
- st.write("### Debug: News Fetch Results")
531
- st.write(f"- Twitter: {len(twitter_df)} items")
532
- st.write(f"- Reddit: {len(reddit_df)} items")
533
- st.write(f"- RSS: {len(rss_all_df)} items")
534
- st.write(f"- AI/Tech: {len(ai_tech_df)} items")
535
- st.write(f"- Predictions: {len(predictions_df)} items")
536
- st.write(f"- Sectoral News: {len(sectoral_news_df)} items")
537
- st.write(f"- Market Events: {len(market_events_df)} items")
538
- st.write(f"- Economic Calendar: {len(economic_calendar_df)} items")
539
- st.write(f"- Availability: Predictions={PREDICTIONS_AVAILABLE}, Sectoral={SECTORAL_AVAILABLE}, Events={EVENTS_AVAILABLE}, Calendar={CALENDAR_AVAILABLE}")
540
- if fetch_errors:
541
- st.write(f"- Errors: {len(fetch_errors)}")
542
- for err in fetch_errors:
543
- st.write(f" - {err}")
544
 
545
  # Clear force refresh flag after fetching is complete
546
  if force_refresh:
 
525
  # Clear the status message after all sources complete
526
  status_placeholder.success(f"βœ… Loaded {len(completed_sources)}/8 sources successfully")
527
 
528
+ # Debug logging (console only, not displayed on page)
529
+ import logging
530
+ logger = logging.getLogger(__name__)
531
+ logger.info(f"News Fetch Results: Twitter={len(twitter_df)}, Reddit={len(reddit_df)}, RSS={len(rss_all_df)}, AI/Tech={len(ai_tech_df)}, Predictions={len(predictions_df)}, Sectoral={len(sectoral_news_df)}, Events={len(market_events_df)}, Calendar={len(economic_calendar_df)}")
532
+ logger.info(f"Availability: Predictions={PREDICTIONS_AVAILABLE}, Sectoral={SECTORAL_AVAILABLE}, Events={EVENTS_AVAILABLE}, Calendar={CALENDAR_AVAILABLE}")
533
+ if fetch_errors:
534
+ for err in fetch_errors:
535
+ logger.warning(f"Fetch error: {err}")
 
 
 
 
 
 
 
 
536
 
537
  # Clear force refresh flag after fetching is complete
538
  if force_refresh: