Anurag33Gaikwad commited on
Commit
a753fbd
·
verified ·
1 Parent(s): dd86788

Update app/config.py

Browse files
Files changed (1) hide show
  1. app/config.py +41 -18
app/config.py CHANGED
@@ -1,18 +1,41 @@
1
- import os
2
- from functools import lru_cache
3
-
4
- class Settings:
5
- app_name: str = "QuantMind Backend"
6
- environment: str = os.getenv("ENVIRONMENT", "dev")
7
- cors_origins: list[str] = os.getenv("CORS_ORIGINS", "*").split(",")
8
- model_path: str = os.getenv(
9
- "MODEL_PATH",
10
- "model/universal_multivariate_model_v1.h5",
11
- )
12
- yfinance_period: str = os.getenv("YF_PERIOD", "1y")
13
- history_window: int = int(os.getenv("HISTORY_WINDOW", "60"))
14
- max_forecast_days: int = int(os.getenv("MAX_FORECAST_DAYS", "14"))
15
-
16
- @lru_cache
17
- def get_settings() -> Settings:
18
- return Settings()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from functools import lru_cache
3
+ from typing import List
4
+
5
+
6
+ class Settings:
7
+ # App
8
+ app_name: str = "QuantMind Backend"
9
+ environment: str = os.getenv("ENVIRONMENT", "dev")
10
+
11
+ # CORS
12
+ cors_origins: List[str] = os.getenv("CORS_ORIGINS", "*").split(",")
13
+
14
+ # Model
15
+ model_path: str = os.getenv(
16
+ "MODEL_PATH",
17
+ "model/universal_multivariate_model_v1.h5",
18
+ )
19
+
20
+ # Market data (Alpha Vantage)
21
+ alpha_vantage_api_key: str = os.getenv("ALPHA_VANTAGE_API_KEY")
22
+
23
+ # Prediction params
24
+ history_window: int = int(os.getenv("HISTORY_WINDOW", "60"))
25
+ max_forecast_days: int = int(os.getenv("MAX_FORECAST_DAYS", "14"))
26
+
27
+ def validate(self):
28
+ """
29
+ Validate critical settings at runtime
30
+ """
31
+ if not self.alpha_vantage_api_key:
32
+ raise RuntimeError(
33
+ "ALPHA_VANTAGE_API_KEY is not set in environment variables"
34
+ )
35
+
36
+
37
+ @lru_cache
38
+ def get_settings() -> Settings:
39
+ settings = Settings()
40
+ settings.validate()
41
+ return settings