Skip to main content

Kill Switch

API to enable or disable one or more trading segments in a single request. The kill switch is a risk management tool that lets traders temporarily halt activity in specific segments to avoid emotionally-driven or compulsive trading decisions. When a segment is disabled, all pending orders in that segment are cancelled and new orders are blocked.

For more information on the kill switch and how it helps with trade risk management, click here.

Before using the kill switch
  • All open positions in a segment must be closed before you can disable it.
  • After disabling a segment, a 12-hour cooling period applies before it can be re-enabled.
  • All open orders in the segment are cancelled automatically when it is disabled.
  • If your given segment is inactive or dormant kill switch cannot be enabled as trading is already blocked. You can only enable kill switch for segments that are currently active.

Request

curl --location 'https://api.upstox.com/v2/user/kill-switch' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}' \
--data '[
{
"segment": "NSE_FO",
"action": "DISABLE"
},
{
"segment": "NSE_EQ",
"action": "DISABLE"
},
{
"segment": "NCD_FO",
"action": "ENABLE"
}
]'

Additional samples in various languages are available in the Sample Code section on this page.

Request Body

The request body is an array of segment update objects. You can update multiple segments in a single call.

NameTypeRequiredDescription
segmentstringYesTrading segment to update. Possible values: BSE_EQ, NSE_EQ, NCD_FO, BCD_FO, NSE_FO, BSE_FO, MCX_FO, NSE_COM
actionstringYesAction to perform. Possible values: ENABLE, DISABLE
Atomic update behaviour

If any segment in the request fails to update, none of the other segments in the same request will be updated.

Responses

Response Body

{
"status": "success",
"data": [
{
"segment": "MCX_FO",
"segment_status": "INACTIVE",
"kill_switch_enabled": false
},
{
"segment": "NCD_FO",
"segment_status": "ACTIVE",
"kill_switch_enabled": false
},
{
"segment": "NSE_EQ",
"segment_status": "ACTIVE",
"kill_switch_enabled": true
},
{
"segment": "BCD_FO",
"segment_status": "ACTIVE",
"kill_switch_enabled": false
},
{
"segment": "BSE_FO",
"segment_status": "ACTIVE",
"kill_switch_enabled": false
},
{
"segment": "NSE_FO",
"segment_status": "ACTIVE",
"kill_switch_enabled": true
},
{
"segment": "BSE_EQ",
"segment_status": "ACTIVE",
"kill_switch_enabled": true
},
{
"segment": "NSE_COM",
"segment_status": "INACTIVE",
"kill_switch_enabled": false
}
]
}
NameTypeDescription
statusstringOutcome of the request. Possible values: success, error
dataarrayUpdated kill switch status for each requested segment
data[].segmentstringExchange segment identifier (e.g. NSE_EQ, BSE_FO, MCX_FO)
data[].segment_statusstringThis is an account-level segment status and it remains independent of the kill switch. Activating the kill switch will block trading, but it will not change the segment's status between ACTIVE and INACTIVE.
data[].kill_switch_enabledbooleantrue if the kill switch is now engaged for this segment

Sample Code

Disable a trading segment using the kill switch

import requests
import json

url = 'https://api.upstox.com/v2/user/kill-switch'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
payload = [
{
"segment": "NSE_EQ",
"action": "DISABLE"
}
]
response = requests.post(url, headers=headers, data=json.dumps(payload))

print(response.status_code)
print(response.json())
Loading...