Class: GrowwMcp::Tools::PlaceOrder

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/groww_mcp/tools/order_tools.rb

Class Method Summary collapse

Class Method Details

.call(server_context:, trading_symbol:, transaction_type:, order_type:, quantity:, product:, exchange: "NSE", price: nil, trigger_price: nil, segment: "CASH", validity: "DAY") ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/groww_mcp/tools/order_tools.rb', line 129

def call(server_context:, trading_symbol:, transaction_type:, order_type:, quantity:, product:,
         exchange: "NSE", price: nil, trigger_price: nil, segment: "CASH", validity: "DAY")
  client = server_context[:client]
  order = {
    trading_symbol: trading_symbol,
    exchange: exchange,
    transaction_type: transaction_type,
    order_type: order_type,
    quantity: quantity,
    product: product,
    segment: segment,
    validity: validity,
  }
  order[:price] = price if price
  order[:trigger_price] = trigger_price if trigger_price

  result = client.place_order(order)
  format_response(result)
rescue GrowwMcp::ApiError => e
  error_response(e)
end