Super Order
dhanhq._super_order
Classes
SuperOrder
SuperOrder(dhan_context)
Interface to manage Dhan 'Super Orders', which are composite trading orders that include multiple legs: ENTRY_LEG, TARGET_LEG, and STOP_LOSS_LEG.
These allow users to define entry, target, and stop-loss instructions as a bundled strategy.
Functions
cancel_super_order
cancel_super_order(order_id, order_leg)
Cancel a super order or a specific leg.
Cancelling the main order ID cancels all legs. If a target or stop-loss leg is cancelled individually, it cannot be added again later.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_id |
str
|
The ID of the order to cancel (required). |
required |
order_leg |
str
|
The leg to cancel: ENTRY_LEG, TARGET_LEG, or STOP_LOSS_LEG. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
API response indicating cancellation status. |
Raises:
Type | Description |
---|---|
ValueError
|
If parameters are missing or invalid. |
get_super_order_list
get_super_order_list()
Retrieve a list of all live/requested super orders with their latest status.
Returns:
Name | Type | Description |
---|---|---|
dict |
The API response containing the list of super orders and their status. |
modify_super_order
modify_super_order(order_id, order_type, leg_name, quantity=0, price=0.0, targetPrice=0.0, stopLossPrice=0.0, trailingJump=0.0)
Modify a pending super order leg.
Super orders consist of three possible legs: ENTRY_LEG, TARGET_LEG, STOP_LOSS_LEG. Based on the leg_name provided, this modifies only the respective leg parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_id |
str
|
ID of the order to modify (required). |
required |
order_type |
str
|
Order type (e.g., LIMIT, MARKET). |
required |
leg_name |
str
|
Must be one of ENTRY_LEG, TARGET_LEG, STOP_LOSS_LEG. |
required |
quantity |
int
|
Updated quantity (for ENTRY_LEG). |
0
|
price |
float
|
Updated price (for ENTRY_LEG). |
0.0
|
targetPrice |
float
|
Target price (for ENTRY_LEG or TARGET_LEG). |
0.0
|
stopLossPrice |
float
|
Stop loss price (for ENTRY_LEG or STOP_LOSS_LEG). |
0.0
|
trailingJump |
float
|
Trailing jump trigger (for ENTRY_LEG or STOP_LOSS_LEG). |
0.0
|
Returns:
Name | Type | Description |
---|---|---|
dict |
The API response with update status. |
Raises:
Type | Description |
---|---|
ValueError
|
If leg_name or order_id is missing or invalid. |
place_super_order
place_super_order(security_id, exchange_segment, transaction_type, quantity, order_type, product_type, price, targetPrice, stopLossPrice, trailingJump, tag)
Place a new Super Order on Dhan platform with entry, target and stop-loss legs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
security_id |
str
|
Instrument/security ID (required). |
required |
exchange_segment |
str
|
Exchange (e.g., NSE, BSE). |
required |
transaction_type |
str
|
BUY or SELL. |
required |
quantity |
int
|
Order quantity (> 0). |
required |
order_type |
str
|
LIMIT, MARKET, etc. |
required |
product_type |
str
|
CNC, INTRA, etc. |
required |
price |
float
|
Entry price. |
required |
targetPrice |
float
|
Target price. |
required |
stopLossPrice |
float
|
Stop loss price. |
required |
trailingJump |
float
|
Trailing SL value. |
required |
tag |
str
|
Optional correlation ID or tracking label. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
The response containing the order placement status. |
Raises:
Type | Description |
---|---|
ValueError
|
If mandatory inputs are missing or logically invalid. |