oanda_api 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -6
  3. data/README.md +31 -3
  4. data/lib/oanda_api.rb +3 -1
  5. data/lib/oanda_api/client/client.rb +17 -12
  6. data/lib/oanda_api/client/namespace_proxy.rb +2 -2
  7. data/lib/oanda_api/client/resource_descriptor.rb +25 -9
  8. data/lib/oanda_api/client/username_client.rb +7 -0
  9. data/lib/oanda_api/configuration.rb +14 -0
  10. data/lib/oanda_api/resource/account.rb +22 -3
  11. data/lib/oanda_api/resource/candle.rb +1 -1
  12. data/lib/oanda_api/resource/labs/calendar_event.rb +25 -0
  13. data/lib/oanda_api/resource/labs/spread_history.rb +61 -0
  14. data/lib/oanda_api/resource/order.rb +4 -4
  15. data/lib/oanda_api/resource/transaction_history.rb +0 -1
  16. data/lib/oanda_api/resource_base.rb +64 -2
  17. data/lib/oanda_api/resource_collection.rb +6 -0
  18. data/lib/oanda_api/streaming/client.rb +1 -0
  19. data/lib/oanda_api/version.rb +1 -1
  20. data/oanda_api.gemspec +2 -2
  21. data/spec/fixtures/vcr_cassettes/accounts_get.yml +13 -79
  22. data/spec/fixtures/vcr_cassettes/accounts_id_get.yml +23 -125
  23. data/spec/fixtures/vcr_cassettes/calendar_events_period_get.yml +54 -0
  24. data/spec/fixtures/vcr_cassettes/calendar_instrument_and_period_get.yml +61 -0
  25. data/spec/fixtures/vcr_cassettes/calendar_period_get.yml +54 -0
  26. data/spec/fixtures/vcr_cassettes/candles_options_get.yml +9 -45
  27. data/spec/fixtures/vcr_cassettes/client_helper_account.yml +45 -0
  28. data/spec/fixtures/vcr_cassettes/client_helper_accounts.yml +45 -0
  29. data/spec/fixtures/vcr_cassettes/instrument_EUR_USD.yml +42 -0
  30. data/spec/fixtures/vcr_cassettes/instrument_USD_JPY.yml +42 -0
  31. data/spec/fixtures/vcr_cassettes/instruments_get.yml +37 -303
  32. data/spec/fixtures/vcr_cassettes/instruments_options_get.yml +6 -43
  33. data/spec/fixtures/vcr_cassettes/order_id_close.yml +448 -0
  34. data/spec/fixtures/vcr_cassettes/order_id_get.yml +84 -0
  35. data/spec/fixtures/vcr_cassettes/order_options_create.yml +42 -0
  36. data/spec/fixtures/vcr_cassettes/order_options_update.yml +82 -0
  37. data/spec/fixtures/vcr_cassettes/orders_get.yml +205 -0
  38. data/spec/fixtures/vcr_cassettes/orders_options_get.yml +120 -0
  39. data/spec/fixtures/vcr_cassettes/positions_get.yml +82 -0
  40. data/spec/fixtures/vcr_cassettes/positions_instrument_close.yml +154 -0
  41. data/spec/fixtures/vcr_cassettes/{account_id_order_options_create.yml → positions_instrument_get.yml} +24 -18
  42. data/spec/fixtures/vcr_cassettes/prices_options_get.yml +11 -48
  43. data/spec/fixtures/vcr_cassettes/spread_history_get.yml +53 -0
  44. data/spec/fixtures/vcr_cassettes/spreads_get.yml +53 -0
  45. data/spec/fixtures/vcr_cassettes/trade_id_close.yml +277 -0
  46. data/spec/fixtures/vcr_cassettes/trade_id_get.yml +82 -0
  47. data/spec/fixtures/vcr_cassettes/trade_options_modify.yml +80 -0
  48. data/spec/fixtures/vcr_cassettes/trades_filter_get.yml +90 -0
  49. data/spec/fixtures/vcr_cassettes/trades_get.yml +171 -0
  50. data/spec/fixtures/vcr_cassettes/transaction_id_get.yml +248 -0
  51. data/spec/fixtures/vcr_cassettes/transactions_options_get.yml +202 -0
  52. data/spec/fixtures/vcr_cassettes/with_throttling_and_max_requests_per_second.yml +25 -19
  53. data/spec/fixtures/vcr_cassettes/with_throttling_with_multiple_threads.yml +51 -39
  54. data/spec/fixtures/vcr_cassettes/without_throttling.yml +81 -61
  55. data/spec/oanda_api/client/client_spec.rb +23 -10
  56. data/spec/oanda_api/client/namespace_proxy_spec.rb +1 -1
  57. data/spec/oanda_api/client/resource_descriptor_spec.rb +45 -14
  58. data/spec/oanda_api/configuration_spec.rb +13 -0
  59. data/spec/oanda_api/examples/accounts_spec.rb +0 -7
  60. data/spec/oanda_api/examples/calendar_spec.rb +27 -0
  61. data/spec/oanda_api/examples/orders_spec.rb +12 -12
  62. data/spec/oanda_api/examples/positions_spec.rb +3 -3
  63. data/spec/oanda_api/examples/rates_spec.rb +4 -2
  64. data/spec/oanda_api/examples/spread_history_spec.rb +32 -0
  65. data/spec/oanda_api/examples/trades_spec.rb +5 -5
  66. data/spec/oanda_api/examples/transactions_spec.rb +2 -2
  67. data/spec/oanda_api/resource_base_spec.rb +48 -8
  68. data/spec/oanda_api/streaming/client_spec.rb +30 -2
  69. data/spec/spec_helper.rb +1 -1
  70. data/spec/support/client_helper.rb +45 -11
  71. data/spec/support/vcr.rb +1 -0
  72. metadata +63 -49
  73. data/spec/fixtures/vcr_cassettes/account_id_order_id_close.yml +0 -264
  74. data/spec/fixtures/vcr_cassettes/account_id_order_id_get.yml +0 -114
  75. data/spec/fixtures/vcr_cassettes/account_id_order_options_update.yml +0 -112
  76. data/spec/fixtures/vcr_cassettes/account_id_orders_get.yml +0 -118
  77. data/spec/fixtures/vcr_cassettes/account_id_orders_options_get.yml +0 -123
  78. data/spec/fixtures/vcr_cassettes/account_id_positions_get.yml +0 -112
  79. data/spec/fixtures/vcr_cassettes/account_id_positions_instrument_close.yml +0 -214
  80. data/spec/fixtures/vcr_cassettes/account_id_positions_instrument_get.yml +0 -110
  81. data/spec/fixtures/vcr_cassettes/account_id_trade_id_close.yml +0 -252
  82. data/spec/fixtures/vcr_cassettes/account_id_trade_id_get.yml +0 -112
  83. data/spec/fixtures/vcr_cassettes/account_id_trade_options_modify.yml +0 -110
  84. data/spec/fixtures/vcr_cassettes/account_id_trades_filter_get.yml +0 -118
  85. data/spec/fixtures/vcr_cassettes/account_id_trades_get.yml +0 -118
  86. data/spec/fixtures/vcr_cassettes/account_id_transaction_id_get.yml +0 -283
  87. data/spec/fixtures/vcr_cassettes/account_id_transactions_options_get.yml +0 -205
  88. data/spec/fixtures/vcr_cassettes/accounts_create.yml +0 -75
  89. data/spec/fixtures/vcr_cassettes/sandbox_client.yml +0 -116
  90. data/spec/fixtures/vcr_cassettes/sandbox_client_account.yml +0 -111
  91. data/spec/fixtures/vcr_cassettes/sandbox_instrument_EUR_USD.yml +0 -77
  92. data/spec/oanda_api/client/username_client_spec.rb +0 -31
@@ -29,11 +29,12 @@ describe "OandaAPI::Streaming::Client" do
29
29
 
30
30
  describe "#api_uri" do
31
31
  let(:client) { Struct.new(:domain) { include OandaAPI::Client }.new }
32
+ let(:resource_descriptor) {OandaAPI::Client::ResourceDescriptor.new "/accounts", :get}
32
33
  it "is domain specific" do
33
34
  uris = {}
34
35
  OandaAPI::DOMAINS.each do |domain|
35
36
  client.domain = domain
36
- uris[client.api_uri("/path")] = domain
37
+ uris[client.api_uri(resource_descriptor)] = domain
37
38
  end
38
39
  expect(uris.size).to eq(3)
39
40
  end
@@ -41,7 +42,7 @@ describe "OandaAPI::Streaming::Client" do
41
42
  it "is an absolute URI" do
42
43
  OandaAPI::DOMAINS.each do |domain|
43
44
  client.domain = domain
44
- uri = URI.parse client.api_uri("/path")
45
+ uri = URI.parse client.api_uri(resource_descriptor)
45
46
  expect(uri.absolute?).to be true
46
47
  end
47
48
  end
@@ -73,6 +74,33 @@ describe "OandaAPI::Streaming::Client" do
73
74
  expect(client.emit_heartbeats?).to be value
74
75
  end
75
76
  end
77
+
78
+ it "includes heartbeats when true" do
79
+ events_json = <<-END
80
+ {"heartbeat":{"time":"2014-05-26T13:58:40Z"}}\r\n
81
+ {"transaction":{"id":10001}}\r\n
82
+ {"transaction":{"id":10002}}
83
+ END
84
+
85
+ client = OandaAPI::Streaming::Client.new(:practice, "token")
86
+ stub_request(:get, "https://stream-fxpractice.oanda.com/v1/events").to_return(body: events_json, status: 200)
87
+
88
+ [{emit_heartbeats: true, heartbeats: 1, non_heartbeats: 2},
89
+ {emit_heartbeats: false, heartbeats: 0, non_heartbeats: 2}].each do |test|
90
+
91
+ client.emit_heartbeats = test[:emit_heartbeats]
92
+ heartbeats = non_heartbeats = 0
93
+ client.events.stream do |resource|
94
+ if resource.is_a? OandaAPI::Resource::Heartbeat
95
+ heartbeats += 1
96
+ else
97
+ non_heartbeats += 1
98
+ end
99
+ end
100
+ expect(heartbeats).to eq test[:heartbeats]
101
+ expect(non_heartbeats).to eq test[:non_heartbeats]
102
+ end
103
+ end
76
104
  end
77
105
 
78
106
  describe "headers" do
@@ -12,7 +12,7 @@ require 'oanda_api'
12
12
  RSpec.configure do |c|
13
13
  c.before(:suite) do
14
14
  # Disable request throttling because all examples are stubbed with VCR and webmock.
15
- OandaAPI.configure { |config| config.use_request_throttling = false }
15
+ OandaAPI.configure { |config| config.use_request_throttling = false }
16
16
  end
17
17
  end
18
18
 
@@ -1,22 +1,55 @@
1
1
  require 'support/vcr'
2
+
2
3
  module ClientHelper
3
- # Returns a sandbox client
4
+ # Returns a practice API client
4
5
  def self.client
5
- VCR.use_cassette("sandbox_client") do
6
- client = OandaAPI::Client::UsernameClient.new "_"
7
- new_account = client.account.create
8
- OandaAPI::Client::UsernameClient.new new_account.username
6
+ @client ||= OandaAPI::Client::TokenClient.new :practice, test_account_token
7
+ end
8
+
9
+ def self.test_account_token
10
+ ENV.fetch("OANDA_API_TESTING_TOKEN") do
11
+ fail(ArgumentError, <<-END
12
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
+ + Missing Authentication Token for testing. +
14
+ + +
15
+ + A test you are running is attempting to create a new +
16
+ + testing fixture by making an API request to the Oanda +
17
+ + Practice API. Normally this is ONLY required when adding +
18
+ + a new API endpoint. Running existing tests do not require +
19
+ + this. +
20
+ + +
21
+ + To create new VCR cassette fixtures for the test suite: +
22
+ + 1. You need to have an Oanda Practice account. (See: +
23
+ + https://fxtrade.oanda.com/your_account/fxtrade/register/) +
24
+ + 2. Define OANDA_API_TESTING_TOKEN as an environment +
25
+ + variable, setting its value to the authentication +
26
+ + token for your Oanda Practice account. +
27
+ + 3. Run the tests. You can examine the VCR test fixures +
28
+ + that were created in /spec/fixtures/vcr_cassettes. +
29
+ + There will not be any reference to your authentication +
30
+ + token in the fixture. +
31
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
+ END
33
+ )
9
34
  end
10
35
  end
11
36
 
12
- # Returns the account namespace for the client
13
- def self.account
14
- VCR.use_cassette("sandbox_client_account") do
15
- account_id = ClientHelper.client.accounts.get.first.account_id
16
- ClientHelper.client.account(account_id)
37
+ # A collection of accounts
38
+ def self.accounts
39
+ VCR.use_cassette("client_helper_accounts") do
40
+ ClientHelper.client.accounts.get
17
41
  end
18
42
  end
19
43
 
44
+ # Returns an account namespace for the client
45
+ def self.account
46
+ client.account(accounts.first.account_id)
47
+ end
48
+
49
+ def self.account_id
50
+ accounts.first.account_id
51
+ end
52
+
20
53
  # Creates a trade
21
54
  def self.create_trade(instrument: "USD_JPY",
22
55
  type: "market",
@@ -41,6 +74,7 @@ module ClientHelper
41
74
  else
42
75
  fail ArgumentError, "invalid order type: #{type}"
43
76
  end
77
+
44
78
  account.order(opts).create
45
79
  end
46
80
 
@@ -48,7 +82,7 @@ module ClientHelper
48
82
 
49
83
  # Returns a lightweight instrument object
50
84
  def self.instrument(instrument)
51
- VCR.use_cassette("sandbox_instrument_#{instrument}") do
85
+ VCR.use_cassette("instrument_#{instrument}") do
52
86
  price = ClientHelper.client.prices(instruments: instrument).get.first
53
87
  o = Struct.new(:instrument, :bid, :ask).new
54
88
  o.instrument = instrument
@@ -4,5 +4,6 @@ VCR.configure do |c|
4
4
  c.hook_into :webmock
5
5
  c.configure_rspec_metadata!
6
6
  c.default_cassette_options = { record: :new_episodes }
7
+ c.filter_sensitive_data('<OANDA_TESTING_API_TOKEN>') { ClientHelper.test_account_token }
7
8
  c.ignore_hosts 'codeclimate.com'
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oanda_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Missikowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -78,28 +78,28 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '2.9'
81
+ version: '3.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '2.9'
88
+ version: '3.0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: webmock
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.21'
95
+ version: '1.24'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '1.21'
102
+ version: '1.24'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: yard
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,8 @@ files:
144
144
  - lib/oanda_api/resource/candle.rb
145
145
  - lib/oanda_api/resource/heartbeat.rb
146
146
  - lib/oanda_api/resource/instrument.rb
147
+ - lib/oanda_api/resource/labs/calendar_event.rb
148
+ - lib/oanda_api/resource/labs/spread_history.rb
147
149
  - lib/oanda_api/resource/order.rb
148
150
  - lib/oanda_api/resource/position.rb
149
151
  - lib/oanda_api/resource/price.rb
@@ -162,32 +164,37 @@ files:
162
164
  - lib/oanda_api/utils/utils.rb
163
165
  - lib/oanda_api/version.rb
164
166
  - oanda_api.gemspec
165
- - spec/fixtures/vcr_cassettes/account_id_order_id_close.yml
166
- - spec/fixtures/vcr_cassettes/account_id_order_id_get.yml
167
- - spec/fixtures/vcr_cassettes/account_id_order_options_create.yml
168
- - spec/fixtures/vcr_cassettes/account_id_order_options_update.yml
169
- - spec/fixtures/vcr_cassettes/account_id_orders_get.yml
170
- - spec/fixtures/vcr_cassettes/account_id_orders_options_get.yml
171
- - spec/fixtures/vcr_cassettes/account_id_positions_get.yml
172
- - spec/fixtures/vcr_cassettes/account_id_positions_instrument_close.yml
173
- - spec/fixtures/vcr_cassettes/account_id_positions_instrument_get.yml
174
- - spec/fixtures/vcr_cassettes/account_id_trade_id_close.yml
175
- - spec/fixtures/vcr_cassettes/account_id_trade_id_get.yml
176
- - spec/fixtures/vcr_cassettes/account_id_trade_options_modify.yml
177
- - spec/fixtures/vcr_cassettes/account_id_trades_filter_get.yml
178
- - spec/fixtures/vcr_cassettes/account_id_trades_get.yml
179
- - spec/fixtures/vcr_cassettes/account_id_transaction_id_get.yml
180
- - spec/fixtures/vcr_cassettes/account_id_transactions_options_get.yml
181
- - spec/fixtures/vcr_cassettes/accounts_create.yml
182
167
  - spec/fixtures/vcr_cassettes/accounts_get.yml
183
168
  - spec/fixtures/vcr_cassettes/accounts_id_get.yml
169
+ - spec/fixtures/vcr_cassettes/calendar_events_period_get.yml
170
+ - spec/fixtures/vcr_cassettes/calendar_instrument_and_period_get.yml
171
+ - spec/fixtures/vcr_cassettes/calendar_period_get.yml
184
172
  - spec/fixtures/vcr_cassettes/candles_options_get.yml
173
+ - spec/fixtures/vcr_cassettes/client_helper_account.yml
174
+ - spec/fixtures/vcr_cassettes/client_helper_accounts.yml
175
+ - spec/fixtures/vcr_cassettes/instrument_EUR_USD.yml
176
+ - spec/fixtures/vcr_cassettes/instrument_USD_JPY.yml
185
177
  - spec/fixtures/vcr_cassettes/instruments_get.yml
186
178
  - spec/fixtures/vcr_cassettes/instruments_options_get.yml
179
+ - spec/fixtures/vcr_cassettes/order_id_close.yml
180
+ - spec/fixtures/vcr_cassettes/order_id_get.yml
181
+ - spec/fixtures/vcr_cassettes/order_options_create.yml
182
+ - spec/fixtures/vcr_cassettes/order_options_update.yml
183
+ - spec/fixtures/vcr_cassettes/orders_get.yml
184
+ - spec/fixtures/vcr_cassettes/orders_options_get.yml
185
+ - spec/fixtures/vcr_cassettes/positions_get.yml
186
+ - spec/fixtures/vcr_cassettes/positions_instrument_close.yml
187
+ - spec/fixtures/vcr_cassettes/positions_instrument_get.yml
187
188
  - spec/fixtures/vcr_cassettes/prices_options_get.yml
188
- - spec/fixtures/vcr_cassettes/sandbox_client.yml
189
- - spec/fixtures/vcr_cassettes/sandbox_client_account.yml
190
- - spec/fixtures/vcr_cassettes/sandbox_instrument_EUR_USD.yml
189
+ - spec/fixtures/vcr_cassettes/spread_history_get.yml
190
+ - spec/fixtures/vcr_cassettes/spreads_get.yml
191
+ - spec/fixtures/vcr_cassettes/trade_id_close.yml
192
+ - spec/fixtures/vcr_cassettes/trade_id_get.yml
193
+ - spec/fixtures/vcr_cassettes/trade_options_modify.yml
194
+ - spec/fixtures/vcr_cassettes/trades_filter_get.yml
195
+ - spec/fixtures/vcr_cassettes/trades_get.yml
196
+ - spec/fixtures/vcr_cassettes/transaction_id_get.yml
197
+ - spec/fixtures/vcr_cassettes/transactions_options_get.yml
191
198
  - spec/fixtures/vcr_cassettes/with_throttling_and_max_requests_per_second.yml
192
199
  - spec/fixtures/vcr_cassettes/with_throttling_with_multiple_threads.yml
193
200
  - spec/fixtures/vcr_cassettes/without_throttling.yml
@@ -196,13 +203,14 @@ files:
196
203
  - spec/oanda_api/client/namespace_proxy_spec.rb
197
204
  - spec/oanda_api/client/resource_descriptor_spec.rb
198
205
  - spec/oanda_api/client/token_client_spec.rb
199
- - spec/oanda_api/client/username_client_spec.rb
200
206
  - spec/oanda_api/configuration_spec.rb
201
207
  - spec/oanda_api/examples/accounts_spec.rb
208
+ - spec/oanda_api/examples/calendar_spec.rb
202
209
  - spec/oanda_api/examples/orders_spec.rb
203
210
  - spec/oanda_api/examples/positions_spec.rb
204
211
  - spec/oanda_api/examples/rates_spec.rb
205
212
  - spec/oanda_api/examples/request_throttling_spec.rb
213
+ - spec/oanda_api/examples/spread_history_spec.rb
206
214
  - spec/oanda_api/examples/trades_spec.rb
207
215
  - spec/oanda_api/examples/transactions_spec.rb
208
216
  - spec/oanda_api/resource_base_spec.rb
@@ -238,37 +246,42 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
246
  version: '0'
239
247
  requirements: []
240
248
  rubyforge_project:
241
- rubygems_version: 2.4.6
249
+ rubygems_version: 2.5.1
242
250
  signing_key:
243
251
  specification_version: 4
244
252
  summary: A ruby client for the Oanda REST API.
245
253
  test_files:
246
- - spec/fixtures/vcr_cassettes/account_id_order_id_close.yml
247
- - spec/fixtures/vcr_cassettes/account_id_order_id_get.yml
248
- - spec/fixtures/vcr_cassettes/account_id_order_options_create.yml
249
- - spec/fixtures/vcr_cassettes/account_id_order_options_update.yml
250
- - spec/fixtures/vcr_cassettes/account_id_orders_get.yml
251
- - spec/fixtures/vcr_cassettes/account_id_orders_options_get.yml
252
- - spec/fixtures/vcr_cassettes/account_id_positions_get.yml
253
- - spec/fixtures/vcr_cassettes/account_id_positions_instrument_close.yml
254
- - spec/fixtures/vcr_cassettes/account_id_positions_instrument_get.yml
255
- - spec/fixtures/vcr_cassettes/account_id_trade_id_close.yml
256
- - spec/fixtures/vcr_cassettes/account_id_trade_id_get.yml
257
- - spec/fixtures/vcr_cassettes/account_id_trade_options_modify.yml
258
- - spec/fixtures/vcr_cassettes/account_id_trades_filter_get.yml
259
- - spec/fixtures/vcr_cassettes/account_id_trades_get.yml
260
- - spec/fixtures/vcr_cassettes/account_id_transaction_id_get.yml
261
- - spec/fixtures/vcr_cassettes/account_id_transactions_options_get.yml
262
- - spec/fixtures/vcr_cassettes/accounts_create.yml
263
254
  - spec/fixtures/vcr_cassettes/accounts_get.yml
264
255
  - spec/fixtures/vcr_cassettes/accounts_id_get.yml
256
+ - spec/fixtures/vcr_cassettes/calendar_events_period_get.yml
257
+ - spec/fixtures/vcr_cassettes/calendar_instrument_and_period_get.yml
258
+ - spec/fixtures/vcr_cassettes/calendar_period_get.yml
265
259
  - spec/fixtures/vcr_cassettes/candles_options_get.yml
260
+ - spec/fixtures/vcr_cassettes/client_helper_account.yml
261
+ - spec/fixtures/vcr_cassettes/client_helper_accounts.yml
262
+ - spec/fixtures/vcr_cassettes/instrument_EUR_USD.yml
263
+ - spec/fixtures/vcr_cassettes/instrument_USD_JPY.yml
266
264
  - spec/fixtures/vcr_cassettes/instruments_get.yml
267
265
  - spec/fixtures/vcr_cassettes/instruments_options_get.yml
266
+ - spec/fixtures/vcr_cassettes/order_id_close.yml
267
+ - spec/fixtures/vcr_cassettes/order_id_get.yml
268
+ - spec/fixtures/vcr_cassettes/order_options_create.yml
269
+ - spec/fixtures/vcr_cassettes/order_options_update.yml
270
+ - spec/fixtures/vcr_cassettes/orders_get.yml
271
+ - spec/fixtures/vcr_cassettes/orders_options_get.yml
272
+ - spec/fixtures/vcr_cassettes/positions_get.yml
273
+ - spec/fixtures/vcr_cassettes/positions_instrument_close.yml
274
+ - spec/fixtures/vcr_cassettes/positions_instrument_get.yml
268
275
  - spec/fixtures/vcr_cassettes/prices_options_get.yml
269
- - spec/fixtures/vcr_cassettes/sandbox_client.yml
270
- - spec/fixtures/vcr_cassettes/sandbox_client_account.yml
271
- - spec/fixtures/vcr_cassettes/sandbox_instrument_EUR_USD.yml
276
+ - spec/fixtures/vcr_cassettes/spread_history_get.yml
277
+ - spec/fixtures/vcr_cassettes/spreads_get.yml
278
+ - spec/fixtures/vcr_cassettes/trade_id_close.yml
279
+ - spec/fixtures/vcr_cassettes/trade_id_get.yml
280
+ - spec/fixtures/vcr_cassettes/trade_options_modify.yml
281
+ - spec/fixtures/vcr_cassettes/trades_filter_get.yml
282
+ - spec/fixtures/vcr_cassettes/trades_get.yml
283
+ - spec/fixtures/vcr_cassettes/transaction_id_get.yml
284
+ - spec/fixtures/vcr_cassettes/transactions_options_get.yml
272
285
  - spec/fixtures/vcr_cassettes/with_throttling_and_max_requests_per_second.yml
273
286
  - spec/fixtures/vcr_cassettes/with_throttling_with_multiple_threads.yml
274
287
  - spec/fixtures/vcr_cassettes/without_throttling.yml
@@ -277,13 +290,14 @@ test_files:
277
290
  - spec/oanda_api/client/namespace_proxy_spec.rb
278
291
  - spec/oanda_api/client/resource_descriptor_spec.rb
279
292
  - spec/oanda_api/client/token_client_spec.rb
280
- - spec/oanda_api/client/username_client_spec.rb
281
293
  - spec/oanda_api/configuration_spec.rb
282
294
  - spec/oanda_api/examples/accounts_spec.rb
295
+ - spec/oanda_api/examples/calendar_spec.rb
283
296
  - spec/oanda_api/examples/orders_spec.rb
284
297
  - spec/oanda_api/examples/positions_spec.rb
285
298
  - spec/oanda_api/examples/rates_spec.rb
286
299
  - spec/oanda_api/examples/request_throttling_spec.rb
300
+ - spec/oanda_api/examples/spread_history_spec.rb
287
301
  - spec/oanda_api/examples/trades_spec.rb
288
302
  - spec/oanda_api/examples/transactions_spec.rb
289
303
  - spec/oanda_api/resource_base_spec.rb
@@ -1,264 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://api-sandbox.oanda.com/v1/accounts/5342358/orders
6
- body:
7
- encoding: UTF-8
8
- string: expiry=2015-01-20T18%3A22%3A31%2B00%3A00&instrument=USD_JPY&price=1.14089&side=buy&type=limit&units=10000&username=dwaymotim
9
- headers:
10
- X-Accept-Datetime-Format:
11
- - RFC3339
12
- Connection:
13
- - keep-alive
14
- Keep-Alive:
15
- - 30
16
- response:
17
- status:
18
- code: 201
19
- message: CREATED
20
- headers:
21
- Server:
22
- - openresty/1.7.0.1
23
- Date:
24
- - Tue, 20 Jan 2015 17:22:28 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '313'
29
- Connection:
30
- - keep-alive
31
- Location:
32
- - http://api-sandbox.oanda.com/v1/accounts/5342358/orders/175503913
33
- body:
34
- encoding: UTF-8
35
- string: "{\n\t\"instrument\" : \"USD_JPY\",\n\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\"price\"
36
- : 1.14089,\n\t\"orderOpened\" : {\n\t\t\"id\" : 175503913,\n\t\t\"units\"
37
- : 10000,\n\t\t\"side\" : \"buy\",\n\t\t\"takeProfit\" : 0,\n\t\t\"stopLoss\"
38
- : 0,\n\t\t\"expiry\" : \"2015-01-20T18:22:31.000000Z\",\n\t\t\"upperBound\"
39
- : 0,\n\t\t\"lowerBound\" : 0,\n\t\t\"trailingStop\" : 0\n\t}\n}"
40
- http_version:
41
- recorded_at: Tue, 20 Jan 2015 17:22:31 GMT
42
- - request:
43
- method: get
44
- uri: http://api-sandbox.oanda.com/v1/accounts/5342358/orders?username=dwaymotim
45
- body:
46
- encoding: US-ASCII
47
- string: ''
48
- headers:
49
- X-Accept-Datetime-Format:
50
- - RFC3339
51
- Connection:
52
- - keep-alive
53
- Keep-Alive:
54
- - 30
55
- response:
56
- status:
57
- code: 200
58
- message: OK
59
- headers:
60
- Server:
61
- - openresty/1.7.0.1
62
- Date:
63
- - Tue, 20 Jan 2015 17:22:28 GMT
64
- Content-Type:
65
- - application/json
66
- Content-Length:
67
- - '1683'
68
- Connection:
69
- - keep-alive
70
- Etag:
71
- - '"f7d8307f842f7716a831e277508d85f5338d2db4"'
72
- X-Result-Count:
73
- - '5'
74
- body:
75
- encoding: UTF-8
76
- string: "{\n\t\"orders\" : [\n\t\t{\n\t\t\t\"id\" : 175503913,\n\t\t\t\"instrument\"
77
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
78
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
79
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
80
- : \"2015-01-20T18:22:31.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
81
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503911,\n\t\t\t\"instrument\"
82
- : \"USD_JPY\",\n\t\t\t\"units\" : 9000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
83
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
84
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
85
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
86
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503910,\n\t\t\t\"instrument\"
87
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
88
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
89
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
90
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
91
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503909,\n\t\t\t\"instrument\"
92
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
93
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
94
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
95
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
96
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503908,\n\t\t\t\"instrument\"
97
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
98
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:27.000000Z\",\n\t\t\t\"price\"
99
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
100
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
101
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t}\n\t]\n}"
102
- http_version:
103
- recorded_at: Tue, 20 Jan 2015 17:22:31 GMT
104
- - request:
105
- method: delete
106
- uri: http://api-sandbox.oanda.com/v1/accounts/5342358/orders/175503913?username=dwaymotim
107
- body:
108
- encoding: US-ASCII
109
- string: ''
110
- headers:
111
- X-Accept-Datetime-Format:
112
- - RFC3339
113
- Connection:
114
- - keep-alive
115
- Keep-Alive:
116
- - 30
117
- response:
118
- status:
119
- code: 200
120
- message: OK
121
- headers:
122
- Server:
123
- - openresty/1.7.0.1
124
- Date:
125
- - Tue, 20 Jan 2015 17:22:29 GMT
126
- Content-Type:
127
- - application/json
128
- Content-Length:
129
- - '166'
130
- Connection:
131
- - keep-alive
132
- body:
133
- encoding: UTF-8
134
- string: "{\n\t\"id\" : 175503913,\n\t\"instrument\" : \"USD_JPY\",\n\t\"units\"
135
- : 10000,\n\t\"side\" : \"buy\",\n\t\"price\" : 1.14089,\n\t\"time\" : \"2015-01-20T17:22:29.000000Z\",\n\t\"type\"
136
- : \"BuyLimit\"\n}"
137
- http_version:
138
- recorded_at: Tue, 20 Jan 2015 17:22:31 GMT
139
- - request:
140
- method: get
141
- uri: http://api-sandbox.oanda.com/v1/accounts/5342358/orders?username=dwaymotim
142
- body:
143
- encoding: US-ASCII
144
- string: ''
145
- headers:
146
- X-Accept-Datetime-Format:
147
- - RFC3339
148
- Connection:
149
- - keep-alive
150
- Keep-Alive:
151
- - 30
152
- response:
153
- status:
154
- code: 200
155
- message: OK
156
- headers:
157
- Server:
158
- - openresty/1.7.0.1
159
- Date:
160
- - Tue, 20 Jan 2015 17:22:29 GMT
161
- Content-Type:
162
- - application/json
163
- Content-Length:
164
- - '1350'
165
- Connection:
166
- - keep-alive
167
- Etag:
168
- - '"16f3da3e5a0a8b39a957a4a071f276157154f4c6"'
169
- X-Result-Count:
170
- - '4'
171
- body:
172
- encoding: UTF-8
173
- string: "{\n\t\"orders\" : [\n\t\t{\n\t\t\t\"id\" : 175503911,\n\t\t\t\"instrument\"
174
- : \"USD_JPY\",\n\t\t\t\"units\" : 9000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
175
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
176
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
177
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
178
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503910,\n\t\t\t\"instrument\"
179
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
180
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
181
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
182
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
183
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503909,\n\t\t\t\"instrument\"
184
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
185
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:28.000000Z\",\n\t\t\t\"price\"
186
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
187
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
188
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t},\n\t\t{\n\t\t\t\"id\" : 175503908,\n\t\t\t\"instrument\"
189
- : \"USD_JPY\",\n\t\t\t\"units\" : 10000,\n\t\t\t\"side\" : \"buy\",\n\t\t\t\"type\"
190
- : \"limit\",\n\t\t\t\"time\" : \"2015-01-20T17:22:27.000000Z\",\n\t\t\t\"price\"
191
- : 1.14089,\n\t\t\t\"takeProfit\" : 0,\n\t\t\t\"stopLoss\" : 0,\n\t\t\t\"expiry\"
192
- : \"2015-01-20T18:22:30.000000Z\",\n\t\t\t\"upperBound\" : 0,\n\t\t\t\"lowerBound\"
193
- : 0,\n\t\t\t\"trailingStop\" : 0\n\t\t}\n\t]\n}"
194
- http_version:
195
- recorded_at: Tue, 20 Jan 2015 17:22:31 GMT
196
- - request:
197
- method: post
198
- uri: http://api-sandbox.oanda.com/v1//accounts/5342358/orders
199
- body:
200
- encoding: UTF-8
201
- string: username=dwaymotim
202
- headers:
203
- X-Accept-Datetime-Format:
204
- - RFC3339
205
- Connection:
206
- - keep-alive
207
- Keep-Alive:
208
- - 30
209
- response:
210
- status:
211
- code: 400
212
- message: BAD_REQUEST
213
- headers:
214
- Server:
215
- - openresty/1.7.0.1
216
- Date:
217
- - Tue, 20 Jan 2015 21:03:07 GMT
218
- Content-Type:
219
- - application/json
220
- Content-Length:
221
- - '145'
222
- Connection:
223
- - keep-alive
224
- body:
225
- encoding: UTF-8
226
- string: "{\n\t\"code\" : 2,\n\t\"message\" : \"Missing required argument: type\",\n\t\"moreInfo\"
227
- : \"http:\\/\\/developer.oanda.com\\/docs\\/v1\\/troubleshooting\\/#errors\"\n}"
228
- http_version:
229
- recorded_at: Tue, 20 Jan 2015 21:03:07 GMT
230
- - request:
231
- method: delete
232
- uri: http://api-sandbox.oanda.com/v1/accounts/5342358/orders/orders/175503913?username=dwaymotim
233
- body:
234
- encoding: US-ASCII
235
- string: ''
236
- headers:
237
- X-Accept-Datetime-Format:
238
- - RFC3339
239
- Connection:
240
- - keep-alive
241
- Keep-Alive:
242
- - 30
243
- response:
244
- status:
245
- code: 400
246
- message: BAD_REQUEST
247
- headers:
248
- Server:
249
- - openresty/1.7.0.1
250
- Date:
251
- - Tue, 20 Jan 2015 23:53:33 GMT
252
- Content-Type:
253
- - application/json
254
- Content-Length:
255
- - '166'
256
- Connection:
257
- - keep-alive
258
- body:
259
- encoding: UTF-8
260
- string: "{\n\t\"code\" : 52,\n\t\"message\" : \"Invalid or malformed resource
261
- identifier: accountId\",\n\t\"moreInfo\" : \"http:\\/\\/developer.oanda.com\\/docs\\/v1\\/troubleshooting\\/#errors\"\n}"
262
- http_version:
263
- recorded_at: Tue, 20 Jan 2015 23:53:33 GMT
264
- recorded_with: VCR 2.9.3