oanda_api 0.9.4 → 0.9.5

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.
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
@@ -1,75 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://api-sandbox.oanda.com/v1/accounts
6
- body:
7
- encoding: UTF-8
8
- string: 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:26 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '77'
29
- Connection:
30
- - keep-alive
31
- Location:
32
- - http://api-sandbox.oanda.com/v1/accounts/7079317
33
- body:
34
- encoding: UTF-8
35
- string: "{\n\t\"username\" : \"shenry\",\n\t\"password\" : \"heewgUjEd\",\n\t\"accountId\"
36
- : 7079317\n}"
37
- http_version:
38
- recorded_at: Tue, 20 Jan 2015 17:22:28 GMT
39
- - request:
40
- method: post
41
- uri: http://api-sandbox.oanda.com/v1/accounts/
42
- body:
43
- encoding: UTF-8
44
- string: username=paudougles
45
- headers:
46
- X-Accept-Datetime-Format:
47
- - RFC3339
48
- Connection:
49
- - keep-alive
50
- Keep-Alive:
51
- - 30
52
- response:
53
- status:
54
- code: 201
55
- message: CREATED
56
- headers:
57
- Server:
58
- - openresty/1.7.0.1
59
- Date:
60
- - Tue, 20 Jan 2015 23:27:03 GMT
61
- Content-Type:
62
- - application/json
63
- Content-Length:
64
- - '79'
65
- Connection:
66
- - keep-alive
67
- Location:
68
- - http://api-sandbox.oanda.com/v1/accounts/2107190
69
- body:
70
- encoding: UTF-8
71
- string: "{\n\t\"username\" : \"flouglee\",\n\t\"password\" : \"1Swasyof9\",\n\t\"accountId\"
72
- : 2107190\n}"
73
- http_version:
74
- recorded_at: Tue, 20 Jan 2015 23:27:03 GMT
75
- recorded_with: VCR 2.9.3
@@ -1,116 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: http://api-sandbox.oanda.com/v1/accounts
6
- body:
7
- encoding: UTF-8
8
- string: username=_
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:25 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '79'
29
- Connection:
30
- - keep-alive
31
- Location:
32
- - http://api-sandbox.oanda.com/v1/accounts/5342358
33
- body:
34
- encoding: UTF-8
35
- string: "{\n\t\"username\" : \"dwaymotim\",\n\t\"password\" : \"hoHahaHu\",\n\t\"accountId\"
36
- : 5342358\n}"
37
- http_version:
38
- recorded_at: Tue, 20 Jan 2015 17:22:28 GMT
39
- - request:
40
- method: post
41
- uri: http://api-sandbox.oanda.com/v1account
42
- body:
43
- encoding: UTF-8
44
- string: username=_
45
- headers:
46
- X-Accept-Datetime-Format:
47
- - RFC3339
48
- Connection:
49
- - keep-alive
50
- Keep-Alive:
51
- - 30
52
- response:
53
- status:
54
- code: 404
55
- message: Not Found
56
- headers:
57
- Server:
58
- - openresty/1.7.0.1
59
- Date:
60
- - Tue, 20 Jan 2015 21:20:26 GMT
61
- Content-Type:
62
- - application/json
63
- Content-Length:
64
- - '170'
65
- Connection:
66
- - keep-alive
67
- Etag:
68
- - '"53f4b7f5-aa"'
69
- body:
70
- encoding: UTF-8
71
- string: |+
72
- {
73
- "code" : 38,
74
- "message" : "No matching handler for the request is found",
75
- "moreInfo" : "http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"
76
- }
77
-
78
- http_version:
79
- recorded_at: Tue, 20 Jan 2015 21:20:26 GMT
80
- - request:
81
- method: post
82
- uri: http://api-sandbox.oanda.com/v1/accounts/
83
- body:
84
- encoding: UTF-8
85
- string: username=_
86
- headers:
87
- X-Accept-Datetime-Format:
88
- - RFC3339
89
- Connection:
90
- - keep-alive
91
- Keep-Alive:
92
- - 30
93
- response:
94
- status:
95
- code: 201
96
- message: CREATED
97
- headers:
98
- Server:
99
- - openresty/1.7.0.1
100
- Date:
101
- - Tue, 20 Jan 2015 23:27:03 GMT
102
- Content-Type:
103
- - application/json
104
- Content-Length:
105
- - '82'
106
- Connection:
107
- - keep-alive
108
- Location:
109
- - http://api-sandbox.oanda.com/v1/accounts/1724176
110
- body:
111
- encoding: UTF-8
112
- string: "{\n\t\"username\" : \"paudougles\",\n\t\"password\" : \"AtIrgElCyp\",\n\t\"accountId\"
113
- : 1724176\n}"
114
- http_version:
115
- recorded_at: Tue, 20 Jan 2015 23:27:02 GMT
116
- recorded_with: VCR 2.9.3
@@ -1,111 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api-sandbox.oanda.com/v1/accounts?username=dwaymotim
6
- body:
7
- encoding: US-ASCII
8
- string: ''
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: 200
19
- message: OK
20
- headers:
21
- Server:
22
- - openresty/1.7.0.1
23
- Date:
24
- - Tue, 20 Jan 2015 17:22:27 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '139'
29
- Connection:
30
- - keep-alive
31
- Etag:
32
- - '"2c8bda3c0aced2c86025961c4e2da0452332ea36"'
33
- body:
34
- encoding: UTF-8
35
- string: "{\n\t\"accounts\" : [\n\t\t{\n\t\t\t\"accountId\" : 5342358,\n\t\t\t\"accountName\"
36
- : \"Primary\",\n\t\t\t\"accountCurrency\" : \"USD\",\n\t\t\t\"marginRate\"
37
- : 0.05\n\t\t}\n\t]\n}"
38
- http_version:
39
- recorded_at: Tue, 20 Jan 2015 17:22:29 GMT
40
- - request:
41
- method: get
42
- uri: http://api-sandbox.oanda.com/v1/accounts/?username=paudougles
43
- body:
44
- encoding: US-ASCII
45
- string: ''
46
- headers:
47
- X-Accept-Datetime-Format:
48
- - RFC3339
49
- Connection:
50
- - keep-alive
51
- Keep-Alive:
52
- - 30
53
- response:
54
- status:
55
- code: 200
56
- message: OK
57
- headers:
58
- Server:
59
- - openresty/1.7.0.1
60
- Date:
61
- - Tue, 20 Jan 2015 23:27:05 GMT
62
- Content-Type:
63
- - application/json
64
- Content-Length:
65
- - '139'
66
- Connection:
67
- - keep-alive
68
- Etag:
69
- - '"61cce213956060b4ccb6fd9f47235b4c03e74095"'
70
- body:
71
- encoding: UTF-8
72
- string: "{\n\t\"accounts\" : [\n\t\t{\n\t\t\t\"accountId\" : 1724176,\n\t\t\t\"accountName\"
73
- : \"Primary\",\n\t\t\t\"accountCurrency\" : \"USD\",\n\t\t\t\"marginRate\"
74
- : 0.05\n\t\t}\n\t]\n}"
75
- http_version:
76
- recorded_at: Tue, 20 Jan 2015 23:27:05 GMT
77
- - request:
78
- method: get
79
- uri: http://api-sandbox.oanda.com/v1/accounts?username
80
- body:
81
- encoding: US-ASCII
82
- string: ''
83
- headers:
84
- X-Accept-Datetime-Format:
85
- - RFC3339
86
- Connection:
87
- - keep-alive
88
- Keep-Alive:
89
- - 30
90
- response:
91
- status:
92
- code: 404
93
- message: NOT_FOUND
94
- headers:
95
- Server:
96
- - openresty/1.7.0.1
97
- Date:
98
- - Fri, 23 Jan 2015 17:37:53 GMT
99
- Content-Type:
100
- - application/json
101
- Content-Length:
102
- - '144'
103
- Connection:
104
- - keep-alive
105
- body:
106
- encoding: UTF-8
107
- string: "{\n\t\"code\" : 55,\n\t\"message\" : \"Username specified is invalid\",\n\t\"moreInfo\"
108
- : \"http:\\/\\/developer.oanda.com\\/docs\\/v1\\/troubleshooting\\/#errors\"\n}"
109
- http_version:
110
- recorded_at: Fri, 23 Jan 2015 17:37:53 GMT
111
- recorded_with: VCR 2.9.3
@@ -1,77 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api-sandbox.oanda.com/v1/prices?instruments=EUR_USD&username=dwaymotim
6
- body:
7
- encoding: US-ASCII
8
- string: ''
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: 200
19
- message: OK
20
- headers:
21
- Server:
22
- - openresty/1.7.0.1
23
- Date:
24
- - Tue, 20 Jan 2015 17:22:27 GMT
25
- Content-Type:
26
- - application/json
27
- Content-Length:
28
- - '139'
29
- Connection:
30
- - keep-alive
31
- Etag:
32
- - '"4c7f5d9d4c94c9bf6cdadb72776e76f6427cf98e"'
33
- body:
34
- encoding: UTF-8
35
- string: "{\n\t\"prices\" : [\n\t\t{\n\t\t\t\"instrument\" : \"EUR_USD\",\n\t\t\t\"time\"
36
- : \"2015-01-20T17:21:05.832175Z\",\n\t\t\t\"bid\" : 1.24089,\n\t\t\t\"ask\"
37
- : 1.24101\n\t\t}\n\t]\n}"
38
- http_version:
39
- recorded_at: Tue, 20 Jan 2015 17:22:30 GMT
40
- - request:
41
- method: get
42
- uri: http://api-sandbox.oanda.com/v1/prices?instruments=EUR_USD&username
43
- body:
44
- encoding: US-ASCII
45
- string: ''
46
- headers:
47
- X-Accept-Datetime-Format:
48
- - RFC3339
49
- Connection:
50
- - keep-alive
51
- Keep-Alive:
52
- - 30
53
- response:
54
- status:
55
- code: 200
56
- message: OK
57
- headers:
58
- Server:
59
- - openresty/1.7.0.1
60
- Date:
61
- - Fri, 23 Jan 2015 17:37:53 GMT
62
- Content-Type:
63
- - application/json
64
- Content-Length:
65
- - '138'
66
- Connection:
67
- - keep-alive
68
- Etag:
69
- - '"16d16d0147a57d698b64bb4f5c784e4cc0256695"'
70
- body:
71
- encoding: UTF-8
72
- string: "{\n\t\"prices\" : [\n\t\t{\n\t\t\t\"instrument\" : \"EUR_USD\",\n\t\t\t\"time\"
73
- : \"2015-01-23T17:37:49.093636Z\",\n\t\t\t\"bid\" : 1.2403,\n\t\t\t\"ask\"
74
- : 1.24048\n\t\t}\n\t]\n}"
75
- http_version:
76
- recorded_at: Fri, 23 Jan 2015 17:37:53 GMT
77
- recorded_with: VCR 2.9.3
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "OandaAPI::Client::UsernameClient" do
4
- let(:client) { OandaAPI::Client::UsernameClient.new("spongebob") }
5
-
6
- describe "#initialize" do
7
- it "sets the username" do
8
- expect(client.username).to eq("spongebob")
9
- end
10
-
11
- it "sets domain to sandbox" do
12
- expect(client.domain).to eq(:sandbox)
13
- end
14
-
15
- it "sets default_params to include username" do
16
- expect(client.default_params).to include("username" => "spongebob")
17
- end
18
- end
19
-
20
- describe "#auth" do
21
- it "returns a hash with username" do
22
- expect(client.auth["username"]).to eq("spongebob")
23
- end
24
- end
25
-
26
- describe "#default_params" do
27
- it "initialize as #auth" do
28
- expect(client.default_params).to eq(client.auth)
29
- end
30
- end
31
- end