Modify OCO Order
You want the Overview/Key-benefits intro block adapted for Modify and Cancel individually, rather than one shared Overview covering all three. Here they are:
Overview
The Modify OCO Order API lets you update the trigger price, limit price, or quantity of an existing OCO order pair without cancelling and re-placing it. This is used when market conditions move and your original stop-loss/target levels need adjusting while keeping the same order pair active.
Key benefits:
- In-Place Adjustment: Update both legs of an existing OCO order in a single call instead of cancelling and placing a new pair.
- Re-Validated Against Live Market: The API re-checks that your updated trigger prices still straddle the current market price before accepting the change.
- Preserves Order Identity: The order keeps the same OCOid after modification, so downstream tracking and reconciliation remain unaffected.
Endpoint & Method
POST
/modifyOcoOrder
URL:
https://api.firstock.in/V1/modifyOcoOrderHeaders:
| Name | Value |
|---|---|
| Content-Type |
application/json |
Body:
| Field | Type | Mandatory | Description | Example |
|---|---|---|---|---|
| userId |
string |
Yes |
Unique identifier for |
AB1234 |
| jKey |
string |
Yes |
Active session token obtained from a successful login. |
6c83407h89jbt8om0n8... |
| exchange |
string |
Yes |
Exchange segment for |
NSE |
| tradingSymbol |
string |
Yes |
Trading symbol for |
VIKASECO-EQ |
| validity |
string |
No |
Order validity. Defaults |
GTT |
| ltp |
string |
No |
Last traded price to |
1.03 |
| OrderParamsLeg1 |
object |
Yes |
Parameters for the first |
- |
| OrderParamsLeg2 |
object |
Yes |
Parameters for the second leg |
- |
Request:
{
"userId": "{{userId}}",
"jKey": "{{jKey}}",
"OCOid": "26100600000035",
"exchange": "NSE",
"tradingSymbol": "VIKASECO-EQ",
"OrderParamsLeg1": {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"retention": "DAY",
"triggerPrice": "0.93",
"quantity": "1",
"price": "0.92"
},
"OrderParamsLeg2": {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"retention": "DAY",
"triggerPrice": "1.15",
"quantity": "1",
"targetPrice": "1.16"
}
}
Example Usage
curl --location 'https://api.firstock.in/V1/modifyOcoOrder' \
--header 'Content-Type: application/json' \
--data '{
"userId": "{{userId}}",
"jKey": "{{jKey}}",
"OCOid": "26100600000035",
"exchange": "NSE",
"tradingSymbol": "VIKASECO-EQ",
"OrderParamsLeg1": {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"triggerPrice": "0.93",
"quantity": "1",
"price": "0.92"
},
"OrderParamsLeg2": {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"triggerPrice": "1.15",
"quantity": "1",
"targetPrice": "1.16"
}
}'
from firstock import firstock
result = firstock.modifyOcoOrder(
userId="{{userId}}",
OCOid="{{OCOid}}",
exchange= "NSE",
tradingSymbol= "VIKASECO-EQ",
OrderParamsLeg1= {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"retention": "DAY",
"triggerPrice": "0.95",
"quantity": "1",
"price": "0.94"
},
OrderParamsLeg2= {
"transactionType": "S",
"priceType": "LMT",
"product": "C",
"retention": "DAY",
"triggerPrice": "1.18",
"quantity": "1",
"targetPrice": "1.20"
}
)
print(modifyOcoOrderData)
firstock.modifyOcoOrder(
{
userId: userDetails.userId,
OCOid: "26100800000049",
exchange: "NSE",
tradingSymbol: "VIKASECO-EQ",
OrderParamsLeg1: {
transactionType: "S",
priceType: "LMT",
product: "C",
triggerPrice: "0.93",
quantity: "1",
price: "0.92",
},
OrderParamsLeg2: {
transactionType: "S",
priceType: "LMT",
product: "C",
triggerPrice: "1.15",
quantity: "1",
targetPrice: "1.16",
},
},
(err, result) => {
console.log("modifyOcoOrder Error, ", err);
console.log("modifyOcoOrder Result: ", result);
}
);
import (
"github.com/the-firstock/firstock-developer-sdk-golang/Firstock"
)
modifyOcoOrderRequest := Firstock.ModifyOcoOrderRequest{
UserID: {{userId}},
Exchange: "NSE",
TradingSymbol: "VIKASECO-EQ",
OCOID: "{{OCOID}}",
OrderParamsLeg1: Firstock.OrderParamsLeg{
TransactionType: "S",
PriceType: "LMT",
Product: "C",
Retention: "DAY",
TriggerPrice: "0.95",
Quantity: "1",
Price: &price,
},
OrderParamsLeg2: Firstock.OrderParamsLeg{
TransactionType: "S",
PriceType: "LMT",
Product: "C",
Retention: "DAY",
TriggerPrice: "1.10",
Quantity: "1",
TargetPrice: &targetPrice,
},
}
modifyOcoOrder, err := Firstock.ModifyOcoOrder(modifyOcoOrderRequest)
fmt.Println("Error:", err)
fmt.Println("Result:", modifyOcoOrder)
Response
{
"status": "success",
"message": "OCO order modified",
"data": {
"OCOid": "26100600000035",
"Status": "OI replaced"
}
}
{
"status": "failed",
"code": "400",
"name": "BAD_REQUEST",
"error": {
"field": "triggerPrice",
"message": "One leg trigger price must be above LTP and the other below LTP"
}
}