Guide
Price and indicator alerts
Get told when a price, a tick field or an indicator crosses a level, on Telegram, in the app or at your webhook.
An alert trigger watches every tick and notifies you once its condition holds, then ends. It never places an order. Needs the triggers scope.
A price alert #
curl -X POST "https://cirrus.pocketful.in/v2/triggers" \
-H "Authorization: token $CIRRUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"account": "P1",
"kind": "alert",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 1
}
],
"spec": {
"when": "ltp >= 2600"
}
}'import os
import requests
response = requests.post(
"https://cirrus.pocketful.in/v2/triggers",
headers={
"Authorization": f"token {os.environ['CIRRUS_API_KEY']}",
},
json={
"account": "P1",
"kind": "alert",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 1,
},
],
"spec": {
"when": "ltp >= 2600",
},
},
timeout=10,
)
print(response.status_code, response.json())const response = await fetch('https://cirrus.pocketful.in/v2/triggers', {
method: 'POST',
headers: {
Authorization: `token ${process.env.CIRRUS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"account": "P1",
"kind": "alert",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 1
}
],
"spec": {
"when": "ltp >= 2600"
}
}),
});
const body = await response.json();
console.log(response.status, body);The answer is 202 with the new trigger_id. Read it with GET /v2/triggers/{trigger_id}: state is submitted until the engine takes it, and fired once the alert went off.
Write the condition #
Conditions are short expressions over tick fields: ltp, bid, ask, volume, oi, high, low and prev.ltp (the previous tick). Combine them with &&, || and comparisons.
| You want | Condition |
|---|---|
| Price at or above 2,600 | ltp >= 2600 |
| Price crosses above 2,600 | crosses_above(ltp, 2600) |
| Buyers outnumber sellers | bid_qty > ask_qty * 2 |
| After 2:30 pm only | ltp >= 2600 && now_ist >= 870 |
| RSI(14) on 5-minute candles below 30 | rsi(14, '5m') < 30 |
Where the alert goes #
Alerts arrive on the channels in your notification preferences: Telegram, the app inbox and your webhooks (notification event). See Webhooks and notifications.