161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
# File 'lib/groww_mcp/tools/smart_order_tools.rb', line 161
def call(server_context:, order_id:, smart_order_type:, segment: "CASH",
quantity: nil, duration: nil, trigger_price: nil, trigger_direction: nil,
order_type: nil, price: nil, transaction_type: nil, product_type: nil,
target_trigger_price: nil, target_order_type: nil, target_price: nil,
stop_loss_trigger_price: nil, stop_loss_order_type: nil, stop_loss_price: nil)
client = server_context[:client]
mods = {}
mods[:quantity] = quantity if quantity
mods[:duration] = duration if duration
mods[:trigger_price] = trigger_price.to_s if trigger_price
mods[:trigger_direction] = trigger_direction if trigger_direction
mods[:product_type] = product_type if product_type
if order_type || price
leg = {}
leg[:order_type] = order_type if order_type
leg[:price] = price if price
leg[:transaction_type] = transaction_type if transaction_type
mods[:order] = leg
end
if target_trigger_price
target = { trigger_price: target_trigger_price, order_type: target_order_type }
target[:price] = target_price if target_price
mods[:target] = target
end
if stop_loss_trigger_price
stop_loss = { trigger_price: stop_loss_trigger_price, order_type: stop_loss_order_type }
stop_loss[:price] = stop_loss_price if stop_loss_price
mods[:stop_loss] = stop_loss
end
result = client.modify_smart_order(order_id, smart_order_type: smart_order_type,
segment: segment, modifications: mods)
format_response(result)
rescue GrowwMcp::ApiError => e
error_response(e)
end
|