feat(tradein): asking_to_sold_ratios table + derivation (#648 S2) #660

Merged
Light1YT merged 1 commit from feat/648-s2-ratio-table into main 2026-05-29 13:18:29 +00:00

1 commit

Author SHA1 Message Date
eb26681af4 feat(tradein): asking_to_sold_ratios table + per-rooms derivation (#648 S2)
New table asking_to_sold_ratios (rooms_bucket × district reserved) holding
ratio = median(SOLD ppm²)/median(ASKING ppm²) per rooms bucket, derived from
rosreestr ДКП deals (trailing 12mo) vs current active listings. Global -1
fallback row always written; per-rooms rows only at n_deals>=30 AND
n_listings>=30 (estimator falls back to -1 when a bucket row is absent).

Dry-run (prod, rollback): seeds 6 rows — global 0.79 + студия 0.72 / 1к 0.74 /
2к 0.80 / 3к 0.84 / 4+ 0.93 (sold is 72-93% of asking by rooms; студия biggest
discount, matching the harness finding). Idempotent (ON CONFLICT DO UPDATE);
derivation CTE structured for Stage-4 refresh reuse. district reserved for #647.
2026-05-29 18:18:19 +05:00