Skip to content

Trader's Control

These set of APIs are built for traders to manage their risks and preferences using advanced tools built in right into Dhan. You can set and manage Kill Switch for your account along with having P&L based auto-exit feature.

POST /killswitch Manage Kill Switch
GET /killswitch Kill Switch Status
PUT /pnlExit Configure P&L Based Exit
DELETE /pnlExit Stop P&L Based Exit
GET /pnlExit Get P&L Based Exit

Manage Kill Switch

This API lets you activate the kill switch for your account, which will disable trading for current trading day. You can pass header parameter as ACTIVATE or DEACTIVATE to manage Kill Switch settings.

Note

You need to ensure that all your positions are closed and there are no pending orders in your account to be able to activate Kill Switch.

curl --request POST \
--url 'https://api.dhan.co/v2/killswitch?killSwitchStatus=ACTIVATE' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

{
    "dhanClientId":"1000000009",
    "killSwitchStatus": "Kill Switch has been successfully activated"
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
killSwitchStatus string Status of Kill Switch - activated or not


Note: For description of enum values, refer Annexure

Kill Switch Status

The API allows you to check kill switch status for your account - whether it is active for the current trade or not.

curl --request GET \
--url https://api.dhanuat.co/v2/killswitch \
--header 'Accept: application/json' \
--header 'access-token:'


Request Structure

No Body

Response Structure

{
    "dhanClientId":"1000000009",
    "killSwitchStatus": "ACTIVATE"
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
killSwitchStatus string Status of Kill Switch ACTIVATE DEACTIVATE

P&L Based Exit

The P&L Based Exit API allows users to configure automatic exit rules based on cumulative profit or loss thresholds. When the defined limits are breached, all applicable positions are exited.

Note

The configured P&L based exit remains active for the current day and is reset at the end of the trading session.

curl --request POST \
  --url https://api.dhan.co/v2/pnlExit \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'access-token: ' \
  --data '{Request Body}'

Request Structure

{
    "profitValue": "1500.00",
    "lossValue": "500.00",
    "productType": ["INTRADAY", "DELIVERY"],
    "enableKillSwitch": true
}

Response Structure

{
    "pnlExitStatus": "ACTIVE",
    "message": "P&L based exit configured successfully"
}

Parameters

Parameter Data Type Description
pnlExitStatus string P&L based exit configured successfully
ACTIVE INACTIVE
message string Status of Conditional Trigger

Warning

In case of profitValue set below the current Profit in P&L, then the P&L based exit will be triggered immediately. This applies to lossValue set above the current Loss in P&L as well.


Stop P&L Based Exit

Disable the active P&L based exit configuration.

curl --request DELETE \
  --url https://api.dhan.co/v2/pnlExit \
  --header 'Accept: application/json' \
  --header 'access-token: '

Request Structure

No Body

Response Structure

{
    "pnlExitStatus": "DISABLED",
    "message": "P&L based exit stopped successfully"
}
Parameters

Parameter Data Type Description
pnlExitStatus string P&L based exit configured successfully
ACTIVE INACTIVE
message string Status of Conditional Trigger

Get P&L Based Exit

Fetch the currently active P&L based exit configuration for the current trading day.

curl --request GET \
  --url https://api.dhan.co/v2/pnlExit \
  --header 'Accept: application/json' \
  --header 'access-token: '

Request Structure

No Body

Response Structure

{
    "pnlExitStatus": "ACTIVE",
    "profit": "1500.00",
    "loss": "500.00",
    "segments": ["INTRADAY", "DELIVERY"],
    "enable_kill_switch": true
}
Parameters

Parameter Data Type Description
pnlExitStatus string Current status of the P&L exit operation
ACTIVE INACTIVE
profit float User-defined target profit amount for the P&L exit
loss float User-defined target loss amount for the P&L exit
enableKillSwitch boolean Indicates if the kill switch is enabled for this P&L exit
productType string Product types applicable for the P&L exit
INTRADAY DELIVERY


Note: For description of enum values, refer Annexure