Modify Smart Order
This API allows you to modify a pending smart order, such as its quantity, price limits or time settings.
USE CASE
Change the quantity, price limits or end time of a smart order without cancelling it.
Send only the fields you want to change.
Note
The smart order must be paused before it can be modified, except for SIP. Partial updates are supported.
- The order must be in a paused state to be modified (except SIP orders).
- Only include the parameters you want to update. All others will retain their original values.
- Certain parameters cannot be modified once the order has started executing.
Details
- You can modify a pending Smart Order by updating parameters such as quantity, price, and time settings, depending on the order type.
- Send the
flowIdplus the fields to change. The fields you can change depend on the order type: Limit (flowtype 4), Trail (6), Step (3) or SIP (7). - The usual flow is Pause, then Modify, then Resume. Pausing first is not needed for Smart Limit and SIP orders. Resuming is mandatory after a modification.
- Orders that are already executed, cancelled or cancelled by the system cannot be modified.
qtycannot be lower than the remaining quantity. It must be a multiple of the lot size and within the freeze limit.- For a Step order,
initQty,limitPriceandorderTypecannot be changed once the order has started. - For a Trail order, send
unsetTargetPriceas true to remove the target price.limitPriceis required for a Limit order and must be 0 for a Market order. - For a SIP, the frequency cannot change, and an amount-based SIP cannot be switched to quantity-based or the other way round.
- Rate limits differ between the Standard and Prime plans. See Plans & rate limits.
Request Attributes
| Attribute | Data Type | Required | Description |
|---|---|---|---|
flowId | string | Yes | Unique identifier of the Smart Order to be modified |
Optional Request Attributes (by Order Type)
Limit Order (flowtype: 4)
| Attribute | Data Type | Description |
|---|---|---|
qty | int | To update order quantity |
limitPrice | float | To update limit price |
stopPrice | float | To update stop/trigger price |
endTime | int | To update expiry time (Unix timestamp) |
hpr | float | To update upper price limit (High Price Range) |
lpr | float | To update lower price limit (Low Price Range) |
mpp | float | To update market protection percentage |
onExp | int | To update expiry action (1 = Cancel, 2 = Market Order) |
Trail Order (flowtype: 6)
| Attribute | Data Type | Description |
|---|---|---|
qty | int | To update order quantity |
limitPrice | float | To update limit price (required if orderType = 1; must be 0 if orderType = 2) |
stopPrice | float | To update stop/trigger price |
jump_diff | float | To update jump value for trailing stop |
target_price | float | To update target price (optional profit booking) |
unsetTargetPrice | boolean | Set true to remove/unset the existing target_price |
mpp | float | To update market protection percentage |
Step Order (flowtype: 3)
| Attribute | Data Type | Description |
|---|---|---|
qty | int | To update total order quantity |
startTime | int | To update order start time |
endTime | int | To update order end time |
hpr | float | To update upper price limit (High Price Range) |
lpr | float | To update lower price limit (Low Price Range) |
mpp | float | To update market protection percentage |
avgqty | int | To update quantity per averaging step |
avgdiff | float | To update price gap between steps |
initQty | int | To update initial quantity (only before order starts) |
limitPrice | float | To update limit price (only before order starts) |
direction | int | To update direction for averaging (1 = price drop, -1 = price rise) |
SIP Order (flowtype: 7)
| Attribute | Data Type | Description |
|---|---|---|
qty | int | To update investment quantity per instalment |
amount | float | To update investment amount per instalment |
hpr | float | To update upper price limit (skip if price is above this) |
lpr | float | To update lower price limit (skip if price is below this) |
sip_day | int | To update SIP day (applicable for monthly/custom frequency) |
sip_time | int | To update SIP time (required for daily/custom frequency) |
step_up_amount | float | To update step-up amount (amount-based SIP only) |
step_up_qty | int | To update step-up quantity (qty-based SIP only) |
exp_qty | int | To update expiry quantity (optional) |
exp_amount | float | To update expiry amount (optional) |
Validations & Error Handling
General Validations
| Scenario | Error Message |
|---|---|
| Invalid flowid | "The provided smart order ID is invalid." |
| Invalid request payload | "The input details entered is invalid." |
| Invalid order type | "Invalid Order type" |
| Order not paused (v3) | "The smart order must be paused before it can be modified." |
| Order already executed | "The modification attempt failed as the smart order was already executed." |
| Order already cancelled | "The modification attempt failed as the smart order was already cancelled." |
| Order cancelled by system | "The modification attempt failed as the smart order cancelled by system" |
| Qty < remaining qty | "Modification attempt failed as the specified quantity is less than the remaining quantity." |
| Qty not multiple of lot size | "Quantity should be multiple of min lot size." |
| Qty exceeds freeze limit | "Quantity exceeds the allowable freeze limit." |
| Field not allowed | "Amount field is not allowed." |
| SIP: changing frequency | "SIP frequency cannot be changed. Please use the same frequency as the existing order." |
| SIP: changing amount->qty | "Cannot change from amount-based SIP to qty-based SIP. Please use amount to modify this order." |
| SIP: changing qty->amount | "Cannot change from qty-based SIP to amount-based SIP. Please use qty to modify this order." |
Limit Order Validations (flowtype: 4)
| Attribute | Validation Rule | Error Message |
|---|---|---|
endTime | Must be within market hours | "End time cannot fall within market closed hours." |
endTime | Must not be in the past | "The end time entered is earlier than the current time." |
endTime | Must be within current day | "The end time cannot extend beyond midnight of the current day." |
hpr (buy) | If provided (>0), must be >= limitPrice | "The maximum price must be higher than the limit price." |
lpr (sell) | If provided (>0), must be <= limitPrice | "The minimum price must be lower than the limit price." |
stopPrice (buy) | If orderType=4, must be < limitPrice | "For buy orders, the stop price must be lower than the limit price." |
stopPrice (sell) | If orderType=4, must be > limitPrice | "For sell orders, the stop price must be higher than the limit price." |
mpp | Must be 0-3 or -1 (disabled) | "MPP must be either -1 or a value between 0 to 3% (0 to 3)." |
Trail Order Validations (flowtype: 6)
| Attribute | Validation Rule | Error Message |
|---|---|---|
stopPrice | Required for trail orders | "Stop Price is required to place orders." |
limitPrice | Required when orderType=1 (Limit) | "Limit price is required." |
limitPrice (buy) | If orderType=1, must be < stopPrice | "For buy orders, the stop price must be lower than the limit price." |
limitPrice (sell) | If orderType=1, must be > stopPrice | "For sell orders, the stop price must be higher than the limit price." |
target_price | If provided (>0), must be > current LTP | "The target price must be greater than the last traded price." |
jump_diff | Must be > 20× tick size | "The jump price must be more than 20 times the tick size." |
mpp | Must be 0-3 or -1 (disabled) | "MPP must be either -1 or a value between 0 to 3% (0 to 3)." |
Step Order Validations (flowtype: 3)
| Attribute | Validation Rule | Error Message |
|---|---|---|
startTime | Not allowed in modify request | "Start time is not required for modify orders." |
startTime | Must not be in the past | "The start time entered is earlier than the current time." |
startTime | Must be within market hours | "Start time cannot fall within market closed hours." |
endTime | Must not be in the past | "The end time entered is earlier than the current time." |
endTime | Must be within market hours | "End time cannot fall within market closed hours." |
avgqty | Must be multiple of lot size | "Avg quantity should be multiple of min lot size." |
initQty | Cannot modify after order starts | "You cannot modify the initial quantity after the order has been placed." |
limitPrice | Cannot modify after order starts | "You cannot modify the Limit price after the order has been placed." |
orderType | Cannot modify after order starts | "You cannot modify the order type after the order has been placed." |
qty | Total qty >= initQty + avgQty | "Total Quantity should be greater than or equal to the sum of Initial Qty and Average Qty." |
mpp | Must be 0-3 or -1 (disabled) | "MPP must be either -1 or a value between 0 to 3% (0 to 3)." |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
code | int | Status code: 200 for success; negative values indicate errors. |
message | string | Message indicating success or failure. Example: "Request sent successfully to modify smart order." |
s | string | "ok" for success, "error" for failure. |
Last updated on