Class: DhanHQ::Models::KillSwitch
- Defined in:
- lib/DhanHQ/models/kill_switch.rb
Overview
Important: Before activating the kill switch, you must ensure that all your positions are closed and there are no pending orders in your account. The kill switch will not activate if there are open positions or pending orders.
Model for managing the trading kill switch feature.
The Kill Switch API lets you activate or deactivate the kill switch for your account, which will disable trading for the current trading day. This is a safety feature that can be used to prevent further trading activity when needed.
Constant Summary collapse
- HTTP_PATH =
Base path used by the kill switch resource.
"/v2/killswitch"
Constants included from ResponseHelper
ResponseHelper::STATUS_ERROR_FALLBACK
Instance Attribute Summary
Attributes inherited from BaseModel
Class Method Summary collapse
-
.activate ⇒ Hash{Symbol => String}
Activates the kill switch for your trading account.
-
.deactivate ⇒ Hash{Symbol => String}
Deactivates the kill switch for your trading account.
-
.resource ⇒ DhanHQ::Resources::KillSwitch
Provides a shared instance of the KillSwitch resource.
-
.status ⇒ Hash{Symbol => String}
Fetches the current kill switch status for your account.
-
.update(status) ⇒ Hash{Symbol => String}
Updates the kill switch status with the specified action.
Methods inherited from BaseModel
all, api, api_type, #assign_attributes, attributes, create, #delete, #destroy, find, #id, #initialize, #new_record?, #optionchain_api?, parse_collection_response, #persisted?, resource_path, #save, #save!, #to_request_params, #update, #valid?, validate_attributes, validation_contract, #validation_contract, where
Methods included from APIHelper
Methods included from AttributeHelper
#camelize_keys, #inspect, #normalize_keys, #snake_case, #titleize_keys
Methods included from ValidationHelper
#valid?, #validate!, #validate_params!
Methods included from RequestHelper
Constructor Details
This class inherits a constructor from DhanHQ::BaseModel
Class Method Details
.activate ⇒ Hash{Symbol => String}
Prerequisites: All positions must be closed and there must be no pending orders in your account before activation. The API will reject the activation request if these conditions are not met.
Activates the kill switch for your trading account.
Disables trading for the current trading day. All trading operations will be blocked until the kill switch is deactivated. This is a safety feature to prevent further trading activity.
107 108 109 |
# File 'lib/DhanHQ/models/kill_switch.rb', line 107 def activate update("ACTIVATE") end |
.deactivate ⇒ Hash{Symbol => String}
Deactivates the kill switch for your trading account.
Re-enables trading for your account. After deactivation, you can resume placing orders and executing trades normally.
132 133 134 |
# File 'lib/DhanHQ/models/kill_switch.rb', line 132 def deactivate update("DEACTIVATE") end |
.resource ⇒ DhanHQ::Resources::KillSwitch
Provides a shared instance of the KillSwitch resource.
40 41 42 |
# File 'lib/DhanHQ/models/kill_switch.rb', line 40 def resource @resource ||= DhanHQ::Resources::KillSwitch.new end |
.status ⇒ Hash{Symbol => String}
Fetches the current kill switch status for your account.
Checks whether the kill switch is currently active or inactive for the current trading day.
154 155 156 |
# File 'lib/DhanHQ/models/kill_switch.rb', line 154 def status resource.status end |
.update(status) ⇒ Hash{Symbol => String}
Updates the kill switch status with the specified action.
Allows you to set the kill switch to either "ACTIVATE" or "DEACTIVATE" state. The status is passed as a query parameter to the API endpoint.
70 71 72 |
# File 'lib/DhanHQ/models/kill_switch.rb', line 70 def update(status) resource.update(status) end |