Module: OandaApiV20::Orders

Included in:
Api
Defined in:
lib/oanda_api_v20/orders.rb

Instance Method Summary collapse

Instance Method Details

#order(*args) ⇒ Object

POST /v3/accounts/:account_id/orders GET /v3/accounts/:account_id/orders/:order_id PUT /v3/accounts/:account_id/orders/:order_id PUT /v3/accounts/:account_id/orders/:order_id/clientExtensions PUT /v3/accounts/:account_id/orders/:order_id/cancel



9
10
11
12
13
14
15
16
17
18
# File 'lib/oanda_api_v20/orders.rb', line 9

def order(*args)
  id_or_options = args.shift
  id_or_options.is_a?(Hash) ? options = id_or_options : id = id_or_options
  options = args.shift unless args.nil? || args.empty?

  url = id ? "#{base_uri}/accounts/#{}/orders/#{id}" : "#{base_uri}/accounts/#{}/orders"
  url = order_url_for_put(url, options) if http_verb == :put

  options ? Client.send(http_verb, url, headers: headers, body: options.to_json) : Client.send(http_verb, url, headers: headers)
end

#orders(options = {}) ⇒ Object

GET /v3/accounts/:account_id/orders



21
22
23
# File 'lib/oanda_api_v20/orders.rb', line 21

def orders(options = {})
  Client.send(http_verb, "#{base_uri}/accounts/#{}/orders", headers: headers, query: options)
end

#pending_ordersObject

GET /v3/accounts/:account_id/pendingOrders



26
27
28
# File 'lib/oanda_api_v20/orders.rb', line 26

def pending_orders
  Client.send(http_verb, "#{base_uri}/accounts/#{}/pendingOrders", headers: headers)
end