iex-ruby-client 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/danger.yml +20 -0
  3. data/.github/workflows/rubocop.yml +14 -0
  4. data/.github/workflows/test.yml +25 -0
  5. data/.gitignore +2 -0
  6. data/.rubocop.yml +1 -0
  7. data/.rubocop_todo.yml +8 -1
  8. data/CHANGELOG.md +14 -0
  9. data/CONTRIBUTING.md +1 -1
  10. data/Gemfile.danger +6 -0
  11. data/README.md +53 -16
  12. data/RELEASING.md +1 -1
  13. data/UPGRADING.md +23 -0
  14. data/iex-ruby-client.gemspec +3 -3
  15. data/lib/iex/api/client.rb +2 -0
  16. data/lib/iex/api/config/client.rb +2 -2
  17. data/lib/iex/api.rb +2 -0
  18. data/lib/iex/endpoints/fx.rb +13 -0
  19. data/lib/iex/endpoints/historial_prices.rb +2 -2
  20. data/lib/iex/endpoints/key_stat.rb +14 -0
  21. data/lib/iex/endpoints/ref_data.rb +5 -0
  22. data/lib/iex/errors/invalid_symbols_list.rb +14 -0
  23. data/lib/iex/errors/stat_not_found_error.rb +13 -0
  24. data/lib/iex/errors.rb +3 -1
  25. data/lib/iex/resources/currency_rate.rb +9 -0
  26. data/lib/iex/resources/resource.rb +5 -1
  27. data/lib/iex/resources/symbols.rb +5 -0
  28. data/lib/iex/resources.rb +1 -0
  29. data/lib/iex/version.rb +1 -1
  30. data/lib/iex-ruby-client.rb +1 -1
  31. data/script/console +9 -0
  32. data/spec/fixtures/iex/fx/invalid.yml +83 -0
  33. data/spec/fixtures/iex/fx/latest.yml +85 -0
  34. data/spec/fixtures/iex/fx/latest_one_symbol.yml +85 -0
  35. data/spec/fixtures/iex/key_stat/individual.yml +60 -0
  36. data/spec/fixtures/iex/key_stat/invalid_stat.yml +60 -0
  37. data/spec/fixtures/iex/key_stat/invalid_symbol.yml +50 -0
  38. data/spec/fixtures/iex/ref-data/exchange_symbols.yml +1 -1869
  39. data/spec/fixtures/iex/ref-data/region_symbols.yml +58 -0
  40. data/spec/iex/config/client_spec.rb +9 -3
  41. data/spec/iex/endpoints/fx_spec.rb +48 -0
  42. data/spec/iex/endpoints/key_stat_spec.rb +43 -0
  43. data/spec/iex/endpoints/ref_data_spec.rb +38 -8
  44. data/spec/support/client.rb +2 -0
  45. metadata +43 -16
  46. data/.travis.yml +0 -9
@@ -1,20 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe IEX::Api::Config::Client do
4
- before do
5
- IEX::Api.config.reset!
6
- end
4
+ before { IEX::Api.config.reset! }
5
+
7
6
  describe '#defaults' do
8
7
  it 'sets endpoint' do
9
8
  expect(IEX::Api.config.endpoint).to eq 'https://cloud.iexapis.com/v1'
10
9
  end
10
+
11
+ it 'does not set SSL options by default' do
12
+ expect(IEX::Api.config.ca_file).to be_nil
13
+ expect(IEX::Api.config.ca_path).to be_nil
14
+ end
11
15
  end
16
+
12
17
  describe '#configure' do
13
18
  before do
14
19
  IEX::Api.configure do |config|
15
20
  config.endpoint = 'updated'
16
21
  end
17
22
  end
23
+
18
24
  it 'sets endpoint' do
19
25
  expect(IEX::Api.config.endpoint).to eq 'updated'
20
26
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Endpoints::FX do
4
+ include_context 'client'
5
+
6
+ context 'known symbol', vcr: { cassette_name: 'fx/latest_one_symbol' } do
7
+ subject do
8
+ client.fx_latest('USDCAD')
9
+ end
10
+ it 'retrieves a list of CurrencyRates' do
11
+ expect(subject.length).to eq 1
12
+
13
+ expect(subject[0].symbol).to eq 'USDCAD'
14
+ expect(subject[0].rate).to eq 1.25674
15
+ expect(subject[0].timestamp).to eq Date.strptime('1627045829.863', '%s')
16
+ end
17
+ end
18
+
19
+ context 'known symbols', vcr: { cassette_name: 'fx/latest' } do
20
+ subject do
21
+ client.fx_latest(%w[USDCAD USDGBP USDJPY])
22
+ end
23
+ it 'retrieves a list of CurrencyRates' do
24
+ expect(subject.length).to eq 3
25
+
26
+ expect(subject[0].symbol).to eq 'USDCAD'
27
+ expect(subject[0].rate).to eq 1.25674
28
+ expect(subject[0].timestamp).to eq Date.strptime('1627045829.863', '%s')
29
+
30
+ expect(subject[1].symbol).to eq 'USDGBP'
31
+ expect(subject[1].rate).to eq 0.7262111386264443
32
+ expect(subject[1].timestamp).to eq Date.strptime('1627045780.863', '%s')
33
+
34
+ expect(subject[2].symbol).to eq 'USDJPY'
35
+ expect(subject[2].rate).to eq 110.426
36
+ expect(subject[2].timestamp).to eq Date.strptime('1627045825.365', '%s')
37
+ end
38
+ end
39
+
40
+ context 'invalid symbol', vcr: { cassette_name: 'fx/invalid' } do
41
+ subject do
42
+ client.fx_latest(%w[INVALID])
43
+ end
44
+ it 'fails with InvalidSymbolsList' do
45
+ expect { subject }.to raise_error IEX::Errors::InvalidSymbolsList, 'Invalid symbol list: INVALID'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Endpoints::KeyStat do
4
+ include_context 'client'
5
+
6
+ let(:stat) { 'ttmDividendRate' }
7
+ let(:symbol) { 'VTI' }
8
+
9
+ context 'when asking for a single stat', vcr: { cassette_name: 'key_stat/individual' } do
10
+ subject { client.key_stat(symbol, stat) }
11
+
12
+ it 'returns that stat in the type provided by the API' do
13
+ expect(subject).to be_within(0.0001).of(2.7887)
14
+ end
15
+ end
16
+
17
+ context 'invalid symbol', vcr: { cassette_name: 'key_stat/invalid_symbol' } do
18
+ subject { client.key_stat('INVALID', stat) }
19
+
20
+ it 'fails with SymbolNotFoundError' do
21
+ expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
22
+ end
23
+ end
24
+
25
+ context 'invalid stat', vcr: { cassette_name: 'key_stat/invalid_stat' } do
26
+ subject { client.key_stat(symbol, 'INVALID') }
27
+
28
+ it 'fails with StatNotFoundError' do
29
+ expect { subject }.to raise_error IEX::Errors::StatNotFoundError, 'Stat INVALID Not Found'
30
+ end
31
+
32
+ it 'keeps the API response so it can be used if caught' do
33
+ response = begin
34
+ subject
35
+ rescue IEX::Errors::StatNotFoundError => e
36
+ e.response
37
+ end
38
+
39
+ expect(response).to be_a(Hash)
40
+ expect(response).to have_key(stat)
41
+ end
42
+ end
43
+ end
@@ -87,24 +87,54 @@ describe IEX::Api::Client do
87
87
  subject { client.ref_data_symbols_for_exchange('TSX') }
88
88
 
89
89
  it 'retrieves all symbols' do
90
- expect(subject.count).to eq 1869
90
+ expect(subject.count).to eq 2351
91
91
  end
92
92
 
93
93
  context 'first symbol' do
94
94
  subject { client.ref_data_symbols_for_exchange('TSX').first }
95
95
  it 'retrieves a symbol data' do
96
- expect(subject.symbol).to eq 'A-CV'
97
- expect(subject.exchange).to eq 'TSX'
98
- expect(subject.name).to eq 'Armor Minerals Inc'
99
- expect(subject.date).to eq Date.parse('2021-05-14')
96
+ expect(subject.symbol).to eq 'A-CT'
97
+ expect(subject.exchange).to eq 'XTSE'
98
+ expect(subject.name).to eq 'Aurigen Capital Limited'
99
+ expect(subject.date).to eq Date.parse('2021-12-20')
100
100
  expect(subject.enabled).to eq true
101
101
  expect(subject.enabled?).to eq true
102
102
  expect(subject.type).to eq 'cs'
103
103
  expect(subject.region).to eq 'CA'
104
104
  expect(subject.currency).to eq 'CAD'
105
- expect(subject.iex_id).to eq 'IEX_4656374258322D52'
106
- expect(subject.figi).to eq 'BBG000V98LH2'
107
- expect(subject.cik).to eq '0001682145'
105
+ expect(subject.iex_id).to eq nil
106
+ expect(subject.figi).to eq nil
107
+ expect(subject.cik).to eq nil
108
+ end
109
+ end
110
+ end
111
+
112
+ describe '#ref_data_symbols_for_region', vcr: { cassette_name: 'ref-data/region_symbols' } do
113
+ subject { client.ref_data_symbols_for_region('ca') }
114
+
115
+ it 'retrieves all symbols' do
116
+ expect(subject.count).to eq 4977
117
+ end
118
+
119
+ context 'first symbol' do
120
+ subject { client.ref_data_symbols_for_region('ca').first }
121
+ it 'retrieves symbol data' do
122
+ expect(subject.symbol).to eq 'A-CT'
123
+ expect(subject.exchange).to eq 'XTSE'
124
+ expect(subject.exchange_suffix).to eq 'CT'
125
+ expect(subject.exchange_name).to eq 'Toronto Stock Exchange'
126
+ expect(subject.exchange_segment).to eq 'XTSE'
127
+ expect(subject.name).to eq 'Aurigen Capital Limited'
128
+ expect(subject.date).to eq Date.parse('2021-12-20')
129
+ expect(subject.enabled).to eq true
130
+ expect(subject.enabled?).to eq true
131
+ expect(subject.type).to eq 'cs'
132
+ expect(subject.region).to eq 'CA'
133
+ expect(subject.currency).to eq 'CAD'
134
+ expect(subject.iex_id).to eq nil
135
+ expect(subject.figi).to eq nil
136
+ expect(subject.cik).to eq nil
137
+ expect(subject.lei).to eq nil
108
138
  end
109
139
  end
110
140
  end
@@ -1,3 +1,5 @@
1
+ require 'rspec'
2
+
1
3
  RSpec.shared_context 'client' do |opts|
2
4
  let(:client) { IEX::Api::Client.new(opts || {}) }
3
5
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iex-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-15 00:00:00.000000000 Z
11
+ date: 2022-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: money_helper
56
+ name: money
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '6.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '6.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.72.0
103
+ version: 0.75.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.72.0
110
+ version: 0.75.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: vcr
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email: dblock@dblock.org
141
141
  executables: []
142
142
  extensions: []
@@ -144,15 +144,18 @@ extra_rdoc_files: []
144
144
  files:
145
145
  - ".env.sample"
146
146
  - ".github/FUNDING.yml"
147
+ - ".github/workflows/danger.yml"
148
+ - ".github/workflows/rubocop.yml"
149
+ - ".github/workflows/test.yml"
147
150
  - ".gitignore"
148
151
  - ".rspec"
149
152
  - ".rubocop.yml"
150
153
  - ".rubocop_todo.yml"
151
- - ".travis.yml"
152
154
  - CHANGELOG.md
153
155
  - CONTRIBUTING.md
154
156
  - Dangerfile
155
157
  - Gemfile
158
+ - Gemfile.danger
156
159
  - LICENSE.md
157
160
  - README.md
158
161
  - RELEASING.md
@@ -176,8 +179,10 @@ files:
176
179
  - lib/iex/endpoints/crypto.rb
177
180
  - lib/iex/endpoints/dividends.rb
178
181
  - lib/iex/endpoints/earnings.rb
182
+ - lib/iex/endpoints/fx.rb
179
183
  - lib/iex/endpoints/historial_prices.rb
180
184
  - lib/iex/endpoints/income.rb
185
+ - lib/iex/endpoints/key_stat.rb
181
186
  - lib/iex/endpoints/key_stats.rb
182
187
  - lib/iex/endpoints/largest_trades.rb
183
188
  - lib/iex/endpoints/logo.rb
@@ -190,7 +195,9 @@ files:
190
195
  - lib/iex/endpoints/stock_market.rb
191
196
  - lib/iex/errors.rb
192
197
  - lib/iex/errors/client_error.rb
198
+ - lib/iex/errors/invalid_symbols_list.rb
193
199
  - lib/iex/errors/permission_denied_error.rb
200
+ - lib/iex/errors/stat_not_found_error.rb
194
201
  - lib/iex/errors/symbol_not_found_error.rb
195
202
  - lib/iex/logger.rb
196
203
  - lib/iex/resources.rb
@@ -200,6 +207,7 @@ files:
200
207
  - lib/iex/resources/chart.rb
201
208
  - lib/iex/resources/company.rb
202
209
  - lib/iex/resources/crypto.rb
210
+ - lib/iex/resources/currency_rate.rb
203
211
  - lib/iex/resources/dividends.rb
204
212
  - lib/iex/resources/earnings.rb
205
213
  - lib/iex/resources/historical_prices.rb
@@ -215,6 +223,7 @@ files:
215
223
  - lib/iex/resources/symbol.rb
216
224
  - lib/iex/resources/symbols.rb
217
225
  - lib/iex/version.rb
226
+ - script/console
218
227
  - spec/fixtures/iex/advanced_stats/invalid.yml
219
228
  - spec/fixtures/iex/advanced_stats/msft.yml
220
229
  - spec/fixtures/iex/balance_sheet/invalid.yml
@@ -239,6 +248,9 @@ files:
239
248
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
240
249
  - spec/fixtures/iex/earnings/invalid.yml
241
250
  - spec/fixtures/iex/earnings/msft.yml
251
+ - spec/fixtures/iex/fx/invalid.yml
252
+ - spec/fixtures/iex/fx/latest.yml
253
+ - spec/fixtures/iex/fx/latest_one_symbol.yml
242
254
  - spec/fixtures/iex/historical_prices/abcd.yml
243
255
  - spec/fixtures/iex/historical_prices/invalid.yml
244
256
  - spec/fixtures/iex/historical_prices/invalid_date.yml
@@ -250,6 +262,9 @@ files:
250
262
  - spec/fixtures/iex/income/invalid.yml
251
263
  - spec/fixtures/iex/income/msft.yml
252
264
  - spec/fixtures/iex/income/nsrgy.yml
265
+ - spec/fixtures/iex/key_stat/individual.yml
266
+ - spec/fixtures/iex/key_stat/invalid_stat.yml
267
+ - spec/fixtures/iex/key_stat/invalid_symbol.yml
253
268
  - spec/fixtures/iex/key_stats/invalid.yml
254
269
  - spec/fixtures/iex/key_stats/msft.yml
255
270
  - spec/fixtures/iex/largest-trades/aapl.yml
@@ -267,6 +282,7 @@ files:
267
282
  - spec/fixtures/iex/ref-data/exchange_symbols.yml
268
283
  - spec/fixtures/iex/ref-data/isin.yml
269
284
  - spec/fixtures/iex/ref-data/isin_mapped.yml
285
+ - spec/fixtures/iex/ref-data/region_symbols.yml
270
286
  - spec/fixtures/iex/ref-data/symbols.yml
271
287
  - spec/fixtures/iex/ref-data/wrong_isin_mapped.yml
272
288
  - spec/fixtures/iex/sectors/invalid.yml
@@ -283,8 +299,10 @@ files:
283
299
  - spec/iex/endpoints/crypto_spec.rb
284
300
  - spec/iex/endpoints/dividends_spec.rb
285
301
  - spec/iex/endpoints/earnings_spec.rb
302
+ - spec/iex/endpoints/fx_spec.rb
286
303
  - spec/iex/endpoints/historical_prices_spec.rb
287
304
  - spec/iex/endpoints/income_spec.rb
305
+ - spec/iex/endpoints/key_stat_spec.rb
288
306
  - spec/iex/endpoints/key_stats_spec.rb
289
307
  - spec/iex/endpoints/largest_trades_spec.rb
290
308
  - spec/iex/endpoints/logo_spec.rb
@@ -304,7 +322,7 @@ homepage: http://github.com/dblock/iex-ruby-client
304
322
  licenses:
305
323
  - MIT
306
324
  metadata: {}
307
- post_install_message:
325
+ post_install_message:
308
326
  rdoc_options: []
309
327
  require_paths:
310
328
  - lib
@@ -312,15 +330,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
330
  requirements:
313
331
  - - ">="
314
332
  - !ruby/object:Gem::Version
315
- version: 2.3.0
333
+ version: 2.4.0
316
334
  required_rubygems_version: !ruby/object:Gem::Requirement
317
335
  requirements:
318
336
  - - ">="
319
337
  - !ruby/object:Gem::Version
320
338
  version: 1.3.6
321
339
  requirements: []
322
- rubygems_version: 3.1.4
323
- signing_key:
340
+ rubygems_version: 3.3.18
341
+ signing_key:
324
342
  specification_version: 4
325
343
  summary: IEX Finance API Ruby client with support for retrieving stock quotes.
326
344
  test_files:
@@ -348,6 +366,9 @@ test_files:
348
366
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
349
367
  - spec/fixtures/iex/earnings/invalid.yml
350
368
  - spec/fixtures/iex/earnings/msft.yml
369
+ - spec/fixtures/iex/fx/invalid.yml
370
+ - spec/fixtures/iex/fx/latest.yml
371
+ - spec/fixtures/iex/fx/latest_one_symbol.yml
351
372
  - spec/fixtures/iex/historical_prices/abcd.yml
352
373
  - spec/fixtures/iex/historical_prices/invalid.yml
353
374
  - spec/fixtures/iex/historical_prices/invalid_date.yml
@@ -359,6 +380,9 @@ test_files:
359
380
  - spec/fixtures/iex/income/invalid.yml
360
381
  - spec/fixtures/iex/income/msft.yml
361
382
  - spec/fixtures/iex/income/nsrgy.yml
383
+ - spec/fixtures/iex/key_stat/individual.yml
384
+ - spec/fixtures/iex/key_stat/invalid_stat.yml
385
+ - spec/fixtures/iex/key_stat/invalid_symbol.yml
362
386
  - spec/fixtures/iex/key_stats/invalid.yml
363
387
  - spec/fixtures/iex/key_stats/msft.yml
364
388
  - spec/fixtures/iex/largest-trades/aapl.yml
@@ -376,6 +400,7 @@ test_files:
376
400
  - spec/fixtures/iex/ref-data/exchange_symbols.yml
377
401
  - spec/fixtures/iex/ref-data/isin.yml
378
402
  - spec/fixtures/iex/ref-data/isin_mapped.yml
403
+ - spec/fixtures/iex/ref-data/region_symbols.yml
379
404
  - spec/fixtures/iex/ref-data/symbols.yml
380
405
  - spec/fixtures/iex/ref-data/wrong_isin_mapped.yml
381
406
  - spec/fixtures/iex/sectors/invalid.yml
@@ -392,8 +417,10 @@ test_files:
392
417
  - spec/iex/endpoints/crypto_spec.rb
393
418
  - spec/iex/endpoints/dividends_spec.rb
394
419
  - spec/iex/endpoints/earnings_spec.rb
420
+ - spec/iex/endpoints/fx_spec.rb
395
421
  - spec/iex/endpoints/historical_prices_spec.rb
396
422
  - spec/iex/endpoints/income_spec.rb
423
+ - spec/iex/endpoints/key_stat_spec.rb
397
424
  - spec/iex/endpoints/key_stats_spec.rb
398
425
  - spec/iex/endpoints/largest_trades_spec.rb
399
426
  - spec/iex/endpoints/logo_spec.rb
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
-
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.4.1
7
-
8
- before_script:
9
- - bundle exec danger