feat: stable macro regime detection — blended signals + Bayesian smoothing
Replace 1-day change_pct with weighted blend (20% 1d / 50% 5d / 30% 10d) for all 20 scored signals. Add Bayesian prior from rolling 25-day history (weight 15%→45%) and a 10-point persistence threshold before regime switch. Bootstrap on first load: replays last 20 trading days via yf.download batch (45d) to pre-populate _regime_history, so stability is visible immediately. Frontend: adds 'stable Xj' badge and history depth indicator on regime banner. Doc: updates v4.0→v4.1, rewrites Étape 1 Régime Macro and glossary entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,8 @@ export default function MacroRegime() {
|
||||
const ranked: [string, number][] = scenarios.ranked ?? []
|
||||
const reasons: Record<string, string[]> = scenarios.reasons ?? {}
|
||||
const assetBias: Record<string, Record<string, string>> = scenarios.asset_bias ?? {}
|
||||
const historyDays: number = scenarios.history_days ?? 0
|
||||
const regimeStability: number = scenarios.regime_stability ?? 0
|
||||
const dominantMeta = meta[dominant] ?? { label: dominant, color: '#94a3b8', emoji: '?' }
|
||||
const dominantBias: Record<string, string> = assetBias[dominant] ?? {}
|
||||
|
||||
@@ -215,6 +217,17 @@ export default function MacroRegime() {
|
||||
{scores[dominant]}%
|
||||
</div>
|
||||
<div className="text-xs text-slate-600">score de régime</div>
|
||||
{regimeStability > 0 && (
|
||||
<div className="text-[10px] mt-1 px-1.5 py-0.5 rounded-full text-center"
|
||||
style={{ background: `${dominantMeta.color}22`, color: dominantMeta.color }}>
|
||||
stable {regimeStability}j
|
||||
</div>
|
||||
)}
|
||||
{historyDays > 0 && (
|
||||
<div className="text-[10px] text-slate-700 mt-0.5 text-center">
|
||||
{historyDays}j d'historique
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user