iex-ruby-client 1.1.1 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.sample +2 -0
- data/.github/FUNDING.yml +1 -0
- data/.rubocop_todo.yml +0 -8
- data/CHANGELOG.md +49 -12
- data/Dangerfile +2 -2
- data/Gemfile +3 -2
- data/README.md +276 -20
- data/RELEASING.md +2 -2
- data/iex-ruby-client.gemspec +2 -1
- data/lib/iex/api.rb +8 -1
- data/lib/iex/api/client.rb +15 -2
- data/lib/iex/api/config/client.rb +52 -0
- data/lib/iex/api/config/logger.rb +35 -0
- data/lib/iex/cloud/connection.rb +22 -19
- data/lib/iex/cloud/response.rb +1 -1
- data/lib/iex/endpoints/advanced_stats.rb +11 -0
- data/lib/iex/endpoints/balance_sheet.rb +13 -0
- data/lib/iex/endpoints/cash_flow.rb +13 -0
- data/lib/iex/endpoints/historial_prices.rb +30 -0
- data/lib/iex/endpoints/ref_data.rb +27 -0
- data/lib/iex/endpoints/stock_market.rb +11 -0
- data/lib/iex/resources.rb +6 -0
- data/lib/iex/resources/advanced_stats.rb +84 -0
- data/lib/iex/resources/balance_sheet.rb +60 -0
- data/lib/iex/resources/cash_flow.rb +43 -0
- data/lib/iex/resources/historical_prices.rb +31 -0
- data/lib/iex/resources/income.rb +2 -0
- data/lib/iex/resources/key_stats.rb +1 -1
- data/lib/iex/resources/news.rb +3 -0
- data/lib/iex/resources/quote.rb +12 -2
- data/lib/iex/resources/resource.rb +12 -0
- data/lib/iex/resources/symbol.rb +10 -0
- data/lib/iex/resources/symbols.rb +19 -0
- data/lib/iex/version.rb +1 -1
- data/spec/fixtures/iex/advanced_stats/invalid.yml +50 -0
- data/spec/fixtures/iex/advanced_stats/msft.yml +57 -0
- data/spec/fixtures/iex/balance_sheet/invalid.yml +50 -0
- data/spec/fixtures/iex/balance_sheet/msft.yml +56 -0
- data/spec/fixtures/iex/cash_flow/invalid.yml +50 -0
- data/spec/fixtures/iex/cash_flow/msft.yml +56 -0
- data/spec/fixtures/iex/historical_prices/abcd.yml +56 -0
- data/spec/fixtures/iex/historical_prices/invalid.yml +50 -0
- data/spec/fixtures/iex/historical_prices/invalid_date.yml +50 -0
- data/spec/fixtures/iex/historical_prices/invalid_range.yml +47 -0
- data/spec/fixtures/iex/historical_prices/msft.yml +79 -0
- data/spec/fixtures/iex/historical_prices/msft_5d.yml +61 -0
- data/spec/fixtures/iex/historical_prices/msft_date_and_chart_by_day.yml +57 -0
- data/spec/fixtures/iex/historical_prices/msft_specific_date_trimmed.yml +445 -0
- data/spec/fixtures/iex/income/msft.yml +54 -51
- data/spec/fixtures/iex/ref-data/exchange_symbols.yml +1926 -0
- data/spec/fixtures/iex/ref-data/isin.yml +9 -9
- data/spec/fixtures/iex/ref-data/isin_mapped.yml +57 -0
- data/spec/fixtures/iex/ref-data/symbols.yml +9002 -0
- data/spec/fixtures/iex/ref-data/wrong_isin_mapped.yml +57 -0
- data/spec/fixtures/iex/stock_market/list_mostactive.yml +76 -0
- data/spec/iex/client_spec.rb +96 -13
- data/spec/iex/config/client_spec.rb +49 -0
- data/spec/iex/config/logger_spec.rb +46 -0
- data/spec/iex/endpoints/advanced_stats_spec.rb +110 -0
- data/spec/iex/endpoints/balance_sheet_spec.rb +80 -0
- data/spec/iex/endpoints/cash_flow_spec.rb +59 -0
- data/spec/iex/endpoints/historical_prices_spec.rb +206 -0
- data/spec/iex/endpoints/income_spec.rb +31 -29
- data/spec/iex/endpoints/key_stats_spec.rb +1 -0
- data/spec/iex/endpoints/news_spec.rb +3 -0
- data/spec/iex/endpoints/quote_spec.rb +2 -0
- data/spec/iex/endpoints/ref_data_spec.rb +103 -8
- data/spec/iex/endpoints/stock_market_spec.rb +14 -0
- data/spec/iex/resources/resource_spec.rb +36 -0
- data/spec/spec_helper.rb +3 -3
- metadata +74 -9
- data/lib/iex/api/config.rb +0 -47
- data/spec/iex/config_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd85bc6a798e1c37eb803200aed631db1d1ff3fb6090714cceb01bb5d12c6c9f
|
4
|
+
data.tar.gz: 0e483fa9cf10d511714de9563034309c463278931628d077c580a33bbdbf32d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe22b477b65f4ade43d1c0f9b44c07dc99664744f4d8fc0081aec8b29053e54c06d3c290e47a27a37c8452c81557f5d2c371d39e936ecd19d5ac0dbd68cd2124
|
7
|
+
data.tar.gz: 14b3664d77a34096534dc9c46fadfa8f7056c7d8bfe82bd5264ee390817363619ccc7de809e1bd8c80e9d7d5cce04e8e5d33b1f8ab8d88f86cf81d1f40e59027
|
data/.env.sample
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: [dblock]
|
data/.rubocop_todo.yml
CHANGED
@@ -11,11 +11,3 @@
|
|
11
11
|
Style/AsciiComments:
|
12
12
|
Exclude:
|
13
13
|
- 'lib/iex/resources/quote.rb'
|
14
|
-
|
15
|
-
# Offense count: 1
|
16
|
-
# Cop supports --auto-correct.
|
17
|
-
# Configuration parameters: EnforcedStyle, Autocorrect.
|
18
|
-
# SupportedStyles: module_function, extend_self
|
19
|
-
Style/ModuleFunction:
|
20
|
-
Exclude:
|
21
|
-
- 'lib/iex/api/config.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,17 +1,54 @@
|
|
1
|
+
### 1.4.1 (2021/05/15)
|
2
|
+
* [#103](https://github.com/dblock/iex-ruby-client/pull/103): Added support for fetching symbols for an exchange - [@mathu97](https://github.com/mathu97).
|
3
|
+
* [#99](https://github.com/dblock/iex-ruby-client/pull/99): Added `image` and `paywalled` to news - [@reddavis](https://github.com/reddavis).
|
4
|
+
* [#100](https://github.com/dblock/iex-ruby-client/pull/100): Added `language` to news - [@reddavis](https://github.com/reddavis).
|
5
|
+
|
6
|
+
### 1.4.0 (2020/11/19)
|
7
|
+
* [#90](https://github.com/dblock/iex-ruby-client/pull/90): Added documentation for advanced stats and removed `avg_30_Volume` from advanced stats since it is found in key stats - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
8
|
+
* [#91](https://github.com/dblock/iex-ruby-client/pull/91): Added support for Balance Sheet API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
9
|
+
* [#92](https://github.com/dblock/iex-ruby-client/pull/92): Added support for Cash Flow Statements API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
10
|
+
* [#93](https://github.com/dblock/iex-ruby-client/pull/93): Added `fiscal_date` and `currency` to income statements - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
11
|
+
* [#94](https://github.com/dblock/iex-ruby-client/pull/94): Added `historical_prices` API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
12
|
+
* [#95](https://github.com/dblock/iex-ruby-client/pull/95): Added all KeyStat properties to AdvancedStats since they are already returned in the API call - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
13
|
+
|
14
|
+
### 1.3.0 (2020/10/31)
|
15
|
+
|
16
|
+
* [#82](https://github.com/dblock/iex-ruby-client/pull/82): Added `config.referer` to set HTTP `Referer` header. This enables IEX's "Manage domains" domain locking for tokens - [@agrberg](https://github.com/agrberg).
|
17
|
+
* [#70](https://github.com/dblock/iex-ruby-client/pull/70): Added support for `ref_data_isin` taking a single `String` parameter - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
18
|
+
* [#84](https://github.com/dblock/iex-ruby-client/pull/84): Added support for Advanced Stats API - [@FanaHOVA](https://github.com/fanahova).
|
19
|
+
* [#86](https://github.com/dblock/iex-ruby-client/issues/86): Added advanced logger configuration to `config.logger`. Now a hash with keys `:instance, :options, and :proc` can be passed and used directly with Faraday - [@agrberg](https://github.com/agrberg).
|
20
|
+
* [#88](https://github.com/dblock/iex-ruby-client/pull/88): Updated logger configuration to work like `Config` class and allow attribute and block based configuration - [@agrberg](https://github.com/agrberg).
|
21
|
+
* [#89](https://github.com/dblock/iex-ruby-client/pull/89): Backfill breaking `Config#logger` setting change from [#88](https://github.com/dblock/iex-ruby-client/pull/88) - [@agrberg](https://github.com/agrberg).
|
22
|
+
|
23
|
+
### 1.2.0 (2020/09/01)
|
24
|
+
|
25
|
+
* [#78](https://github.com/dblock/iex-ruby-client/pull/78): Added `Quote#extended_change_percent` and `Quote#extended_change_percent_s` properties to Quote - [@reddavis](https://github.com/reddavis).
|
26
|
+
* [#71](https://github.com/dblock/iex-ruby-client/pull/71): Added `symbols` resource - [@ryosuke-endo](https://github.com/ryosuke-endo).
|
27
|
+
* [#69](https://github.com/dblock/iex-ruby-client/pull/69): Fixed `ref_data_isin` request - [@bguban](https://github.com/bguban).
|
28
|
+
* [#72](https://github.com/dblock/iex-ruby-client/pull/72): Cache `Faraday::Connection` for persistent adapters - [@dblock](https://github.com/dblock).
|
29
|
+
|
30
|
+
### 1.1.2 (2020/03/25)
|
31
|
+
|
32
|
+
* [#68](https://github.com/dblock/iex-ruby-client/pull/68): Fixed `ref_data_isin` request with wrong isin - [@bguban](https://github.com/bguban).
|
33
|
+
* [#67](https://github.com/dblock/iex-ruby-client/pull/67): Added required ruby version to gemspec - [@wdperson](https://github.com/wdperson).
|
34
|
+
* [#66](https://github.com/dblock/iex-ruby-client/pull/66): Fixed `KeyStats#week_52_change always` returns nil - [@brunjo](https://github.com/brunjo).
|
35
|
+
* [#65](https://github.com/dblock/iex-ruby-client/pull/65): Added `stock_market_list` - [@bguban](https://github.com/bguban).
|
36
|
+
* [#64](https://github.com/dblock/iex-ruby-client/pull/64): Added `ref_data_isin` - [@bguban](https://github.com/bguban).
|
37
|
+
|
1
38
|
### 1.1.1 (2020/03/02)
|
2
39
|
|
3
40
|
* [#63](https://github.com/dblock/iex-ruby-client/pull/63): Allow direct API calls with support for secret_token - [@bguban](https://github.com/bguban).
|
4
|
-
* [#61](https://github.com/dblock/iex-ruby-client/pull/61):
|
5
|
-
* [#57](https://github.com/dblock/iex-ruby-client/pull/57):
|
41
|
+
* [#61](https://github.com/dblock/iex-ruby-client/pull/61): Fixed income endpoint if the api returns no result - [@brunjo](https://github.com/brunjo).
|
42
|
+
* [#57](https://github.com/dblock/iex-ruby-client/pull/57): Updated properties for chart api endpoint - [@brunjo](https://github.com/brunjo).
|
6
43
|
|
7
44
|
### 1.1.0 (2019/07/08)
|
8
45
|
|
9
|
-
* [#55](https://github.com/dblock/iex-ruby-client/pull/55):
|
46
|
+
* [#55](https://github.com/dblock/iex-ruby-client/pull/55): Added `income` statement API and add `tags` to the `company` - [@bingxie](https://github.com/bingxie).
|
10
47
|
|
11
48
|
### 1.0.1 (2019/07/08)
|
12
49
|
|
13
|
-
* [#50](https://github.com/dblock/iex-ruby-client/pull/50):
|
14
|
-
*
|
50
|
+
* [#50](https://github.com/dblock/iex-ruby-client/pull/50): Added missing properties for key stats API - [@bingxie](https://github.com/bingxie).
|
51
|
+
* Fixed `uninitialized constant IEX::Endpoints::Chart::Date (NameError)` - [@dblock](https://github.com/dblock).
|
15
52
|
|
16
53
|
### 1.0.0 (2019/04/23)
|
17
54
|
|
@@ -21,9 +58,9 @@
|
|
21
58
|
### 0.4.4 (2018/12/27)
|
22
59
|
|
23
60
|
* [#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).
|
24
|
-
* [#37](https://github.com/dblock/iex-ruby-client/pull/37):
|
25
|
-
* [#34](https://github.com/dblock/iex-ruby-client/pull/34):
|
26
|
-
* [#32](https://github.com/dblock/iex-ruby-client/pull/32):
|
61
|
+
* [#37](https://github.com/dblock/iex-ruby-client/pull/37): Added `IEX::Resource::Crypto` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
62
|
+
* [#34](https://github.com/dblock/iex-ruby-client/pull/34): Added `IEX::Resource::LargestTrades` - [@gil27](https://github.com/gil27).
|
63
|
+
* [#32](https://github.com/dblock/iex-ruby-client/pull/32): Added `IEX::Resource::Sectors` - [@gil27](https://github.com/gil27).
|
27
64
|
|
28
65
|
### 0.4.3 (2018/08/18)
|
29
66
|
|
@@ -31,7 +68,7 @@
|
|
31
68
|
|
32
69
|
### 0.4.2 (2018/08/14)
|
33
70
|
|
34
|
-
* [#24](https://github.com/dblock/iex-ruby-client/pull/24):
|
71
|
+
* [#24](https://github.com/dblock/iex-ruby-client/pull/24): Added danger-toc and danger-changelog - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
35
72
|
* [#21](https://github.com/dblock/iex-ruby-client/pull/21): Added `IEX::Resources::Dividends` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
36
73
|
|
37
74
|
### 0.4.1 (2018/08/07)
|
@@ -50,18 +87,18 @@
|
|
50
87
|
|
51
88
|
### 0.3.2 (2018/05/26)
|
52
89
|
|
53
|
-
*
|
90
|
+
* Fixed undefined method > for nil:NilClass error - [@dblock](https://github.com/dblock).
|
54
91
|
|
55
92
|
### 0.3.1 (2018/05/23)
|
56
93
|
|
57
|
-
* [#3](https://github.com/dblock/iex-ruby-client/issues/3):
|
94
|
+
* [#3](https://github.com/dblock/iex-ruby-client/issues/3): Fixed do not error on undefined properties - [@dblock](https://github.com/dblock).
|
58
95
|
|
59
96
|
### 0.3.0 (2018/05/22)
|
60
97
|
|
61
98
|
* Added `IEX::Resources::Chart#get` - [@dblock](https://github.com/dblock).
|
62
99
|
* Added `IEX::Resources::News#get` - [@dblock](https://github.com/dblock).
|
63
100
|
* Added `IEX::Resources::Price#get` - [@dblock](https://github.com/dblock).
|
64
|
-
*
|
101
|
+
* Fixed added `IEX::Resources::Quote#extendedPrice` and `IEX::Resources::Quote#extendedPriceTime` - [@dblock](https://github.com/dblock).
|
65
102
|
|
66
103
|
### 0.2.0 (2018/03/26)
|
67
104
|
|
data/Dangerfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
toc.check
|
2
|
-
changelog.check
|
1
|
+
toc.check!
|
2
|
+
changelog.check!
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -15,19 +15,29 @@ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
|
|
15
15
|
- [Get a Quote](#get-a-quote)
|
16
16
|
- [Get a OHLC (Open, High, Low, Close) price](#get-a-ohlc-open-high-low-close-price)
|
17
17
|
- [Get a Market OHLC (Open, High, Low, Close) prices](#get-a-market-ohlc-open-high-low-close-prices)
|
18
|
+
- [Get Historical Prices](#get-historical-prices)
|
18
19
|
- [Get Company Information](#get-company-information)
|
19
20
|
- [Get a Company Logo](#get-a-company-logo)
|
20
21
|
- [Get Recent News](#get-recent-news)
|
21
22
|
- [Get Chart](#get-chart)
|
22
23
|
- [Get Key Stats](#get-key-stats)
|
24
|
+
- [Get Advanced Stats](#get-advanced-stats)
|
23
25
|
- [Get Dividends](#get-dividends)
|
24
26
|
- [Get Earnings](#get-earnings)
|
25
27
|
- [Get Income Statement](#get-income-statement)
|
28
|
+
- [Get Balance Sheet](#get-balance-sheet)
|
29
|
+
- [Get Cash Flow Statement](#get-cash-flow-statement)
|
26
30
|
- [Get Sector Performance](#get-sector-performance)
|
27
31
|
- [Get Largest Trades](#get-largest-trades)
|
28
32
|
- [Get a Quote for Crypto Currencies](#get-a-quote-for-crypto-currencies)
|
33
|
+
- [ISIN Mapping](#isin-mapping)
|
34
|
+
- [Get Symbols](#get-symbols)
|
35
|
+
- [Get Symbols for an Exchange](#get-symbols-for-an-exchange)
|
36
|
+
- [Get List](#get-list)
|
29
37
|
- [Other Requests](#other-requests)
|
30
38
|
- [Configuration](#configuration)
|
39
|
+
- [Logging](#logging)
|
40
|
+
- [Sandbox Environment](#sandbox-environment)
|
31
41
|
- [Errors](#errors)
|
32
42
|
- [SymbolNotFound](#symbolnotfound)
|
33
43
|
- [PermissionDeniedError](#permissiondeniederror)
|
@@ -49,7 +59,7 @@ Run `bundle install`.
|
|
49
59
|
|
50
60
|
### Get an API Token
|
51
61
|
|
52
|
-
Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console.
|
62
|
+
Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console.
|
53
63
|
|
54
64
|
### Configure
|
55
65
|
|
@@ -57,7 +67,7 @@ Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable toke
|
|
57
67
|
IEX::Api.configure do |config|
|
58
68
|
config.publishable_token = 'publishable_token' # defaults to ENV['IEX_API_PUBLISHABLE_TOKEN']
|
59
69
|
config.secret_token = 'secret_token' # defaults to ENV['IEX_API_SECRET_TOKEN']
|
60
|
-
config.endpoint = 'https://
|
70
|
+
config.endpoint = 'https://cloud.iexapis.com/v1' # use 'https://sandbox.iexapis.com/v1' for Sandbox
|
61
71
|
end
|
62
72
|
```
|
63
73
|
|
@@ -67,7 +77,7 @@ You can also configure an instance of a client directly.
|
|
67
77
|
client = IEX::Api::Client.new(
|
68
78
|
publishable_token: 'publishable_token',
|
69
79
|
secret_token: 'secret_token',
|
70
|
-
endpoint: 'https://
|
80
|
+
endpoint: 'https://cloud.iexapis.com/v1'
|
71
81
|
)
|
72
82
|
```
|
73
83
|
|
@@ -101,7 +111,7 @@ See [#quote](https://iexcloud.io/docs/api/#quote) for detailed documentation or
|
|
101
111
|
Fetches a single stock OHLC price. Open and Close prices contain timestamp.
|
102
112
|
|
103
113
|
```ruby
|
104
|
-
ohlc = client.ohlc
|
114
|
+
ohlc = client.ohlc('MSFT')
|
105
115
|
|
106
116
|
ohlc.close.price # 90.165
|
107
117
|
ohlc.close.time #
|
@@ -125,6 +135,60 @@ market['SPY'].high #
|
|
125
135
|
market['SPY'].low #
|
126
136
|
```
|
127
137
|
|
138
|
+
### Get Historical Prices
|
139
|
+
|
140
|
+
Fetches a list of historical prices.
|
141
|
+
|
142
|
+
There are currently a few limitations of this endpoint compared to the official IEX one.
|
143
|
+
|
144
|
+
Options for `range` include:
|
145
|
+
`max, ytd, 5y, 2y, 1y, 6m, 3m, 1m, 5d, date`
|
146
|
+
|
147
|
+
NOTE: If you use the `date` value for the `range` parameter:
|
148
|
+
|
149
|
+
- The options _must_ include a date entry, `{date: ...}`
|
150
|
+
- The date value _must_ be either a Date object, or a string formatted as `YYYYMMDD`. Anything else will result in an `IEX::Errors::ClientError`.
|
151
|
+
- The options _must_ include `chartByDay: 'true'` or an `ArgumentError` will be raised.
|
152
|
+
- See below for examples.
|
153
|
+
|
154
|
+
`Query params` supported include:
|
155
|
+
`chartByDay`
|
156
|
+
|
157
|
+
This is a complicated endpoint as there is a lot of granularity over the time period of data returned. See below for a variety of ways to request data, NOTE: this is _NOT_ as exhaustive list.
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
historial_prices = client.historical_prices('MSFT') # One month of data
|
161
|
+
historial_prices = client.historical_prices('MSFT', {range: 'max'}) # All data up to 15 years
|
162
|
+
historial_prices = client.historical_prices('MSFT', {range: 'ytd'}) # Year to date data
|
163
|
+
historial_prices = client.historical_prices('MSFT', {range: '5y'}) # 5 years of data
|
164
|
+
historial_prices = client.historical_prices('MSFT', {range: '6m'}) # 6 months of data
|
165
|
+
historial_prices = client.historical_prices('MSFT', {range: '5d'}) # 5 days of data
|
166
|
+
historial_prices = client.historical_prices('MSFT', {range: 'date', date: '20200930', chartByDay: 'true'}) # One day of data
|
167
|
+
historial_prices = client.historical_prices('MSFT', {range: 'date', date: Date.parse('2020-09-30'), chartByDay: 'true'}) # One day of data
|
168
|
+
...
|
169
|
+
```
|
170
|
+
|
171
|
+
Once you have the data over the preferred time period, you can access the following fields
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
historial_prices = client.historical_prices('MSFT') # One month of data
|
175
|
+
|
176
|
+
historial_price = historial_prices.first
|
177
|
+
historical_price.date # 2020-10-07
|
178
|
+
historical_price.open #207.06
|
179
|
+
historical_price.open_dollar # '$207.06'
|
180
|
+
historical_price.close # 209.83
|
181
|
+
historical_price.close_dollar # '$209.83'
|
182
|
+
historical_price.high # 210.11
|
183
|
+
historical_price.high_dollar # '$210.11'
|
184
|
+
historical_price.low # 206.72
|
185
|
+
historical_price.low_dollar # '$206.72'
|
186
|
+
historical_price.volume # 25681054
|
187
|
+
...
|
188
|
+
```
|
189
|
+
|
190
|
+
There are a lot of options here so I would recommend viewing the official IEX documentation [#historical-prices](https://iexcloud.io/docs/api/#historical-prices) or [historical_prices.rb](lib/iex/resources/historical_prices.rb) for returned fields.
|
191
|
+
|
128
192
|
### Get Company Information
|
129
193
|
|
130
194
|
Fetches company information for a symbol.
|
@@ -260,6 +324,50 @@ key_stats.beta # 1.4135449089973444
|
|
260
324
|
|
261
325
|
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.
|
262
326
|
|
327
|
+
### Get Advanced Stats
|
328
|
+
|
329
|
+
Fetches company's advanced stats for a symbol, this will include all key stats as well.
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
advanced_stats = client.advanced_stats('MSFT')
|
333
|
+
|
334
|
+
advanced_stats.total_cash # 66301000000
|
335
|
+
advanced_stats.total_cash_dollars # "$66,301,000,000"
|
336
|
+
advanced_stats.current_debt # 20748000000
|
337
|
+
advanced_stats.current_debt_dollars # "$2,074,8000,000"
|
338
|
+
advanced_stats.revenue # 265809000000
|
339
|
+
advanced_stats.revenue_dollars # "$265,809,000,000"
|
340
|
+
advanced_stats.gross_profit # 101983000000
|
341
|
+
advanced_stats.gross_profit_dollar # "$101,983,000,000"
|
342
|
+
advanced_stats.total_revenue # 265809000000
|
343
|
+
advanced_stats.total_revenue_dollar # "$265,809,000,000"
|
344
|
+
advanced_stats.ebitda # 80342000000
|
345
|
+
advanced_stats.ebitda_dollar # "$80,342,000,000"
|
346
|
+
advanced_stats.revenue_per_share # 0.02
|
347
|
+
advanced_stats.revenue_per_share_dollar # "$0.02"
|
348
|
+
advanced_stats.revenue_per_employee # 2013704.55
|
349
|
+
advanced_stats.revenue_per_employee_dollar # "$2,013,704.55"
|
350
|
+
advanced_stats.debt_to_equity # 1.07
|
351
|
+
advanced_stats.profit_margin # 22.396157
|
352
|
+
advanced_stats.enterprise_value # 1022460690000
|
353
|
+
advanced_stats.enterprise_value_dollar # "$1,022,460,690,000"
|
354
|
+
advanced_stats.enterprise_value_to_revenue # 3.85
|
355
|
+
advanced_stats.price_to_sales # 3.49
|
356
|
+
advanced_stats.price_to_sales_dollar # "$3.49"
|
357
|
+
advanced_stats.price_to_book # 8.805916432564608
|
358
|
+
advanced_stats.forward_pe_ratio # 18.14
|
359
|
+
advanced_stats.pe_high # 22.61
|
360
|
+
advanced_stats.pe_low # 11.98
|
361
|
+
advanced_stats.peg_ratio # 2.19
|
362
|
+
advanced_stats.week_52_high_date # "2019-11-19"
|
363
|
+
advanced_stats.week_52_low_date # "2019-01-03
|
364
|
+
advanced_stats.beta # 1.4661365583766115
|
365
|
+
advanced_stats.put_call_ratio # 0.6780362005229779
|
366
|
+
...
|
367
|
+
```
|
368
|
+
|
369
|
+
See [#advanced-stats](https://iexcloud.io/docs/api/#advanced-stats) for detailed documentation or [advanced_stats.rb](lib/iex/resources/advanced_stats.rb) for returned fields.
|
370
|
+
|
263
371
|
### Get Dividends
|
264
372
|
|
265
373
|
Fetches dividends for a symbol.
|
@@ -299,12 +407,16 @@ See [#earnings](https://iexcloud.io/docs/api/#earnings) for detailed documentati
|
|
299
407
|
|
300
408
|
### Get Income Statement
|
301
409
|
|
302
|
-
Fetches income
|
410
|
+
Fetches income statements for a symbol.
|
303
411
|
|
304
412
|
```ruby
|
305
|
-
|
413
|
+
income_statements = client.income('MSFT')
|
306
414
|
|
415
|
+
# Multiple income statements are returned with 1 API call.
|
416
|
+
income = income_statements.first
|
307
417
|
income.report_date # '2019-03-31'
|
418
|
+
income.fiscal_date # '2019-03-31'
|
419
|
+
income.currency # 'USD'
|
308
420
|
income.total_revenue # 30_505_000_000
|
309
421
|
income.total_revenue_dollar # '$30,505,000,000'
|
310
422
|
income.cost_of_revenue # 10_170_000_000
|
@@ -316,6 +428,48 @@ income.gross_profit_dollar # '$20,335,000,000'
|
|
316
428
|
|
317
429
|
See [#income-statement](https://iexcloud.io/docs/api/#income-statement) for detailed documentation or [income.rb](lib/iex/resources/income.rb) for returned fields.
|
318
430
|
|
431
|
+
### Get Balance Sheet
|
432
|
+
|
433
|
+
Fetches balance sheets for a symbol.
|
434
|
+
|
435
|
+
```ruby
|
436
|
+
balance_sheets = client.balance_sheet('MSFT')
|
437
|
+
|
438
|
+
# Multiple balance sheets are returned with 1 API call.
|
439
|
+
balance_sheet = balance_sheets.first
|
440
|
+
balance_sheet.report_date # '2017-03-31'
|
441
|
+
balance_sheet.fiscal_date # '2017-03-31'
|
442
|
+
balance_sheet.currency # 'USD'
|
443
|
+
balance_sheet.current_cash # 25_913_000_000
|
444
|
+
balance_sheet.current_cash_dollar # '$25,913,000,000'
|
445
|
+
balance_sheet.short_term_investments # 40_388_000_000
|
446
|
+
balance_sheet.short_term_investments_dollar # '$40,388,000,000'
|
447
|
+
...
|
448
|
+
```
|
449
|
+
|
450
|
+
See [#balance-sheet](https://iexcloud.io/docs/api/#balance-sheet) for detailed documentation or [balance_sheet.rb](lib/iex/resources/balance_sheet.rb) for returned fields.
|
451
|
+
|
452
|
+
### Get Cash Flow Statement
|
453
|
+
|
454
|
+
Fetches cash flow statements for a symbol.
|
455
|
+
|
456
|
+
```ruby
|
457
|
+
cash_flow_statements = client.cash_flow('MSFT')
|
458
|
+
|
459
|
+
# Multiple cash flow statements are returned with 1 API call.
|
460
|
+
cash_flow = cash_flow_statements.first
|
461
|
+
cash_flow.report_date # '2018-09-30'
|
462
|
+
cash_flow.fiscal_date # '2018-09-30'
|
463
|
+
cash_flow.currency # 'USD'
|
464
|
+
cash_flow.net_income # 14_125_000_000
|
465
|
+
cash_flow.net_income_dollar # '$14,125,000,000'
|
466
|
+
cash_flow.depreciation # 2_754_000_000
|
467
|
+
cash_flow.depreciation_dollar # '$2,754,000,000'
|
468
|
+
...
|
469
|
+
```
|
470
|
+
|
471
|
+
See [#cash-flow](https://iexcloud.io/docs/api/#cash-flow) for detailed documentation or [cash_flow.rb](lib/iex/resources/cash_flow.rb) for returned fields.
|
472
|
+
|
319
473
|
### Get Sector Performance
|
320
474
|
|
321
475
|
Fetches latest sector's performance.
|
@@ -372,9 +526,78 @@ crypto.high_dollar #'$3,590'
|
|
372
526
|
|
373
527
|
See [#crypto](https://iexcloud.io/docs/api/#crypto) for detailed documentation or [crypto.rb](lib/iex/resources/crypto.rb) for returned fields.
|
374
528
|
|
529
|
+
### ISIN Mapping
|
530
|
+
|
531
|
+
Convert ISIN to IEX Cloud symbols.
|
532
|
+
|
533
|
+
```ruby
|
534
|
+
symbols = client.ref_data_isin('US0378331005')
|
535
|
+
|
536
|
+
symbols.first.exchange # NAS
|
537
|
+
symbols.first.iex_id # IEX_4D48333344362D52
|
538
|
+
symbols.first.region # US
|
539
|
+
symbols.first.symbol # AAPL
|
540
|
+
```
|
541
|
+
|
542
|
+
The API also lets you convert multiple ISINs to IEX Cloud symbols.
|
543
|
+
|
544
|
+
```ruby
|
545
|
+
symbols = client.ref_data_isin(['US0378331005', 'US0378331006'])
|
546
|
+
```
|
547
|
+
|
548
|
+
You can use `mapped: true` option to receive symbols grouped by their ISINs.
|
549
|
+
|
550
|
+
```ruby
|
551
|
+
client.ref_data_isin(['US0378331005', 'US5949181045'], mapped: true) # {'US0378331005' => [...], 'US5949181045' => [...]}
|
552
|
+
```
|
553
|
+
|
554
|
+
See [#ISIN Mapping](https://iexcloud.io/docs/api/#isin-mapping) for detailed documentation or [isin_mapping.rb](lib/iex/resources/isin_mapping.rb) for returned fields.
|
555
|
+
|
556
|
+
### Get Symbols
|
557
|
+
|
558
|
+
Returns an array of symbols
|
559
|
+
|
560
|
+
```ruby
|
561
|
+
symbols = client.ref_data_symbols()
|
562
|
+
|
563
|
+
symbol = symbols.first
|
564
|
+
symbol.exchange # NAS
|
565
|
+
symbol.iex_id # IEX_46574843354B2D52
|
566
|
+
symbol.region # US
|
567
|
+
symbol.symbol # A
|
568
|
+
```
|
569
|
+
|
570
|
+
See [#symbols](https://iexcloud.io/docs/api/#symbols) for detailed documentation or [symbols.rb](lib/iex/resources/symbols.rb) for returned fields.
|
571
|
+
|
572
|
+
### Get Symbols for an Exchange
|
573
|
+
|
574
|
+
Returns an array of symbols for a given exchange
|
575
|
+
|
576
|
+
```ruby
|
577
|
+
symbols = client.ref_data_symbols_for_exchange('TSX')
|
578
|
+
|
579
|
+
symbol = symbols.first
|
580
|
+
symbol.exchange # TSX
|
581
|
+
symbol.iex_id # IEX_4656374258322D52
|
582
|
+
symbol.region # CA
|
583
|
+
symbol.symbol # A-CV
|
584
|
+
```
|
585
|
+
|
586
|
+
See [#international-symbols](https://iexcloud.io/docs/api/#international-symbols).
|
587
|
+
|
588
|
+
### Get List
|
589
|
+
|
590
|
+
Returns an array of quotes for the top 10 symbols in a specified list.
|
591
|
+
|
592
|
+
```ruby
|
593
|
+
client.stock_market_list(:mostactive) # [{symbol: 'AAPL', ...}, {...}]
|
594
|
+
```
|
595
|
+
|
596
|
+
See [#list](https://iexcloud.io/docs/api/#list) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.
|
597
|
+
|
375
598
|
### Other Requests
|
376
599
|
|
377
|
-
Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
|
600
|
+
Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
|
378
601
|
and `client.delete` methods. Pass the required token explicitly:
|
379
602
|
|
380
603
|
```ruby
|
@@ -386,7 +609,7 @@ client.post('ref-data/isin', isin: ['US0378331005'], token: 'secret_token') # [{
|
|
386
609
|
You can configure client options globally or directly with a `IEX::Api::Client` instance.
|
387
610
|
|
388
611
|
```ruby
|
389
|
-
IEX::Api
|
612
|
+
IEX::Api.configure do |config|
|
390
613
|
config.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
|
391
614
|
config.endpoint = 'https://sandbox.iexapis.com/v1' # use sandbox environment
|
392
615
|
end
|
@@ -395,23 +618,56 @@ end
|
|
395
618
|
```ruby
|
396
619
|
client = IEX::Api::Client.new(
|
397
620
|
publishable_token: ENV['IEX_API_PUBLISHABLE_TOKEN'],
|
398
|
-
endpoint: 'https://
|
621
|
+
endpoint: 'https://cloud.iexapis.com/v1'
|
399
622
|
)
|
400
623
|
```
|
401
624
|
|
402
625
|
The following settings are supported.
|
403
626
|
|
404
|
-
setting
|
405
|
-
|
406
|
-
user_agent
|
407
|
-
proxy
|
408
|
-
ca_path
|
409
|
-
ca_file
|
410
|
-
logger
|
411
|
-
timeout
|
412
|
-
open_timeout
|
413
|
-
publishable_token
|
414
|
-
endpoint
|
627
|
+
| setting | description |
|
628
|
+
| ----------------- | --------------------------------------------------------------------------- |
|
629
|
+
| user_agent | User-agent, defaults to _IEX Ruby Client/version_. |
|
630
|
+
| proxy | Optional HTTP proxy. |
|
631
|
+
| ca_path | Optional SSL certificates path. |
|
632
|
+
| ca_file | Optional SSL certificates file. |
|
633
|
+
| logger | Optional `Logger` instance or logger configuration to log HTTP requests. |
|
634
|
+
| timeout | Optional open/read timeout in seconds. |
|
635
|
+
| open_timeout | Optional connection open timeout in seconds. |
|
636
|
+
| publishable_token | IEX Cloud API publishable token. |
|
637
|
+
| endpoint | Defaults to `https://cloud.iexapis.com/v1`. |
|
638
|
+
| referer | Optional string for HTTP `Referer` header, enables token domain management. |
|
639
|
+
|
640
|
+
### Logging
|
641
|
+
|
642
|
+
Faraday will not log HTTP requests by default. In order to do this you can either provide a `logger` instance or configuration attributes to `IEX::Api::Client`. Configuration allows you to supply the `instance`, `options`, and `proc` to [Faraday](https://lostisland.github.io/faraday/middleware/logger#include-and-exclude-headersbodies).
|
643
|
+
|
644
|
+
```ruby
|
645
|
+
logger_instance = Logger.new(STDOUT)
|
646
|
+
|
647
|
+
IEX::Api.configure do |config|
|
648
|
+
config.logger.instance = logger_instance
|
649
|
+
config.logger.options = { bodies: true }
|
650
|
+
config.logger.proc = proc { |logger| logger.filter(/T?[sp]k_\w+/i, '[REMOVED]') }
|
651
|
+
end
|
652
|
+
# or
|
653
|
+
IEX::Api.logger do |logger|
|
654
|
+
logger.instance = logger_instance
|
655
|
+
logger.options = …
|
656
|
+
logger.proc = …
|
657
|
+
end
|
658
|
+
# or
|
659
|
+
IEX::Api.logger = logger_instance
|
660
|
+
# or
|
661
|
+
IEX::Api::Client.new(logger: logger_instance)
|
662
|
+
```
|
663
|
+
|
664
|
+
## Sandbox Environment
|
665
|
+
|
666
|
+
IEX recommends you use a sandbox token and endpoint for testing.
|
667
|
+
|
668
|
+
However, please note that data in the IEX sandbox environment is scrambled. Therefore elements such as company and people names, descriptions, tags, and website URLs don't render any coherent data. In addition, results, such as closing market prices and dividend yield, are not accurate and vary on every call.
|
669
|
+
|
670
|
+
See [IEX sandbox environment](https://intercom.help/iexcloud/en/articles/2915433-testing-with-the-iex-cloud-sandbox) for more information.
|
415
671
|
|
416
672
|
## Errors
|
417
673
|
|