Files
fx-quant/src/config_loader.py
T
Brent Neale 0d0c363bfa Add config-driven system.yaml and multi-window indicators
- Create config/system.yaml with full master prompt template
- Create src/config_loader.py to load YAML config and .env
- Update data_engine.build_all_features() to support lists of windows
  (e.g. sma_windows: [3, 20] produces sma_3 and sma_20 columns)
- Rewrite get_candles.py to loop over all instruments × granularities
  from config instead of hardcoding EUR_USD/M5
- Fix supabase_upload.py indentation bug and wire up config for table name

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:22:07 +10:00

45 lines
953 B
Python

# src/config_loader.py
"""
Loads config/system.yaml and config/.env for the fx-quant project.
"""
from pathlib import Path
from dotenv import load_dotenv
import yaml
def get_project_root() -> Path:
"""Return the fx-quant project root (parent of src/)."""
return Path(__file__).resolve().parents[1]
def load_config(path=None) -> dict:
"""
Load config/system.yaml and config/.env.
Parameters
----------
path : str or Path, optional
Explicit path to a YAML config file. Defaults to
<project_root>/config/system.yaml.
Returns
-------
dict
Parsed YAML contents.
"""
root = get_project_root()
# Always load .env as a side effect
env_path = root / "config" / ".env"
if env_path.exists():
load_dotenv(env_path)
if path is None:
path = root / "config" / "system.yaml"
with open(path, "r") as f:
cfg = yaml.safe_load(f)
return cfg