Class: DhanHQ::Resources::SuperOrders
- Includes:
- Concerns::OrderAudit
- Defined in:
- lib/DhanHQ/resources/super_orders.rb
Overview
Resource client for multi-leg super orders.
Constant Summary collapse
- API_TYPE =
Super orders are executed via the trading API.
:order_api- HTTP_PATH =
Base path for super order endpoints.
"/v2/super/orders"- SUPER_ORDER_LEGS =
%w[ENTRY_LEG STOP_LOSS_LEG TARGET_LEG].freeze
Instance Attribute Summary
Attributes inherited from BaseAPI
Instance Method Summary collapse
-
#all ⇒ Array<Hash>
Lists all configured super orders.
-
#cancel(order_id, leg_name) ⇒ Hash
Cancels a specific leg from a super order.
-
#create(params) ⇒ Hash
Creates a new super order.
-
#update(order_id, params) ⇒ Hash
Updates an existing super order.
Methods inherited from BaseAPI
#delete, #get, #initialize, #post, #put
Methods included from AttributeHelper
#camelize_keys, #deep_camelize_keys, #inspect, #normalize_keys, #snake_case, #titleize_keys
Methods included from APIHelper
Constructor Details
This class inherits a constructor from DhanHQ::BaseAPI
Instance Method Details
#all ⇒ Array<Hash>
Lists all configured super orders.
21 22 23 |
# File 'lib/DhanHQ/resources/super_orders.rb', line 21 def all get("") end |
#cancel(order_id, leg_name) ⇒ Hash
Cancels a specific leg from a super order.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/DhanHQ/resources/super_orders.rb', line 53 def cancel(order_id, leg_name) normalized = leg_name.to_s.upcase.strip unless SUPER_ORDER_LEGS.include?(normalized) raise DhanHQ::ValidationError, "leg_name must be one of: #{SUPER_ORDER_LEGS.join(", ")}" end ensure_live_trading! log_order_context("DHAN_SUPER_ORDER_CANCEL_ATTEMPT", { order_id: order_id, leg_name: normalized }) delete("/#{order_id}/#{normalized}") end |
#create(params) ⇒ Hash
Creates a new super order.
29 30 31 32 33 34 |
# File 'lib/DhanHQ/resources/super_orders.rb', line 29 def create(params) ensure_live_trading! run_risk_checks!(params) log_order_context("DHAN_SUPER_ORDER_ATTEMPT", params) post("", params: params) end |
#update(order_id, params) ⇒ Hash
Updates an existing super order.
41 42 43 44 45 |
# File 'lib/DhanHQ/resources/super_orders.rb', line 41 def update(order_id, params) ensure_live_trading! log_order_context("DHAN_SUPER_ORDER_MODIFY_ATTEMPT", params.merge(order_id: order_id)) put("/#{order_id}", params: params) end |