fix(sf-12): MarketTrend — adaptive n<30/n<100 confidence warnings #287
1 changed files with 35 additions and 0 deletions
|
|
@ -13,6 +13,9 @@ const LABEL_COLORS: Record<string, { bg: string; color: string }> = {
|
||||||
Падение: { bg: "#fecaca", color: "#b91c1c" },
|
Падение: { bg: "#fecaca", color: "#b91c1c" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const N_WEAK = 30;
|
||||||
|
const N_STRONG = 100;
|
||||||
|
|
||||||
function trendArrow(delta: number): string {
|
function trendArrow(delta: number): string {
|
||||||
if (delta > 1) return "↑";
|
if (delta > 1) return "↑";
|
||||||
if (delta < -1) return "↓";
|
if (delta < -1) return "↓";
|
||||||
|
|
@ -52,6 +55,31 @@ export function MarketTrendBlock({ trend }: Props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const n = trend.recent_deals_count;
|
||||||
|
|
||||||
|
// n < 30 — hide trend entirely, show data-insufficient state
|
||||||
|
if (n < N_WEAK) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
borderRadius: 10,
|
||||||
|
padding: "14px 16px",
|
||||||
|
background: "#f3f4f6",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: 6,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: 12, fontWeight: 700, color: "#374151" }}>
|
||||||
|
Тренд рынка в радиусе {trend.radius_km} км
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 13, color: "#9ca3af" }}>
|
||||||
|
Недостаточно данных (n={n}) — расширьте радиус для анализа тренда
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const arrow = trendArrow(trend.delta_6m_pct);
|
const arrow = trendArrow(trend.delta_6m_pct);
|
||||||
const arrowColor = deltaColor(trend.delta_6m_pct);
|
const arrowColor = deltaColor(trend.delta_6m_pct);
|
||||||
const labelStyle = LABEL_COLORS[trend.label] ?? {
|
const labelStyle = LABEL_COLORS[trend.label] ?? {
|
||||||
|
|
@ -132,6 +160,13 @@ export function MarketTrendBlock({ trend }: Props) {
|
||||||
>
|
>
|
||||||
{trend.label}
|
{trend.label}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Weak data warning: 30 ≤ n < 100 */}
|
||||||
|
{n < N_STRONG && (
|
||||||
|
<div className="bg-amber-50 border border-amber-200 text-amber-800 text-xs px-2 py-1 rounded">
|
||||||
|
Слабые данные (n={n}) — расширьте радиус для точности
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue