Edwin Salguero commited on
Commit
b204d55
·
2 Parent(s): f63ddad ae5c255

Merge remote changes and resolve conflicts - Fixed frequency error (ME -> M) - Updated analytics availability checks - Resolved merge conflicts keeping local improvements

Browse files
config/__pycache__/settings.cpython-39.pyc DELETED
Binary file (2.38 kB)
 
frontend/demo_data.py ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ FRED ML - Demo Data Generator
3
+ Provides realistic economic data and senior data scientist insights
4
+ """
5
+
6
+ import pandas as pd
7
+ import numpy as np
8
+ from datetime import datetime, timedelta
9
+ import random
10
+
11
+ def generate_economic_data():
12
+ """Generate realistic economic data for demonstration"""
13
+
14
+ # Generate date range (last 5 years)
15
+ end_date = datetime.now()
16
+ start_date = end_date - timedelta(days=365*5)
17
+ dates = pd.date_range(start=start_date, end=end_date, freq='M')
18
+
19
+ # Base values and trends for realistic economic data
20
+ base_values = {
21
+ 'GDPC1': 20000, # Real GDP in billions
22
+ 'INDPRO': 100, # Industrial Production Index
23
+ 'RSAFS': 500, # Retail Sales in billions
24
+ 'CPIAUCSL': 250, # Consumer Price Index
25
+ 'FEDFUNDS': 2.5, # Federal Funds Rate
26
+ 'DGS10': 3.0, # 10-Year Treasury Rate
27
+ 'UNRATE': 4.0, # Unemployment Rate
28
+ 'PAYEMS': 150000, # Total Nonfarm Payrolls (thousands)
29
+ 'PCE': 18000, # Personal Consumption Expenditures
30
+ 'M2SL': 21000, # M2 Money Stock
31
+ 'TCU': 75, # Capacity Utilization
32
+ 'DEXUSEU': 1.1 # US/Euro Exchange Rate
33
+ }
34
+
35
+ # Growth rates and volatility for realistic trends
36
+ growth_rates = {
37
+ 'GDPC1': 0.02, # 2% annual growth
38
+ 'INDPRO': 0.015, # 1.5% annual growth
39
+ 'RSAFS': 0.03, # 3% annual growth
40
+ 'CPIAUCSL': 0.025, # 2.5% annual inflation
41
+ 'FEDFUNDS': 0.0, # Policy rate
42
+ 'DGS10': 0.0, # Market rate
43
+ 'UNRATE': 0.0, # Unemployment
44
+ 'PAYEMS': 0.015, # Employment growth
45
+ 'PCE': 0.025, # Consumption growth
46
+ 'M2SL': 0.04, # Money supply growth
47
+ 'TCU': 0.005, # Capacity utilization
48
+ 'DEXUSEU': 0.0 # Exchange rate
49
+ }
50
+
51
+ # Generate realistic data
52
+ data = {'Date': dates}
53
+
54
+ for indicator, base_value in base_values.items():
55
+ # Create trend with realistic economic cycles
56
+ trend = np.linspace(0, len(dates) * growth_rates[indicator], len(dates))
57
+
58
+ # Add business cycle effects
59
+ cycle = 0.05 * np.sin(2 * np.pi * np.arange(len(dates)) / 48) # 4-year cycle
60
+
61
+ # Add random noise
62
+ noise = np.random.normal(0, 0.02, len(dates))
63
+
64
+ # Combine components
65
+ values = base_value * (1 + trend + cycle + noise)
66
+
67
+ # Ensure realistic bounds
68
+ if indicator in ['UNRATE', 'FEDFUNDS', 'DGS10']:
69
+ values = np.clip(values, 0, 20)
70
+ elif indicator in ['CPIAUCSL']:
71
+ values = np.clip(values, 200, 350)
72
+ elif indicator in ['TCU']:
73
+ values = np.clip(values, 60, 90)
74
+
75
+ data[indicator] = values
76
+
77
+ return pd.DataFrame(data)
78
+
79
+ def generate_insights():
80
+ """Generate senior data scientist insights"""
81
+
82
+ insights = {
83
+ 'GDPC1': {
84
+ 'current_value': '$21,847.2B',
85
+ 'growth_rate': '+2.1%',
86
+ 'trend': 'Moderate growth',
87
+ 'forecast': '+2.3% next quarter',
88
+ 'key_insight': 'GDP growth remains resilient despite monetary tightening, supported by strong consumer spending and business investment.',
89
+ 'risk_factors': ['Inflation persistence', 'Geopolitical tensions', 'Supply chain disruptions'],
90
+ 'opportunities': ['Technology sector expansion', 'Infrastructure investment', 'Green energy transition']
91
+ },
92
+ 'INDPRO': {
93
+ 'current_value': '102.4',
94
+ 'growth_rate': '+0.8%',
95
+ 'trend': 'Recovery phase',
96
+ 'forecast': '+0.6% next month',
97
+ 'key_insight': 'Industrial production shows signs of recovery, with manufacturing leading the rebound. Capacity utilization improving.',
98
+ 'risk_factors': ['Supply chain bottlenecks', 'Labor shortages', 'Energy price volatility'],
99
+ 'opportunities': ['Advanced manufacturing', 'Automation adoption', 'Reshoring initiatives']
100
+ },
101
+ 'RSAFS': {
102
+ 'current_value': '$579.2B',
103
+ 'growth_rate': '+3.2%',
104
+ 'trend': 'Strong consumer spending',
105
+ 'forecast': '+2.8% next month',
106
+ 'key_insight': 'Retail sales demonstrate robust consumer confidence, with e-commerce continuing to gain market share.',
107
+ 'risk_factors': ['Inflation impact on purchasing power', 'Interest rate sensitivity', 'Supply chain issues'],
108
+ 'opportunities': ['Digital transformation', 'Omnichannel retail', 'Personalization']
109
+ },
110
+ 'CPIAUCSL': {
111
+ 'current_value': '312.3',
112
+ 'growth_rate': '+3.2%',
113
+ 'trend': 'Moderating inflation',
114
+ 'forecast': '+2.9% next month',
115
+ 'key_insight': 'Inflation continues to moderate from peak levels, with core CPI showing signs of stabilization.',
116
+ 'risk_factors': ['Energy price volatility', 'Wage pressure', 'Supply chain costs'],
117
+ 'opportunities': ['Productivity improvements', 'Technology adoption', 'Supply chain optimization']
118
+ },
119
+ 'FEDFUNDS': {
120
+ 'current_value': '5.25%',
121
+ 'growth_rate': '0%',
122
+ 'trend': 'Stable policy rate',
123
+ 'forecast': '5.25% next meeting',
124
+ 'key_insight': 'Federal Reserve maintains restrictive stance to combat inflation, with policy rate at 22-year high.',
125
+ 'risk_factors': ['Inflation persistence', 'Economic slowdown', 'Financial stability'],
126
+ 'opportunities': ['Policy normalization', 'Inflation targeting', 'Financial regulation']
127
+ },
128
+ 'DGS10': {
129
+ 'current_value': '4.12%',
130
+ 'growth_rate': '-0.15%',
131
+ 'trend': 'Declining yields',
132
+ 'forecast': '4.05% next week',
133
+ 'key_insight': '10-year Treasury yields declining on economic uncertainty and flight to quality. Yield curve inversion persists.',
134
+ 'risk_factors': ['Economic recession', 'Inflation expectations', 'Geopolitical risks'],
135
+ 'opportunities': ['Bond market opportunities', 'Portfolio diversification', 'Interest rate hedging']
136
+ },
137
+ 'UNRATE': {
138
+ 'current_value': '3.7%',
139
+ 'growth_rate': '0%',
140
+ 'trend': 'Stable employment',
141
+ 'forecast': '3.6% next month',
142
+ 'key_insight': 'Unemployment rate remains near historic lows, indicating tight labor market conditions.',
143
+ 'risk_factors': ['Labor force participation', 'Skills mismatch', 'Economic slowdown'],
144
+ 'opportunities': ['Workforce development', 'Technology training', 'Remote work adoption']
145
+ },
146
+ 'PAYEMS': {
147
+ 'current_value': '156,847K',
148
+ 'growth_rate': '+1.2%',
149
+ 'trend': 'Steady job growth',
150
+ 'forecast': '+0.8% next month',
151
+ 'key_insight': 'Nonfarm payrolls continue steady growth, with healthcare and technology sectors leading job creation.',
152
+ 'risk_factors': ['Labor shortages', 'Wage pressure', 'Economic uncertainty'],
153
+ 'opportunities': ['Skills development', 'Industry partnerships', 'Immigration policy']
154
+ },
155
+ 'PCE': {
156
+ 'current_value': '$19,847B',
157
+ 'growth_rate': '+2.8%',
158
+ 'trend': 'Strong consumption',
159
+ 'forecast': '+2.5% next quarter',
160
+ 'key_insight': 'Personal consumption expenditures show resilience, supported by strong labor market and wage growth.',
161
+ 'risk_factors': ['Inflation impact', 'Interest rate sensitivity', 'Consumer confidence'],
162
+ 'opportunities': ['Digital commerce', 'Experience economy', 'Sustainable consumption']
163
+ },
164
+ 'M2SL': {
165
+ 'current_value': '$20,847B',
166
+ 'growth_rate': '+2.1%',
167
+ 'trend': 'Moderate growth',
168
+ 'forecast': '+1.8% next month',
169
+ 'key_insight': 'Money supply growth moderating as Federal Reserve tightens monetary policy to combat inflation.',
170
+ 'risk_factors': ['Inflation expectations', 'Financial stability', 'Economic growth'],
171
+ 'opportunities': ['Digital payments', 'Financial innovation', 'Monetary policy']
172
+ },
173
+ 'TCU': {
174
+ 'current_value': '78.4%',
175
+ 'growth_rate': '+0.3%',
176
+ 'trend': 'Improving utilization',
177
+ 'forecast': '78.7% next quarter',
178
+ 'key_insight': 'Capacity utilization improving as supply chain issues resolve and demand remains strong.',
179
+ 'risk_factors': ['Supply chain disruptions', 'Labor shortages', 'Energy constraints'],
180
+ 'opportunities': ['Efficiency improvements', 'Technology adoption', 'Process optimization']
181
+ },
182
+ 'DEXUSEU': {
183
+ 'current_value': '1.087',
184
+ 'growth_rate': '+0.2%',
185
+ 'trend': 'Stable exchange rate',
186
+ 'forecast': '1.085 next week',
187
+ 'key_insight': 'US dollar remains strong against euro, supported by relative economic performance and interest rate differentials.',
188
+ 'risk_factors': ['Economic divergence', 'Geopolitical tensions', 'Trade policies'],
189
+ 'opportunities': ['Currency hedging', 'International trade', 'Investment diversification']
190
+ }
191
+ }
192
+
193
+ return insights
194
+
195
+ def generate_forecast_data():
196
+ """Generate forecast data with confidence intervals"""
197
+
198
+ # Generate future dates (next 4 quarters)
199
+ last_date = datetime.now()
200
+ future_dates = pd.date_range(start=last_date + timedelta(days=90), periods=4, freq='Q')
201
+
202
+ forecasts = {}
203
+
204
+ # Realistic forecast scenarios
205
+ forecast_scenarios = {
206
+ 'GDPC1': {'growth': 0.02, 'volatility': 0.01}, # 2% quarterly growth
207
+ 'INDPRO': {'growth': 0.015, 'volatility': 0.008}, # 1.5% monthly growth
208
+ 'RSAFS': {'growth': 0.025, 'volatility': 0.012}, # 2.5% monthly growth
209
+ 'CPIAUCSL': {'growth': 0.006, 'volatility': 0.003}, # 0.6% monthly inflation
210
+ 'FEDFUNDS': {'growth': 0.0, 'volatility': 0.25}, # Stable policy rate
211
+ 'DGS10': {'growth': -0.001, 'volatility': 0.15}, # Slight decline
212
+ 'UNRATE': {'growth': -0.001, 'volatility': 0.1}, # Slight decline
213
+ 'PAYEMS': {'growth': 0.008, 'volatility': 0.005}, # 0.8% monthly growth
214
+ 'PCE': {'growth': 0.02, 'volatility': 0.01}, # 2% quarterly growth
215
+ 'M2SL': {'growth': 0.015, 'volatility': 0.008}, # 1.5% monthly growth
216
+ 'TCU': {'growth': 0.003, 'volatility': 0.002}, # 0.3% quarterly growth
217
+ 'DEXUSEU': {'growth': -0.001, 'volatility': 0.02} # Slight decline
218
+ }
219
+
220
+ for indicator, scenario in forecast_scenarios.items():
221
+ base_value = 100 # Normalized base value
222
+
223
+ # Generate forecast values
224
+ forecast_values = []
225
+ confidence_intervals = []
226
+
227
+ for i in range(4):
228
+ # Add trend and noise
229
+ value = base_value * (1 + scenario['growth'] * (i + 1) +
230
+ np.random.normal(0, scenario['volatility']))
231
+
232
+ # Generate confidence interval
233
+ lower = value * (1 - 0.05 - np.random.uniform(0, 0.03))
234
+ upper = value * (1 + 0.05 + np.random.uniform(0, 0.03))
235
+
236
+ forecast_values.append(value)
237
+ confidence_intervals.append({'lower': lower, 'upper': upper})
238
+
239
+ forecasts[indicator] = {
240
+ 'forecast': forecast_values,
241
+ 'confidence_intervals': pd.DataFrame(confidence_intervals),
242
+ 'dates': future_dates
243
+ }
244
+
245
+ return forecasts
246
+
247
+ def generate_correlation_matrix():
248
+ """Generate realistic correlation matrix"""
249
+
250
+ # Define realistic correlations between economic indicators
251
+ correlations = {
252
+ 'GDPC1': {'INDPRO': 0.85, 'RSAFS': 0.78, 'CPIAUCSL': 0.45, 'FEDFUNDS': -0.32, 'DGS10': -0.28},
253
+ 'INDPRO': {'RSAFS': 0.72, 'CPIAUCSL': 0.38, 'FEDFUNDS': -0.25, 'DGS10': -0.22},
254
+ 'RSAFS': {'CPIAUCSL': 0.42, 'FEDFUNDS': -0.28, 'DGS10': -0.25},
255
+ 'CPIAUCSL': {'FEDFUNDS': 0.65, 'DGS10': 0.58},
256
+ 'FEDFUNDS': {'DGS10': 0.82}
257
+ }
258
+
259
+ # Create correlation matrix
260
+ indicators = ['GDPC1', 'INDPRO', 'RSAFS', 'CPIAUCSL', 'FEDFUNDS', 'DGS10', 'UNRATE', 'PAYEMS', 'PCE', 'M2SL', 'TCU', 'DEXUSEU']
261
+ corr_matrix = pd.DataFrame(index=indicators, columns=indicators)
262
+
263
+ # Fill diagonal with 1
264
+ for indicator in indicators:
265
+ corr_matrix.loc[indicator, indicator] = 1.0
266
+
267
+ # Fill with realistic correlations
268
+ for i, indicator1 in enumerate(indicators):
269
+ for j, indicator2 in enumerate(indicators):
270
+ if i != j:
271
+ if indicator1 in correlations and indicator2 in correlations[indicator1]:
272
+ corr_matrix.loc[indicator1, indicator2] = correlations[indicator1][indicator2]
273
+ elif indicator2 in correlations and indicator1 in correlations[indicator2]:
274
+ corr_matrix.loc[indicator1, indicator2] = correlations[indicator2][indicator1]
275
+ else:
276
+ # Generate random correlation between -0.3 and 0.3
277
+ corr_matrix.loc[indicator1, indicator2] = np.random.uniform(-0.3, 0.3)
278
+
279
+ return corr_matrix
280
+
281
+ def get_demo_data():
282
+ """Get comprehensive demo data"""
283
+ return {
284
+ 'economic_data': generate_economic_data(),
285
+ 'insights': generate_insights(),
286
+ 'forecasts': generate_forecast_data(),
287
+ 'correlation_matrix': generate_correlation_matrix()
288
+ }