createPriceRule
Creates a new price rule for monitoring cryptocurrency prices and triggering alerts based on specified conditions.
The price rule configuration Show PriceRuleInput fields
The name of the price rule
A description of what the price rule monitors
The ID of the cryptocurrency instrument to monitor (e.g., BTC/USDT)
Whether the rule is active. Defaults to true when created.
notificationChannel
NotificationChannelType
default: "NONE"
The channel to send notifications through when the rule triggers Options: NONE, SMS, EMAIL, WEBHOOK, TELEGRAM, PUSH_NOTIFICATION
conditions
PriceConditionInput[]
required
Array of conditions that must be met for the rule to trigger Show PriceConditionInput fields
The type of price condition to monitor Options:
PRICE - Absolute price threshold
PRICE_PERCENTAGE - Percentage change from a reference price
PRICE_ACTION - Price movement patterns
PRICE_CROSSOVER - Price crossing a moving average or other indicator
TECHNICAL_INDICATOR - Technical analysis indicators (RSI, SMA, EMA)
The threshold value for the condition
Additional configuration parameters for the condition (e.g., time period, indicator settings)
Returns
The created price rule object Unique identifier for the price rule
The name of the price rule
Description of the price rule
The cryptocurrency instrument being monitored
Whether the rule is currently active
The notification channel configured for this rule
Array of price conditions for this rule
Timestamp when the rule was last triggered
The price at which the rule was last triggered
Timestamp when the rule was created
Example
mutation {
createPriceRule (
input : {
name : "BTC Price Alert"
description : "Alert when Bitcoin drops below $60,000"
instrumentId : "550e8400-e29b-41d4-a716-446655440000"
isEnabled : true
notificationChannel : TELEGRAM
conditions : [
{
conditionType : PRICE
value : 60000.00
additionalValues : "{ \" direction \" : \" below \" }"
}
]
}
) {
id
name
description
isEnabled
instrument {
id
symbol
name
}
conditions {
conditionType
value
additionalValues
}
createdAt
}
}
After creating a price rule, the system automatically updates the WebSocket subscriptions to monitor the specified instrument in real-time.
updatePriceRule
Updates an existing price rule. You can modify the name, description, instrument, conditions, and notification settings.
The updated price rule configuration. Must include the id field to identify which rule to update. Show PriceRuleInput fields
The ID of the price rule to update
The updated name of the price rule
The instrument to monitor (can be changed to monitor a different cryptocurrency)
Whether the rule is active
The notification channel for alerts
conditions
PriceConditionInput[]
required
Updated array of conditions. This replaces all existing conditions.
Returns
The updated price rule object with all current values
Example
mutation {
updatePriceRule (
input : {
id : "123e4567-e89b-12d3-a456-426614174000"
name : "BTC Price Alert - Updated"
description : "Alert when Bitcoin drops below $55,000 or rises above $70,000"
instrumentId : "550e8400-e29b-41d4-a716-446655440000"
isEnabled : true
notificationChannel : TELEGRAM
conditions : [
{
conditionType : PRICE
value : 55000.00
additionalValues : "{ \" direction \" : \" below \" }"
},
{
conditionType : PRICE
value : 70000.00
additionalValues : "{ \" direction \" : \" above \" }"
}
]
}
) {
id
name
description
isEnabled
conditions {
conditionType
value
additionalValues
}
lastTriggeredAt
lastTriggeredPrice
}
}
The update mutation replaces all existing conditions with the new ones provided. Make sure to include all conditions you want to keep.
deletePriceRule
Deletes a price rule permanently. This action cannot be undone.
The unique identifier of the price rule to delete
Returns
The deleted price rule object. This is returned so you can confirm which rule was deleted or potentially restore it.
Example
mutation {
deletePriceRule ( id : "123e4567-e89b-12d3-a456-426614174000" ) {
id
name
description
}
}
When a price rule is deleted, it is also automatically removed from the in-memory rule cache and WebSocket subscriptions are updated accordingly.
togglePriceRule
Toggles the enabled state of a price rule. If the rule is currently enabled, it will be disabled, and vice versa.
The unique identifier of the price rule to toggle
Returns
The price rule object with the updated isEnabled state
Example
mutation {
togglePriceRule ( id : "123e4567-e89b-12d3-a456-426614174000" ) {
id
name
isEnabled
lastTriggeredAt
}
}
Toggling a price rule updates the rule cache and WebSocket subscriptions in real-time. When disabled, the rule will not trigger any alerts even if conditions are met.
Error Handling
All price rule mutations may throw the following errors:
“User not found” - The authenticated user could not be identified
“Instrument not found” - The specified instrumentId does not exist
“Price rule not found” - The specified price rule ID does not exist or does not belong to the current user (for update, delete, toggle operations)
“Error creating price rule” - A database or system error occurred during creation
“Error updating price rule” - A database or system error occurred during update
“Error deleting price rule” - A database or system error occurred during deletion
“Error enabling price rule” - A database or system error occurred during toggle
All price rule operations are scoped to the authenticated user. You can only modify or delete your own price rules.