Understanding Price Rules
A price rule consists of:- Name: A descriptive identifier for your rule
- Description: Optional details about the rule’s purpose
- Instrument: The cryptocurrency pair to monitor (e.g., BTCUSDT, ETHUSDT)
- Conditions: One or more conditions that trigger the alert
- Status: Enabled or disabled
Condition Types
PriceSignal supports five types of price conditions:| Type | Description | Example |
|---|---|---|
PRICE | Triggers when price reaches a specific value | BTC reaches $50,000 |
PRICE_PERCENTAGE | Triggers on percentage change | ETH drops 5% |
PRICE_ACTION | Monitors price movement patterns | Price crosses moving average |
PRICE_CROSSOVER | Detects when price crosses a threshold | Price breaks above resistance |
TECHNICAL_INDICATOR | Uses technical indicators | RSI exceeds 70 |
Creating a Price Rule
Authenticate your request
All rule operations require authentication. Ensure you have a valid JWT token from Firebase.
Choose your instrument
Get the instrument ID for the cryptocurrency pair you want to monitor:Supported pairs: BTCUSDT, ETHUSDT (configurable via backend)
Define your conditions
Create one or more conditions for your rule. Each condition requires:
conditionType: The type of conditionvalue: The threshold or target valueadditionalValues: JSON string with extra parameters
Implementation Details
ThecreatePriceRule mutation is implemented in src/PriceSignal/GraphQL/Mutations/PriceRuleMutations.cs:18-65:
Updating a Price Rule
Modify existing rules using theupdatePriceRule mutation:
Enabling/Disabling Rules
Toggle rule status without modifying conditions:isEnabled between true and false, and updates the rule cache and Binance subscriptions automatically.
Deleting a Price Rule
Permanently remove a rule:Querying Your Rules
Retrieve all rules for the authenticated user:Example: Complete Rule Creation
Here’s a complete example creating a rule that alerts when ETH drops 5%:How Rules Are Monitored
Once created, your rules are:- Stored in the database for persistence
- Loaded into RuleCache for fast evaluation
- Monitored by BinancePriceFetcherService which:
- Subscribes to real-time price feeds from Binance
- Evaluates conditions on every price update
- Triggers notifications when conditions are met
Best Practices
- Use descriptive names to easily identify rules
- Start with simple conditions before creating complex multi-condition rules
- Disable rules you don’t need instead of deleting them
- Test rules with price thresholds you expect to be reached soon
- Monitor notification channels to ensure alerts are being delivered
Next Steps
Telegram Setup
Configure Telegram to receive your alerts
Real-time Charts
Visualize price movements with live charts