JayLacoma commited on
Commit
4b43805
·
verified ·
1 Parent(s): eaef0b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -11,7 +11,7 @@ import requests
11
  from typing import Dict, Optional
12
  import os
13
  import logging
14
- import tempfile # Added for download functionality
15
 
16
  # Configure logging
17
  logging.basicConfig(level=logging.INFO)
@@ -118,7 +118,7 @@ class MarketDataDownloader:
118
 
119
 
120
  # ============================================================================
121
- # FIRST-PRINCIPLES FEATURE ENGINEERING (13 CHAOS RATIOS)
122
  # ============================================================================
123
 
124
  class FirstPrinciplesFeatureEngine:
@@ -294,7 +294,7 @@ class EnhancedMacroAnalyzer:
294
  print(f"Error downloading market data: {e}")
295
 
296
  # ============================================================================
297
- # IMPROVED: Updated to Weekly, Quarterly, YTD timeframes
298
  # ============================================================================
299
  def get_live_data(self) -> Dict:
300
  """Get live data with improved timeframes: Weekly, Quarterly, YTD"""
@@ -501,7 +501,7 @@ class EnhancedMacroAnalyzer:
501
  return fig
502
 
503
  # ============================================================================
504
- # IMPROVED: Updated tables with Weekly, Quarterly, YTD
505
  # ============================================================================
506
  def create_live_performance_tables(self, live_data: Dict) -> tuple:
507
  """Create enhanced tables with weekly, quarterly, and YTD metrics"""
@@ -539,7 +539,7 @@ class EnhancedMacroAnalyzer:
539
  return tables
540
 
541
  # ============================================================================
542
- # IMPROVED: Updated chaos ratios with Weekly, Quarterly, YTD
543
  # ============================================================================
544
  def create_chaos_ratios_table(self) -> pd.DataFrame:
545
  """Create chaos ratios table with weekly, quarterly, and YTD changes"""
@@ -697,7 +697,7 @@ class EnhancedMacroAnalyzer:
697
  # Create subplots WITHOUT titles at top
698
  fig = make_subplots(
699
  rows=2, cols=2,
700
- subplot_titles=('', '', '', ''), # 👈 No titles at top
701
  vertical_spacing=0.1
702
  )
703
 
@@ -756,7 +756,7 @@ class EnhancedMacroAnalyzer:
756
  return fig
757
 
758
  # ============================================================================
759
- # IMPROVED: Updated markdown report with Weekly, Quarterly, YTD
760
  # ============================================================================
761
  def generate_markdown_report(self, live_data: Dict, macro_data: pd.DataFrame) -> str:
762
  """Generate a comprehensive markdown report from all data for LLM consumption"""
@@ -974,9 +974,9 @@ def analyze_all():
974
 
975
  return [empty_fig, empty_fig, empty_fig, empty_df, empty_df, empty_df, empty_df, empty_df, empty_df, empty_markdown]
976
 
977
- # FIXED: Download function that actually works
978
  def download_markdown(markdown_content):
979
- """Create a downloadable markdown file - FIXED VERSION"""
980
  if not markdown_content or "Error" in markdown_content:
981
  markdown_content = "# No Data Available\n\nPlease update the data first."
982
 
@@ -1026,7 +1026,6 @@ with gr.Blocks(title="Global Macro Dashboard", theme=gr.themes.Soft()) as demo:
1026
 
1027
  gr.Markdown("---")
1028
  gr.Markdown("## 🏭 US Sector Performance")
1029
- gr.Markdown("*Weekly momentum & Quarterly trends show clearer signals than daily data*")
1030
  sector_table = gr.DataFrame(label="Sector ETFs - Weekly, Quarterly, YTD")
1031
 
1032
  gr.Markdown("---")
 
11
  from typing import Dict, Optional
12
  import os
13
  import logging
14
+ import tempfile
15
 
16
  # Configure logging
17
  logging.basicConfig(level=logging.INFO)
 
118
 
119
 
120
  # ============================================================================
121
+ # FEATURE ENGINEERING RATIOS
122
  # ============================================================================
123
 
124
  class FirstPrinciplesFeatureEngine:
 
294
  print(f"Error downloading market data: {e}")
295
 
296
  # ============================================================================
297
+ # Timeframes
298
  # ============================================================================
299
  def get_live_data(self) -> Dict:
300
  """Get live data with improved timeframes: Weekly, Quarterly, YTD"""
 
501
  return fig
502
 
503
  # ============================================================================
504
+ # Tables with Weekly, Quarterly, YTD
505
  # ============================================================================
506
  def create_live_performance_tables(self, live_data: Dict) -> tuple:
507
  """Create enhanced tables with weekly, quarterly, and YTD metrics"""
 
539
  return tables
540
 
541
  # ============================================================================
542
+ # Macro ratios with Weekly, Quarterly, YTD
543
  # ============================================================================
544
  def create_chaos_ratios_table(self) -> pd.DataFrame:
545
  """Create chaos ratios table with weekly, quarterly, and YTD changes"""
 
697
  # Create subplots WITHOUT titles at top
698
  fig = make_subplots(
699
  rows=2, cols=2,
700
+ subplot_titles=('', '', '', ''),
701
  vertical_spacing=0.1
702
  )
703
 
 
756
  return fig
757
 
758
  # ============================================================================
759
+ # Markdown report with Weekly, Quarterly, YTD
760
  # ============================================================================
761
  def generate_markdown_report(self, live_data: Dict, macro_data: pd.DataFrame) -> str:
762
  """Generate a comprehensive markdown report from all data for LLM consumption"""
 
974
 
975
  return [empty_fig, empty_fig, empty_fig, empty_df, empty_df, empty_df, empty_df, empty_df, empty_df, empty_markdown]
976
 
977
+
978
  def download_markdown(markdown_content):
979
+ """Create a downloadable markdown file"""
980
  if not markdown_content or "Error" in markdown_content:
981
  markdown_content = "# No Data Available\n\nPlease update the data first."
982
 
 
1026
 
1027
  gr.Markdown("---")
1028
  gr.Markdown("## 🏭 US Sector Performance")
 
1029
  sector_table = gr.DataFrame(label="Sector ETFs - Weekly, Quarterly, YTD")
1030
 
1031
  gr.Markdown("---")