File size: 2,860 Bytes
6ce20d9
 
 
38a6b6a
6ce20d9
 
38a6b6a
f35bff2
6ce20d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f35bff2
6ce20d9
 
 
f35bff2
6ce20d9
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
Configuration settings for FRED ML application
"""

import os
from typing import Optional

# FRED API Configuration
FRED_API_KEY = os.getenv('FRED_API_KEY', '')

# AWS Configuration
AWS_REGION = os.getenv('AWS_REGION', 'us-east-1')
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID', '')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY', '')

# Application Configuration
DEBUG = os.getenv('DEBUG', 'False').lower() == 'true'
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')

# Performance Configuration
MAX_WORKERS = int(os.getenv('MAX_WORKERS', '10'))  # For parallel processing
REQUEST_TIMEOUT = int(os.getenv('REQUEST_TIMEOUT', '30'))  # API request timeout
CACHE_DURATION = int(os.getenv('CACHE_DURATION', '3600'))  # Cache duration in seconds

# Streamlit Configuration
STREAMLIT_SERVER_PORT = int(os.getenv('STREAMLIT_SERVER_PORT', '8501'))
STREAMLIT_SERVER_ADDRESS = os.getenv('STREAMLIT_SERVER_ADDRESS', '0.0.0.0')

# Data Configuration
DEFAULT_SERIES_LIST = [
    'GDPC1',    # Real GDP
    'INDPRO',   # Industrial Production
    'RSAFS',    # Retail Sales
    'CPIAUCSL', # Consumer Price Index
    'FEDFUNDS', # Federal Funds Rate
    'DGS10',    # 10-Year Treasury
    'UNRATE',   # Unemployment Rate
    'PAYEMS',   # Total Nonfarm Payrolls
    'PCE',      # Personal Consumption Expenditures
    'M2SL',     # M2 Money Stock
    'TCU',      # Capacity Utilization
    'DEXUSEU'   # US/Euro Exchange Rate
]

# Default date ranges
DEFAULT_START_DATE = '2019-01-01'
DEFAULT_END_DATE = '2024-12-31'

# Directory Configuration
OUTPUT_DIR = os.path.join(os.path.dirname(__file__), '..', 'data', 'processed')
PLOTS_DIR = os.path.join(os.path.dirname(__file__), '..', 'data', 'exports')

# Analysis Configuration
ANALYSIS_TYPES = {
    'comprehensive': 'Comprehensive Analysis',
    'forecasting': 'Time Series Forecasting',
    'segmentation': 'Market Segmentation',
    'statistical': 'Statistical Modeling'
}

def get_aws_config() -> dict:
    """Get AWS configuration with proper fallbacks"""
    config = {
        'region_name': AWS_REGION,
        'aws_access_key_id': AWS_ACCESS_KEY_ID,
        'aws_secret_access_key': AWS_SECRET_ACCESS_KEY
    }
    
    # Remove empty values to allow boto3 to use default credentials
    config = {k: v for k, v in config.items() if v}
    
    return config

def is_fred_api_configured() -> bool:
    """Check if FRED API is properly configured"""
    return bool(FRED_API_KEY and FRED_API_KEY.strip())

def is_aws_configured() -> bool:
    """Check if AWS is properly configured"""
    return bool(AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY)

def get_analysis_config(analysis_type: str) -> dict:
    """Get configuration for specific analysis type"""
    return {
        'type': analysis_type,
        'name': ANALYSIS_TYPES.get(analysis_type, analysis_type.title()),
        'enabled': True
    }