Guide
Multiple targets (ladder)
Book profit in steps: exit part of a position at each target and move the stop-loss up as each one is hit.
A ladder trigger holds several targets (rungs) on a position you hold. Each rung can exit some units; the last exits the rest. Each rung hit moves the stop-loss up. Up to 20 rungs. 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": "ladder",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 10,
"product": "MIS"
}
],
"spec": {
"entry_px": 2500,
"targets": [
{
"price": "entry_px + 20",
"qty": 4
},
{
"price": "entry_px + 40",
"qty": 3
},
{
"price": "entry_px + 60"
}
],
"stop_loss": {
"init_sl": "entry_px - 25"
}
}
}'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": "ladder",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 10,
"product": "MIS",
},
],
"spec": {
"entry_px": 2500,
"targets": [
{
"price": "entry_px + 20",
"qty": 4,
},
{
"price": "entry_px + 40",
"qty": 3,
},
{
"price": "entry_px + 60",
},
],
"stop_loss": {
"init_sl": "entry_px - 25",
},
},
},
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": "ladder",
"legs": [
{
"instrument_token": "CT:TEST:RELIANCE",
"side": "BUY",
"quantity": 10,
"product": "MIS"
}
],
"spec": {
"entry_px": 2500,
"targets": [
{
"price": "entry_px + 20",
"qty": 4
},
{
"price": "entry_px + 40",
"qty": 3
},
{
"price": "entry_px + 60"
}
],
"stop_loss": {
"init_sl": "entry_px - 25"
}
}
}),
});
const body = await response.json();
console.log(response.status, body);- Rungs must move away from the entry in the profit direction (up for a buy, down for a sell).
- A rung without
qtyonly notifies you; the last rung always exits everything left. stop_loss.trail.steptrails the stop while no rung has been hit yet.