File size: 1,038 Bytes
a753fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36d5a6b
a753fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from functools import lru_cache
from typing import List


class Settings:
    # App
    app_name: str = "QuantMind Backend"
    environment: str = os.getenv("ENVIRONMENT", "dev")

    # CORS
    cors_origins: List[str] = os.getenv("CORS_ORIGINS", "*").split(",")

    # Model
    model_path: str = os.getenv(
        "MODEL_PATH",
        "model/universal_multivariate_model_v1.h5",
    )

    # Market data (Alpha Vantage)
    alpha_vantage_api_key: str = os.getenv("ALPHA_VANTAGE_API_KEY")

    # Prediction params
    history_window: int = int(os.getenv("HISTORY_WINDOW", "50"))
    max_forecast_days: int = int(os.getenv("MAX_FORECAST_DAYS", "14"))

    def validate(self):
        """
        Validate critical settings at runtime
        """
        if not self.alpha_vantage_api_key:
            raise RuntimeError(
                "ALPHA_VANTAGE_API_KEY is not set in environment variables"
            )


@lru_cache
def get_settings() -> Settings:
    settings = Settings()
    settings.validate()
    return settings