Class: DhanHQ::Resources::TwapOrders
- Includes:
- Concerns::OrderAudit
- Defined in:
- lib/DhanHQ/resources/twap_orders.rb
Overview
Resource client for TWAP order management.
Constant Summary collapse
- API_TYPE =
:order_api- HTTP_PATH =
"/v2/orders/twap"
Instance Attribute Summary
Attributes inherited from BaseAPI
Instance Method Summary collapse
-
#all ⇒ Array<Hash>
Lists all TWAP orders for the account.
-
#cancel(order_id) ⇒ Hash
Cancels a TWAP order.
-
#create(params) ⇒ Hash
Creates a new TWAP order.
-
#find(order_id) ⇒ Hash
Fetches a specific TWAP order by ID.
-
#update(order_id, params) ⇒ Hash
Updates an existing TWAP order.
Methods inherited from BaseAPI
#delete, #get, #initialize, #post, #put
Methods included from AttributeHelper
#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 TWAP orders for the account.
17 18 19 |
# File 'lib/DhanHQ/resources/twap_orders.rb', line 17 def all get("") end |
#cancel(order_id) ⇒ Hash
Cancels a TWAP order.
55 56 57 58 59 |
# File 'lib/DhanHQ/resources/twap_orders.rb', line 55 def cancel(order_id) ensure_live_trading! log_order_context("DHAN_TWAP_ORDER_CANCEL_ATTEMPT", { order_id: order_id }) delete("/#{order_id}") end |
#create(params) ⇒ Hash
Creates a new TWAP order.
25 26 27 28 29 30 |
# File 'lib/DhanHQ/resources/twap_orders.rb', line 25 def create(params) ensure_live_trading! run_risk_checks!(params) log_order_context("DHAN_TWAP_ORDER_ATTEMPT", params) post("", params: params) end |
#find(order_id) ⇒ Hash
Fetches a specific TWAP order by ID.
36 37 38 |
# File 'lib/DhanHQ/resources/twap_orders.rb', line 36 def find(order_id) get("/#{order_id}") end |
#update(order_id, params) ⇒ Hash
Updates an existing TWAP order.
45 46 47 48 49 |
# File 'lib/DhanHQ/resources/twap_orders.rb', line 45 def update(order_id, params) ensure_live_trading! log_order_context("DHAN_TWAP_ORDER_MODIFY_ATTEMPT", params.merge(order_id: order_id)) put("/#{order_id}", params: params) end |