oanda_api_v20 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fea2b5abda5730c36fa1d535c0de33c82f96c3d
4
- data.tar.gz: ea80f60cd1263e3eb80e12d3715a052d9b08ab17
3
+ metadata.gz: 0c701def72ef104194002af2f65acc194a8f2b37
4
+ data.tar.gz: 5ed313d698c3b7914ae9f2a02e76bcf28e857506
5
5
  SHA512:
6
- metadata.gz: ea0776c3df49196324f703632f6090b39fe4d203f3931872b927e086292aa9719abaf5f4ce64db56d7890cc611fe07f81eabdbc85b832a64c1b01dc34b2d6eab
7
- data.tar.gz: 9e9a3fa546f6d3a6f47283b3cbeb2c18f8c096fb1a2d6d3992a77bcbd12ff4c5f68f5faaf4106b9fc5364c50998f507e7e51bf223a3de304c3b9449223d5e559
6
+ metadata.gz: fcd956994384f069a5b26d01f0ed79db68069bbced7d889a125a0da1515f8d9de751eef77d3b753306f3089e1425aae2f11e12d88c1cc1ece4740ad569d2c795
7
+ data.tar.gz: bafa52e682df3017a7fadaf73811a6699cdb580de817ffac280416ebf6e0afcb3def4298956db92a63dd1e597c463aec9759cdd3bcd4bc096a4c990a767d1b52
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.0
4
+ #### 2016-12-03
5
+ * Added the instruments method to retrieve candlestick data.
6
+
3
7
  ## 1.1.0
4
8
  #### 2016-10-24
5
9
  * Added an optional field to the account instruments method to query only a list of instruments instead of returning all instruments.
data/README.md CHANGED
@@ -69,6 +69,16 @@ options = { alias: 'My New Account #2' }
69
69
  client.account('account_id').configuration(options).update
70
70
  ```
71
71
 
72
+ ### Instruments
73
+
74
+ See the [Oanda Documentation](http://developer.oanda.com/rest-live-v20/instrument-ep/) for all available options on instruments.
75
+
76
+ ```ruby
77
+ options = { count: 10 }
78
+
79
+ client.instrument('EUR_USD').candles(options).show
80
+ ```
81
+
72
82
  ### Orders
73
83
 
74
84
  See the [Oanda Documentation](http://developer.oanda.com/rest-live-v20/orders-ep/) for all available options on orders.
@@ -5,6 +5,7 @@ require 'http/exceptions'
5
5
  require 'oanda_api_v20/version'
6
6
  require 'oanda_api_v20/exceptions'
7
7
  require 'oanda_api_v20/accounts'
8
+ require 'oanda_api_v20/instruments'
8
9
  require 'oanda_api_v20/orders'
9
10
  require 'oanda_api_v20/trades'
10
11
  require 'oanda_api_v20/positions'
@@ -1,13 +1,14 @@
1
1
  module OandaApiV20
2
2
  class Api
3
3
  include Accounts
4
+ include Instruments
4
5
  include Orders
5
6
  include Trades
6
7
  include Positions
7
8
  include Transactions
8
9
  include Pricing
9
10
 
10
- attr_accessor :http_verb, :base_uri, :headers, :account_id, :last_transaction_id
11
+ attr_accessor :http_verb, :base_uri, :headers, :account_id, :instrument, :last_transaction_id
11
12
 
12
13
  def initialize(options = {})
13
14
  options.each do |key, value|
@@ -66,6 +66,7 @@ module OandaApiV20
66
66
  when *api_methods
67
67
  set_last_action_and_arguments(name, args)
68
68
  set_account_id(args.first) if name == :account
69
+ set_instrument(args.first) if name == :instrument
69
70
  self
70
71
  else
71
72
  super
@@ -74,10 +75,10 @@ module OandaApiV20
74
75
 
75
76
  private
76
77
 
77
- attr_accessor :http_verb, :account_id, :last_transaction_id, :last_action, :last_arguments, :last_api_request_at
78
+ attr_accessor :http_verb, :account_id, :instrument, :last_transaction_id, :last_action, :last_arguments, :last_api_request_at
78
79
 
79
80
  def api_methods
80
- Accounts.instance_methods + Orders.instance_methods + Trades.instance_methods + Positions.instance_methods + Transactions.instance_methods + Pricing.instance_methods
81
+ Accounts.instance_methods + Instruments.instance_methods + Orders.instance_methods + Trades.instance_methods + Positions.instance_methods + Transactions.instance_methods + Pricing.instance_methods
81
82
  end
82
83
 
83
84
  def govern_api_request_rate
@@ -107,6 +108,10 @@ module OandaApiV20
107
108
  self.account_id = id
108
109
  end
109
110
 
111
+ def set_instrument(instrument)
112
+ self.instrument = instrument
113
+ end
114
+
110
115
  def set_last_transaction_id(id)
111
116
  self.last_transaction_id = id
112
117
  end
@@ -130,6 +135,7 @@ module OandaApiV20
130
135
  base_uri: base_uri,
131
136
  headers: headers,
132
137
  account_id: account_id,
138
+ instrument: instrument,
133
139
  last_transaction_id: last_transaction_id
134
140
  }
135
141
  end
@@ -0,0 +1,11 @@
1
+ # @see http://developer.oanda.com/rest-live-v20/instrument-ep/
2
+ module OandaApiV20
3
+ module Instruments
4
+ attr_accessor :instrument
5
+
6
+ # GET /v3/instruments/:instrument/candles
7
+ def candles(options = {})
8
+ Client.send(http_verb, "#{base_uri}/instruments/#{instrument}/candles", headers: headers, query: options)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module OandaApiV20
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -99,6 +99,16 @@ describe OandaApiV20::Api do
99
99
  end
100
100
  end
101
101
 
102
+ context 'instruments for' do
103
+ let!(:api) { OandaApiV20::Api.new(base_uri: 'https://api-fxtrade.oanda.com/v3', account_id: '100-100-100', instrument: 'EUR_USD', headers: {}) }
104
+
105
+ it 'retrieving candlestick data' do
106
+ options = { 'count' => '10' }
107
+ api.candles(options)
108
+ expect(a_request(:get, 'https://api-fxtrade.oanda.com/v3/instruments/EUR_USD/candles').with(query: options)).to have_been_made.once
109
+ end
110
+ end
111
+
102
112
  context 'orders for' do
103
113
  it 'retrieving an order' do
104
114
  api.order('1')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oanda_api_v20
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kobus Joubert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -128,6 +128,7 @@ files:
128
128
  - lib/oanda_api_v20/api.rb
129
129
  - lib/oanda_api_v20/client.rb
130
130
  - lib/oanda_api_v20/exceptions.rb
131
+ - lib/oanda_api_v20/instruments.rb
131
132
  - lib/oanda_api_v20/oanda_api_v20.rb
132
133
  - lib/oanda_api_v20/orders.rb
133
134
  - lib/oanda_api_v20/positions.rb