45: Add hysteresis support to CROSSING alarms

This commit is contained in:
2026-08-05 10:12:39 +02:00
parent bf492c9db1
commit 4cc14ceef5
7 changed files with 209 additions and 17 deletions
+15 -2
View File
@@ -224,12 +224,14 @@ On the first accepted oracle price after startup, an already-satisfied `ONETIME`
- Triggers when the condition changes from not satisfied to satisfied.
- The first accepted price establishes the initial state and never triggers the alarm.
- Remaining inside the condition does not trigger again.
- Leaving the condition re-arms the alarm, so the next entry triggers again.
- Without hysteresis, leaving the condition re-arms the alarm, so the next entry triggers again.
- An optional hysteresis can be appended to the condition as `/H` or `/P%`.
- With hysteresis, the alarm remains disarmed until the price reaches the re-arm boundary.
- A grace period is not supported; `CROSSING:1m` is rejected.
- Only the strict directional comparisons `<` and `>` are supported.
- `=`, `<=`, `>=`, and range conditions are rejected during configuration parsing.
The condition determines the crossing direction. For example:
The condition determines the crossing direction. Without hysteresis:
```text
19 SOL >{{SOL_LONG_ENTRY_PRICE}} CROSSING
@@ -238,6 +240,17 @@ The condition determines the crossing direction. For example:
Alarm 19 triggers when the price moves from at or below the entry price to above it. Alarm 20 triggers when the price moves from at or above the entry price to below it. Landing exactly on the entry price is not a crossing.
Hysteresis prevents repeated triggers when the price fluctuates around the target:
```text
21 SOL >{{SOL_LONG_ENTRY_PRICE}}/0.25 CROSSING
22 SOL <{{SOL_LONG_ENTRY_PRICE}}/0.25% CROSSING
```
Alarm 21 triggers above the entry price and re-arms only at or below `entry price - 0.25`. Alarm 22 triggers below the entry price and re-arms only at or above `entry price + 0.25%`.
Percentage hysteresis is calculated from the fully resolved comparison target. Hysteresis is an unsigned distance, so a leading `+` or `-` is rejected. Hysteresis is supported only for `CROSSING` alarms.
### `PERSISTENT`
- Triggers immediately on the first accepted matching price.