feat: Telegram alert on regime quadrant change (hysteresis + cooldown)
Deploy / lint (push) Successful in 6s
Deploy / test (push) Successful in 41s
Deploy / deploy (push) Successful in 27s

Fires once when the regime monitor shifts quadrant (regime index x early
warning), so you don't have to watch the tab. Two guards against spam:

- Hysteresis: each axis only flips once the value crosses its divider by a
  margin, so a point parked on a boundary keeps its quadrant instead of
  flip-flopping day to day.
- Cooldown: a genuine change stays quiet for a few days after the last alert.

Seeds the baseline silently on first run; reuses the existing Telegram dispatch
+ AlertLog. New per-trigger toggle in Admin → Alerts (on by default).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-26 19:05:01 +02:00
parent e683513857
commit 65dd53baa3
5 changed files with 161 additions and 2 deletions
@@ -12,13 +12,15 @@ type TriggerKey =
| 'qualified_enabled'
| 'sr_proximity_enabled'
| 'score_drop_enabled'
| 'digest_enabled';
| 'digest_enabled'
| 'regime_quadrant_enabled';
const TRIGGERS: { key: TriggerKey; label: string; hint: string }[] = [
{ key: 'qualified_enabled', label: 'Qualified setups', hint: 'a setup newly clears the activation gate' },
{ key: 'sr_proximity_enabled', label: 'Watchlist S/R proximity', hint: 'a watched ticker nears a strong support/resistance' },
{ key: 'score_drop_enabled', label: 'Score deterioration', hint: 'a watched tickers composite drops sharply' },
{ key: 'digest_enabled', label: 'Daily digest', hint: 'one end-of-day summary of qualified setups' },
{ key: 'regime_quadrant_enabled', label: 'Regime quadrant change', hint: 'the regime monitor shifts quadrant (hysteresis + cooldown)' },
];
function Toggle({ checked, onChange, label, hint }: {
@@ -56,6 +58,7 @@ export function AlertSettings() {
sr_proximity_enabled: true,
score_drop_enabled: true,
digest_enabled: true,
regime_quadrant_enabled: true,
});
useEffect(() => {
@@ -67,6 +70,7 @@ export function AlertSettings() {
sr_proximity_enabled: data.sr_proximity_enabled,
score_drop_enabled: data.score_drop_enabled,
digest_enabled: data.digest_enabled,
regime_quadrant_enabled: data.regime_quadrant_enabled,
});
}
}, [data]);
+1
View File
@@ -380,6 +380,7 @@ export interface AlertConfig {
sr_proximity_enabled: boolean;
score_drop_enabled: boolean;
digest_enabled: boolean;
regime_quadrant_enabled: boolean;
}
export interface AlertTestResult {