New backend/app/services/forecasting package (Site Finder v2 EPIC 7, §9.5/§9.6 foundation). Deterministic, no LLM. MonthlyMacro dataclass + get_monthly_macro (daily key_rate resampled to monthly last-known-value via SQL DISTINCT ON, reuses macro.get_macro_series for the already-monthly sverdl mortgage series, carry-forward key_rate over a continuous month grid, graceful on empty/DB error). Pure helpers: classify_regime (down/up/stable, eps 0.25pp), macro_at_lag (0/1/2/3/6), is_confounded_window (COVID 2020-03, geopolitics 2022-02, subsidy cutback 2024-07). 51 unit tests, no live DB. psycopg v3 CAST(:x AS type) throughout.
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""Forecasting services — детерминированный форсайт-слой Site Finder v2.
|
|
|
|
#951 (Site Finder v2 / «GG-форсайт», EPIC 7 «Чувствительность к ключевой ставке»).
|
|
|
|
Этот пакет — фундамент data-independent логики прогноза: monthly макро-ряды,
|
|
классификатор режима ставки, лаговые помощники. Всё ДЕТЕРМИНИРОВАННО, БЕЗ LLM.
|
|
|
|
Слои (по PR):
|
|
• macro_series (этот PR, #951b) — monthly макро-ряд + классификатор режима ставки.
|
|
• sales_series (later PR) — monthly ряд продаж по локации.
|
|
• rate_sensitivity (later PR) — §9.6 чувствительность продаж к key_rate.
|
|
• macro_coefficient (later PR) — §9.5 макро-коэффициент.
|
|
|
|
Источник макро-данных — таблица macro_indicator через тонкий reader
|
|
backend/app/services/site_finder/macro.py (переиспользуем, не дублируем).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app.services.forecasting.macro_series import (
|
|
MonthlyMacro,
|
|
classify_regime,
|
|
get_monthly_macro,
|
|
is_confounded_window,
|
|
macro_at_lag,
|
|
)
|
|
|
|
__all__ = [
|
|
"MonthlyMacro",
|
|
"classify_regime",
|
|
"get_monthly_macro",
|
|
"is_confounded_window",
|
|
"macro_at_lag",
|
|
]
|