iex-ruby-client 0.4.4 → 1.0.0

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 (129) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +6 -0
  3. data/.rubocop_todo.yml +8 -36
  4. data/CHANGELOG.md +5 -0
  5. data/LICENSE.md +1 -1
  6. data/README.md +113 -160
  7. data/UPGRADING.md +55 -3
  8. data/iex-ruby-client.gemspec +1 -1
  9. data/lib/iex-ruby-client.rb +2 -0
  10. data/lib/iex/api.rb +15 -31
  11. data/lib/iex/api/client.rb +30 -0
  12. data/lib/iex/api/config.rb +45 -0
  13. data/lib/iex/cloud.rb +3 -0
  14. data/lib/iex/cloud/connection.rb +37 -0
  15. data/lib/iex/cloud/request.rb +38 -0
  16. data/lib/iex/cloud/response.rb +20 -0
  17. data/lib/iex/endpoints/chart.rb +39 -0
  18. data/lib/iex/endpoints/company.rb +11 -0
  19. data/lib/iex/endpoints/crypto.rb +11 -0
  20. data/lib/iex/endpoints/dividends.rb +18 -0
  21. data/lib/iex/endpoints/earnings.rb +13 -0
  22. data/lib/iex/endpoints/key_stats.rb +11 -0
  23. data/lib/iex/endpoints/largest_trades.rb +13 -0
  24. data/lib/iex/endpoints/logo.rb +11 -0
  25. data/lib/iex/endpoints/news.rb +19 -0
  26. data/lib/iex/endpoints/ohlc.rb +17 -0
  27. data/lib/iex/endpoints/price.rb +11 -0
  28. data/lib/iex/endpoints/quote.rb +11 -0
  29. data/lib/iex/endpoints/sectors.rb +17 -0
  30. data/lib/iex/errors.rb +1 -0
  31. data/lib/iex/errors/client_error.rb +13 -1
  32. data/lib/iex/errors/permission_denied_error.rb +5 -0
  33. data/lib/iex/logger.rb +13 -0
  34. data/lib/iex/resources.rb +0 -1
  35. data/lib/iex/resources/chart.rb +38 -21
  36. data/lib/iex/resources/company.rb +2 -8
  37. data/lib/iex/resources/crypto.rb +10 -18
  38. data/lib/iex/resources/dividends.rb +5 -15
  39. data/lib/iex/resources/earnings.rb +1 -15
  40. data/lib/iex/resources/key_stats.rb +11 -57
  41. data/lib/iex/resources/largest_trades.rb +0 -10
  42. data/lib/iex/resources/logo.rb +0 -8
  43. data/lib/iex/resources/news.rb +1 -11
  44. data/lib/iex/resources/ohlc.rb +8 -16
  45. data/lib/iex/resources/quote.rb +0 -8
  46. data/lib/iex/resources/resource.rb +19 -2
  47. data/lib/iex/resources/sectors.rb +0 -10
  48. data/lib/iex/version.rb +1 -1
  49. data/spec/fixtures/iex/chart/1d.yml +472 -444
  50. data/spec/fixtures/iex/chart/20190306.yml +475 -0
  51. data/spec/fixtures/iex/chart/bad_option.yml +80 -62
  52. data/spec/fixtures/iex/chart/chartInterval.yml +121 -98
  53. data/spec/fixtures/iex/chart/dynamic/1m.yml +106 -81
  54. data/spec/fixtures/iex/chart/invalid.yml +80 -58
  55. data/spec/fixtures/iex/chart/msft.yml +106 -81
  56. data/spec/fixtures/iex/client/access_denied.yml +49 -0
  57. data/spec/fixtures/iex/company/invalid.yml +80 -58
  58. data/spec/fixtures/iex/company/msft.yml +87 -65
  59. data/spec/fixtures/iex/crypto/btcusdt.yml +87 -0
  60. data/spec/fixtures/iex/dividends/invalid.yml +80 -62
  61. data/spec/fixtures/iex/dividends/msft.yml +88 -66
  62. data/spec/fixtures/iex/dividends/msft_1y.yml +92 -68
  63. data/spec/fixtures/iex/dividends/msft_default_range.yml +85 -65
  64. data/spec/fixtures/iex/dividends/msft_invalid_range.yml +82 -64
  65. data/spec/fixtures/iex/earnings/invalid.yml +80 -62
  66. data/spec/fixtures/iex/earnings/msft.yml +84 -68
  67. data/spec/fixtures/iex/key_stats/invalid.yml +80 -62
  68. data/spec/fixtures/iex/key_stats/msft.yml +84 -65
  69. data/spec/fixtures/iex/largest-trades/aapl.yml +91 -73
  70. data/spec/fixtures/iex/largest-trades/invalid.yml +80 -62
  71. data/spec/fixtures/iex/logo/msft.yml +82 -64
  72. data/spec/fixtures/iex/news/invalid.yml +80 -58
  73. data/spec/fixtures/iex/news/msft.yml +83 -61
  74. data/spec/fixtures/iex/news/msft_7.yml +83 -61
  75. data/spec/fixtures/iex/ohlc/market.yml +82 -65
  76. data/spec/fixtures/iex/ohlc/msft.yml +82 -64
  77. data/spec/fixtures/iex/price/invalid.yml +80 -58
  78. data/spec/fixtures/iex/price/msft.yml +82 -60
  79. data/spec/fixtures/iex/quote/invalid.yml +80 -62
  80. data/spec/fixtures/iex/quote/msft.yml +84 -66
  81. data/spec/fixtures/iex/sectors/invalid.yml +80 -62
  82. data/spec/fixtures/iex/sectors/sectors-performance.yml +88 -69
  83. data/spec/iex/client_spec.rb +138 -0
  84. data/spec/iex/config_spec.rb +22 -0
  85. data/spec/iex/{resources → endpoints}/chart_spec.rb +23 -21
  86. data/spec/iex/{resources → endpoints}/company_spec.rb +11 -7
  87. data/spec/iex/endpoints/crypto_spec.rb +66 -0
  88. data/spec/iex/{resources → endpoints}/dividends_spec.rb +17 -14
  89. data/spec/iex/endpoints/earnings_spec.rb +36 -0
  90. data/spec/iex/endpoints/key_stats_spec.rb +62 -0
  91. data/spec/iex/{resources → endpoints}/largest_trades_spec.rb +8 -6
  92. data/spec/iex/{resources → endpoints}/logo_spec.rb +3 -1
  93. data/spec/iex/endpoints/news_spec.rb +36 -0
  94. data/spec/iex/{resources → endpoints}/ohlc_spec.rb +15 -13
  95. data/spec/iex/{resources → endpoints}/price_spec.rb +6 -4
  96. data/spec/iex/endpoints/quote_spec.rb +38 -0
  97. data/spec/iex/{resources → endpoints}/sectors_spec.rb +7 -6
  98. data/spec/iex/resources/{base_spec.rb → resource_spec.rb} +6 -6
  99. data/spec/spec_helper.rb +2 -0
  100. data/spec/support/client.rb +6 -0
  101. metadata +66 -59
  102. data/lib/iex/api/chart.rb +0 -24
  103. data/lib/iex/api/company.rb +0 -13
  104. data/lib/iex/api/crypto.rb +0 -13
  105. data/lib/iex/api/dividends.rb +0 -17
  106. data/lib/iex/api/earnings.rb +0 -13
  107. data/lib/iex/api/key_stats.rb +0 -13
  108. data/lib/iex/api/largest_trades.rb +0 -13
  109. data/lib/iex/api/logo.rb +0 -13
  110. data/lib/iex/api/news.rb +0 -18
  111. data/lib/iex/api/ohlc.rb +0 -17
  112. data/lib/iex/api/price.rb +0 -13
  113. data/lib/iex/api/quote.rb +0 -13
  114. data/lib/iex/api/sectors.rb +0 -16
  115. data/lib/iex/resources/base.rb +0 -27
  116. data/lib/iex/resources/chart/base.rb +0 -14
  117. data/lib/iex/resources/chart/default.rb +0 -21
  118. data/lib/iex/resources/chart/one_day.rb +0 -20
  119. data/lib/iex/resources/ohlc/base.rb +0 -14
  120. data/lib/iex/resources/ohlc/timed_price.rb +0 -12
  121. data/lib/iex/resources/price.rb +0 -13
  122. data/spec/fixtures/iex/chart/20180227.yml +0 -452
  123. data/spec/fixtures/iex/crypto.yml +0 -101
  124. data/spec/fixtures/iex/news/market.yml +0 -64
  125. data/spec/iex/resources/crypto_spec.rb +0 -65
  126. data/spec/iex/resources/earnings_spec.rb +0 -38
  127. data/spec/iex/resources/key_stats_spec.rb +0 -94
  128. data/spec/iex/resources/news_spec.rb +0 -44
  129. data/spec/iex/resources/quote_spec.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 17fd934d31cffa99721a3046560f2e9d1fbec9ddc78161829c199c29fd3b807e
4
- data.tar.gz: c12a34546c617ff6145f52632387a63d4dd4866dadafcf7cbf95c934863499a9
2
+ SHA1:
3
+ metadata.gz: df29afbbbd95d15992840fdfe66fd8fa31ed1cee
4
+ data.tar.gz: df551117e4b8dcfa5e223a765c1fa97e7bc4bedb
5
5
  SHA512:
6
- metadata.gz: 7935962fa422e12cea770c3dff841a2b66c97f3dc1121a2e94e96160fc27449535c07bb9ed72247830324159f1dd3a3a22b210a6b2980c95b478df8401718386
7
- data.tar.gz: 840148d3f1aa4bd174e737781f0a0e5063ec243541f82966eaddf95a653c0cf0964915447dcb115d598824fba5da3827486b513454a9c6ed47b58874e8fd6fda
6
+ metadata.gz: b28d4ea0c36db77958e86a5c0ad347a04876a7bd8e51582f853435316444f0b7277c1a1b98bd299e4b77f89821ec89dc58e9923c45e631e961433dcc5dfe2aa9
7
+ data.tar.gz: 34f851cf3b8e46f2475531717055c1a9cf9ca7abb96675fc50c88a766a5ff6f92f6f52459fda71e1d046eba4ade185d7e368639222195a662c8ee1bba957c4e9
@@ -9,4 +9,10 @@ Naming/FileName:
9
9
  Exclude:
10
10
  - 'lib/iex-ruby-client.rb'
11
11
 
12
+ Style/Documentation:
13
+ Enabled: false
14
+
15
+ Metrics:
16
+ Enabled: false
17
+
12
18
  inherit_from: .rubocop_todo.yml
@@ -1,49 +1,21 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-10-19 21:17:47 -0400 using RuboCop version 0.51.0.
3
+ # on 2019-04-19 14:36:19 -0400 using RuboCop version 0.67.2.
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
9
  # Offense count: 1
10
- # Cop supports --auto-correct.
11
- Layout/EmptyLines:
12
- Exclude:
13
- - 'lib/iex/resources/crypto.rb'
14
-
15
- # Offense count: 2
16
- Lint/AmbiguousOperator:
17
- Exclude:
18
- - 'spec/iex/resources/crypto_spec.rb'
19
-
20
- # Offense count: 15
21
- # Configuration parameters: CountComments, ExcludedMethods.
22
- Metrics/BlockLength:
23
- Max: 86
24
-
25
- # Offense count: 83
26
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
27
- # URISchemes: http, https
28
- Metrics/LineLength:
29
- Max: 221
30
-
31
- # Offense count: 1
32
- # Configuration parameters: CountComments.
33
- Metrics/MethodLength:
34
- Max: 15
35
-
36
- # Offense count: 1
10
+ # Configuration parameters: AllowedChars.
37
11
  Style/AsciiComments:
38
12
  Exclude:
39
13
  - 'lib/iex/resources/quote.rb'
40
14
 
41
- # Offense count: 2
42
- Style/DateTime:
15
+ # Offense count: 1
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: EnforcedStyle, Autocorrect.
18
+ # SupportedStyles: module_function, extend_self
19
+ Style/ModuleFunction:
43
20
  Exclude:
44
- - 'lib/iex/resources/news.rb'
45
- - 'spec/iex/resources/news_spec.rb'
46
-
47
- # Offense count: 36
48
- Style/Documentation:
49
- Enabled: false
21
+ - 'lib/iex/api/config.rb'
@@ -1,3 +1,8 @@
1
+ ### 1.0.0 (2019/04/23)
2
+
3
+ * [#42](https://github.com/dblock/iex-ruby-client/pull/42): Migrated to the IEX Cloud API - [@bingxie](https://github.com/bingxie).
4
+ * [#46](https://github.com/dblock/iex-ruby-client/pull/46): Made client configurable - [@dblock](https://github.com/dblock).
5
+
1
6
  ### 0.4.4 (2018/12/27)
2
7
 
3
8
  * [#39](https://github.com/dblock/iex-ruby-client/pull/39): Remove default range and use iextrading default range 1m instead in `IEX::Api::Dividends` - [@ildarkayumov](https://github.com/ildarkayumov).
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Daniel Doubrovkine and Contributors
3
+ Copyright (c) 2018-2019 Daniel Doubrovkine and Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,21 +1,20 @@
1
- IEX Finance API
2
- ===============
1
+ # IEX Finance API
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/iex-ruby-client.svg)](https://badge.fury.io/rb/iex-ruby-client)
5
4
  [![Build Status](https://travis-ci.org/dblock/iex-ruby-client.svg?branch=master)](https://travis-ci.org/dblock/iex-ruby-client)
6
5
 
7
- A Ruby client for the [IEX Finance API](https://iextrading.com/developer).
8
-
6
+ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
9
7
 
10
8
  # Table of Contents
11
9
 
12
10
  - [Installation](#installation)
13
- - [Methods Available](#methods-available)
14
11
  - [Usage](#usage)
12
+ - [Get an API Token](#get-an-api-token)
13
+ - [Configure](#configure)
15
14
  - [Get a Single Price](#get-a-single-price)
16
15
  - [Get a Quote](#get-a-quote)
17
16
  - [Get a OHLC (Open, High, Low, Close) price](#get-a-ohlc-open-high-low-close-price)
18
- - [Get a market OHLC (Open, High, Low, Close) prices](#get-a-market-ohlc-open-high-low-close-prices)
17
+ - [Get a Market OHLC (Open, High, Low, Close) prices](#get-a-market-ohlc-open-high-low-close-prices)
19
18
  - [Get Company Information](#get-company-information)
20
19
  - [Get a Company Logo](#get-a-company-logo)
21
20
  - [Get Recent News](#get-recent-news)
@@ -25,14 +24,15 @@ A Ruby client for the [IEX Finance API](https://iextrading.com/developer).
25
24
  - [Get Earnings](#get-earnings)
26
25
  - [Get Sector Performance](#get-sector-performance)
27
26
  - [Get Largest Trades](#get-largest-trades)
28
- - [Get Cryptocurrencies](#get-cryptocurrencies)
27
+ - [Get a Quote for Crypto Currencies](#get-a-quote-for-crypto-currencies)
28
+ - [Configuration](#configuration)
29
29
  - [Errors](#errors)
30
30
  - [SymbolNotFound](#symbolnotfound)
31
+ - [PermissionDeniedError](#permissiondeniederror)
31
32
  - [ClientError](#clienterror)
32
33
  - [Contributing](#contributing)
33
34
  - [Copyright and License](#copyright-and-license)
34
35
 
35
-
36
36
  ## Installation
37
37
 
38
38
  Add to Gemfile.
@@ -43,41 +43,42 @@ gem 'iex-ruby-client'
43
43
 
44
44
  Run `bundle install`.
45
45
 
46
+ ## Usage
46
47
 
47
- ## Methods Available
48
+ ### Get an API Token
48
49
 
49
- - [Get a Single Price](#get-a-single-price)
50
- - [Get a Quote](#get-a-quote)
51
- - [Get a OHLC (Open, High, Low, Close) price](#get-a-ohlc-open-high-low-close-price)
52
- - [Get a Market OHLC (Open, High, Low, Close) prices](#get-a-market-ohlc-open-high-low-close-prices)
53
- - [Get Company Information](#get-company-information)
54
- - [Get Company Logo](#get-company-logo)
55
- - [Get Recent News](#get-recent-news)
56
- - [Get Chart](#get-chat)
57
- - [Get Key Stats](#get-key-stats)
58
- - [Get Dividends](#get-dividends)
59
- - [Get Earnings](#get-earnings)
60
- - [Get Sector Performance](#get-sector-performance)
61
- - [Get Largest Trades](#get-Largest-trades)
50
+ Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the cloud console.
62
51
 
63
- ## Usage
52
+ ### Configure
53
+
54
+ ```ruby
55
+ IEX::Api.configure do |config|
56
+ config.publishable_token = 'token' # defaults to ENV['IEX_API_PUBLISHABLE_TOKEN']
57
+ end
58
+ ```
59
+
60
+ You can also configure an instance of a client directly.
61
+
62
+ ```ruby
63
+ client = IEX::Api::Client.new(publishable_token: 'token')
64
+ ```
64
65
 
65
66
  ### Get a Single Price
66
67
 
67
68
  Fetches a single number, being the IEX real time price, the 15 minute delayed market price, or the previous close price.
68
69
 
69
70
  ```ruby
70
- IEX::Resources::Price.get('MSFT') # 93.78
71
+ client.get('MSFT') # 93.78
71
72
  ```
72
73
 
73
- See [#price](https://iextrading.com/developer/docs/#price) for detailed documentation.
74
+ See [#price](https://iexcloud.io/docs/api/#price) for detailed documentation.
74
75
 
75
76
  ### Get a Quote
76
77
 
77
78
  Fetches a single stock quote.
78
79
 
79
80
  ```ruby
80
- quote = IEX::Resources::Quote.get('MSFT')
81
+ quote = client.quote('MSFT')
81
82
 
82
83
  quote.latest_price # 90.165
83
84
  quote.change # 0.375
@@ -85,13 +86,14 @@ quote.change_percent # 0.00418
85
86
  quote.change_percent_s # '+0.42%'
86
87
  ```
87
88
 
88
- See [#quote](https://iextrading.com/developer/docs/#quote) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.
89
+ See [#quote](https://iexcloud.io/docs/api/#quote) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.
89
90
 
90
91
  ### Get a OHLC (Open, High, Low, Close) price
91
92
 
92
93
  Fetches a single stock OHLC price. Open and Close prices contain timestamp.
94
+
93
95
  ```ruby
94
- ohlc = IEX::Resources::OHLC.get('MSFT')
96
+ ohlc = client.ohlc.get('MSFT')
95
97
 
96
98
  ohlc.close.price # 90.165
97
99
  ohlc.close.time #
@@ -101,11 +103,12 @@ ohlc.high # 0.00418
101
103
  ohlc.low # '+0.42%'
102
104
  ```
103
105
 
104
- ### Get a market OHLC (Open, High, Low, Close) prices
106
+ ### Get a Market OHLC (Open, High, Low, Close) prices
105
107
 
106
108
  Fetches a hash market OHLC prices.
109
+
107
110
  ```ruby
108
- market = IEX::Resources::OHLC.market
111
+ market = client.market
109
112
  market['SPY'].close.price # 278.56
110
113
  market['SPY'].close.time # 2018-06-11 23:00:00 +0300
111
114
  market['SPY'].open.price # 279.05
@@ -119,32 +122,32 @@ market['SPY'].low #
119
122
  Fetches company information for a symbol.
120
123
 
121
124
  ```ruby
122
- company = IEX::Resources::Company.get('MSFT')
125
+ company = client.company('MSFT')
123
126
 
124
127
  company.ceo # 'Satya Nadella'
125
128
  company.company_name # 'Microsoft Corporation'
126
129
  ```
127
130
 
128
- See [#company](https://iextrading.com/developer/docs/#company) for detailed documentation or [company.rb](lib/iex/resources/company.rb) for returned fields.
131
+ See [#company](https://iexcloud.io/docs/api/#company) for detailed documentation or [company.rb](lib/iex/resources/company.rb) for returned fields.
129
132
 
130
133
  ### Get a Company Logo
131
134
 
132
135
  Fetches company logo for a symbol.
133
136
 
134
137
  ```ruby
135
- logo = IEX::Resources::Logo.get('MSFT')
138
+ logo = client.logo('MSFT')
136
139
 
137
140
  logo.url # 'https://storage.googleapis.com/iex/api/logos/MSFT.png'
138
141
  ```
139
142
 
140
- See [#logo](https://iextrading.com/developer/docs/#logo) for detailed documentation or [logo.rb](lib/iex/resources/logo.rb) for returned fields.
143
+ See [#logo](https://iexcloud.io/docs/api/#logo) for detailed documentation or [logo.rb](lib/iex/resources/logo.rb) for returned fields.
141
144
 
142
145
  ### Get Recent News
143
146
 
144
147
  Fetches news for a symbol.
145
148
 
146
149
  ```ruby
147
- news = IEX::Resources::News.get('MSFT')
150
+ news = client.news('MSFT')
148
151
 
149
152
  news.size # 10
150
153
 
@@ -153,26 +156,20 @@ latest.headline # 'Smartsheet files for $100M IPO with growing losses'
153
156
  latest.url # 'https://...'
154
157
  ```
155
158
 
156
- Use `market` to get market-wide news.
157
-
158
- ```ruby
159
- news = IEX::Resources::News.get(:market)
160
- ```
161
-
162
159
  Retrieve a range between 1 and 50.
163
160
 
164
161
  ```ruby
165
- news = IEX::Resources::News.get('MSFT', 5)
162
+ news = client.news('MSFT', 5)
166
163
  ```
167
164
 
168
- See [#news](https://iextrading.com/developer/docs/#news) for detailed documentation or [news.rb](lib/iex/resources/news.rb) for returned fields.
165
+ See [#news](https://iexcloud.io/docs/api/#news) for detailed documentation or [news.rb](lib/iex/resources/news.rb) for returned fields.
169
166
 
170
167
  ### Get Chart
171
168
 
172
169
  Fetches charts for a symbol.
173
170
 
174
171
  ```ruby
175
- chart = IEX::Resources::Chart.get('MSFT')
172
+ chart = client.chart('MSFT')
176
173
 
177
174
  chart.size # 38510
178
175
 
@@ -184,9 +181,9 @@ first.high # 94.97
184
181
  You can specify a chart range and additional options.
185
182
 
186
183
  ```ruby
187
- IEX::Resources::Chart.get('MSFT', 'dynamic') # 1d or 1m data depending on the day or week and time of day
188
- IEX::Resources::Chart.get('MSFT', Date.new(2018, 3, 26)) # a specific date
189
- IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10) # every n-th data point
184
+ client.chart('MSFT', 'dynamic') # 1d or 1m data depending on the day or week and time of day
185
+ client.chart('MSFT', Date.new(2018, 3, 26)) # a specific date
186
+ client.chart('MSFT', '1d', chart_interval: 10) # every n-th data point
190
187
  ```
191
188
 
192
189
  ### Get Key Stats
@@ -194,56 +191,22 @@ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10) # every n-th data po
194
191
  Fetches company's key stats for a symbol.
195
192
 
196
193
  ```ruby
197
- key_stats = IEX::Resources::KeyStats.get('MSFT')
194
+ key_stats = client.key_stats('MSFT')
198
195
 
199
- key_stats.symbol # MSFT
200
196
  key_stats.market_cap # 825814890000
201
197
  key_stats.market_cap_dollars # '$825,814,890,000'
202
- key_stats.beta # 1.261768
203
198
  key_stats.week_52_high # 111.15
204
199
  key_stats.week_52_high_dollar # '$111.15'
205
200
  key_stats.week_52_low # 71.28
206
201
  key_stats.week_52_low_dollar # '$71.28'
207
202
  key_stats.week_52_change_dollar # '$51.77'
208
- key_stats.short_interest # 47158592
209
- key_stats.short_date # '2018-07-13'
210
- key_stats.dividend_rate # 1.68
211
203
  key_stats.dividend_yield # 1.5617738
212
204
  key_stats.ex_dividend_date # '2018-08-15 00:00:00.0'
213
- key_stats.latest_eps # 2.11
214
- key_stats.latest_eps_date # '2018-06-30'
215
205
  key_stats.shares_outstanding # 7677000000
216
206
  key_stats.float # 7217387757
217
- key_stats.return_on_equity # 20.82
218
- key_stats.consensus_eps # 0.86
219
- key_stats.number_of_estimates # 14
220
- key_stats.eps_surprise_dollar # nil
221
- key_stats.eps_surprise_percent # 11.6279
222
- key_stats.eps_surprise_percent_s # '+1162.79%'
223
- key_stats.ebitda # 23558000000
224
- key_stats.revenue_dollar # '$53,456,000,000'
225
- key_stats.gross_profit # 34114000000
226
- key_stats.gross_profit_dollar # '$34,114,000,000'
227
- key_stats.cash_dollar # '$281,251,000,000'
228
207
  key_stats.ttm_eps # 3.51
229
- key_stats.revenue_per_share # 7
230
- key_stats.revenue_per_employee # 431097
231
- key_stats.pe_ratio_high # 0
232
- key_stats.pe_ratio_low # 0
233
- key_stats.return_on_assets # 6.46
234
- key_stats.return_on_capital # nil
235
- key_stats.profit_margin # 15.1
236
- key_stats.price_to_sales # 7.393182
237
- key_stats.price_to_sales_dollar # '$7.39'
238
- key_stats.price_to_book # 10.73
239
- key_stats.price_to_book_dollar # '$10.73'
240
208
  key_stats.day_200_moving_avg # 91.99065
241
209
  key_stats.day_50_moving_avg # 102.2528
242
- key_stats.institution_percent # 75.1
243
- key_stats.institution_percent_s # '+7510.00%'
244
- key_stats.insider_percent # nil
245
- key_stats.insider_percent_s # nil
246
- key_stats.short_ratio # 1.7330703
247
210
  key_stats.year_5_change_percent # 2.85141424991049
248
211
  key_stats.year_5_change_percent_s # '+285.14%'
249
212
  key_stats.year_2_change_percent # 0.9732002824884664
@@ -260,38 +223,33 @@ key_stats.month_1_change_percent_s # '+8.60%'
260
223
  key_stats.day_5_change_percent # -0.0010215453194652084
261
224
  key_stats.day_5_change_percent_s # '-0.10%'
262
225
  ```
263
- 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.
226
+
227
+ See [#key-stats](https://iexcloud.io/docs/api/#key-stats) for detailed documentation or [key_stats.rb](lib/iex/resources/key_stats.rb) for returned fields.
264
228
 
265
229
  ### Get Dividends
266
230
 
267
231
  Fetches dividends for a symbol.
268
232
 
269
233
  ```ruby
270
- dividends = IEX::Resources::Dividends.get('MSFT', '6m') # Options are: 5y, 2y, 1y, ytd, 6m, 3m, 1m
234
+ dividends = client.dividends('MSFT', '6m') # Options are: 5y, 2y, 1y, ytd, 6m, 3m, 1m
271
235
 
272
236
  dividends.payment_date # '2018-03-08'
273
237
  dividends.record_date # '2018-02-15'
274
238
  dividends.declared_date # '2017-11-29'
275
239
  dividends.amount # 0.42
276
- dividends.amount_dollar # '$0.42'
277
- dividends.flag # ''
278
- dividends.type # 'Dividend income'
279
- dividends.qualified # 'Q'
280
- dividends.indicated # ''
281
240
  ```
282
- See [#dividends](https://iextrading.com/developer/docs/#dividends) for detailed documentation or [dividends.rb](lib/iex/resources/dividends.rb) for returned fields.
283
241
 
242
+ See [#dividends](https://iexcloud.io/docs/api/#dividends) for detailed documentation or [dividends.rb](lib/iex/resources/dividends.rb) for returned fields.
284
243
 
285
244
  ### Get Earnings
286
245
 
287
246
  Fetches earnings for a symbol.
288
247
 
289
248
  ```ruby
290
- earnings = IEX::Resources::Earnings.get('MSFT')
249
+ earnings = client.earnings('MSFT')
291
250
 
292
251
  earnings.actual_eps # 1.13
293
252
  earnings.consensus_eps # 1.07
294
- earnings.estimated_eps # 1.07
295
253
  earnings.announce_time # 'AMC'
296
254
  earnings.number_of_estimates # 14
297
255
  earnings.eps_surprise_dollar # 0.06
@@ -301,33 +259,31 @@ earnings.fiscal_end_date # '2018-06-30'
301
259
  earnings.year_ago # 0.98
302
260
  earnings.year_ago_change_percent # 0.15306122448979584
303
261
  earnings.year_ago_change_percent_s # '+15.31%'
304
- earnings.estimated_change_percent # 0.09183673469387764
305
- earnings.estimated_change_percent_s # '+9.18%'
306
- earnings.symbol_id # 4563
307
262
  ```
308
- See [#earnings](https://iextrading.com/developer/docs/#earnings) for detailed documentation or [earnings.rb](lib/iex/resources/earnings.rb) for returned fields.
309
263
 
264
+ See [#earnings](https://iexcloud.io/docs/api/#earnings) for detailed documentation or [earnings.rb](lib/iex/resources/earnings.rb) for returned fields.
310
265
 
311
266
  ### Get Sector Performance
312
267
 
313
268
  Fetches latest sector's performance.
314
269
 
315
270
  ```ruby
316
- sectors = IEX::Resources::Sectors.get('MARKET')
271
+ sectors = client.sectors('MARKET')
317
272
 
318
273
  sectors.type # sectors
319
274
  sectors.name # Industrials
320
275
  sectors.performance # 0.00711
321
276
  sectors.last_updated # 1533672000437
322
277
  ```
323
- See [#sector-performance](https://iextrading.com/developer/docs/#sector-performance) for detailed documentation or [sectors.rb](lib/iex/resources/sectors.rb) for returned fields.
278
+
279
+ See [#sector-performance](https://iexcloud.io/docs/api/#sector-performance) for detailed documentation or [sectors.rb](lib/iex/resources/sectors.rb) for returned fields.
324
280
 
325
281
  ### Get Largest Trades
326
282
 
327
283
  Fetches largest trades in the day for a specific stock. Ordered by largest trade on the top.
328
284
 
329
285
  ```ruby
330
- trades = IEX::Resources::LargestTrades.get('aapl')
286
+ trades = client.largest_trades('aapl')
331
287
 
332
288
  trades.first.price # 186.39
333
289
  trades.first.size # 10000 - refers to the number of shares negotiated in the day.
@@ -336,77 +292,74 @@ trades.first.time_label # 11:51:30
336
292
  trades.first.venue # EDGX
337
293
  trades.first.venue_name # Cboe EDGX
338
294
  ```
339
- See [#largest-trades](https://iextrading.com/developer/docs/#largest-trades) for detailed documentation or [largest_trades.rb](lib/iex/resources/largest_trades.rb) for returned fields.
340
295
 
341
- ### Get Cryptocurrencies
296
+ See [#largest-trades](https://iexcloud.io/docs/api/#largest-trades) for detailed documentation or [largest_trades.rb](lib/iex/resources/largest_trades.rb) for returned fields.
297
+
298
+ ### Get a Quote for Crypto Currencies
299
+
300
+ Fetches a crypto currency quote.
301
+
302
+ ```ruby
303
+ crypto = client.crypto('BTCUSDT')
304
+
305
+ crypto.symbol #'BTCUSDT'
306
+ crypto.company_name #'Bitcoin USD'
307
+ crypto.primary_exchange #'crypto'
308
+ crypto.sector #'cryptocurrency'
309
+ crypto.calculation_price #'realtime'
310
+ crypto.open #3527.79
311
+ crypto.open_dollar #'$3,527'
312
+ crypto.open_time #1_548_082_840_296
313
+ crypto.close #3522.05522498
314
+ crypto.close_dollar #'$3,522'
315
+ crypto.close_time #1_548_169_240_296
316
+ crypto.high #3590.51
317
+ crypto.high_dollar #'$3,590'
318
+ ```
319
+
320
+ See [#crypto](https://iexcloud.io/docs/api/#crypto) for detailed documentation or [crypto.rb](lib/iex/resources/crypto.rb) for returned fields.
342
321
 
343
- Fetches a list of cryptocurrencies' latest quotes and information.
322
+ ## Configuration
344
323
 
324
+ You can configure client options globally or directly with a `IEX::Api::Client` instance.
325
+
326
+ ```ruby
327
+ IEX::Api::Client.configure do |config|
328
+ config.user_agent = 'IEX Ruby Client/1.0.0'
329
+ end
345
330
  ```
346
- crypto = IEX::Resources::Crypto.get
347
-
348
- crypto.first.ask_price # 6617.99
349
- crypto.first.symbol # 'BTCUSDT'
350
- crypto.first.company_name # 'Bitcoin USD'
351
- crypto.first.primary_exchange # 'crypto'
352
- crypto.first.sector # 'cryptocurrency'
353
- crypto.first.calculation_price # 'realtime'
354
- crypto.first.open # 6645.76
355
- crypto.first.open_dollar # '$6,645'
356
- crypto.first.open_time # 1_538_360_540_423
357
- crypto.first.close # 6595.49934953
358
- crypto.first.close_dollar # '$6,595'
359
- crypto.first.close_time # 1_538_446_940_423
360
- crypto.first.high # 6663.1
361
- crypto.first.high_dollar # '$6,663'
362
- crypto.first.low # 6510
363
- crypto.first.low_dollar # '$6,510'
364
- crypto.first.latest_price # 6618.7
365
- crypto.first.latest_price_dollar # '$6,618'
366
- crypto.first.latest_source # 'Real time price'
367
- crypto.first.latest_time # '10:22:20 PM'
368
- crypto.first.latest_update # 1_538_446_940_423
369
- crypto.first.latest_volume # 20_027.36393
370
- crypto.first.latest_volume_dollar # '$20,027'
371
- crypto.first.iex_realtime_price # nil
372
- crypto.first.iex_realtime_size # nil
373
- crypto.first.iex_last_updated # nil
374
- crypto.first.delayed_price # nil
375
- crypto.first.delayed_price_time # nil
376
- crypto.first.extended_change # nil
377
- crypto.first.extended_change_percent # nil
378
- crypto.first.extended_price_time # nil
379
- crypto.first.previous_close # 6645.76
380
- crypto.first.previous_close_dollar # '$6,645'
381
- crypto.first.change # -27.06
382
- crypto.first.change_percent # -0.00407
383
- crypto.first.change_percent_s # '-0.41%'
384
- crypto.first.iex_market_percent # nil
385
- crypto.first.iex_volume # nil
386
- crypto.first.avg_total_volume # nil
387
- crypto.first.iex_bid_price # nil
388
- crypto.first.iex_bid_size # nil
389
- crypto.first.iex_ask_price # nil
390
- crypto.first.iex_ask_size # nil
391
- crypto.first.market_cap # nil
392
- crypto.first.pe_ratio # nil
393
- crypto.first.week52_high # nil
394
- crypto.first.week52_high_dollar # nil
395
- crypto.first.week52_low # nil
396
- crypto.first.week52_low_dollar # nil
397
- crypto.first.ytd_change # nil
398
- crypto.first.bid_price # 6613.16
399
- crypto.first.bid_size # 2.166213
400
- crypto.first.ask_price # 6617.99
401
- crypto.first.ask_size # 0.264944
331
+
332
+ ```ruby
333
+ client = IEX::Api::Client.new(
334
+ publishable_token: 'token',
335
+ user_agent: 'IEX Ruby Client/1.0.0'
336
+ )
402
337
  ```
403
338
 
339
+ The following settings are supported.
340
+
341
+ setting | description
342
+ --------------------|------------
343
+ user_agent | User-agent, defaults to _IEX Ruby Client/version_.
344
+ proxy | Optional HTTP proxy.
345
+ ca_path | Optional SSL certificates path.
346
+ ca_file | Optional SSL certificates file.
347
+ logger | Optional `Logger` instance that logs HTTP requests.
348
+ timeout | Optional open/read timeout in seconds.
349
+ open_timeout | Optional connection open timeout in seconds.
350
+ publishable_token | IEX Cloud API publishable token.
351
+ endpoint | Defaults to `https://cloud.iexapis.com/v1`.
352
+
404
353
  ## Errors
405
354
 
406
355
  ### SymbolNotFound
407
356
 
408
357
  If a symbol cannot be found an [IEX::Errors::SymbolNotFound](lib/iex/errors/symbol_not_found_error.rb) exception is raised.
409
358
 
359
+ ### PermissionDeniedError
360
+
361
+ All errors that return HTTP code 403 result in a [IEX::Errors::PermissionDeniedError](lib/iex/errors/permission_denied_error.rb) exception.
362
+
410
363
  ### ClientError
411
364
 
412
365
  All errors that return HTTP codes 400-600 result in a [IEX::Errors::ClientError](lib/iex/errors/client_error.rb) exception.
@@ -417,8 +370,8 @@ See [CONTRIBUTING](CONTRIBUTING.md).
417
370
 
418
371
  ## Copyright and License
419
372
 
420
- Copyright (c) 2018, [Daniel Doubrovkine](https://twitter.com/dblockdotorg) and [Contributors](CHANGELOG.md).
373
+ Copyright (c) 2018-2019, [Daniel Doubrovkine](https://twitter.com/dblockdotorg) and [Contributors](CHANGELOG.md).
421
374
 
422
375
  This project is licensed under the [MIT License](LICENSE.md).
423
376
 
424
- Data provided for free by [IEX](https://iextrading.com/developer), see [terms](https://iextrading.com/api-terms).
377
+ Data provided for free by [IEX](https://iexcloud.io), see [terms](https://iexcloud.io/terms/).