Triggers
Set conditions, get actions. Horizon’s trigger system evaluates rules each cycle and fires actions when conditions are met. Supports 8 condition types, 5 action types, cooldown periods, and hysteresis to prevent trigger storms. The evaluation logic is pure Rust (stateless); all mutable state lives in the Python closure.Overview
8 Conditions
Above, below, cross above/below, percent change, absolute change, between, outside.
5 Actions
Alert, webhook, order, hedge, kill switch.
Cooldown & Hysteresis
Prevent trigger storms with configurable cooldown and hysteresis bands.
Oracle Server
hz.oracle() exposes feed prices as a JSON HTTP endpoint.Core Functions
hz.evaluate_trigger
Evaluate a trigger rule against current market state. Pure function (no side effects).hz.create_trigger
Create a trigger rule with full configuration.| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | required | Trigger name |
condition | TriggerCondition | required | Condition type |
threshold | float | required | Primary threshold |
action | TriggerActionType | required | Action to take |
threshold_upper | float | 0.0 | Upper threshold (for Between/Outside) |
cooldown_secs | float | 60.0 | Minimum seconds between fires |
hysteresis | float | 0.0 | Hysteresis band to prevent flapping |
Condition Types
| Condition | Fires when |
|---|---|
Above | value > threshold |
Below | value < threshold |
CrossAbove | previous <= threshold AND current > threshold |
CrossBelow | previous >= threshold AND current < threshold |
PercentChange | abs(current - previous) / previous > threshold |
AbsoluteChange | abs(current - previous) > threshold |
Between | threshold <= value <= threshold_upper |
Outside | value < threshold OR value > threshold_upper |
Action Types
| Action | Description |
|---|---|
Alert | Send alert via AlertManager |
Webhook | Fire HTTP POST to configured URL |
Order | Submit an order |
Hedge | Trigger a hedge trade |
KillSwitch | Activate kill switch |
Pipeline Functions
hz.trigger
Evaluate multiple trigger rules each cycle.| Parameter | Type | Description |
|---|---|---|
triggers | list[TriggerConfig] | Trigger configurations |
alert_manager | Any | Optional AlertManager for alert actions |
hz.conditional_hedge
Automatically hedge when a condition is met.hz.oracle
Start a minimal HTTP server exposing live feed prices as JSON.| Parameter | Type | Default | Description |
|---|---|---|---|
port | int | 8099 | HTTP server port |