From 9d945d3b63d428c62c7f66a3d32b12c74119e0c4 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Sun, 31 May 2026 16:44:43 +0300 Subject: [PATCH 1/2] feat(tradein): add EKB/MSK REF_AREA codes to sber_price_index pull (#794) --- .../backend/app/services/sber_index.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tradein-mvp/backend/app/services/sber_index.py b/tradein-mvp/backend/app/services/sber_index.py index f64cf30f..1e0b5318 100644 --- a/tradein-mvp/backend/app/services/sber_index.py +++ b/tradein-mvp/backend/app/services/sber_index.py @@ -24,15 +24,12 @@ Full asking-vs-our-median reconciliation is a separate follow-up (#887 step 5+). NOTE — estimator time-adjust wire (step 4) is OUT OF SCOPE for this PR. It is a client-visible change that requires a backtest gate. Defer to a separate issue. -REF_AREA codes: - 643 = РФ (confirmed from live session, vault research note 2026-05-31-0845). - # TODO (#887 follow-up): resolve EKB (Свердловская обл) + Moscow REF_AREA codes. - # The dynpage config endpoint (GET /api/dynpage/ru/dashboards/) returns - # a base64-encoded React config with region options, but requires a working TLS chain - # from the deployment environment. Candidate codes: Свердловская обл ≈ 66, - # Москва ≈ 77 (ОКАТО-derived). Confirm by inspecting the dynpage form field - # «REF_AREA» values in a browser session or after fixing TLS in prod. - # Once confirmed, add them to SBER_REF_AREAS below and remove this TODO. +REF_AREA codes (sberindex internal region IDs, not ОКАТО/ISO): + 643 = Россия — confirmed live, vault research note 2026-05-31-0845. + 8 = Свердловская область — verified 2026-05-31 via dynpage form REF_AREA codelist; + real_estate_deals: 2017-01 61 632 → 2026-04 146 329 руб/м². + 47 = Москва — verified 2026-05-31 via dynpage form REF_AREA codelist; + real_estate_deals: 2017-01 211 194 → 2026-04 374 030 руб/м². """ from __future__ import annotations @@ -56,13 +53,12 @@ logger = logging.getLogger(__name__) # --------------------------------------------------------------------------- # REF_AREA code → city label used as the primary key in sber_price_index. -# 643 = РФ is confirmed (live reverse-engineering, vault 2026-05-31-0845). -# EKB and Moscow codes are pending TLS resolution — see TODO in module docstring. +# Codes confirmed 2026-05-31 via /api/dynpage/ru/dashboards/real_estate_deals +# → form field «REF_AREA» codelist (sberindex internal region IDs, not ОКАТО/ISO). SBER_REF_AREAS: dict[str, str] = { "643": "Россия", - # TODO (#887 follow-up): uncomment + verify EKB / Moscow REF_AREA codes. - # "66": "Свердловская область", # candidate — confirm via dynpage form - # "77": "Москва", # candidate — confirm via dynpage form + "8": "Свердловская область", + "47": "Москва", } # Dashboards to pull: slug → human label (used as 'segment' placeholder) -- 2.45.3 From 4138584de11ca1d5a7badf3fb2c0d14a89d71969 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Sun, 31 May 2026 16:50:46 +0300 Subject: [PATCH 2/2] fix(tradein): correct EKB/MSK REF_AREA codes to 66/77 (#794) --- tradein-mvp/backend/app/services/sber_index.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tradein-mvp/backend/app/services/sber_index.py b/tradein-mvp/backend/app/services/sber_index.py index 1e0b5318..813a1df8 100644 --- a/tradein-mvp/backend/app/services/sber_index.py +++ b/tradein-mvp/backend/app/services/sber_index.py @@ -26,10 +26,12 @@ It is a client-visible change that requires a backtest gate. Defer to a separate REF_AREA codes (sberindex internal region IDs, not ОКАТО/ISO): 643 = Россия — confirmed live, vault research note 2026-05-31-0845. - 8 = Свердловская область — verified 2026-05-31 via dynpage form REF_AREA codelist; - real_estate_deals: 2017-01 61 632 → 2026-04 146 329 руб/м². - 47 = Москва — verified 2026-05-31 via dynpage form REF_AREA codelist; - real_estate_deals: 2017-01 211 194 → 2026-04 374 030 руб/м². + 66 = Свердловская область — verified 2026-05-31 brute-force against /api/sowa + (region name from ref_area field of response); + real_estate_deals: 2017-01 51 046 → 2026-04 128 443 руб/м². + 77 = Москва — verified 2026-05-31 brute-force against /api/sowa + (region name from ref_area field of response); + real_estate_deals: 2017-01 148 471 → 2026-04 309 510 руб/м². """ from __future__ import annotations @@ -53,12 +55,12 @@ logger = logging.getLogger(__name__) # --------------------------------------------------------------------------- # REF_AREA code → city label used as the primary key in sber_price_index. -# Codes confirmed 2026-05-31 via /api/dynpage/ru/dashboards/real_estate_deals -# → form field «REF_AREA» codelist (sberindex internal region IDs, not ОКАТО/ISO). +# Codes verified 2026-05-31 by brute-force scan against /api/sowa +# (region name taken from ref_area field of API response; not ОКАТО/ISO). SBER_REF_AREAS: dict[str, str] = { "643": "Россия", - "8": "Свердловская область", - "47": "Москва", + "66": "Свердловская область", + "77": "Москва", } # Dashboards to pull: slug → human label (used as 'segment' placeholder) -- 2.45.3