Rule Structure
Each price rule consists of:- Name: Descriptive identifier for the rule
- Description: Detailed explanation of what the rule monitors
- Instrument: The cryptocurrency pair to track
- Conditions: One or more conditions that must be met
- Notification Channel: How you’ll be alerted when the rule triggers
- Status: Whether the rule is currently active
Create a Price Rule
Rules are evaluated in real-time as price updates are received. Once a rule triggers, it won’t trigger again until the conditions are reset.
Condition Types
PriceSignal supports five powerful condition types extracted from the codebase:1. PRICE
Trigger when the price crosses a specific absolute value.- Above Threshold
- Below Threshold
2. PRICE_PERCENTAGE
Trigger based on percentage change from a reference point.Percentage Calculation Details
Percentage Calculation Details
The percentage change is calculated from the price at the start of the specified timeframe:
- Reference Price: Price at the start of the timeframe
- Direction: Can be “increase” or “decrease”
- Timeframe: Supported values: “1h”, “4h”, “24h”, “7d”
3. PRICE_ACTION
Detect specific price movement patterns.higher_high: Price makes a new high compared to the lookback periodlower_low: Price makes a new low compared to the lookback periodbreakout: Price breaks above a consolidation rangebreakdown: Price breaks below a consolidation range
4. PRICE_CROSSOVER
Trigger when price crosses a moving average or when two moving averages cross.- Price crosses MA
- Golden Cross
- Death Cross
5. TECHNICAL_INDICATOR
Trigger based on technical indicator values (RSI, SMA, EMA).Managing Rules
Query Your Rules
Update a Rule
Toggle Rule Status
Toggling a rule automatically manages WebSocket subscriptions. Enabling subscribes to price feeds; disabling unsubscribes if no other rules need that instrument.
Delete a Rule
Activation History
Every time a rule triggers, an activation log is created with detailed context:triggeredAt
Exact timestamp when the rule was triggered
price
The price that triggered the rule
priceChange
Absolute price change from the previous trigger
priceChangePercentage
Percentage change from the previous trigger
priceRuleSnapshot
Complete snapshot of the rule configuration at trigger time
Why are snapshots important?
Why are snapshots important?
Rule snapshots preserve the exact configuration when the alert triggered. This is crucial for:
- Audit Trail: See what conditions were in effect
- Historical Analysis: Understand past performance even if you’ve modified the rule
- Compliance: Maintain records of automated trading decisions
- Debugging: Identify why a rule triggered when you didn’t expect it
Best Practices
Combine Multiple Conditions
While the current implementation evaluates conditions independently, you can create multiple rules for the same instrument with different notification channels:Avoid Alert Fatigue
- Set meaningful thresholds that represent significant price movements
- Use percentage-based alerts for volatile assets
- Monitor activation history to tune your rules
- Disable rules during low-confidence periods
Test Before Deploying
- Create a rule with a notification channel you actively monitor
- Set conservative thresholds initially
- Review activation logs after 24-48 hours
- Adjust conditions based on trigger frequency
- Enable more aggressive rules once confident