Dmitry Beresnev
commited on
Commit
Β·
cfe2c87
1
Parent(s):
253cc2c
fix economic calendar
Browse files- app/components/news.py +20 -41
- 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 |
-
#
|
| 671 |
-
widget_html = """
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 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 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 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
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 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:
|