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.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +8 -36
- data/CHANGELOG.md +5 -0
- data/LICENSE.md +1 -1
- data/README.md +113 -160
- data/UPGRADING.md +55 -3
- data/iex-ruby-client.gemspec +1 -1
- data/lib/iex-ruby-client.rb +2 -0
- data/lib/iex/api.rb +15 -31
- data/lib/iex/api/client.rb +30 -0
- data/lib/iex/api/config.rb +45 -0
- data/lib/iex/cloud.rb +3 -0
- data/lib/iex/cloud/connection.rb +37 -0
- data/lib/iex/cloud/request.rb +38 -0
- data/lib/iex/cloud/response.rb +20 -0
- data/lib/iex/endpoints/chart.rb +39 -0
- data/lib/iex/endpoints/company.rb +11 -0
- data/lib/iex/endpoints/crypto.rb +11 -0
- data/lib/iex/endpoints/dividends.rb +18 -0
- data/lib/iex/endpoints/earnings.rb +13 -0
- data/lib/iex/endpoints/key_stats.rb +11 -0
- data/lib/iex/endpoints/largest_trades.rb +13 -0
- data/lib/iex/endpoints/logo.rb +11 -0
- data/lib/iex/endpoints/news.rb +19 -0
- data/lib/iex/endpoints/ohlc.rb +17 -0
- data/lib/iex/endpoints/price.rb +11 -0
- data/lib/iex/endpoints/quote.rb +11 -0
- data/lib/iex/endpoints/sectors.rb +17 -0
- data/lib/iex/errors.rb +1 -0
- data/lib/iex/errors/client_error.rb +13 -1
- data/lib/iex/errors/permission_denied_error.rb +5 -0
- data/lib/iex/logger.rb +13 -0
- data/lib/iex/resources.rb +0 -1
- data/lib/iex/resources/chart.rb +38 -21
- data/lib/iex/resources/company.rb +2 -8
- data/lib/iex/resources/crypto.rb +10 -18
- data/lib/iex/resources/dividends.rb +5 -15
- data/lib/iex/resources/earnings.rb +1 -15
- data/lib/iex/resources/key_stats.rb +11 -57
- data/lib/iex/resources/largest_trades.rb +0 -10
- data/lib/iex/resources/logo.rb +0 -8
- data/lib/iex/resources/news.rb +1 -11
- data/lib/iex/resources/ohlc.rb +8 -16
- data/lib/iex/resources/quote.rb +0 -8
- data/lib/iex/resources/resource.rb +19 -2
- data/lib/iex/resources/sectors.rb +0 -10
- data/lib/iex/version.rb +1 -1
- data/spec/fixtures/iex/chart/1d.yml +472 -444
- data/spec/fixtures/iex/chart/20190306.yml +475 -0
- data/spec/fixtures/iex/chart/bad_option.yml +80 -62
- data/spec/fixtures/iex/chart/chartInterval.yml +121 -98
- data/spec/fixtures/iex/chart/dynamic/1m.yml +106 -81
- data/spec/fixtures/iex/chart/invalid.yml +80 -58
- data/spec/fixtures/iex/chart/msft.yml +106 -81
- data/spec/fixtures/iex/client/access_denied.yml +49 -0
- data/spec/fixtures/iex/company/invalid.yml +80 -58
- data/spec/fixtures/iex/company/msft.yml +87 -65
- data/spec/fixtures/iex/crypto/btcusdt.yml +87 -0
- data/spec/fixtures/iex/dividends/invalid.yml +80 -62
- data/spec/fixtures/iex/dividends/msft.yml +88 -66
- data/spec/fixtures/iex/dividends/msft_1y.yml +92 -68
- data/spec/fixtures/iex/dividends/msft_default_range.yml +85 -65
- data/spec/fixtures/iex/dividends/msft_invalid_range.yml +82 -64
- data/spec/fixtures/iex/earnings/invalid.yml +80 -62
- data/spec/fixtures/iex/earnings/msft.yml +84 -68
- data/spec/fixtures/iex/key_stats/invalid.yml +80 -62
- data/spec/fixtures/iex/key_stats/msft.yml +84 -65
- data/spec/fixtures/iex/largest-trades/aapl.yml +91 -73
- data/spec/fixtures/iex/largest-trades/invalid.yml +80 -62
- data/spec/fixtures/iex/logo/msft.yml +82 -64
- data/spec/fixtures/iex/news/invalid.yml +80 -58
- data/spec/fixtures/iex/news/msft.yml +83 -61
- data/spec/fixtures/iex/news/msft_7.yml +83 -61
- data/spec/fixtures/iex/ohlc/market.yml +82 -65
- data/spec/fixtures/iex/ohlc/msft.yml +82 -64
- data/spec/fixtures/iex/price/invalid.yml +80 -58
- data/spec/fixtures/iex/price/msft.yml +82 -60
- data/spec/fixtures/iex/quote/invalid.yml +80 -62
- data/spec/fixtures/iex/quote/msft.yml +84 -66
- data/spec/fixtures/iex/sectors/invalid.yml +80 -62
- data/spec/fixtures/iex/sectors/sectors-performance.yml +88 -69
- data/spec/iex/client_spec.rb +138 -0
- data/spec/iex/config_spec.rb +22 -0
- data/spec/iex/{resources → endpoints}/chart_spec.rb +23 -21
- data/spec/iex/{resources → endpoints}/company_spec.rb +11 -7
- data/spec/iex/endpoints/crypto_spec.rb +66 -0
- data/spec/iex/{resources → endpoints}/dividends_spec.rb +17 -14
- data/spec/iex/endpoints/earnings_spec.rb +36 -0
- data/spec/iex/endpoints/key_stats_spec.rb +62 -0
- data/spec/iex/{resources → endpoints}/largest_trades_spec.rb +8 -6
- data/spec/iex/{resources → endpoints}/logo_spec.rb +3 -1
- data/spec/iex/endpoints/news_spec.rb +36 -0
- data/spec/iex/{resources → endpoints}/ohlc_spec.rb +15 -13
- data/spec/iex/{resources → endpoints}/price_spec.rb +6 -4
- data/spec/iex/endpoints/quote_spec.rb +38 -0
- data/spec/iex/{resources → endpoints}/sectors_spec.rb +7 -6
- data/spec/iex/resources/{base_spec.rb → resource_spec.rb} +6 -6
- data/spec/spec_helper.rb +2 -0
- data/spec/support/client.rb +6 -0
- metadata +66 -59
- data/lib/iex/api/chart.rb +0 -24
- data/lib/iex/api/company.rb +0 -13
- data/lib/iex/api/crypto.rb +0 -13
- data/lib/iex/api/dividends.rb +0 -17
- data/lib/iex/api/earnings.rb +0 -13
- data/lib/iex/api/key_stats.rb +0 -13
- data/lib/iex/api/largest_trades.rb +0 -13
- data/lib/iex/api/logo.rb +0 -13
- data/lib/iex/api/news.rb +0 -18
- data/lib/iex/api/ohlc.rb +0 -17
- data/lib/iex/api/price.rb +0 -13
- data/lib/iex/api/quote.rb +0 -13
- data/lib/iex/api/sectors.rb +0 -16
- data/lib/iex/resources/base.rb +0 -27
- data/lib/iex/resources/chart/base.rb +0 -14
- data/lib/iex/resources/chart/default.rb +0 -21
- data/lib/iex/resources/chart/one_day.rb +0 -20
- data/lib/iex/resources/ohlc/base.rb +0 -14
- data/lib/iex/resources/ohlc/timed_price.rb +0 -12
- data/lib/iex/resources/price.rb +0 -13
- data/spec/fixtures/iex/chart/20180227.yml +0 -452
- data/spec/fixtures/iex/crypto.yml +0 -101
- data/spec/fixtures/iex/news/market.yml +0 -64
- data/spec/iex/resources/crypto_spec.rb +0 -65
- data/spec/iex/resources/earnings_spec.rb +0 -38
- data/spec/iex/resources/key_stats_spec.rb +0 -94
- data/spec/iex/resources/news_spec.rb +0 -44
- data/spec/iex/resources/quote_spec.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df29afbbbd95d15992840fdfe66fd8fa31ed1cee
|
4
|
+
data.tar.gz: df551117e4b8dcfa5e223a765c1fa97e7bc4bedb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28d4ea0c36db77958e86a5c0ad347a04876a7bd8e51582f853435316444f0b7277c1a1b98bd299e4b77f89821ec89dc58e9923c45e631e961433dcc5dfe2aa9
|
7
|
+
data.tar.gz: 34f851cf3b8e46f2475531717055c1a9cf9ca7abb96675fc50c88a766a5ff6f92f6f52459fda71e1d046eba4ade185d7e368639222195a662c8ee1bba957c4e9
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,49 +1,21 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
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
|
-
#
|
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:
|
42
|
-
|
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/
|
45
|
-
- 'spec/iex/resources/news_spec.rb'
|
46
|
-
|
47
|
-
# Offense count: 36
|
48
|
-
Style/Documentation:
|
49
|
-
Enabled: false
|
21
|
+
- 'lib/iex/api/config.rb'
|
data/CHANGELOG.md
CHANGED
@@ -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
|
[](https://badge.fury.io/rb/iex-ruby-client)
|
5
4
|
[](https://travis-ci.org/dblock/iex-ruby-client)
|
6
5
|
|
7
|
-
A Ruby client for the [IEX
|
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
|
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
|
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
|
-
|
48
|
+
### Get an API Token
|
48
49
|
|
49
|
-
|
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
|
-
|
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
|
-
|
71
|
+
client.get('MSFT') # 93.78
|
71
72
|
```
|
72
73
|
|
73
|
-
See [#price](https://
|
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 =
|
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://
|
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 =
|
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
|
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 =
|
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 =
|
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://
|
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 =
|
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://
|
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 =
|
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 =
|
162
|
+
news = client.news('MSFT', 5)
|
166
163
|
```
|
167
164
|
|
168
|
-
See [#news](https://
|
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 =
|
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
|
-
|
188
|
-
|
189
|
-
|
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 =
|
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
|
-
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
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://
|
377
|
+
Data provided for free by [IEX](https://iexcloud.io), see [terms](https://iexcloud.io/terms/).
|