module OandaApiV20::Trades
Public Instance Methods
open_trades()
click to toggle source
GET /v3/accounts/:account_id/openTrades
# File lib/oanda_api_v20/trades.rb, line 24 def open_trades Client.send(http_verb, "#{base_uri}/accounts/#{account_id}/openTrades", headers: headers) end
trade(*args)
click to toggle source
GET /v3/accounts/:account_id/trades/:trade_id PUT /v3/accounts/:account_id/trades/:trade_id/orders PUT /v3/accounts/:account_id/trades/:trade_id/clientExtensions PUT /v3/accounts/:account_id/trades/:trade_id/close
# File lib/oanda_api_v20/trades.rb, line 8 def trade(*args) id = args.shift options = args.shift unless args.nil? || args.empty? url = "#{base_uri}/accounts/#{account_id}/trades/#{id}" url = trade_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
trades(options)
click to toggle source
GET /v3/accounts/:account_id/trades
# File lib/oanda_api_v20/trades.rb, line 19 def trades(options) Client.send(http_verb, "#{base_uri}/accounts/#{account_id}/trades", headers: headers, query: options) end
Private Instance Methods
trade_url_for_put(url, options = nil)
click to toggle source
# File lib/oanda_api_v20/trades.rb, line 30 def trade_url_for_put(url, options = nil) return "#{url}/close" unless options return "#{url}/clientExtensions" if options['clientExtensions'] return "#{url}/orders" if options['takeProfit'] || options['stopLoss'] || options['trailingStopLoss'] return "#{url}/close" if options['units'] return url end