Skip to content

Config Resolution

Syed Ibrahim Omer edited this page Apr 13, 2026 · 1 revision

Config Resolution (Deep Dive)

Indicator windows come from embedded defaults (DEFAULT_CONFIG in src/indicators.py) or from an optional JSON file passed as -c / --config_json.

Lookup shape

Each tunable family uses nested keys:

<family_key>[<period>][<timeframe_interval>]

Example: defaults["rsi_window"]["5y"]["1d"] → integer window length.

  • period: must match the period string for the current row (e.g. 5y from run_main).
  • timeframe_interval: must be the interval string for that run (e.g. 1d, 1wk), not the whole timeframe JSON object.

Canonical defaults also live in src/default_configs.json (kept in sync with the embedded string in code).

Merge semantics (important)

When config is not None, the code uses a per-family switch:

  • If the top-level key exists (e.g. "sma_window" in config), all lookups for that family use config["sma_window"][period][time_frame].
  • If the key is absent, that family falls back entirely to defaults[...].

There is no deep merge inside a family: you cannot override only 5y/1d for sma_window while leaving other period/timeframe cells to defaults unless you include the key and supply all cells you need, or omit the key and use defaults only.

Practical rule: either omit a family key to use defaults for that family, or supply a complete nested map for that family for every (period, time_frame) pair you will hit.

Timeframe JSON and window lookup

When -t points to a JSON file, run_main loads a dict mapping period → interval string. Fetch uses interval = timeframe[period].

calculate_indicators(..., time_frame=...) receives that same time_frame value from run_main. Window resolution uses defaults[...][period][time_frame]. For a dict timeframe, the inner key must be the interval string for that period (e.g. time_frame resolved to "1d"), not the full mapping. If the implementation passes the mapping dict through where a string key is expected, config/default lookup can raise TypeError or mis-key. Prefer a single string -t 1d when validating window behavior unless the codebase explicitly resolves the interval before lookup.

MACD triple

macd_short, macd_long, and macd_signal are resolved together from config or defaults per (period, time_frame).

Related pages:

Clone this wiki locally