fix(tradein): per-bucket velocity formula + realistic срок продажи (#574) #631
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#631
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/574-per-bucket-velocity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes #574
Root causes fixed: 1. Bug_Velocity_Mix_Static: bucket_v = market_vel_pm × share/100 made all bucket velocities proportional to market share, so Σ bucket_v ≡ market_vel_pm regardless of mix. Moving a slider changed share_pct but not the aggregate срок продажи (velocity numerator and denominator both scaled with share). 2. Bug_Velocity_Unrealistic: rosreestr fallback used city-wide total_deals (region 66, ~3815 deals/24 mo = 159 кв/мес) divided by district-only competitors_weighted (~5-10 ЖК), yielding 16-32 кв/мес per project and срок ~0.7 мес instead of realistic months. Changes: - Add _n_active_zhk_region(db, region_code): COUNT DISTINCT active ЖК in the full region — used as city-wide denominator for rosreestr fallback. Lazy-cached to avoid duplicate DB round-trips. - Add _velocity_baseline_per_bucket(db, ...): query objective_corpus_room_month grouped by room_bucket (same mapping as _elasticity_per_bucket_coef) to get per-bucket median velocity. Returns None when < 3 observations. - Replace static bucket_market_velocities computation in recommend_mix: - Objective path: use _velocity_baseline_per_bucket per-bucket medians. Each bucket is an independent constant (not share-derived). - Rosreestr fallback: bucket_deals / months / N_active_region. N_active_region (200-400+ for EKB) replaces competitors_district (5-10), giving realistic per-project velocities (~0.1-0.6 кв/мес per bucket). - Add bucket["velocity_source"] = "objective_per_bucket" | "rosreestr_fallback" for transparency in API response and UI warnings. - Add scope["n_active_region"] for debugging. - Add 19 unit tests in test_recommend_mix_velocity.py covering both bugs.