iex-ruby-client 0.4.3 → 0.4.4
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 +4 -4
- data/.rubocop_todo.yml +15 -4
- data/CHANGELOG.md +7 -0
- data/README.md +98 -1
- data/iex-ruby-client.gemspec +1 -1
- data/lib/iex/api.rb +3 -0
- data/lib/iex/api/crypto.rb +13 -0
- data/lib/iex/api/dividends.rb +0 -1
- data/lib/iex/api/largest_trades.rb +13 -0
- data/lib/iex/api/sectors.rb +16 -0
- data/lib/iex/resources.rb +3 -0
- data/lib/iex/resources/crypto.rb +68 -0
- data/lib/iex/resources/largest_trades.rb +22 -0
- data/lib/iex/resources/sectors.rb +20 -0
- data/lib/iex/version.rb +1 -1
- data/spec/fixtures/iex/crypto.yml +101 -0
- data/spec/fixtures/iex/dividends/invalid.yml +6 -6
- data/spec/fixtures/iex/dividends/msft.yml +9 -9
- data/spec/fixtures/iex/dividends/msft_1y.yml +11 -9
- data/spec/fixtures/iex/dividends/msft_default_range.yml +8 -8
- data/spec/fixtures/iex/dividends/msft_invalid_range.yml +8 -10
- data/spec/fixtures/iex/largest-trades/aapl.yml +76 -0
- data/spec/fixtures/iex/largest-trades/invalid.yml +65 -0
- data/spec/fixtures/iex/sectors/invalid.yml +65 -0
- data/spec/fixtures/iex/sectors/sectors-performance.yml +72 -0
- data/spec/iex/resources/crypto_spec.rb +65 -0
- data/spec/iex/resources/dividends_spec.rb +2 -3
- data/spec/iex/resources/largest_trades_spec.rb +26 -0
- data/spec/iex/resources/sectors_spec.rb +28 -0
- metadata +28 -6
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IEX::Resources::Crypto do
|
4
|
+
context 'gets crypto information', vcr: { cassette_name: 'crypto' } do
|
5
|
+
subject do
|
6
|
+
IEX::Resources::Crypto.get
|
7
|
+
end
|
8
|
+
it 'retrieves real-time information' do
|
9
|
+
expect(subject.first.ask_price).to eq 6617.99
|
10
|
+
expect(subject.first.symbol).to eq 'BTCUSDT'
|
11
|
+
expect(subject.first.company_name).to eq 'Bitcoin USD'
|
12
|
+
expect(subject.first.primary_exchange).to eq 'crypto'
|
13
|
+
expect(subject.first.sector).to eq 'cryptocurrency'
|
14
|
+
expect(subject.first.calculation_price).to eq 'realtime'
|
15
|
+
expect(subject.first.open).to eq 6645.76
|
16
|
+
expect(subject.first.open_dollar).to eq '$6,645'
|
17
|
+
expect(subject.first.open_time).to eq 1_538_360_540_423
|
18
|
+
expect(subject.first.close).to eq 6595.49934953
|
19
|
+
expect(subject.first.close_dollar).to eq '$6,595'
|
20
|
+
expect(subject.first.close_time).to eq 1_538_446_940_423
|
21
|
+
expect(subject.first.high).to eq 6663.1
|
22
|
+
expect(subject.first.high_dollar).to eq '$6,663'
|
23
|
+
expect(subject.first.low).to eq 6510
|
24
|
+
expect(subject.first.low_dollar).to eq '$6,510'
|
25
|
+
expect(subject.first.latest_price).to eq 6618.7
|
26
|
+
expect(subject.first.latest_price_dollar).to eq '$6,618'
|
27
|
+
expect(subject.first.latest_source).to eq 'Real time price'
|
28
|
+
expect(subject.first.latest_time).to eq '10:22:20 PM'
|
29
|
+
expect(subject.first.latest_update).to eq 1_538_446_940_423
|
30
|
+
expect(subject.first.latest_volume).to eq 20_027.36393
|
31
|
+
expect(subject.first.latest_volume_dollar).to eq '$20,027'
|
32
|
+
expect(subject.first.iex_realtime_price).to eq nil
|
33
|
+
expect(subject.first.iex_realtime_size).to eq nil
|
34
|
+
expect(subject.first.iex_last_updated).to eq nil
|
35
|
+
expect(subject.first.delayed_price).to eq nil
|
36
|
+
expect(subject.first.delayed_price_time).to eq nil
|
37
|
+
expect(subject.first.extended_change).to eq nil
|
38
|
+
expect(subject.first.extended_change_percent).to eq nil
|
39
|
+
expect(subject.first.extended_price_time).to eq nil
|
40
|
+
expect(subject.first.previous_close).to eq 6645.76
|
41
|
+
expect(subject.first.previous_close_dollar).to eq '$6,645'
|
42
|
+
expect(subject.first.change).to eq -27.06
|
43
|
+
expect(subject.first.change_percent).to eq -0.00407
|
44
|
+
expect(subject.first.change_percent_s).to eq '-0.41%'
|
45
|
+
expect(subject.first.iex_market_percent).to eq nil
|
46
|
+
expect(subject.first.iex_volume).to eq nil
|
47
|
+
expect(subject.first.avg_total_volume).to eq nil
|
48
|
+
expect(subject.first.iex_bid_price).to eq nil
|
49
|
+
expect(subject.first.iex_bid_size).to eq nil
|
50
|
+
expect(subject.first.iex_ask_price).to eq nil
|
51
|
+
expect(subject.first.iex_ask_size).to eq nil
|
52
|
+
expect(subject.first.market_cap).to eq nil
|
53
|
+
expect(subject.first.pe_ratio).to eq nil
|
54
|
+
expect(subject.first.week52_high).to eq nil
|
55
|
+
expect(subject.first.week52_high_dollar).to eq nil
|
56
|
+
expect(subject.first.week52_low).to eq nil
|
57
|
+
expect(subject.first.week52_low_dollar).to eq nil
|
58
|
+
expect(subject.first.ytd_change).to eq nil
|
59
|
+
expect(subject.first.bid_price).to eq 6613.16
|
60
|
+
expect(subject.first.bid_size).to eq 2.166213
|
61
|
+
expect(subject.first.ask_price).to eq 6617.99
|
62
|
+
expect(subject.first.ask_size).to eq 0.264944
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -32,8 +32,7 @@ describe IEX::Resources::Dividends do
|
|
32
32
|
end
|
33
33
|
let(:dividends) { subject.first }
|
34
34
|
it 'retrieves dividends when invalid range is passed' do
|
35
|
-
expect(subject.size).to eq
|
36
|
-
expect(dividends.type).to eq 'Dividend income'
|
35
|
+
expect(subject.size).to eq 0
|
37
36
|
end
|
38
37
|
end
|
39
38
|
context 'with range', vcr: { cassette_name: 'dividends/msft_1y' } do
|
@@ -41,7 +40,7 @@ describe IEX::Resources::Dividends do
|
|
41
40
|
IEX::Resources::Dividends.get('MSFT', '1y')
|
42
41
|
end
|
43
42
|
it 'retrieves dividends with range of 1 year' do
|
44
|
-
expect(subject.size).to eq
|
43
|
+
expect(subject.size).to eq 4
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IEX::Resources::LargestTrades do
|
4
|
+
context 'retrieves the largest trade for a specific stock', vcr: { cassette_name: 'largest-trades/aapl' } do
|
5
|
+
subject do
|
6
|
+
IEX::Resources::LargestTrades.get('aapl')
|
7
|
+
end
|
8
|
+
it 'retrieve largest trades' do
|
9
|
+
expect(subject.first.size).to eq 9_000
|
10
|
+
expect(subject.first.price).to eq 217.76
|
11
|
+
expect(subject.first.time).to eq 1_539_699_300_665
|
12
|
+
expect(subject.first.time_label).to eq '10:15:00'
|
13
|
+
expect(subject.first.venue).to eq('None')
|
14
|
+
expect(subject.first.venue_name).to eq('Off Exchange')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'invalid symbol', vcr: { cassette_name: 'largest-trades/invalid' } do
|
19
|
+
subject do
|
20
|
+
IEX::Resources::LargestTrades.get('INVALID')
|
21
|
+
end
|
22
|
+
it 'fails with SymbolNotFoundError' do
|
23
|
+
expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe IEX::Resources::Sectors do
|
5
|
+
context 'known symbol' do
|
6
|
+
context 'with defaults', vcr: { cassette_name: 'sectors/sectors-performance' } do
|
7
|
+
subject do
|
8
|
+
IEX::Resources::Sectors.get('market')
|
9
|
+
end
|
10
|
+
let(:Sectors) { subject.first }
|
11
|
+
it 'retrieves Sectors' do
|
12
|
+
expect(subject.size).to eq 11
|
13
|
+
expect(subject.first.type).to eq('sector')
|
14
|
+
expect(subject.first.name).to eq 'Energy'
|
15
|
+
expect(subject.first.performance).to eq 0.01386
|
16
|
+
expect(subject.first.last_updated).to eq 1_538_424_000_406
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context 'invalid symbol', vcr: { cassette_name: 'sectors/invalid' } do
|
21
|
+
subject do
|
22
|
+
IEX::Resources::Sectors.get('INVALID')
|
23
|
+
end
|
24
|
+
it 'fails with SymbolNotFoundError' do
|
25
|
+
expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
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: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: money_helper
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '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: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,14 +161,17 @@ files:
|
|
161
161
|
- lib/iex/api.rb
|
162
162
|
- lib/iex/api/chart.rb
|
163
163
|
- lib/iex/api/company.rb
|
164
|
+
- lib/iex/api/crypto.rb
|
164
165
|
- lib/iex/api/dividends.rb
|
165
166
|
- lib/iex/api/earnings.rb
|
166
167
|
- lib/iex/api/key_stats.rb
|
168
|
+
- lib/iex/api/largest_trades.rb
|
167
169
|
- lib/iex/api/logo.rb
|
168
170
|
- lib/iex/api/news.rb
|
169
171
|
- lib/iex/api/ohlc.rb
|
170
172
|
- lib/iex/api/price.rb
|
171
173
|
- lib/iex/api/quote.rb
|
174
|
+
- lib/iex/api/sectors.rb
|
172
175
|
- lib/iex/errors.rb
|
173
176
|
- lib/iex/errors/client_error.rb
|
174
177
|
- lib/iex/errors/symbol_not_found_error.rb
|
@@ -179,9 +182,11 @@ files:
|
|
179
182
|
- lib/iex/resources/chart/default.rb
|
180
183
|
- lib/iex/resources/chart/one_day.rb
|
181
184
|
- lib/iex/resources/company.rb
|
185
|
+
- lib/iex/resources/crypto.rb
|
182
186
|
- lib/iex/resources/dividends.rb
|
183
187
|
- lib/iex/resources/earnings.rb
|
184
188
|
- lib/iex/resources/key_stats.rb
|
189
|
+
- lib/iex/resources/largest_trades.rb
|
185
190
|
- lib/iex/resources/logo.rb
|
186
191
|
- lib/iex/resources/news.rb
|
187
192
|
- lib/iex/resources/ohlc.rb
|
@@ -190,6 +195,7 @@ files:
|
|
190
195
|
- lib/iex/resources/price.rb
|
191
196
|
- lib/iex/resources/quote.rb
|
192
197
|
- lib/iex/resources/resource.rb
|
198
|
+
- lib/iex/resources/sectors.rb
|
193
199
|
- lib/iex/version.rb
|
194
200
|
- spec/fixtures/iex/chart/1d.yml
|
195
201
|
- spec/fixtures/iex/chart/20180227.yml
|
@@ -200,6 +206,7 @@ files:
|
|
200
206
|
- spec/fixtures/iex/chart/msft.yml
|
201
207
|
- spec/fixtures/iex/company/invalid.yml
|
202
208
|
- spec/fixtures/iex/company/msft.yml
|
209
|
+
- spec/fixtures/iex/crypto.yml
|
203
210
|
- spec/fixtures/iex/dividends/invalid.yml
|
204
211
|
- spec/fixtures/iex/dividends/msft.yml
|
205
212
|
- spec/fixtures/iex/dividends/msft_1y.yml
|
@@ -209,6 +216,8 @@ files:
|
|
209
216
|
- spec/fixtures/iex/earnings/msft.yml
|
210
217
|
- spec/fixtures/iex/key_stats/invalid.yml
|
211
218
|
- spec/fixtures/iex/key_stats/msft.yml
|
219
|
+
- spec/fixtures/iex/largest-trades/aapl.yml
|
220
|
+
- spec/fixtures/iex/largest-trades/invalid.yml
|
212
221
|
- spec/fixtures/iex/logo/msft.yml
|
213
222
|
- spec/fixtures/iex/news/invalid.yml
|
214
223
|
- spec/fixtures/iex/news/market.yml
|
@@ -220,17 +229,22 @@ files:
|
|
220
229
|
- spec/fixtures/iex/price/msft.yml
|
221
230
|
- spec/fixtures/iex/quote/invalid.yml
|
222
231
|
- spec/fixtures/iex/quote/msft.yml
|
232
|
+
- spec/fixtures/iex/sectors/invalid.yml
|
233
|
+
- spec/fixtures/iex/sectors/sectors-performance.yml
|
223
234
|
- spec/iex/resources/base_spec.rb
|
224
235
|
- spec/iex/resources/chart_spec.rb
|
225
236
|
- spec/iex/resources/company_spec.rb
|
237
|
+
- spec/iex/resources/crypto_spec.rb
|
226
238
|
- spec/iex/resources/dividends_spec.rb
|
227
239
|
- spec/iex/resources/earnings_spec.rb
|
228
240
|
- spec/iex/resources/key_stats_spec.rb
|
241
|
+
- spec/iex/resources/largest_trades_spec.rb
|
229
242
|
- spec/iex/resources/logo_spec.rb
|
230
243
|
- spec/iex/resources/news_spec.rb
|
231
244
|
- spec/iex/resources/ohlc_spec.rb
|
232
245
|
- spec/iex/resources/price_spec.rb
|
233
246
|
- spec/iex/resources/quote_spec.rb
|
247
|
+
- spec/iex/resources/sectors_spec.rb
|
234
248
|
- spec/iex/version_spec.rb
|
235
249
|
- spec/spec_helper.rb
|
236
250
|
- spec/support/vcr.rb
|
@@ -268,6 +282,7 @@ test_files:
|
|
268
282
|
- spec/fixtures/iex/chart/msft.yml
|
269
283
|
- spec/fixtures/iex/company/invalid.yml
|
270
284
|
- spec/fixtures/iex/company/msft.yml
|
285
|
+
- spec/fixtures/iex/crypto.yml
|
271
286
|
- spec/fixtures/iex/dividends/invalid.yml
|
272
287
|
- spec/fixtures/iex/dividends/msft.yml
|
273
288
|
- spec/fixtures/iex/dividends/msft_1y.yml
|
@@ -277,6 +292,8 @@ test_files:
|
|
277
292
|
- spec/fixtures/iex/earnings/msft.yml
|
278
293
|
- spec/fixtures/iex/key_stats/invalid.yml
|
279
294
|
- spec/fixtures/iex/key_stats/msft.yml
|
295
|
+
- spec/fixtures/iex/largest-trades/aapl.yml
|
296
|
+
- spec/fixtures/iex/largest-trades/invalid.yml
|
280
297
|
- spec/fixtures/iex/logo/msft.yml
|
281
298
|
- spec/fixtures/iex/news/invalid.yml
|
282
299
|
- spec/fixtures/iex/news/market.yml
|
@@ -288,17 +305,22 @@ test_files:
|
|
288
305
|
- spec/fixtures/iex/price/msft.yml
|
289
306
|
- spec/fixtures/iex/quote/invalid.yml
|
290
307
|
- spec/fixtures/iex/quote/msft.yml
|
308
|
+
- spec/fixtures/iex/sectors/invalid.yml
|
309
|
+
- spec/fixtures/iex/sectors/sectors-performance.yml
|
291
310
|
- spec/iex/resources/base_spec.rb
|
292
311
|
- spec/iex/resources/chart_spec.rb
|
293
312
|
- spec/iex/resources/company_spec.rb
|
313
|
+
- spec/iex/resources/crypto_spec.rb
|
294
314
|
- spec/iex/resources/dividends_spec.rb
|
295
315
|
- spec/iex/resources/earnings_spec.rb
|
296
316
|
- spec/iex/resources/key_stats_spec.rb
|
317
|
+
- spec/iex/resources/largest_trades_spec.rb
|
297
318
|
- spec/iex/resources/logo_spec.rb
|
298
319
|
- spec/iex/resources/news_spec.rb
|
299
320
|
- spec/iex/resources/ohlc_spec.rb
|
300
321
|
- spec/iex/resources/price_spec.rb
|
301
322
|
- spec/iex/resources/quote_spec.rb
|
323
|
+
- spec/iex/resources/sectors_spec.rb
|
302
324
|
- spec/iex/version_spec.rb
|
303
325
|
- spec/spec_helper.rb
|
304
326
|
- spec/support/vcr.rb
|