Forever Order
Users can create and manage Forever Orders or Good Till Triggered orders using this set of APIs.
POST | /forever/orderEntry | Create Forever Order |
POST | /forever/orderModify | Modify existing Forever Order |
DELETE | /forever/{order-id} | Cancel existing Forever Order |
GET | /forever/all | Retrieve an array of all existing forever orders |
forever_order | Create Forever Order |
forever_modify | Modify existing Forever Order |
forever_delete | Cancel existing Forever Order |
forever_order_list | Retrieve an array of all existing forever orders |
Create Forever Order
This API helps you create a new Forever Order.
curl --request POST \
--url https://api.dhan.co/forever/orderEntry \
--header 'Content-Type: application/json' \
--header 'access-token: ' \
--data '{Request JSON}'
dhan.forever_order(data)
Request structure
{
"dhanClientId": "1000000132",
"correlationId": "",
"orderFlag": "OCO",
"transactionType": "BUY",
"exchangeSegment": "NSE_EQ",
"productType": "CNC",
"orderType": "LIMIT"
"validity": "DAY",
"tradingSymbol": "HDFCBANK",
"securityId": "1333",
"quantity": 5,
"disclosedQuantity": 1,
"price": 1428,
"triggerPrice": 1427,
"price1": 1420,
"triggerPrice1": 1419,
"quantity1": 10
}
dhan.forever_order(
tag='',
order_flag='SINGLE',
transaction_type=dhan.BUY,
exchange_segment=dhan.NSE,
product_type=dhan.CNC,
order_type=dhan.LIMIT
validity=dhan.DAY,
security_id='1333',
quantity=5,
disclosed_quantity=1,
price=1428,
trigger_price=1427,
price1=1420,
trigger_price1=1419,
quantity1=10
)
Parameters
Field | Type | Description |
dhanClientId required |
string | User specific identification generated by Dhan |
correlationId | string | The user/partner generated id for tracking back |
order_flag required |
string | Order Flag OCO for OCO order and SINGLE for Forever OrderSINGLE
OCO |
transactionType required |
string | The trading side of transaction BUY
SELL |
exchangeSegment required |
string | Exchange & SegmentNSE_EQ
NSE_FNO
NSE_CURRENCY
BSE_EQ
MCX_COMM |
productType required |
string | Product typeCNC
INTRADAY
MARGIN
CO
BO |
orderType required |
enum string | Order TypeLIMIT
MARKET
STOP_LOSS
STOP_LOSS_MARKET |
validity required |
string | Validity of OrderDAY
IOC |
tradingSymbol | string | Refer Trading Symbol in Tables |
securityId required |
string | Exchange standard id for each scrip. Refer here |
quantity required |
int | Number of shares for the order |
disclosedQuantity | int | Number of shares visible (Keep more than 30% of quantity) |
price required |
float | Price at which order is placed |
triggerPrice required |
float | Price at which order is to be triggered |
price1 conditionally required |
float | Target price for OCO order |
triggerPrice1 conditionally required |
float | Target trigger price For OCO order |
quantity1 conditionally required |
integer | Target Quantity for OCO order |
Field | Type | Description |
tag | string | The user/partner generated id for tracking back |
order_flag required |
string | Order Flag OCO for OCO order and SINGLE for Forever OrderSINGLE
OCO |
transaction_type required |
string | The trading side of transaction BUY
SELL |
exchange_segment required |
string | Exchange & SegmentNSE_EQ
NSE_FNO
NSE_CURRENCY
BSE_EQ
MCX_COMM |
product_type required |
string | Product typeCNC
INTRADAY
MARGIN
CO
BO |
order_type required |
enum string | Order TypeLIMIT
MARKET
STOP_LOSS
STOP_LOSS_MARKET |
validity required |
string | Validity of OrderDAY
IOC |
security_id required |
string | Exchange standard id for each scrip. Refer here |
quantity required |
int | Number of shares for the order |
disclosed_quantity | int | Number of shares visible (Keep more than 30% of quantity) |
price required |
float | Price at which order is placed |
trigger_price required |
float | Price at which order is to be triggered |
price1 conditionally required |
float | Target price for OCO order |
trigger_price1 conditionally required |
float | Target trigger price For OCO order |
quantity1 conditionally required |
integer | Target Quantity for OCO order |
Response Structure
{
"orderId": "5132208051112",
"orderStatus": "PENDING"
}
Parameters
Field | Type | Description |
orderId | string | Order specific identification generated by Dhan |
orderStatus | string | Order StatusTRANSIT
PENDING
REJECTED
CANCELLED
TRADED
EXPIRED
CONFIRM
|
Modify Forever Order
Users can take use of this API to make changes to already created forever orders. The variables that can be modified are price, quantity, order type, disclosed quantity, trigger price & validity.
curl --request POST \
--url https://api.dhan.co/forever/orderModify \
--header 'Content-Type: application/json' \
--header 'access-token: ' \
--data '{Request JSON}'
dhan.forever_modify(data)
Requested Structure
{
"dhanClientId": "1000000132",
"orderId": "5132208051112",
"orderType": "LIMIT",
"legName": "ENTRY_LEG",
"quantity": 15,
"price": 1421,
"disclosedQuantity":1,
"triggerPrice": 1420,
"validity": "DAY"
}
dhan.forever_modify(
order_id='5132208051112',
order_type=dhan.LIMIT,
leg_name='ENTRY_LEG',
quantity=15,
price=1421,
trigger_price=1420,
disclosed_quantity=1,
validity=dhan.DAY
)
Parameters
Field | Type | Description |
dhanClientId required |
string | User specific identification generated by Dhan |
orderId required |
enum string | Order specific identification generated by Dhan |
orderType required |
enum string | Order TypeLIMIT
MARKET
STOP_LOSS
STOP_LOSS_MARKET |
legName required |
string | Order leg of Forever Order where modification is to be doneENTRY_LEG - For Single and First leg of OCO TARGET_LEG - For Second leg of OCO
|
quantity required |
int | Number of shares for the order |
price required |
float | Price at which order is placed |
disclosedQuantity | int | Number of shares visible (Keep more than 30% of quantity) |
triggerPrice required |
float | Price at which order is to be triggered |
validity required |
string | Validity of OrderDAY
IOC |
Field | Type | Description |
order_id required |
enum string | Order specific identification generated by Dhan |
order_type required |
enum string | Order TypeLIMIT
MARKET
STOP_LOSS
STOP_LOSS_MARKET |
leg_name
required |
string | Order leg of Forever Order where modification is to be doneENTRY_LEG - For Single and First leg of OCO TARGET_LEG - For Second leg of OCO
|
quantity required |
int | Number of shares for the order |
price required |
float | Price at which order is placed |
disclosed_quantity | int | Number of shares visible (Keep more than 30% of quantity) |
trigger_price required |
float | Price at which order is to be triggered |
validity required |
string | Validity of OrderDAY
IOC |
Response Structure
{
"orderId": "5132208051112",
"orderStatus": "PENDING"
}
Parameters
Field | Type | Description |
orderId | string | Order specific identification generated by Dhan |
orderStatus | string | Last updated status of the orderTRANSIT
PENDING
REJECTED
CANCELLED
TRADED
EXPIRED
CONFIRM
|
Delete Forever Order
This API lets you delete pending Forever Order using the Order ID.
curl --request DELETE \
--url https://api.dhan.co/forever/{order-id} \
--header 'Content-Type: application/json' \
--header 'access-token: '
dhan.forever_delete(order_id)
Request Structure
No Body
Response Structure
{
"orderId": "5132208051112",
"orderStatus": "CANCELLED"
}
Parameters
Field | Type | Description |
orderId | string | Order specific identification generated by Dhan |
orderStatus | string | Order StatusTRANSIT
PENDING
REJECTED
CANCELLED
TRADED
EXPIRED
CONFIRM
|
All Forever Order Detail
Users can retrieve an array of all existing Forever Orders in their account using this API.
curl --request GET \
--url https://api.dhan.co/forever/all \
--header 'Content-Type: application/json' \
--header 'access-token: ' \
dhan.forever_order_list()
Request Structure
No Body
Response Structure
[
{
"dhanClientId": "1000000132",
"orderId": "1132208051115",
"orderStatus": "CONFIRM",
"transactionType": "BUY",
"exchangeSegment": "NSE_EQ",
"productType": "CNC",
"orderType": "SINGLE",
"tradingSymbol": "HDFCBANK",
"securityId": "1333",
"quantity": 10,
"price": 1428,
"triggerPrice": 1427,
"legName": "ENTRY_LEG",
"createTime": "2022-08-05 12:41:19",
"updateTime": null,
"exchangeTime": null,
"drvExpiryDate": null,
"drvOptionType": null,
"drvStrikePrice": 0
}
]
Parameters
Field | Type | Description |
dhanClientId | string | User specific identification generated by Dhan |
orderId | string | Order specific identification generated by Dhan |
orderStatus | enum string | Last updated status of the orderTRANSIT
PENDING
REJECTED
CANCELLED
TRADED
EXPIRED
CONFIRM
|
transactionType | enum string | The trading side of transactionBUY
SELL |
exchangeSegment | enum string | Exchange & Segment NSE_EQ NSE_FNO NSE_CURRENCY BSE_EQ MCX_COMM |
productType | enum string | Product type of tradeCNC INTRADAY MARGIN CO BO |
orderType | enum string | Order TypeSINGLE
OCO
|
tradingSymbol | string | Refer Trading Symbol in Tables |
securityId | string | Exchange standard id for each scrip. Refer here |
quantity | int | Number of shares for the order |
price | float | Price at which order is placed |
triggerPrice | float | Price at which order is to be triggered |
legName | string | Order TypeENTRY_LEG
STOP_LOSS_LEG
TARGET_LEG
NA |
createTime | string | Time at which the Forever Order is created |
updateTime | string | Time at which the Forever Order is updated |
exchangeTime | string | Time at which order reached at exchange end |
drvExpiryDate | string | Contract Expiry Date for F&O |
drvOptionType | enum string | Type of OptionCALL PUT |
drvStrikePrice | float | Strike Price for Options |
Note: For description of enum values, refer Annexure