iex-ruby-client 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 122b8435449269a11df3e45d0c9742f2cc23090d
4
- data.tar.gz: d7581662b889893a85d771d79c3bcbbd657b7273
3
+ metadata.gz: 31f82e417e023dae4b43a116a26c363f998452ee
4
+ data.tar.gz: f567de4892dbc778d9c4a285269d9fb2bfc2a204
5
5
  SHA512:
6
- metadata.gz: 66c2cf2f5e2df6f46aea535436961d0aac6adf86259d135411f7879ab41db1e750e47275255a27db4b4c37ab187d579e1a69d72dc4d86e19c2ef26b721b5d6ae
7
- data.tar.gz: 73611d7582829ef959585c72114d4f1bc135a4afad69b0765b308a00f02fa58516dfc680d4b9e416909ff416d6b31e338b508b302fbc54d6fd7e054b1bbfb138
6
+ metadata.gz: 8682c270ea7b9fb8a19deb4b6423252bcbd4b8fd1bdfb5b1805b28d94866309a126bbccea0c70b6c1b58e00e216e2315509f982bac3c20f701a1e5882a1d50a5
7
+ data.tar.gz: ea4d46ac096195a920681dc104a1822d97544c97a1089b2a386030f76e284147b6581e64fb87a20742c0f75695d1ec2a27749159240c907fe5e57f6f3701c19c
@@ -1,28 +1,28 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-07-27 05:38:15 -0400 using RuboCop version 0.58.2.
3
+ # on 2018-08-05 20:08:18 -0400 using RuboCop version 0.51.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- Metrics/AbcSize:
11
- Max: 16
12
-
13
- # Offense count: 5
9
+ # Offense count: 9
14
10
  # Configuration parameters: CountComments, ExcludedMethods.
15
- # ExcludedMethods: refine
16
11
  Metrics/BlockLength:
17
- Max: 79
12
+ Max: 85
13
+
14
+ # Offense count: 64
15
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
16
+ # URISchemes: http, https
17
+ Metrics/LineLength:
18
+ Max: 221
18
19
 
19
20
  # Offense count: 1
20
21
  # Configuration parameters: CountComments.
21
22
  Metrics/MethodLength:
22
- Max: 17
23
+ Max: 15
23
24
 
24
25
  # Offense count: 1
25
- # Configuration parameters: AllowedChars.
26
26
  Style/AsciiComments:
27
27
  Exclude:
28
28
  - 'lib/iex/resources/quote.rb'
@@ -33,12 +33,6 @@ Style/DateTime:
33
33
  - 'lib/iex/resources/news.rb'
34
34
  - 'spec/iex/resources/news_spec.rb'
35
35
 
36
- # Offense count: 23
36
+ # Offense count: 26
37
37
  Style/Documentation:
38
38
  Enabled: false
39
-
40
- # Offense count: 43
41
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
42
- # URISchemes: http, https
43
- Metrics/LineLength:
44
- Max: 221
@@ -1,3 +1,7 @@
1
+ ### 0.4.1 (2018/08/07)
2
+
3
+ * [#18](https://github.com/dblock/iex-ruby-client/pull/18): Added `IEX::Resources::KeyStats` - [@rodolfobandeira](https://github.com/rodolfobandeira).
4
+
1
5
  ### 0.4.0 (2018/07/29)
2
6
 
3
7
  * [#9](https://github.com/dblock/iex-ruby-client/pull/9): Added `IEX::Errors::ClientError` - [@rodolfobandeira](https://github.com/rodolfobandeira).
data/README.md CHANGED
@@ -16,6 +16,20 @@ gem 'iex-ruby-client'
16
16
 
17
17
  Run `bundle install`.
18
18
 
19
+
20
+ ## Methods Available:
21
+
22
+ - [Get a Single Price](#get-a-single-price)
23
+ - [Get a Quote](#get-a-quote)
24
+ - [Get a OHLC (Open, High, Low, Close) price](#get-a-ohlc-open-high-low-close-price)
25
+ - [Get a Market OHLC (Open, High, Low, Close) prices](#get-a-market-ohlc-open-high-low-close-prices)
26
+ - [Get Company Information](#get-company-information)
27
+ - [Get Company Logo](#get-company-logo)
28
+ - [Get Recent News](#get-recent-news)
29
+ - [Get Chart](#get-chat)
30
+ - [Get Key Stats](#get-key-stats)
31
+
32
+
19
33
  ## Usage
20
34
 
21
35
  ### Get a Single Price
@@ -83,7 +97,7 @@ company.company_name # 'Microsoft Corporation'
83
97
 
84
98
  See [#company](https://iextrading.com/developer/docs/#company) for detailed documentation or [company.rb](lib/iex/resources/company.rb) for returned fields.
85
99
 
86
- ### Get Company Logo
100
+ ### Get a Company Logo
87
101
 
88
102
  Fetches company logo for a symbol.
89
103
 
@@ -150,7 +164,79 @@ IEX::Resources::Chart.get('MSFT', Date.new(2018, 3, 26))
150
164
  IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10)
151
165
  ```
152
166
 
153
- See [#chart](https://iextrading.com/developer/docs/#chart) for detailed documentation or [chart/default](lib/iex/resources/chart/default.rb) and [chart/one_day](lib/iex/resources/chart/one_day.rb) for returned fields.
167
+ ### Get Key Stats
168
+
169
+ Fetches company's key stats for a symbol.
170
+
171
+ ```ruby
172
+ key_stats = IEX::Resources::KeyStats.get('MSFT')
173
+
174
+ key_stats.symbol # MSFT
175
+ key_stats.market_cap # 825814890000
176
+ key_stats.market_cap_dollars # '$825,814,890,000'
177
+ key_stats.beta # 1.261768
178
+ key_stats.week_52_high # 111.15
179
+ key_stats.week_52_high_dollar # '$111.15'
180
+ key_stats.week_52_low # 71.28
181
+ key_stats.week_52_low_dollar # '$71.28'
182
+ key_stats.week_52_change_dollar # '$51.77'
183
+ key_stats.short_interest # 47158592
184
+ key_stats.short_date # '2018-07-13'
185
+ key_stats.dividend_rate # 1.68
186
+ key_stats.dividend_yield # 1.5617738
187
+ key_stats.ex_dividend_date # '2018-08-15 00:00:00.0'
188
+ key_stats.latest_eps # 2.11
189
+ key_stats.latest_eps_date # '2018-06-30'
190
+ key_stats.shares_outstanding # 7677000000
191
+ key_stats.float # 7217387757
192
+ key_stats.return_on_equity # 20.82
193
+ key_stats.consensus_eps # 0.86
194
+ key_stats.number_of_estimates # 14
195
+ key_stats.eps_surprise_dollar # nil
196
+ key_stats.eps_surprise_percent # 11.6279
197
+ key_stats.eps_surprise_percent_s # '+1162.79%'
198
+ key_stats.ebitda # 23558000000
199
+ key_stats.revenue_dollar # '$53,456,000,000'
200
+ key_stats.gross_profit # 34114000000
201
+ key_stats.gross_profit_dollar # '$34,114,000,000'
202
+ key_stats.cash_dollar # '$281,251,000,000'
203
+ key_stats.ttm_eps # 3.51
204
+ key_stats.revenue_per_share # 7
205
+ key_stats.revenue_per_employee # 431097
206
+ key_stats.pe_ratio_high # 0
207
+ key_stats.pe_ratio_low # 0
208
+ key_stats.return_on_assets # 6.46
209
+ key_stats.return_on_capital # nil
210
+ key_stats.profit_margin # 15.1
211
+ key_stats.price_to_sales # 7.393182
212
+ key_stats.price_to_sales_dollar # '$7.39'
213
+ key_stats.price_to_book # 10.73
214
+ key_stats.price_to_book_dollar # '$10.73'
215
+ key_stats.day_200_moving_avg # 91.99065
216
+ key_stats.day_50_moving_avg # 102.2528
217
+ key_stats.institution_percent # 75.1
218
+ key_stats.institution_percent_s # '+7510.00%'
219
+ key_stats.insider_percent # nil
220
+ key_stats.insider_percent_s # nil
221
+ key_stats.short_ratio # 1.7330703
222
+ key_stats.year_5_change_percent # 2.85141424991049
223
+ key_stats.year_5_change_percent_s # '+285.14%'
224
+ key_stats.year_2_change_percent # 0.9732002824884664
225
+ key_stats.year_2_change_percent_s # '+97.32%'
226
+ key_stats.year_1_change_percent # 0.5200287133805482
227
+ key_stats.year_1_change_percent_s # '+52.00%'
228
+ key_stats.ytd_change_percent # 0.2628699562098638
229
+ key_stats.month_6_change_percent # 0.23345097958275707
230
+ key_stats.month_6_change_percent_s # '+23.35%'
231
+ key_stats.month_3_change_percent # 0.14846686026648437
232
+ key_stats.month_3_change_percent_s # '+14.85%'
233
+ key_stats.month_1_change_percent # 0.08601716304896513
234
+ key_stats.month_1_change_percent_s # '+8.60%'
235
+ key_stats.day_5_change_percent # -0.0010215453194652084
236
+ key_stats.day_5_change_percent_s # '-0.10%'
237
+ ```
238
+ See [#key-stats](https://iextrading.com/developer/docs/#key-stats) for detailed documentation or [key_stats.rb](lib/iex/resources/key_stats.rb) for returned fields.
239
+
154
240
 
155
241
  ## Errors
156
242
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'faraday', '>= 0.9'
19
19
  s.add_dependency 'faraday_middleware'
20
20
  s.add_dependency 'hashie'
21
+ s.add_dependency 'money_helper'
21
22
  s.add_development_dependency 'rake', '~> 10'
22
23
  s.add_development_dependency 'rspec'
23
24
  s.add_development_dependency 'rubocop', '0.51.0'
@@ -2,6 +2,7 @@ require 'faraday'
2
2
  require 'faraday_middleware'
3
3
  require 'faraday_middleware/response_middleware'
4
4
  require 'hashie'
5
+ require 'money_helper'
5
6
 
6
7
  require_relative 'iex/version'
7
8
  require_relative 'iex/errors'
@@ -20,6 +20,7 @@ end
20
20
  require_relative 'api/chart'
21
21
  require_relative 'api/company'
22
22
  require_relative 'api/logo'
23
+ require_relative 'api/key_stats'
23
24
  require_relative 'api/news'
24
25
  require_relative 'api/ohlc'
25
26
  require_relative 'api/price'
@@ -0,0 +1,13 @@
1
+ module IEX
2
+ module Api
3
+ module KeyStats
4
+ def self.get(symbol)
5
+ connection(symbol).get.body
6
+ end
7
+
8
+ def self.connection(symbol)
9
+ IEX::Api.default_connection "#{symbol}/stats"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -6,3 +6,4 @@ require_relative 'resources/news'
6
6
  require_relative 'resources/chart'
7
7
  require_relative 'resources/ohlc'
8
8
  require_relative 'resources/logo'
9
+ require_relative 'resources/key_stats'
@@ -8,6 +8,20 @@ module IEX
8
8
  rescue Faraday::ClientError => e
9
9
  raise IEX::Errors::ClientError, e.response
10
10
  end
11
+
12
+ def self.float_to_percentage(float_number)
13
+ return unless float_number.is_a? Numeric
14
+ return '+0.00%' if float_number.zero?
15
+ [
16
+ float_number > 0 ? '+' : '',
17
+ format('%.2f', float_number * 100),
18
+ '%'
19
+ ].join
20
+ end
21
+
22
+ def self.to_dollar(amount:, ignore_cents: true)
23
+ MoneyHelper.money_to_text(amount, 'USD', nil, no_cents: ignore_cents)
24
+ end
11
25
  end
12
26
  end
13
27
  end
@@ -0,0 +1,81 @@
1
+ module IEX
2
+ module Resources
3
+ class KeyStats < Resource
4
+ property 'company_name', from: 'companyName'
5
+ property 'market_cap', from: 'marketcap'
6
+ property 'market_cap_dollars', from: 'marketcap', with: ->(v) { Base.to_dollar(amount: v) }
7
+ property 'beta'
8
+ property 'week_52_high', from: 'week52high'
9
+ property 'week_52_high_dollar', from: 'week52high', with: ->(v) { Base.to_dollar(amount: v, ignore_cents: false) }
10
+ property 'week_52_low', from: 'week52low'
11
+ property 'week_52_low_dollar', from: 'week52low', with: ->(v) { Base.to_dollar(amount: v, ignore_cents: false) }
12
+ property 'week_52_change'
13
+ property 'week_52_change_dollar', from: 'week52change', with: ->(v) { Base.to_dollar(amount: v, ignore_cents: false) }
14
+ property 'short_interest', from: 'shortInterest'
15
+ property 'short_date', from: 'shortDate'
16
+ property 'dividend_rate', from: 'dividendRate'
17
+ property 'dividend_yield', from: 'dividendYield'
18
+ property 'ex_dividend_date', from: 'exDividendDate'
19
+ property 'latest_eps', from: 'latestEPS'
20
+ property 'latest_eps_date', from: 'latestEPSDate'
21
+ property 'shares_outstanding', from: 'sharesOutstanding'
22
+ property 'float'
23
+ property 'return_on_equity', from: 'returnOnEquity'
24
+ property 'consensus_eps', from: 'consensusEPS'
25
+ property 'number_of_estimates', from: 'numberOfEstimates'
26
+ property 'symbol'
27
+ property 'ebitda', from: 'EBITDA'
28
+ property 'revenue'
29
+ property 'revenue_dollar', from: 'revenue', with: ->(v) { Base.to_dollar(amount: v) }
30
+ property 'gross_profit', from: 'grossProfit'
31
+ property 'gross_profit_dollar', from: 'grossProfit', with: ->(v) { Base.to_dollar(amount: v) }
32
+ property 'cash'
33
+ property 'cash_dollar', from: 'cash', with: ->(v) { Base.to_dollar(amount: v) }
34
+ property 'dept'
35
+ property 'dept_dollar', from: 'dept', with: ->(v) { Base.to_dollar(amount: v) }
36
+ property 'ttm_eps', from: 'ttmEPS'
37
+ property 'revenue_per_share', from: 'revenuePerShare'
38
+ property 'revenue_per_employee', from: 'revenuePerEmployee'
39
+ property 'pe_ratio_high', from: 'peRatioHigh'
40
+ property 'pe_ratio_low', from: 'peRatioLow'
41
+ property 'eps_surprise_dollar', from: 'EPSSurpriseDollar'
42
+ property 'eps_surprise_percent', from: 'EPSSurprisePercent'
43
+ property 'eps_surprise_percent_s', from: 'EPSSurprisePercent', with: ->(v) { Base.float_to_percentage(v) }
44
+ property 'return_on_assets', from: 'returnOnAssets'
45
+ property 'return_on_capital', from: 'returnOnCapital'
46
+ property 'profit_margin', from: 'profitMargin'
47
+ property 'price_to_sales', from: 'priceToSales'
48
+ property 'price_to_book', from: 'priceToBook'
49
+ property 'price_to_sales_dollar', from: 'priceToSales', with: ->(v) { Base.to_dollar(amount: v, ignore_cents: false) }
50
+ property 'price_to_book_dollar', from: 'priceToBook', with: ->(v) { Base.to_dollar(amount: v, ignore_cents: false) }
51
+ property 'day_200_moving_avg', from: 'day200MovingAvg'
52
+ property 'day_50_moving_avg', from: 'day50MovingAvg'
53
+ property 'institution_percent', from: 'institutionPercent'
54
+ property 'institution_percent_s', from: 'institutionPercent', with: ->(v) { Base.float_to_percentage(v) }
55
+ property 'insider_percent', from: 'insiderPercent'
56
+ property 'insider_percent_s', from: 'insiderPercent', with: ->(v) { Base.float_to_percentage(v) }
57
+ property 'short_ratio', from: 'shortRatio'
58
+ property 'year_5_change_percent', from: 'year5ChangePercent'
59
+ property 'year_5_change_percent_s', from: 'year5ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
60
+ property 'year_2_change_percent', from: 'year2ChangePercent'
61
+ property 'year_2_change_percent_s', from: 'year2ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
62
+ property 'year_1_change_percent', from: 'year1ChangePercent'
63
+ property 'year_1_change_percent_s', from: 'year1ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
64
+ property 'ytd_change_percent', from: 'ytdChangePercent'
65
+ property 'month_6_change_percent', from: 'month6ChangePercent'
66
+ property 'month_6_change_percent_s', from: 'month6ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
67
+ property 'month_3_change_percent', from: 'month3ChangePercent'
68
+ property 'month_3_change_percent_s', from: 'month3ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
69
+ property 'month_1_change_percent', from: 'month1ChangePercent'
70
+ property 'month_1_change_percent_s', from: 'month1ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
71
+ property 'day_5_change_percent', from: 'day5ChangePercent'
72
+ property 'day_5_change_percent_s', from: 'day5ChangePercent', with: ->(v) { Base.float_to_percentage(v) }
73
+
74
+ def self.get(symbol)
75
+ new IEX::Api::KeyStats.get(symbol)
76
+ rescue Faraday::ResourceNotFound => e
77
+ raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,3 @@
1
1
  module IEX
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.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/stats
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
+ - Fri, 03 Aug 2018 23:45:27 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=f749efd72bd44615ae05dbd800720ac3; Domain=.iextrading.com; Path=/; Expires=Sat,
33
+ 04 Aug 2018 11:45:27 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: Fri, 03 Aug 2018 23:45:27 GMT
65
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,68 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.iextrading.com/1.0/stock/MSFT/stats
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
+ - Fri, 03 Aug 2018 23:45:26 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - '1311'
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=743c58ee68264c2c8adc8b1713024ad6; Domain=.iextrading.com; Path=/; Expires=Sat,
33
+ 04 Aug 2018 11:45:26 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: '{"companyName":"Microsoft Corporation","marketcap":825814890000,"beta":1.261768,"week52high":111.15,"week52low":71.28,"week52change":51.7715,"shortInterest":47158592,"shortDate":"2018-07-13","dividendRate":1.68,"dividendYield":1.5617738,"exDividendDate":"2018-08-15
65
+ 00:00:00.0","latestEPS":2.11,"latestEPSDate":"2018-06-30","sharesOutstanding":7677000000,"float":7217387757,"returnOnEquity":20.82,"consensusEPS":0.86,"numberOfEstimates":14,"EPSSurpriseDollar":null,"EPSSurprisePercent":11.6279,"symbol":"MSFT","EBITDA":23558000000,"revenue":53456000000,"grossProfit":34114000000,"cash":281251000000,"debt":180503000000,"ttmEPS":3.51,"revenuePerShare":7,"revenuePerEmployee":431097,"peRatioHigh":0,"peRatioLow":0,"returnOnAssets":6.46,"returnOnCapital":null,"profitMargin":15.1,"priceToSales":7.393182,"priceToBook":10.73,"day200MovingAvg":91.99065,"day50MovingAvg":102.2528,"institutionPercent":75.1,"insiderPercent":null,"shortRatio":1.7330703,"year5ChangePercent":2.85141424991049,"year2ChangePercent":0.9732002824884664,"year1ChangePercent":0.5200287133805482,"ytdChangePercent":0.2628699562098638,"month6ChangePercent":0.23345097958275707,"month3ChangePercent":0.14846686026648437,"month1ChangePercent":0.08601716304896513,"day5ChangePercent":-0.0010215453194652084,"day30ChangePercent":0.06357524223848124}'
66
+ http_version:
67
+ recorded_at: Fri, 03 Aug 2018 23:45:26 GMT
68
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Resources::Base do
4
+ context 'float number to percent (Positive)' do
5
+ subject do
6
+ IEX::Resources::Base.float_to_percentage(0.09123)
7
+ end
8
+ it 'converts to percentage' do
9
+ expect(subject).to eq '+9.12%'
10
+ end
11
+ end
12
+
13
+ context 'float number to percent (Negative)' do
14
+ subject do
15
+ IEX::Resources::Base.float_to_percentage(-0.09123)
16
+ end
17
+ it 'converts to percentage' do
18
+ expect(subject).to eq '-9.12%'
19
+ end
20
+ end
21
+
22
+ context 'float number to percent (nil)' do
23
+ subject do
24
+ IEX::Resources::Base.float_to_percentage(nil)
25
+ end
26
+ it 'nil argument does not convert' do
27
+ expect(subject).to eq nil
28
+ end
29
+ end
30
+
31
+ context 'float number to percent (0)' do
32
+ subject do
33
+ IEX::Resources::Base.float_to_percentage(0)
34
+ end
35
+ it 'Zero converts to +0.00%' do
36
+ expect(subject).to eq '+0.00%'
37
+ end
38
+ end
39
+
40
+ context 'Unformatted money amount to dollar' do
41
+ subject do
42
+ IEX::Resources::Base.to_dollar(amount: 123_391)
43
+ end
44
+ it 'converts to dollar' do
45
+ expect(subject).to eq '$123,391'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Resources::KeyStats do
4
+ context 'general information', vcr: { cassette_name: 'key_stats/msft' } do
5
+ subject do
6
+ IEX::Resources::KeyStats.get('MSFT')
7
+ end
8
+ it 'retrieves a keyStats' do
9
+ expect(subject.symbol).to eq 'MSFT'
10
+ expect(subject.company_name).to eq 'Microsoft Corporation'
11
+ expect(subject.market_cap).to eq 825_814_890_000
12
+ expect(subject.market_cap_dollars).to eq '$825,814,890,000'
13
+ expect(subject.beta).to eq 1.261768
14
+ end
15
+
16
+ it 'weekly stats' do
17
+ expect(subject.week_52_high).to eq 111.15
18
+ expect(subject.week_52_high_dollar).to eq '$111.15'
19
+ expect(subject.week_52_low).to eq 71.28
20
+ expect(subject.week_52_low_dollar).to eq '$71.28'
21
+ expect(subject.week_52_change_dollar).to eq '$51.77'
22
+ end
23
+
24
+ it 'general stats' do
25
+ expect(subject.short_interest).to eq 47_158_592
26
+ expect(subject.short_date).to eq '2018-07-13'
27
+ expect(subject.dividend_rate).to eq 1.68
28
+ expect(subject.dividend_yield).to eq 1.5617738
29
+ expect(subject.ex_dividend_date).to eq '2018-08-15 00:00:00.0'
30
+ expect(subject.latest_eps).to eq 2.11
31
+ expect(subject.latest_eps_date).to eq '2018-06-30'
32
+ expect(subject.shares_outstanding).to eq 7_677_000_000
33
+ expect(subject.float).to eq 7_217_387_757
34
+ expect(subject.return_on_equity).to eq 20.82
35
+ expect(subject.consensus_eps).to eq 0.86
36
+ expect(subject.number_of_estimates).to eq 14
37
+ expect(subject.eps_surprise_dollar).to eq nil
38
+ expect(subject.eps_surprise_percent).to eq 11.6279
39
+ expect(subject.eps_surprise_percent_s).to eq '+1162.79%'
40
+ expect(subject.ebitda).to eq 23_558_000_000
41
+ expect(subject.revenue_dollar).to eq '$53,456,000,000'
42
+ expect(subject.gross_profit).to eq 34_114_000_000
43
+ expect(subject.gross_profit_dollar).to eq '$34,114,000,000'
44
+ expect(subject.cash_dollar).to eq '$281,251,000,000'
45
+ expect(subject.ttm_eps).to eq 3.51
46
+ expect(subject.revenue_per_share).to eq 7
47
+ expect(subject.revenue_per_employee).to eq 431_097
48
+ expect(subject.pe_ratio_high).to eq 0
49
+ expect(subject.pe_ratio_low).to eq 0
50
+ expect(subject.return_on_assets).to eq 6.46
51
+ expect(subject.return_on_capital).to eq nil
52
+ expect(subject.profit_margin).to eq 15.1
53
+ expect(subject.price_to_sales).to eq 7.393182
54
+ expect(subject.price_to_sales_dollar).to eq '$7.39'
55
+ expect(subject.price_to_book).to eq 10.73
56
+ expect(subject.price_to_book_dollar).to eq '$10.73'
57
+ expect(subject.day_200_moving_avg).to eq 91.99065
58
+ expect(subject.day_50_moving_avg).to eq 102.2528
59
+ expect(subject.institution_percent).to eq 75.1
60
+ expect(subject.institution_percent_s).to eq '+7510.00%'
61
+ expect(subject.insider_percent).to eq nil
62
+ expect(subject.insider_percent_s).to eq nil
63
+ expect(subject.short_ratio).to eq 1.7330703
64
+ end
65
+
66
+ it 'changes stats' do
67
+ expect(subject.year_5_change_percent).to be 2.85141424991049
68
+ expect(subject.year_5_change_percent_s).to eq '+285.14%'
69
+ expect(subject.year_2_change_percent).to eq 0.9732002824884664
70
+ expect(subject.year_2_change_percent_s).to eq '+97.32%'
71
+ expect(subject.year_1_change_percent).to eq 0.5200287133805482
72
+ expect(subject.year_1_change_percent_s).to eq '+52.00%'
73
+ expect(subject.ytd_change_percent).to eq 0.2628699562098638
74
+ expect(subject.month_6_change_percent).to eq 0.23345097958275707
75
+ expect(subject.month_6_change_percent_s).to eq '+23.35%'
76
+ expect(subject.month_3_change_percent).to eq 0.14846686026648437
77
+ expect(subject.month_3_change_percent_s).to eq '+14.85%'
78
+ expect(subject.month_1_change_percent).to eq 0.08601716304896513
79
+ expect(subject.month_1_change_percent_s).to eq '+8.60%'
80
+ expect(subject.day_5_change_percent).to eq 0.0010215453194652084 * -1
81
+ expect(subject.day_5_change_percent_s).to eq '-0.10%'
82
+ end
83
+ end
84
+
85
+ context 'invalid symbol', vcr: { cassette_name: 'key_stats/invalid' } do
86
+ subject do
87
+ IEX::Resources::KeyStats.get('INVALID')
88
+ end
89
+ it 'fails with SymbolNotFoundError' do
90
+ expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
91
+ end
92
+ end
93
+ 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.0
4
+ version: 0.4.1
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-07-30 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: money_helper
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +160,7 @@ files:
146
160
  - lib/iex/api.rb
147
161
  - lib/iex/api/chart.rb
148
162
  - lib/iex/api/company.rb
163
+ - lib/iex/api/key_stats.rb
149
164
  - lib/iex/api/logo.rb
150
165
  - lib/iex/api/news.rb
151
166
  - lib/iex/api/ohlc.rb
@@ -161,6 +176,7 @@ files:
161
176
  - lib/iex/resources/chart/default.rb
162
177
  - lib/iex/resources/chart/one_day.rb
163
178
  - lib/iex/resources/company.rb
179
+ - lib/iex/resources/key_stats.rb
164
180
  - lib/iex/resources/logo.rb
165
181
  - lib/iex/resources/news.rb
166
182
  - lib/iex/resources/ohlc.rb
@@ -179,6 +195,8 @@ files:
179
195
  - spec/fixtures/iex/chart/msft.yml
180
196
  - spec/fixtures/iex/company/invalid.yml
181
197
  - spec/fixtures/iex/company/msft.yml
198
+ - spec/fixtures/iex/key_stats/invalid.yml
199
+ - spec/fixtures/iex/key_stats/msft.yml
182
200
  - spec/fixtures/iex/logo/msft.yml
183
201
  - spec/fixtures/iex/news/invalid.yml
184
202
  - spec/fixtures/iex/news/market.yml
@@ -190,8 +208,10 @@ files:
190
208
  - spec/fixtures/iex/price/msft.yml
191
209
  - spec/fixtures/iex/quote/invalid.yml
192
210
  - spec/fixtures/iex/quote/msft.yml
211
+ - spec/iex/resources/base_spec.rb
193
212
  - spec/iex/resources/chart_spec.rb
194
213
  - spec/iex/resources/company_spec.rb
214
+ - spec/iex/resources/key_stats_spec.rb
195
215
  - spec/iex/resources/logo_spec.rb
196
216
  - spec/iex/resources/news_spec.rb
197
217
  - spec/iex/resources/ohlc_spec.rb
@@ -234,6 +254,8 @@ test_files:
234
254
  - spec/fixtures/iex/chart/msft.yml
235
255
  - spec/fixtures/iex/company/invalid.yml
236
256
  - spec/fixtures/iex/company/msft.yml
257
+ - spec/fixtures/iex/key_stats/invalid.yml
258
+ - spec/fixtures/iex/key_stats/msft.yml
237
259
  - spec/fixtures/iex/logo/msft.yml
238
260
  - spec/fixtures/iex/news/invalid.yml
239
261
  - spec/fixtures/iex/news/market.yml
@@ -245,8 +267,10 @@ test_files:
245
267
  - spec/fixtures/iex/price/msft.yml
246
268
  - spec/fixtures/iex/quote/invalid.yml
247
269
  - spec/fixtures/iex/quote/msft.yml
270
+ - spec/iex/resources/base_spec.rb
248
271
  - spec/iex/resources/chart_spec.rb
249
272
  - spec/iex/resources/company_spec.rb
273
+ - spec/iex/resources/key_stats_spec.rb
250
274
  - spec/iex/resources/logo_spec.rb
251
275
  - spec/iex/resources/news_spec.rb
252
276
  - spec/iex/resources/ohlc_spec.rb