iex-ruby-client 0.4.2 → 0.4.3

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
- SHA1:
3
- metadata.gz: c7e9b5e2e6d7d24bdd96a69cc425066f793e3d37
4
- data.tar.gz: d5173ee19bc5a824a9ba55e297911c895fe77b69
2
+ SHA256:
3
+ metadata.gz: aadc76d9ae171fdabe4a3ea228f886eaee9d4eba1be253e340fae6df21a08f67
4
+ data.tar.gz: 4d0f8dc08ec139b05f0f00ae265487b9c6cc1b13b29b7e8e56935add30651511
5
5
  SHA512:
6
- metadata.gz: 89c30e29f8fc386597b870ec70f4181f8a7b3db659fc6532caea0c439b0fde7f91375bb8575fe0c8fe0fefbfc0c87d1fe0a0cd56ba87930a2cc41e4bf0d50e9e
7
- data.tar.gz: 34697845fe238e7ac05e9a77da770e87fb191aba6865a5291567caed7860aa5afe072d1df2f591e068723028ce4c906f67f87877dd859f43757d77e8c7f517d0
6
+ metadata.gz: 3ca0fbb369bcc5c5f860c4d29e24c21bca12138b2393f5afc50029f9065bd88862018d760b0d615b84f8579b53e32bfaf410c7fdf4902561809c9d01da94fbb3
7
+ data.tar.gz: f750e5d85f77744783e4a8a0ff7f335991775971cab7b444996287b948bf71f97d226065e09d0ba5b9af428a80fc1f8abd4cf79ae3e8f19f0b219ca2252916a1
@@ -1,3 +1,7 @@
1
+ ### 0.4.3 (2018/08/18)
2
+
3
+ * [#27](https://github.com/dblock/iex-ruby-client/pull/27): Added `IEX::Resources::Earnings` - [@rodolfobandeira](https://github.com/rodolfobandeira).
4
+
1
5
  ### 0.4.2 (2018/08/14)
2
6
 
3
7
  * [#24](https://github.com/dblock/iex-ruby-client/pull/24): Add danger-toc and danger-changelog - [@rodolfobandeira](https://github.com/rodolfobandeira).
data/Gemfile CHANGED
@@ -2,11 +2,8 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- group :development do
6
- gem 'pry'
7
- end
8
-
9
5
  group :test do
10
6
  gem 'danger-changelog', '~> 0.3.0'
11
7
  gem 'danger-toc', '~> 0.1'
8
+ gem 'pry'
12
9
  end
data/README.md CHANGED
@@ -10,7 +10,7 @@ A Ruby client for the [IEX Finance API](https://iextrading.com/developer).
10
10
  # Table of Contents
11
11
 
12
12
  - [Installation](#installation)
13
- - [Methods Available:](#methods-available)
13
+ - [Methods Available](#methods-available)
14
14
  - [Usage](#usage)
15
15
  - [Get a Single Price](#get-a-single-price)
16
16
  - [Get a Quote](#get-a-quote)
@@ -22,6 +22,7 @@ A Ruby client for the [IEX Finance API](https://iextrading.com/developer).
22
22
  - [Get Chart](#get-chart)
23
23
  - [Get Key Stats](#get-key-stats)
24
24
  - [Get Dividends](#get-dividends)
25
+ - [Get Earnings](#get-earnings)
25
26
  - [Errors](#errors)
26
27
  - [SymbolNotFound](#symbolnotfound)
27
28
  - [ClientError](#clienterror)
@@ -40,7 +41,7 @@ gem 'iex-ruby-client'
40
41
  Run `bundle install`.
41
42
 
42
43
 
43
- ## Methods Available:
44
+ ## Methods Available
44
45
 
45
46
  - [Get a Single Price](#get-a-single-price)
46
47
  - [Get a Quote](#get-a-quote)
@@ -52,6 +53,7 @@ Run `bundle install`.
52
53
  - [Get Chart](#get-chat)
53
54
  - [Get Key Stats](#get-key-stats)
54
55
  - [Get Dividends](#get-dividends)
56
+ - [Get Earnings](#get-earnings)
55
57
 
56
58
 
57
59
  ## Usage
@@ -276,6 +278,32 @@ dividends.indicated # ''
276
278
  See [#dividends](https://iextrading.com/developer/docs/#dividends) for detailed documentation or [dividends.rb](lib/iex/resources/dividends.rb) for returned fields.
277
279
 
278
280
 
281
+ ### Get Earnings
282
+
283
+ Fetches earnings for a symbol.
284
+
285
+ ```ruby
286
+ earnings = IEX::Resources::Earnings.get('MSFT')
287
+
288
+ earnings.actual_eps # 1.13
289
+ earnings.consensus_eps # 1.07
290
+ earnings.estimated_eps # 1.07
291
+ earnings.announce_time # 'AMC'
292
+ earnings.number_of_estimates # 14
293
+ earnings.eps_surprise_dollar # 0.06
294
+ earnings.eps_report_date # '2018-07-19'
295
+ earnings.fiscal_period # 'Q4 2018'
296
+ earnings.fiscal_end_date # '2018-06-30'
297
+ earnings.year_ago # 0.98
298
+ earnings.year_ago_change_percent # 0.15306122448979584
299
+ earnings.year_ago_change_percent_s # '+15.31%'
300
+ earnings.estimated_change_percent # 0.09183673469387764
301
+ earnings.estimated_change_percent_s # '+9.18%'
302
+ earnings.symbol_id # 4563
303
+ ```
304
+ See [#earnings](https://iextrading.com/developer/docs/#earnings) for detailed documentation or [earnings.rb](lib/iex/resources/earnings.rb) for returned fields.
305
+
306
+
279
307
  ## Errors
280
308
 
281
309
  ### SymbolNotFound
@@ -20,6 +20,7 @@ end
20
20
  require_relative 'api/chart'
21
21
  require_relative 'api/company'
22
22
  require_relative 'api/dividends'
23
+ require_relative 'api/earnings'
23
24
  require_relative 'api/logo'
24
25
  require_relative 'api/key_stats'
25
26
  require_relative 'api/news'
@@ -13,12 +13,6 @@ module IEX
13
13
  end
14
14
 
15
15
  def self.connection(symbol, range)
16
- puts [
17
- symbol,
18
- 'chart',
19
- range && range.respond_to?(:strftime) ? "date/#{range.strftime('%Y%m%d')}" : range
20
- ].compact.join('/')
21
-
22
16
  IEX::Api.default_connection [
23
17
  symbol,
24
18
  'chart',
@@ -0,0 +1,13 @@
1
+ module IEX
2
+ module Api
3
+ module Earnings
4
+ def self.get(symbol)
5
+ connection(symbol).get.body
6
+ end
7
+
8
+ def self.connection(symbol)
9
+ IEX::Api.default_connection "#{symbol}/earnings"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,7 @@ require_relative 'resources/resource'
3
3
  require_relative 'resources/chart'
4
4
  require_relative 'resources/company'
5
5
  require_relative 'resources/dividends'
6
+ require_relative 'resources/earnings'
6
7
  require_relative 'resources/key_stats'
7
8
  require_relative 'resources/logo'
8
9
  require_relative 'resources/news'
@@ -0,0 +1,31 @@
1
+ require_relative 'base'
2
+
3
+ module IEX
4
+ module Resources
5
+ class Earnings < Resource
6
+ property 'actual_eps', from: 'actualEPS'
7
+ property 'consensus_eps', from: 'consensusEPS'
8
+ property 'estimated_eps', from: 'estimatedEPS'
9
+ property 'announce_time', from: 'announceTime'
10
+ property 'number_of_estimates', from: 'numberOfEstimates'
11
+ property 'eps_surprise_dollar', from: 'EPSSurpriseDollar'
12
+ property 'eps_report_date', from: 'EPSReportDate'
13
+ property 'fiscal_period', from: 'fiscalPeriod'
14
+ property 'fiscal_end_date', from: 'fiscalEndDate'
15
+ property 'year_ago', from: 'yearAgo'
16
+ property 'year_ago_change_percent', from: 'yearAgoChangePercent'
17
+ property 'year_ago_change_percent_s', from: 'yearAgoChangePercent', with: ->(v) { Base.float_to_percentage(v) }
18
+ property 'estimated_change_percent', from: 'estimatedChangePercent'
19
+ property 'estimated_change_percent_s', from: 'estimatedChangePercent', with: ->(v) { Base.float_to_percentage(v) }
20
+ property 'symbol_id', from: 'symbolId'
21
+
22
+ def self.get(stock_symbol)
23
+ Base.symbol(stock_symbol) do
24
+ IEX::Api::Earnings.get(stock_symbol)['earnings'].map do |data|
25
+ new data
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module IEX
2
- VERSION = '0.4.2'.freeze
2
+ VERSION = '0.4.3'.freeze
3
3
  end
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.iextrading.com/1.0/stock/INVALID/earnings
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 404
19
+ message: Not Found
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Wed, 15 Aug 2018 01:06:15 GMT
25
+ Content-Type:
26
+ - text/html; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=29d5876cf17f40ebb98f027a7a443647; Domain=.iextrading.com; Path=/; Expires=Wed,
33
+ 15 Aug 2018 13:06:15 GMT; Secure
34
+ Content-Security-Policy:
35
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
36
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
37
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
38
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
39
+ 'self' 'unsafe-inline' 'unsafe-eval';
40
+ X-Content-Security-Policy:
41
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
42
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
43
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
44
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
45
+ 'self' 'unsafe-inline' 'unsafe-eval';
46
+ Frame-Options:
47
+ - SAMEORIGIN
48
+ X-Frame-Options:
49
+ - SAMEORIGIN
50
+ Strict-Transport-Security:
51
+ - max-age=15768000
52
+ Access-Control-Allow-Origin:
53
+ - "*"
54
+ Access-Control-Allow-Credentials:
55
+ - 'true'
56
+ Access-Control-Allow-Methods:
57
+ - GET, OPTIONS
58
+ Access-Control-Allow-Headers:
59
+ - Origin, X-Requested-With, Content-Type, Accept
60
+ body:
61
+ encoding: ASCII-8BIT
62
+ string: Unknown symbol
63
+ http_version:
64
+ recorded_at: Wed, 15 Aug 2018 01:06:15 GMT
65
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.iextrading.com/1.0/stock/MSFT/earnings
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Wed, 15 Aug 2018 01:14:34 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - '1346'
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=7590339f2473416cbe5a802b0fbcafc5; Domain=.iextrading.com; Path=/; Expires=Wed,
33
+ 15 Aug 2018 13:14:34 GMT; Secure
34
+ Content-Security-Policy:
35
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
36
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
37
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
38
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
39
+ 'self' 'unsafe-inline' 'unsafe-eval';
40
+ X-Content-Security-Policy:
41
+ - default-src 'self'; child-src 'none'; object-src 'none'; style-src 'self'
42
+ 'unsafe-inline'; font-src data:; frame-src 'self'; connect-src 'self' https://auth.iextrading.com
43
+ https://api.iextrading.com https://api.iextrading.com wss://iextrading.com
44
+ wss://tops.iextrading.com wss://api.iextrading.com wss://iextrading.com; script-src
45
+ 'self' 'unsafe-inline' 'unsafe-eval';
46
+ Frame-Options:
47
+ - SAMEORIGIN
48
+ X-Frame-Options:
49
+ - SAMEORIGIN
50
+ X-Content-Type-Options:
51
+ - nosniff
52
+ Strict-Transport-Security:
53
+ - max-age=15768000
54
+ Access-Control-Allow-Origin:
55
+ - "*"
56
+ Access-Control-Allow-Credentials:
57
+ - 'true'
58
+ Access-Control-Allow-Methods:
59
+ - GET, OPTIONS
60
+ Access-Control-Allow-Headers:
61
+ - Origin, X-Requested-With, Content-Type, Accept
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{"symbol":"MSFT","earnings":[{"actualEPS":1.13,"consensusEPS":1.07,"estimatedEPS":1.07,"announceTime":"AMC","numberOfEstimates":14,"EPSSurpriseDollar":0.06,"EPSReportDate":"2018-07-19","fiscalPeriod":"Q4
65
+ 2018","fiscalEndDate":"2018-06-30","yearAgo":0.98,"yearAgoChangePercent":0.15306122448979584,"estimatedChangePercent":0.09183673469387764,"symbolId":4563},{"actualEPS":0.95,"consensusEPS":0.85,"estimatedEPS":0.85,"announceTime":"AMC","numberOfEstimates":14,"EPSSurpriseDollar":0.1,"EPSReportDate":"2018-04-26","fiscalPeriod":"Q3
66
+ 2018","fiscalEndDate":"2018-03-31","yearAgo":0.73,"yearAgoChangePercent":0.3013698630136986,"estimatedChangePercent":0.1643835616438356,"symbolId":4563},{"actualEPS":0.96,"consensusEPS":0.86,"estimatedEPS":0.86,"announceTime":"AMC","numberOfEstimates":14,"EPSSurpriseDollar":0.1,"EPSReportDate":"2018-01-31","fiscalPeriod":"Q2
67
+ 2018","fiscalEndDate":"2017-12-31","yearAgo":0.83,"yearAgoChangePercent":0.1566265060240964,"estimatedChangePercent":0.036144578313253045,"symbolId":4563},{"actualEPS":0.84,"consensusEPS":0.72,"estimatedEPS":0.72,"announceTime":"AMC","numberOfEstimates":14,"EPSSurpriseDollar":0.12,"EPSReportDate":"2017-10-26","fiscalPeriod":"Q1
68
+ 2018","fiscalEndDate":"2017-09-30","yearAgo":0.76,"yearAgoChangePercent":0.1052631578947368,"estimatedChangePercent":-0.05263157894736847,"symbolId":4563}]}'
69
+ http_version:
70
+ recorded_at: Wed, 15 Aug 2018 01:14:34 GMT
71
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Resources::Earnings do
4
+ context 'known symbol' do
5
+ context 'with defaults', vcr: { cassette_name: 'earnings/msft' } do
6
+ subject do
7
+ IEX::Resources::Earnings.get('MSFT')
8
+ end
9
+ let(:earnings) { subject.first }
10
+ it 'retrieves earnings' do
11
+ expect(subject.size).to eq 4
12
+ expect(earnings.actual_eps).to eq 1.13
13
+ expect(earnings.consensus_eps).to eq 1.07
14
+ expect(earnings.estimated_eps).to eq 1.07
15
+ expect(earnings.announce_time).to eq 'AMC'
16
+ expect(earnings.number_of_estimates).to eq 14
17
+ expect(earnings.eps_surprise_dollar).to eq 0.06
18
+ expect(earnings.eps_report_date).to eq '2018-07-19'
19
+ expect(earnings.fiscal_period).to eq 'Q4 2018'
20
+ expect(earnings.fiscal_end_date).to eq '2018-06-30'
21
+ expect(earnings.year_ago).to eq 0.98
22
+ expect(earnings.year_ago_change_percent).to eq 0.15306122448979584
23
+ expect(earnings.year_ago_change_percent_s).to eq '+15.31%'
24
+ expect(earnings.estimated_change_percent).to eq 0.09183673469387764
25
+ expect(earnings.estimated_change_percent_s).to eq '+9.18%'
26
+ expect(earnings.symbol_id).to eq 4563
27
+ end
28
+ end
29
+ end
30
+ context 'invalid symbol', vcr: { cassette_name: 'earnings/invalid' } do
31
+ subject do
32
+ IEX::Resources::Earnings.get('INVALID')
33
+ end
34
+ it 'fails with SymbolNotFoundError' do
35
+ expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
36
+ end
37
+ end
38
+ 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.2
4
+ version: 0.4.3
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-08-14 00:00:00.000000000 Z
11
+ date: 2018-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -162,6 +162,7 @@ files:
162
162
  - lib/iex/api/chart.rb
163
163
  - lib/iex/api/company.rb
164
164
  - lib/iex/api/dividends.rb
165
+ - lib/iex/api/earnings.rb
165
166
  - lib/iex/api/key_stats.rb
166
167
  - lib/iex/api/logo.rb
167
168
  - lib/iex/api/news.rb
@@ -179,6 +180,7 @@ files:
179
180
  - lib/iex/resources/chart/one_day.rb
180
181
  - lib/iex/resources/company.rb
181
182
  - lib/iex/resources/dividends.rb
183
+ - lib/iex/resources/earnings.rb
182
184
  - lib/iex/resources/key_stats.rb
183
185
  - lib/iex/resources/logo.rb
184
186
  - lib/iex/resources/news.rb
@@ -203,6 +205,8 @@ files:
203
205
  - spec/fixtures/iex/dividends/msft_1y.yml
204
206
  - spec/fixtures/iex/dividends/msft_default_range.yml
205
207
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
208
+ - spec/fixtures/iex/earnings/invalid.yml
209
+ - spec/fixtures/iex/earnings/msft.yml
206
210
  - spec/fixtures/iex/key_stats/invalid.yml
207
211
  - spec/fixtures/iex/key_stats/msft.yml
208
212
  - spec/fixtures/iex/logo/msft.yml
@@ -220,6 +224,7 @@ files:
220
224
  - spec/iex/resources/chart_spec.rb
221
225
  - spec/iex/resources/company_spec.rb
222
226
  - spec/iex/resources/dividends_spec.rb
227
+ - spec/iex/resources/earnings_spec.rb
223
228
  - spec/iex/resources/key_stats_spec.rb
224
229
  - spec/iex/resources/logo_spec.rb
225
230
  - spec/iex/resources/news_spec.rb
@@ -249,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
254
  version: 1.3.6
250
255
  requirements: []
251
256
  rubyforge_project:
252
- rubygems_version: 2.5.2
257
+ rubygems_version: 2.7.6
253
258
  signing_key:
254
259
  specification_version: 4
255
260
  summary: IEX Finance API Ruby client with support for retrieving stock quotes.
@@ -268,6 +273,8 @@ test_files:
268
273
  - spec/fixtures/iex/dividends/msft_1y.yml
269
274
  - spec/fixtures/iex/dividends/msft_default_range.yml
270
275
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
276
+ - spec/fixtures/iex/earnings/invalid.yml
277
+ - spec/fixtures/iex/earnings/msft.yml
271
278
  - spec/fixtures/iex/key_stats/invalid.yml
272
279
  - spec/fixtures/iex/key_stats/msft.yml
273
280
  - spec/fixtures/iex/logo/msft.yml
@@ -285,6 +292,7 @@ test_files:
285
292
  - spec/iex/resources/chart_spec.rb
286
293
  - spec/iex/resources/company_spec.rb
287
294
  - spec/iex/resources/dividends_spec.rb
295
+ - spec/iex/resources/earnings_spec.rb
288
296
  - spec/iex/resources/key_stats_spec.rb
289
297
  - spec/iex/resources/logo_spec.rb
290
298
  - spec/iex/resources/news_spec.rb