iex-ruby-client 1.1.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env.sample +2 -0
- data/.github/FUNDING.yml +1 -0
- data/.rubocop_todo.yml +0 -8
- data/CHANGELOG.md +48 -10
- data/Dangerfile +2 -2
- data/Gemfile +3 -2
- data/README.md +260 -11
- 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/request.rb +1 -1
- 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/chart.rb +1 -1
- data/lib/iex/endpoints/company.rb +1 -1
- data/lib/iex/endpoints/crypto.rb +1 -1
- data/lib/iex/endpoints/dividends.rb +1 -1
- data/lib/iex/endpoints/earnings.rb +1 -1
- data/lib/iex/endpoints/historial_prices.rb +30 -0
- data/lib/iex/endpoints/income.rb +1 -1
- data/lib/iex/endpoints/key_stats.rb +1 -1
- data/lib/iex/endpoints/largest_trades.rb +1 -1
- data/lib/iex/endpoints/logo.rb +1 -1
- data/lib/iex/endpoints/news.rb +1 -1
- data/lib/iex/endpoints/ohlc.rb +2 -2
- data/lib/iex/endpoints/price.rb +1 -1
- data/lib/iex/endpoints/quote.rb +1 -1
- data/lib/iex/endpoints/ref_data.rb +22 -0
- data/lib/iex/endpoints/sectors.rb +1 -1
- 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/chart.rb +8 -13
- 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/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/chart/1d.yml +440 -473
- data/spec/fixtures/iex/chart/20190306.yml +440 -473
- data/spec/fixtures/iex/chart/bad_option.yml +47 -81
- data/spec/fixtures/iex/chart/chartInterval.yml +89 -122
- data/spec/fixtures/iex/chart/dynamic/1m.yml +73 -107
- data/spec/fixtures/iex/chart/invalid.yml +47 -81
- data/spec/fixtures/iex/chart/msft.yml +74 -107
- 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/invalid.yml +47 -47
- data/spec/fixtures/iex/income/msft.yml +54 -51
- data/spec/fixtures/iex/income/nsrgy.yml +55 -0
- data/spec/fixtures/iex/ref-data/isin.yml +57 -0
- 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 +97 -14
- 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/chart_spec.rb +7 -7
- data/spec/iex/endpoints/historical_prices_spec.rb +206 -0
- data/spec/iex/endpoints/income_spec.rb +41 -30
- data/spec/iex/endpoints/key_stats_spec.rb +1 -0
- data/spec/iex/endpoints/quote_spec.rb +2 -0
- data/spec/iex/endpoints/ref_data_spec.rb +76 -0
- 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 -2
- data/spec/support/vcr.rb +3 -0
- metadata +82 -14
- data/lib/iex/api/config.rb +0 -45
- data/spec/iex/config_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 36c3afc87c696f3bb31e32bc65e987f794ee40ad2e7545aa7fab2fce99b267cd
|
4
|
+
data.tar.gz: 58c9280ac2e9f36ecb5b2c00a7d8d5cccda7b54f7935f4391abe1767f90a0225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ac7d1a3a9d952e9dba3e75af5624720b31a2aa4d8c33ee432755cebfffda5d5e121b36fcaf572bb2e59123c0715864c259afe902fc19ed88ad05a6c2419302
|
7
|
+
data.tar.gz: 18fe9215733f10ab5f80c4a5e6419fcece10a7772a77a42f0c6a1ea64772fe7c279b181f3bc56af948af4e2ad5aa56c582dc31460bd0646104bbba2d1af5bbb9
|
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,11 +1,49 @@
|
|
1
|
+
### 1.4.0 (2020/11/19)
|
2
|
+
* [#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).
|
3
|
+
* [#91](https://github.com/dblock/iex-ruby-client/pull/91): Added support for Balance Sheet API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
4
|
+
* [#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).
|
5
|
+
* [#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).
|
6
|
+
* [#94](https://github.com/dblock/iex-ruby-client/pull/94): Added `historical_prices` API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
7
|
+
* [#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).
|
8
|
+
|
9
|
+
### 1.3.0 (2020/10/31)
|
10
|
+
|
11
|
+
* [#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).
|
12
|
+
* [#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).
|
13
|
+
* [#84](https://github.com/dblock/iex-ruby-client/pull/84): Added support for Advanced Stats API - [@FanaHOVA](https://github.com/fanahova).
|
14
|
+
* [#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).
|
15
|
+
* [#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).
|
16
|
+
* [#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).
|
17
|
+
|
18
|
+
### 1.2.0 (2020/09/01)
|
19
|
+
|
20
|
+
* [#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).
|
21
|
+
* [#71](https://github.com/dblock/iex-ruby-client/pull/71): Added `symbols` resource - [@ryosuke-endo](https://github.com/ryosuke-endo).
|
22
|
+
* [#69](https://github.com/dblock/iex-ruby-client/pull/69): Fixed `ref_data_isin` request - [@bguban](https://github.com/bguban).
|
23
|
+
* [#72](https://github.com/dblock/iex-ruby-client/pull/72): Cache `Faraday::Connection` for persistent adapters - [@dblock](https://github.com/dblock).
|
24
|
+
|
25
|
+
### 1.1.2 (2020/03/25)
|
26
|
+
|
27
|
+
* [#68](https://github.com/dblock/iex-ruby-client/pull/68): Fixed `ref_data_isin` request with wrong isin - [@bguban](https://github.com/bguban).
|
28
|
+
* [#67](https://github.com/dblock/iex-ruby-client/pull/67): Added required ruby version to gemspec - [@wdperson](https://github.com/wdperson).
|
29
|
+
* [#66](https://github.com/dblock/iex-ruby-client/pull/66): Fixed `KeyStats#week_52_change always` returns nil - [@brunjo](https://github.com/brunjo).
|
30
|
+
* [#65](https://github.com/dblock/iex-ruby-client/pull/65): Added `stock_market_list` - [@bguban](https://github.com/bguban).
|
31
|
+
* [#64](https://github.com/dblock/iex-ruby-client/pull/64): Added `ref_data_isin` - [@bguban](https://github.com/bguban).
|
32
|
+
|
33
|
+
### 1.1.1 (2020/03/02)
|
34
|
+
|
35
|
+
* [#63](https://github.com/dblock/iex-ruby-client/pull/63): Allow direct API calls with support for secret_token - [@bguban](https://github.com/bguban).
|
36
|
+
* [#61](https://github.com/dblock/iex-ruby-client/pull/61): Fixed income endpoint if the api returns no result - [@brunjo](https://github.com/brunjo).
|
37
|
+
* [#57](https://github.com/dblock/iex-ruby-client/pull/57): Updated properties for chart api endpoint - [@brunjo](https://github.com/brunjo).
|
38
|
+
|
1
39
|
### 1.1.0 (2019/07/08)
|
2
40
|
|
3
|
-
* [#55](https://github.com/dblock/iex-ruby-client/pull/55):
|
41
|
+
* [#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).
|
4
42
|
|
5
43
|
### 1.0.1 (2019/07/08)
|
6
44
|
|
7
|
-
* [#50](https://github.com/dblock/iex-ruby-client/pull/50):
|
8
|
-
*
|
45
|
+
* [#50](https://github.com/dblock/iex-ruby-client/pull/50): Added missing properties for key stats API - [@bingxie](https://github.com/bingxie).
|
46
|
+
* Fixed `uninitialized constant IEX::Endpoints::Chart::Date (NameError)` - [@dblock](https://github.com/dblock).
|
9
47
|
|
10
48
|
### 1.0.0 (2019/04/23)
|
11
49
|
|
@@ -15,9 +53,9 @@
|
|
15
53
|
### 0.4.4 (2018/12/27)
|
16
54
|
|
17
55
|
* [#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).
|
18
|
-
* [#37](https://github.com/dblock/iex-ruby-client/pull/37):
|
19
|
-
* [#34](https://github.com/dblock/iex-ruby-client/pull/34):
|
20
|
-
* [#32](https://github.com/dblock/iex-ruby-client/pull/32):
|
56
|
+
* [#37](https://github.com/dblock/iex-ruby-client/pull/37): Added `IEX::Resource::Crypto` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
57
|
+
* [#34](https://github.com/dblock/iex-ruby-client/pull/34): Added `IEX::Resource::LargestTrades` - [@gil27](https://github.com/gil27).
|
58
|
+
* [#32](https://github.com/dblock/iex-ruby-client/pull/32): Added `IEX::Resource::Sectors` - [@gil27](https://github.com/gil27).
|
21
59
|
|
22
60
|
### 0.4.3 (2018/08/18)
|
23
61
|
|
@@ -25,7 +63,7 @@
|
|
25
63
|
|
26
64
|
### 0.4.2 (2018/08/14)
|
27
65
|
|
28
|
-
* [#24](https://github.com/dblock/iex-ruby-client/pull/24):
|
66
|
+
* [#24](https://github.com/dblock/iex-ruby-client/pull/24): Added danger-toc and danger-changelog - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
29
67
|
* [#21](https://github.com/dblock/iex-ruby-client/pull/21): Added `IEX::Resources::Dividends` - [@rodolfobandeira](https://github.com/rodolfobandeira).
|
30
68
|
|
31
69
|
### 0.4.1 (2018/08/07)
|
@@ -44,18 +82,18 @@
|
|
44
82
|
|
45
83
|
### 0.3.2 (2018/05/26)
|
46
84
|
|
47
|
-
*
|
85
|
+
* Fixed undefined method > for nil:NilClass error - [@dblock](https://github.com/dblock).
|
48
86
|
|
49
87
|
### 0.3.1 (2018/05/23)
|
50
88
|
|
51
|
-
* [#3](https://github.com/dblock/iex-ruby-client/issues/3):
|
89
|
+
* [#3](https://github.com/dblock/iex-ruby-client/issues/3): Fixed do not error on undefined properties - [@dblock](https://github.com/dblock).
|
52
90
|
|
53
91
|
### 0.3.0 (2018/05/22)
|
54
92
|
|
55
93
|
* Added `IEX::Resources::Chart#get` - [@dblock](https://github.com/dblock).
|
56
94
|
* Added `IEX::Resources::News#get` - [@dblock](https://github.com/dblock).
|
57
95
|
* Added `IEX::Resources::Price#get` - [@dblock](https://github.com/dblock).
|
58
|
-
*
|
96
|
+
* Fixed added `IEX::Resources::Quote#extendedPrice` and `IEX::Resources::Quote#extendedPriceTime` - [@dblock](https://github.com/dblock).
|
59
97
|
|
60
98
|
### 0.2.0 (2018/03/26)
|
61
99
|
|
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,18 +15,28 @@ 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 List](#get-list)
|
36
|
+
- [Other Requests](#other-requests)
|
29
37
|
- [Configuration](#configuration)
|
38
|
+
- [Logging](#logging)
|
39
|
+
- [Sandbox Environment](#sandbox-environment)
|
30
40
|
- [Errors](#errors)
|
31
41
|
- [SymbolNotFound](#symbolnotfound)
|
32
42
|
- [PermissionDeniedError](#permissiondeniederror)
|
@@ -48,14 +58,15 @@ Run `bundle install`.
|
|
48
58
|
|
49
59
|
### Get an API Token
|
50
60
|
|
51
|
-
Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console.
|
61
|
+
Create an account on [IEX Cloud](https://iexcloud.io) and get a publishable token from the IEX cloud console.
|
52
62
|
|
53
63
|
### Configure
|
54
64
|
|
55
65
|
```ruby
|
56
66
|
IEX::Api.configure do |config|
|
57
|
-
config.publishable_token = '
|
58
|
-
config.
|
67
|
+
config.publishable_token = 'publishable_token' # defaults to ENV['IEX_API_PUBLISHABLE_TOKEN']
|
68
|
+
config.secret_token = 'secret_token' # defaults to ENV['IEX_API_SECRET_TOKEN']
|
69
|
+
config.endpoint = 'https://cloud.iexapis.com/v1' # use 'https://sandbox.iexapis.com/v1' for Sandbox
|
59
70
|
end
|
60
71
|
```
|
61
72
|
|
@@ -63,8 +74,9 @@ You can also configure an instance of a client directly.
|
|
63
74
|
|
64
75
|
```ruby
|
65
76
|
client = IEX::Api::Client.new(
|
66
|
-
publishable_token: '
|
67
|
-
|
77
|
+
publishable_token: 'publishable_token',
|
78
|
+
secret_token: 'secret_token',
|
79
|
+
endpoint: 'https://cloud.iexapis.com/v1'
|
68
80
|
)
|
69
81
|
```
|
70
82
|
|
@@ -98,7 +110,7 @@ See [#quote](https://iexcloud.io/docs/api/#quote) for detailed documentation or
|
|
98
110
|
Fetches a single stock OHLC price. Open and Close prices contain timestamp.
|
99
111
|
|
100
112
|
```ruby
|
101
|
-
ohlc = client.ohlc
|
113
|
+
ohlc = client.ohlc('MSFT')
|
102
114
|
|
103
115
|
ohlc.close.price # 90.165
|
104
116
|
ohlc.close.time #
|
@@ -122,6 +134,57 @@ market['SPY'].high #
|
|
122
134
|
market['SPY'].low #
|
123
135
|
```
|
124
136
|
|
137
|
+
### Get Historical Prices
|
138
|
+
|
139
|
+
Fetches a list of historical prices.
|
140
|
+
|
141
|
+
There are currently a few limitations of this endpoint compared to the official IEX one.
|
142
|
+
|
143
|
+
Options for `range` include:
|
144
|
+
`max, ytd, 5y, 2y, 1y, 6m, 3m, 1m, 5d, date`
|
145
|
+
|
146
|
+
NOTE: If you use the `date` value for the `range` parameter:
|
147
|
+
* The options _must_ include a date entry, `{date: ...}`
|
148
|
+
* The date value _must_ be either a Date object, or a string formatted as `YYYYMMDD`. Anything else will result in an `IEX::Errors::ClientError`.
|
149
|
+
* The options _must_ include `chartByDay: 'true'` or an `ArgumentError` will be raised.
|
150
|
+
* See below for examples.
|
151
|
+
|
152
|
+
`Query params` supported include:
|
153
|
+
`chartByDay`
|
154
|
+
|
155
|
+
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.
|
156
|
+
```ruby
|
157
|
+
historial_prices = client.historical_prices('MSFT') # One month of data
|
158
|
+
historial_prices = client.historical_prices('MSFT', {range: 'max'}) # All data up to 15 years
|
159
|
+
historial_prices = client.historical_prices('MSFT', {range: 'ytd'}) # Year to date data
|
160
|
+
historial_prices = client.historical_prices('MSFT', {range: '5y'}) # 5 years of data
|
161
|
+
historial_prices = client.historical_prices('MSFT', {range: '6m'}) # 6 months of data
|
162
|
+
historial_prices = client.historical_prices('MSFT', {range: '5d'}) # 5 days of data
|
163
|
+
historial_prices = client.historical_prices('MSFT', {range: 'date', date: '20200930', chartByDay: 'true'}) # One day of data
|
164
|
+
historial_prices = client.historical_prices('MSFT', {range: 'date', date: Date.parse('2020-09-30)', chartByDay: 'true'}) # One day of data
|
165
|
+
...
|
166
|
+
```
|
167
|
+
|
168
|
+
Once you have the data over the preferred time period, you can access the following fields
|
169
|
+
```ruby
|
170
|
+
historial_prices = client.historical_prices('MSFT') # One month of data
|
171
|
+
|
172
|
+
historial_price = historial_prices.first
|
173
|
+
historical_price.date # 2020-10-07
|
174
|
+
historical_price.open #207.06
|
175
|
+
historical_price.open_dollar # '$207.06'
|
176
|
+
historical_price.close # 209.83
|
177
|
+
historical_price.close_dollar # '$209.83'
|
178
|
+
historical_price.high # 210.11
|
179
|
+
historical_price.high_dollar # '$210.11'
|
180
|
+
historical_price.low # 206.72
|
181
|
+
historical_price.low_dollar # '$206.72'
|
182
|
+
historical_price.volume # 25681054
|
183
|
+
...
|
184
|
+
```
|
185
|
+
|
186
|
+
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.
|
187
|
+
|
125
188
|
### Get Company Information
|
126
189
|
|
127
190
|
Fetches company information for a symbol.
|
@@ -257,6 +320,50 @@ key_stats.beta # 1.4135449089973444
|
|
257
320
|
|
258
321
|
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.
|
259
322
|
|
323
|
+
### Get Advanced Stats
|
324
|
+
|
325
|
+
Fetches company's advanced stats for a symbol, this will include all key stats as well.
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
advanced_stats = client.advanced_stats('MSFT')
|
329
|
+
|
330
|
+
advanced_stats.total_cash # 66301000000
|
331
|
+
advanced_stats.total_cash_dollars # "$66,301,000,000"
|
332
|
+
advanced_stats.current_debt # 20748000000
|
333
|
+
advanced_stats.current_debt_dollars # "$2,074,8000,000"
|
334
|
+
advanced_stats.revenue # 265809000000
|
335
|
+
advanced_stats.revenue_dollars # "$265,809,000,000"
|
336
|
+
advanced_stats.gross_profit # 101983000000
|
337
|
+
advanced_stats.gross_profit_dollar # "$101,983,000,000"
|
338
|
+
advanced_stats.total_revenue # 265809000000
|
339
|
+
advanced_stats.total_revenue_dollar # "$265,809,000,000"
|
340
|
+
advanced_stats.ebitda # 80342000000
|
341
|
+
advanced_stats.ebitda_dollar # "$80,342,000,000"
|
342
|
+
advanced_stats.revenue_per_share # 0.02
|
343
|
+
advanced_stats.revenue_per_share_dollar # "$0.02"
|
344
|
+
advanced_stats.revenue_per_employee # 2013704.55
|
345
|
+
advanced_stats.revenue_per_employee_dollar # "$2,013,704.55"
|
346
|
+
advanced_stats.debt_to_equity # 1.07
|
347
|
+
advanced_stats.profit_margin # 22.396157
|
348
|
+
advanced_stats.enterprise_value # 1022460690000
|
349
|
+
advanced_stats.enterprise_value_dollar # "$1,022,460,690,000"
|
350
|
+
advanced_stats.enterprise_value_to_revenue # 3.85
|
351
|
+
advanced_stats.price_to_sales # 3.49
|
352
|
+
advanced_stats.price_to_sales_dollar # "$3.49"
|
353
|
+
advanced_stats.price_to_book # 8.805916432564608
|
354
|
+
advanced_stats.forward_pe_ratio # 18.14
|
355
|
+
advanced_stats.pe_high # 22.61
|
356
|
+
advanced_stats.pe_low # 11.98
|
357
|
+
advanced_stats.peg_ratio # 2.19
|
358
|
+
advanced_stats.week_52_high_date # "2019-11-19"
|
359
|
+
advanced_stats.week_52_low_date # "2019-01-03
|
360
|
+
advanced_stats.beta # 1.4661365583766115
|
361
|
+
advanced_stats.put_call_ratio # 0.6780362005229779
|
362
|
+
...
|
363
|
+
```
|
364
|
+
|
365
|
+
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.
|
366
|
+
|
260
367
|
### Get Dividends
|
261
368
|
|
262
369
|
Fetches dividends for a symbol.
|
@@ -296,12 +403,16 @@ See [#earnings](https://iexcloud.io/docs/api/#earnings) for detailed documentati
|
|
296
403
|
|
297
404
|
### Get Income Statement
|
298
405
|
|
299
|
-
Fetches income
|
406
|
+
Fetches income statements for a symbol.
|
300
407
|
|
301
408
|
```ruby
|
302
|
-
|
409
|
+
income_statements = client.income('MSFT')
|
303
410
|
|
411
|
+
# Multiple income statements are returned with 1 API call.
|
412
|
+
income = income_statements.first
|
304
413
|
income.report_date # '2019-03-31'
|
414
|
+
income.fiscal_date # '2019-03-31'
|
415
|
+
income.currency # 'USD'
|
305
416
|
income.total_revenue # 30_505_000_000
|
306
417
|
income.total_revenue_dollar # '$30,505,000,000'
|
307
418
|
income.cost_of_revenue # 10_170_000_000
|
@@ -313,6 +424,48 @@ income.gross_profit_dollar # '$20,335,000,000'
|
|
313
424
|
|
314
425
|
See [#income-statement](https://iexcloud.io/docs/api/#income-statement) for detailed documentation or [income.rb](lib/iex/resources/income.rb) for returned fields.
|
315
426
|
|
427
|
+
### Get Balance Sheet
|
428
|
+
|
429
|
+
Fetches balance sheets for a symbol.
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
balance_sheets = client.balance_sheet('MSFT')
|
433
|
+
|
434
|
+
# Multiple balance sheets are returned with 1 API call.
|
435
|
+
balance_sheet = balance_sheets.first
|
436
|
+
balance_sheet.report_date # '2017-03-31'
|
437
|
+
balance_sheet.fiscal_date # '2017-03-31'
|
438
|
+
balance_sheet.currency # 'USD'
|
439
|
+
balance_sheet.current_cash # 25_913_000_000
|
440
|
+
balance_sheet.current_cash_dollar # '$25,913,000,000'
|
441
|
+
balance_sheet.short_term_investments # 40_388_000_000
|
442
|
+
balance_sheet.short_term_investments_dollar # '$40,388,000,000'
|
443
|
+
...
|
444
|
+
```
|
445
|
+
|
446
|
+
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.
|
447
|
+
|
448
|
+
### Get Cash Flow Statement
|
449
|
+
|
450
|
+
Fetches cash flow statements for a symbol.
|
451
|
+
|
452
|
+
```ruby
|
453
|
+
cash_flow_statements = client.cash_flow('MSFT')
|
454
|
+
|
455
|
+
# Multiple cash flow statements are returned with 1 API call.
|
456
|
+
cash_flow = cash_flow_statements.first
|
457
|
+
cash_flow.report_date # '2018-09-30'
|
458
|
+
cash_flow.fiscal_date # '2018-09-30'
|
459
|
+
cash_flow.currency # 'USD'
|
460
|
+
cash_flow.net_income # 14_125_000_000
|
461
|
+
cash_flow.net_income_dollar # '$14,125,000,000'
|
462
|
+
cash_flow.depreciation # 2_754_000_000
|
463
|
+
cash_flow.depreciation_dollar # '$2,754,000,000'
|
464
|
+
...
|
465
|
+
```
|
466
|
+
|
467
|
+
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.
|
468
|
+
|
316
469
|
### Get Sector Performance
|
317
470
|
|
318
471
|
Fetches latest sector's performance.
|
@@ -369,12 +522,75 @@ crypto.high_dollar #'$3,590'
|
|
369
522
|
|
370
523
|
See [#crypto](https://iexcloud.io/docs/api/#crypto) for detailed documentation or [crypto.rb](lib/iex/resources/crypto.rb) for returned fields.
|
371
524
|
|
525
|
+
### ISIN Mapping
|
526
|
+
|
527
|
+
Convert ISIN to IEX Cloud symbols.
|
528
|
+
|
529
|
+
```ruby
|
530
|
+
symbols = client.ref_data_isin('US0378331005')
|
531
|
+
|
532
|
+
symbols.first.exchange # NAS
|
533
|
+
symbols.first.iex_id # IEX_4D48333344362D52
|
534
|
+
symbols.first.region # US
|
535
|
+
symbols.first.symbol # AAPL
|
536
|
+
```
|
537
|
+
|
538
|
+
The API also lets you convert multiple ISINs to IEX Cloud symbols.
|
539
|
+
|
540
|
+
```ruby
|
541
|
+
symbols = client.ref_data_isin(['US0378331005', 'US0378331006'])
|
542
|
+
```
|
543
|
+
|
544
|
+
|
545
|
+
You can use `mapped: true` option to receive symbols grouped by their ISINs.
|
546
|
+
|
547
|
+
```ruby
|
548
|
+
client.ref_data_isin(['US0378331005', 'US5949181045'], mapped: true) # {'US0378331005' => [...], 'US5949181045' => [...]}
|
549
|
+
```
|
550
|
+
|
551
|
+
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.
|
552
|
+
|
553
|
+
### Get Symbols
|
554
|
+
|
555
|
+
Returns an array of symbols
|
556
|
+
|
557
|
+
```ruby
|
558
|
+
symbols = client.ref_data_symbols()
|
559
|
+
|
560
|
+
symbol = symbols.first
|
561
|
+
symbol.exchange # NAS
|
562
|
+
symbol.iex_id # IEX_46574843354B2D52
|
563
|
+
symbol.region # US
|
564
|
+
symbol.symbol # A
|
565
|
+
```
|
566
|
+
|
567
|
+
See [#symbols](https://iexcloud.io/docs/api/#symbols) for detailed documentation or [symbols.rb](lib/iex/resources/symbols.rb) for returned fields.
|
568
|
+
|
569
|
+
### Get List
|
570
|
+
|
571
|
+
Returns an array of quotes for the top 10 symbols in a specified list.
|
572
|
+
|
573
|
+
```ruby
|
574
|
+
client.stock_market_list(:mostactive) # [{symbol: 'AAPL', ...}, {...}]
|
575
|
+
```
|
576
|
+
|
577
|
+
See [#list](https://iexcloud.io/docs/api/#list) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.
|
578
|
+
|
579
|
+
### Other Requests
|
580
|
+
|
581
|
+
Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
|
582
|
+
and `client.delete` methods. Pass the required token explicitly:
|
583
|
+
|
584
|
+
```ruby
|
585
|
+
client.post('ref-data/isin', isin: ['US0378331005'], token: 'secret_token') # [{'exchange' => 'NAS', ..., 'symbol' => 'AAPL'}, {'exchange' => 'ETR', ..., 'symbol' => 'APC-GY']
|
586
|
+
```
|
587
|
+
|
372
588
|
## Configuration
|
373
589
|
|
374
590
|
You can configure client options globally or directly with a `IEX::Api::Client` instance.
|
375
591
|
|
376
592
|
```ruby
|
377
|
-
IEX::Api
|
593
|
+
IEX::Api.configure do |config|
|
378
594
|
config.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
|
379
595
|
config.endpoint = 'https://sandbox.iexapis.com/v1' # use sandbox environment
|
380
596
|
end
|
@@ -383,7 +599,7 @@ end
|
|
383
599
|
```ruby
|
384
600
|
client = IEX::Api::Client.new(
|
385
601
|
publishable_token: ENV['IEX_API_PUBLISHABLE_TOKEN'],
|
386
|
-
endpoint: 'https://
|
602
|
+
endpoint: 'https://cloud.iexapis.com/v1'
|
387
603
|
)
|
388
604
|
```
|
389
605
|
|
@@ -395,11 +611,44 @@ user_agent | User-agent, defaults to _IEX Ruby Client/version_.
|
|
395
611
|
proxy | Optional HTTP proxy.
|
396
612
|
ca_path | Optional SSL certificates path.
|
397
613
|
ca_file | Optional SSL certificates file.
|
398
|
-
logger | Optional `Logger` instance
|
614
|
+
logger | Optional `Logger` instance or logger configuration to log HTTP requests.
|
399
615
|
timeout | Optional open/read timeout in seconds.
|
400
616
|
open_timeout | Optional connection open timeout in seconds.
|
401
617
|
publishable_token | IEX Cloud API publishable token.
|
402
618
|
endpoint | Defaults to `https://cloud.iexapis.com/v1`.
|
619
|
+
referer | Optional string for HTTP `Referer` header, enables token domain management.
|
620
|
+
|
621
|
+
### Logging
|
622
|
+
|
623
|
+
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).
|
624
|
+
|
625
|
+
```ruby
|
626
|
+
logger_instance = Logger.new(STDOUT)
|
627
|
+
|
628
|
+
IEX::Api.configure do |config|
|
629
|
+
config.logger.instance = logger_instance
|
630
|
+
config.logger.options = { bodies: true }
|
631
|
+
config.logger.proc = proc { |logger| logger.filter(/T?[sp]k_\w+/i, '[REMOVED]') }
|
632
|
+
end
|
633
|
+
# or
|
634
|
+
IEX::Api.logger do |logger|
|
635
|
+
logger.instance = logger_instance
|
636
|
+
logger.options = …
|
637
|
+
logger.proc = …
|
638
|
+
end
|
639
|
+
# or
|
640
|
+
IEX::Api.logger = logger_instance
|
641
|
+
# or
|
642
|
+
IEX::Api::Client.new(logger: logger_instance)
|
643
|
+
```
|
644
|
+
|
645
|
+
## Sandbox Environment
|
646
|
+
|
647
|
+
IEX recommends you use a sandbox token and endpoint for testing.
|
648
|
+
|
649
|
+
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.
|
650
|
+
|
651
|
+
See [IEX sandbox environment](https://intercom.help/iexcloud/en/articles/2915433-testing-with-the-iex-cloud-sandbox) for more information.
|
403
652
|
|
404
653
|
## Errors
|
405
654
|
|