Guide
Entry trigger with a bracket
Wait for a price or condition to enter, then manage the trade with a target, a stop-loss and a trailing stop.
A bracket trigger can wait for an entry condition. When it holds, the entry price becomes that tick’s price and the target and stop-loss take over. Needs the triggers scope.
curl -X POST "https://cirrus.pocketful.in/v2/triggers" \
-H "Authorization: token $CIRRUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"account": "P1",
"kind": "bracket",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 5,
"product": "MIS"
}
],
"spec": {
"entry": {
"when": "ltp >= 2520"
},
"target": {
"when": "ltp >= entry_px * 1.02"
},
"stop_loss": {
"init_sl": "entry_px - 25",
"trail": {
"step": "5"
}
}
}
}'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": "bracket",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 5,
"product": "MIS",
},
],
"spec": {
"entry": {
"when": "ltp >= 2520",
},
"target": {
"when": "ltp >= entry_px * 1.02",
},
"stop_loss": {
"init_sl": "entry_px - 25",
"trail": {
"step": "5",
},
},
},
},
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": "bracket",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 5,
"product": "MIS"
}
],
"spec": {
"entry": {
"when": "ltp >= 2520"
},
"target": {
"when": "ltp >= entry_px * 1.02"
},
"stop_loss": {
"init_sl": "entry_px - 25",
"trail": {
"step": "5"
}
}
}
}),
});
const body = await response.json();
console.log(response.status, body);What happens #
- The trigger waits (
pending) untilentry.whenholds. entry_pxbecomes that tick’s last price; the trigger isactive.- The stop starts at
init_sland moves up bystepas the price rises. It never loosens. - Target hit (
target_hit) or stop hit (sl_hit): everything is exited at market.
Follow every step of a trigger (armed, entered, stop moved, exited) with GET /v2/triggers/{trigger_id}/journey.