iex-ruby-client 1.3.0 → 1.6.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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +21 -0
- data/README.md +202 -16
- data/RELEASING.md +3 -3
- data/UPGRADING.md +8 -0
- data/iex-ruby-client.gemspec +1 -1
- data/lib/iex/api/client.rb +5 -0
- data/lib/iex/api.rb +5 -0
- data/lib/iex/endpoints/balance_sheet.rb +13 -0
- data/lib/iex/endpoints/cash_flow.rb +13 -0
- data/lib/iex/endpoints/fx.rb +13 -0
- data/lib/iex/endpoints/historial_prices.rb +30 -0
- data/lib/iex/endpoints/key_stat.rb +14 -0
- data/lib/iex/endpoints/ref_data.rb +5 -0
- data/lib/iex/errors/invalid_symbols_list.rb +14 -0
- data/lib/iex/errors/stat_not_found_error.rb +13 -0
- data/lib/iex/errors.rb +3 -1
- data/lib/iex/resources/advanced_stats.rb +43 -1
- data/lib/iex/resources/balance_sheet.rb +60 -0
- data/lib/iex/resources/cash_flow.rb +43 -0
- data/lib/iex/resources/currency_rate.rb +9 -0
- data/lib/iex/resources/historical_prices.rb +31 -0
- data/lib/iex/resources/income.rb +2 -0
- data/lib/iex/resources/news.rb +3 -0
- data/lib/iex/resources/resource.rb +17 -1
- data/lib/iex/resources.rb +4 -0
- data/lib/iex/version.rb +1 -1
- data/lib/iex-ruby-client.rb +1 -1
- data/script/console +9 -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/fx/invalid.yml +83 -0
- data/spec/fixtures/iex/fx/latest.yml +85 -0
- data/spec/fixtures/iex/fx/latest_one_symbol.yml +85 -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/key_stat/individual.yml +60 -0
- data/spec/fixtures/iex/key_stat/invalid_stat.yml +60 -0
- data/spec/fixtures/iex/key_stat/invalid_symbol.yml +50 -0
- data/spec/fixtures/iex/ref-data/exchange_symbols.yml +1926 -0
- data/spec/iex/endpoints/advanced_stats_spec.rb +56 -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/fx_spec.rb +48 -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_stat_spec.rb +43 -0
- data/spec/iex/endpoints/news_spec.rb +3 -0
- data/spec/iex/endpoints/ref_data_spec.rb +44 -9
- data/spec/iex/resources/resource_spec.rb +36 -0
- metadata +68 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 842d8fd485aebd159c318088ca1137348555a4a2106e4e4089da3e13ecc596eb
|
4
|
+
data.tar.gz: dc2046dd1efbd5c0593134fa99daf5a280f62c629c2779d785f5f34f41896c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 543f9a5bea937226e974b430654c53d4fab1f4cbb79d025784888f6a4924aeb2c59bcceb2214257a78544274c217f555594cc100a9820dae2b8f90d72ef9b1ae
|
7
|
+
data.tar.gz: 205d65bf85cfd152e4cddb8f6344658cea65a12201aceba42a43a52a524efcbf02e9695ddfa543c99b5fc90f402b096e490fe6341697fbb07e7de5a5a7961c72
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
### 1.6.0 (2021/10/17)
|
2
|
+
* [#110](https://github.com/dblock/iex-ruby-client/pull/110): Drop `money_helper` dependency and utilize `money` gem directly - [@agrberg](https://github.com/agrberg).
|
3
|
+
|
4
|
+
### 1.5.0 (2021/08/15)
|
5
|
+
* [#105](https://github.com/dblock/iex-ruby-client/pull/105): Added support for fetching latest foreign exchange rates - [@mathu97](https://github.com/mathu97).
|
6
|
+
* [#106](https://github.com/dblock/iex-ruby-client/pull/106): Added support for fetching a single key stat with `key_stat(symbol, stat)` endpoint - [@agrberg](https://github.com/agrberg).
|
7
|
+
* [#107](https://github.com/dblock/iex-ruby-client/pull/107): Added `./script/console` for ease of local development - [@agrberg](https://github.com/agrberg).
|
8
|
+
|
9
|
+
### 1.4.1 (2021/05/15)
|
10
|
+
* [#103](https://github.com/dblock/iex-ruby-client/pull/103): Added support for fetching symbols for an exchange - [@mathu97](https://github.com/mathu97).
|
11
|
+
* [#99](https://github.com/dblock/iex-ruby-client/pull/99): Added `image` and `paywalled` to news - [@reddavis](https://github.com/reddavis).
|
12
|
+
* [#100](https://github.com/dblock/iex-ruby-client/pull/100): Added `language` to news - [@reddavis](https://github.com/reddavis).
|
13
|
+
|
14
|
+
### 1.4.0 (2020/11/19)
|
15
|
+
* [#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).
|
16
|
+
* [#91](https://github.com/dblock/iex-ruby-client/pull/91): Added support for Balance Sheet API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
17
|
+
* [#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).
|
18
|
+
* [#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).
|
19
|
+
* [#94](https://github.com/dblock/iex-ruby-client/pull/94): Added `historical_prices` API endpoint - [@tylerhaugen-stanley](https://github.com/tylerhaugen-stanley).
|
20
|
+
* [#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).
|
21
|
+
|
1
22
|
### 1.3.0 (2020/10/31)
|
2
23
|
|
3
24
|
* [#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).
|
data/README.md
CHANGED
@@ -15,19 +15,25 @@ 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)
|
29
33
|
- [ISIN Mapping](#isin-mapping)
|
30
34
|
- [Get Symbols](#get-symbols)
|
35
|
+
- [Get Symbols for an Exchange](#get-symbols-for-an-exchange)
|
36
|
+
- [Get Latest Foreign Exchange Rates](#get-latest-foreign-exchange-rates)
|
31
37
|
- [Get List](#get-list)
|
32
38
|
- [Other Requests](#other-requests)
|
33
39
|
- [Configuration](#configuration)
|
@@ -130,6 +136,60 @@ market['SPY'].high #
|
|
130
136
|
market['SPY'].low #
|
131
137
|
```
|
132
138
|
|
139
|
+
### Get Historical Prices
|
140
|
+
|
141
|
+
Fetches a list of historical prices.
|
142
|
+
|
143
|
+
There are currently a few limitations of this endpoint compared to the official IEX one.
|
144
|
+
|
145
|
+
Options for `range` include:
|
146
|
+
`max, ytd, 5y, 2y, 1y, 6m, 3m, 1m, 5d, date`
|
147
|
+
|
148
|
+
NOTE: If you use the `date` value for the `range` parameter:
|
149
|
+
|
150
|
+
- The options _must_ include a date entry, `{date: ...}`
|
151
|
+
- The date value _must_ be either a Date object, or a string formatted as `YYYYMMDD`. Anything else will result in an `IEX::Errors::ClientError`.
|
152
|
+
- The options _must_ include `chartByDay: 'true'` or an `ArgumentError` will be raised.
|
153
|
+
- See below for examples.
|
154
|
+
|
155
|
+
`Query params` supported include:
|
156
|
+
`chartByDay`
|
157
|
+
|
158
|
+
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.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
historical_prices = client.historical_prices('MSFT') # One month of data
|
162
|
+
historical_prices = client.historical_prices('MSFT', {range: 'max'}) # All data up to 15 years
|
163
|
+
historical_prices = client.historical_prices('MSFT', {range: 'ytd'}) # Year to date data
|
164
|
+
historical_prices = client.historical_prices('MSFT', {range: '5y'}) # 5 years of data
|
165
|
+
historical_prices = client.historical_prices('MSFT', {range: '6m'}) # 6 months of data
|
166
|
+
historical_prices = client.historical_prices('MSFT', {range: '5d'}) # 5 days of data
|
167
|
+
historical_prices = client.historical_prices('MSFT', {range: 'date', date: '20200930', chartByDay: 'true'}) # One day of data
|
168
|
+
historical_prices = client.historical_prices('MSFT', {range: 'date', date: Date.parse('2020-09-30'), chartByDay: 'true'}) # One day of data
|
169
|
+
...
|
170
|
+
```
|
171
|
+
|
172
|
+
Once you have the data over the preferred time period, you can access the following fields
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
historical_prices = client.historical_prices('MSFT') # One month of data
|
176
|
+
|
177
|
+
historical_price = historical_prices.first
|
178
|
+
historical_price.date # 2020-10-07
|
179
|
+
historical_price.open #207.06
|
180
|
+
historical_price.open_dollar # '$207.06'
|
181
|
+
historical_price.close # 209.83
|
182
|
+
historical_price.close_dollar # '$209.83'
|
183
|
+
historical_price.high # 210.11
|
184
|
+
historical_price.high_dollar # '$210.11'
|
185
|
+
historical_price.low # 206.72
|
186
|
+
historical_price.low_dollar # '$206.72'
|
187
|
+
historical_price.volume # 25681054
|
188
|
+
...
|
189
|
+
```
|
190
|
+
|
191
|
+
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.
|
192
|
+
|
133
193
|
### Get Company Information
|
134
194
|
|
135
195
|
Fetches company information for a symbol.
|
@@ -263,8 +323,58 @@ key_stats.pe_ratio # 29.47
|
|
263
323
|
key_stats.beta # 1.4135449089973444
|
264
324
|
```
|
265
325
|
|
326
|
+
You can also fetch a single stat for a symbol. **Note** that IEX uses `lowerCamelCase` for the names of the stats.
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
client.key_stat('VTI', 'dividendYield') # 0.01271760965303361
|
330
|
+
```
|
331
|
+
|
266
332
|
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.
|
267
333
|
|
334
|
+
### Get Advanced Stats
|
335
|
+
|
336
|
+
Fetches company's advanced stats for a symbol, this will include all key stats as well.
|
337
|
+
|
338
|
+
```ruby
|
339
|
+
advanced_stats = client.advanced_stats('MSFT')
|
340
|
+
|
341
|
+
advanced_stats.total_cash # 66301000000
|
342
|
+
advanced_stats.total_cash_dollars # "$66,301,000,000"
|
343
|
+
advanced_stats.current_debt # 20748000000
|
344
|
+
advanced_stats.current_debt_dollars # "$2,074,8000,000"
|
345
|
+
advanced_stats.revenue # 265809000000
|
346
|
+
advanced_stats.revenue_dollars # "$265,809,000,000"
|
347
|
+
advanced_stats.gross_profit # 101983000000
|
348
|
+
advanced_stats.gross_profit_dollar # "$101,983,000,000"
|
349
|
+
advanced_stats.total_revenue # 265809000000
|
350
|
+
advanced_stats.total_revenue_dollar # "$265,809,000,000"
|
351
|
+
advanced_stats.ebitda # 80342000000
|
352
|
+
advanced_stats.ebitda_dollar # "$80,342,000,000"
|
353
|
+
advanced_stats.revenue_per_share # 0.02
|
354
|
+
advanced_stats.revenue_per_share_dollar # "$0.02"
|
355
|
+
advanced_stats.revenue_per_employee # 2013704.55
|
356
|
+
advanced_stats.revenue_per_employee_dollar # "$2,013,704.55"
|
357
|
+
advanced_stats.debt_to_equity # 1.07
|
358
|
+
advanced_stats.profit_margin # 22.396157
|
359
|
+
advanced_stats.enterprise_value # 1022460690000
|
360
|
+
advanced_stats.enterprise_value_dollar # "$1,022,460,690,000"
|
361
|
+
advanced_stats.enterprise_value_to_revenue # 3.85
|
362
|
+
advanced_stats.price_to_sales # 3.49
|
363
|
+
advanced_stats.price_to_sales_dollar # "$3.49"
|
364
|
+
advanced_stats.price_to_book # 8.805916432564608
|
365
|
+
advanced_stats.forward_pe_ratio # 18.14
|
366
|
+
advanced_stats.pe_high # 22.61
|
367
|
+
advanced_stats.pe_low # 11.98
|
368
|
+
advanced_stats.peg_ratio # 2.19
|
369
|
+
advanced_stats.week_52_high_date # "2019-11-19"
|
370
|
+
advanced_stats.week_52_low_date # "2019-01-03
|
371
|
+
advanced_stats.beta # 1.4661365583766115
|
372
|
+
advanced_stats.put_call_ratio # 0.6780362005229779
|
373
|
+
...
|
374
|
+
```
|
375
|
+
|
376
|
+
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.
|
377
|
+
|
268
378
|
### Get Dividends
|
269
379
|
|
270
380
|
Fetches dividends for a symbol.
|
@@ -304,12 +414,16 @@ See [#earnings](https://iexcloud.io/docs/api/#earnings) for detailed documentati
|
|
304
414
|
|
305
415
|
### Get Income Statement
|
306
416
|
|
307
|
-
Fetches income
|
417
|
+
Fetches income statements for a symbol.
|
308
418
|
|
309
419
|
```ruby
|
310
|
-
|
420
|
+
income_statements = client.income('MSFT')
|
311
421
|
|
422
|
+
# Multiple income statements are returned with 1 API call.
|
423
|
+
income = income_statements.first
|
312
424
|
income.report_date # '2019-03-31'
|
425
|
+
income.fiscal_date # '2019-03-31'
|
426
|
+
income.currency # 'USD'
|
313
427
|
income.total_revenue # 30_505_000_000
|
314
428
|
income.total_revenue_dollar # '$30,505,000,000'
|
315
429
|
income.cost_of_revenue # 10_170_000_000
|
@@ -321,6 +435,48 @@ income.gross_profit_dollar # '$20,335,000,000'
|
|
321
435
|
|
322
436
|
See [#income-statement](https://iexcloud.io/docs/api/#income-statement) for detailed documentation or [income.rb](lib/iex/resources/income.rb) for returned fields.
|
323
437
|
|
438
|
+
### Get Balance Sheet
|
439
|
+
|
440
|
+
Fetches balance sheets for a symbol.
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
balance_sheets = client.balance_sheet('MSFT')
|
444
|
+
|
445
|
+
# Multiple balance sheets are returned with 1 API call.
|
446
|
+
balance_sheet = balance_sheets.first
|
447
|
+
balance_sheet.report_date # '2017-03-31'
|
448
|
+
balance_sheet.fiscal_date # '2017-03-31'
|
449
|
+
balance_sheet.currency # 'USD'
|
450
|
+
balance_sheet.current_cash # 25_913_000_000
|
451
|
+
balance_sheet.current_cash_dollar # '$25,913,000,000'
|
452
|
+
balance_sheet.short_term_investments # 40_388_000_000
|
453
|
+
balance_sheet.short_term_investments_dollar # '$40,388,000,000'
|
454
|
+
...
|
455
|
+
```
|
456
|
+
|
457
|
+
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.
|
458
|
+
|
459
|
+
### Get Cash Flow Statement
|
460
|
+
|
461
|
+
Fetches cash flow statements for a symbol.
|
462
|
+
|
463
|
+
```ruby
|
464
|
+
cash_flow_statements = client.cash_flow('MSFT')
|
465
|
+
|
466
|
+
# Multiple cash flow statements are returned with 1 API call.
|
467
|
+
cash_flow = cash_flow_statements.first
|
468
|
+
cash_flow.report_date # '2018-09-30'
|
469
|
+
cash_flow.fiscal_date # '2018-09-30'
|
470
|
+
cash_flow.currency # 'USD'
|
471
|
+
cash_flow.net_income # 14_125_000_000
|
472
|
+
cash_flow.net_income_dollar # '$14,125,000,000'
|
473
|
+
cash_flow.depreciation # 2_754_000_000
|
474
|
+
cash_flow.depreciation_dollar # '$2,754,000,000'
|
475
|
+
...
|
476
|
+
```
|
477
|
+
|
478
|
+
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.
|
479
|
+
|
324
480
|
### Get Sector Performance
|
325
481
|
|
326
482
|
Fetches latest sector's performance.
|
@@ -396,7 +552,6 @@ The API also lets you convert multiple ISINs to IEX Cloud symbols.
|
|
396
552
|
symbols = client.ref_data_isin(['US0378331005', 'US0378331006'])
|
397
553
|
```
|
398
554
|
|
399
|
-
|
400
555
|
You can use `mapped: true` option to receive symbols grouped by their ISINs.
|
401
556
|
|
402
557
|
```ruby
|
@@ -407,7 +562,7 @@ See [#ISIN Mapping](https://iexcloud.io/docs/api/#isin-mapping) for detailed doc
|
|
407
562
|
|
408
563
|
### Get Symbols
|
409
564
|
|
410
|
-
Returns an array of symbols
|
565
|
+
Returns an array of symbols.
|
411
566
|
|
412
567
|
```ruby
|
413
568
|
symbols = client.ref_data_symbols()
|
@@ -421,6 +576,37 @@ symbol.symbol # A
|
|
421
576
|
|
422
577
|
See [#symbols](https://iexcloud.io/docs/api/#symbols) for detailed documentation or [symbols.rb](lib/iex/resources/symbols.rb) for returned fields.
|
423
578
|
|
579
|
+
### Get Symbols for an Exchange
|
580
|
+
|
581
|
+
Returns an array of symbols for a given exchange.
|
582
|
+
|
583
|
+
```ruby
|
584
|
+
symbols = client.ref_data_symbols_for_exchange('TSX')
|
585
|
+
|
586
|
+
symbol = symbols.first
|
587
|
+
symbol.exchange # TSX
|
588
|
+
symbol.iex_id # IEX_4656374258322D52
|
589
|
+
symbol.region # CA
|
590
|
+
symbol.symbol # A-CV
|
591
|
+
```
|
592
|
+
|
593
|
+
See [#international-symbols](https://iexcloud.io/docs/api/#international-symbols) for returned fields.
|
594
|
+
|
595
|
+
### Get Latest Foreign Exchange Rates
|
596
|
+
|
597
|
+
Returns an array of foreign exchange rates for a given list of symbols.
|
598
|
+
|
599
|
+
```ruby
|
600
|
+
rates = client.fx_latest(['USDCAD', 'USDGBP', 'USDJPY'])
|
601
|
+
|
602
|
+
rate = rates.first
|
603
|
+
rate.symbol # USDCAD
|
604
|
+
rate.rate # 1.25674
|
605
|
+
rate.timestamp # <Date: 2021-07-23 ((2459419j,0s,0n),+0s,2299161j)>
|
606
|
+
```
|
607
|
+
|
608
|
+
See [#latest-currency-rates](https://iexcloud.io/docs/api/#latest-currency-rates) for returned fields.
|
609
|
+
|
424
610
|
### Get List
|
425
611
|
|
426
612
|
Returns an array of quotes for the top 10 symbols in a specified list.
|
@@ -460,18 +646,18 @@ client = IEX::Api::Client.new(
|
|
460
646
|
|
461
647
|
The following settings are supported.
|
462
648
|
|
463
|
-
setting
|
464
|
-
|
465
|
-
user_agent
|
466
|
-
proxy
|
467
|
-
ca_path
|
468
|
-
ca_file
|
469
|
-
logger
|
470
|
-
timeout
|
471
|
-
open_timeout
|
472
|
-
publishable_token
|
473
|
-
endpoint
|
474
|
-
referer
|
649
|
+
| setting | description |
|
650
|
+
| ----------------- | --------------------------------------------------------------------------- |
|
651
|
+
| user_agent | User-agent, defaults to _IEX Ruby Client/version_. |
|
652
|
+
| proxy | Optional HTTP proxy. |
|
653
|
+
| ca_path | Optional SSL certificates path. |
|
654
|
+
| ca_file | Optional SSL certificates file. |
|
655
|
+
| logger | Optional `Logger` instance or logger configuration to log HTTP requests. |
|
656
|
+
| timeout | Optional open/read timeout in seconds. |
|
657
|
+
| open_timeout | Optional connection open timeout in seconds. |
|
658
|
+
| publishable_token | IEX Cloud API publishable token. |
|
659
|
+
| endpoint | Defaults to `https://cloud.iexapis.com/v1`. |
|
660
|
+
| referer | Optional string for HTTP `Referer` header, enables token domain management. |
|
475
661
|
|
476
662
|
### Logging
|
477
663
|
|
data/RELEASING.md
CHANGED
@@ -11,15 +11,15 @@ bundle install
|
|
11
11
|
rake
|
12
12
|
```
|
13
13
|
|
14
|
-
Check that the last build succeeded in [Travis CI](https://travis-ci.
|
14
|
+
Check that the last build succeeded in [Travis CI](https://travis-ci.com/github/dblock/iex-ruby-client) for all supported platforms.
|
15
15
|
|
16
16
|
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
|
17
17
|
|
18
18
|
```
|
19
|
-
### 0.2.2 (
|
19
|
+
### 0.2.2 (2015/10/07)
|
20
20
|
```
|
21
21
|
|
22
|
-
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
22
|
+
Remove the line with "* Your contribution here.", since there will be no more contributions to this release.
|
23
23
|
|
24
24
|
Commit your changes.
|
25
25
|
|
data/UPGRADING.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Upgrading iex-ruby-client
|
2
2
|
=========================
|
3
3
|
|
4
|
+
### Upgrading to >= 1.6.0
|
5
|
+
|
6
|
+
[#110](https://github.com/dblock/iex-ruby-client/pull/110) drops the dependency on `money_helper` in favor of using the `money` library directly.
|
7
|
+
|
8
|
+
Previously the `money_helper` library set `Money.locale_backend = :currency` globally. The default is `I18n` which looks up the thousands separator and decimal marker. Depending on your project you may need to set this value if you use `Money#format` without the `thousands_separator` or `decimal_mark` options. You are less likely to require this in a Rails project.
|
9
|
+
|
10
|
+
This represents a change in the `money` library's method of handling defaults and is similar to the deprecation warning the library provides until you set `Money.rounding_mode=`.
|
11
|
+
|
4
12
|
### Upgrading to >= 1.0.0
|
5
13
|
|
6
14
|
On June 1, 2019, IEX API has been sunset for all non-IEX data. IEX Cloud, a non-Exchange platform, continues to provide access to third-party data sources and requires a token. When upgrading to 1.0.0, create an account and get a `publishable token` from [IEX Cloud Console](https://iexcloud.io).
|
data/iex-ruby-client.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency 'faraday', '>= 0.17'
|
20
20
|
s.add_dependency 'faraday_middleware'
|
21
21
|
s.add_dependency 'hashie'
|
22
|
-
s.add_dependency '
|
22
|
+
s.add_dependency 'money', '~> 6.0'
|
23
23
|
s.add_development_dependency 'rake', '~> 10'
|
24
24
|
s.add_development_dependency 'rspec'
|
25
25
|
s.add_development_dependency 'rubocop', '0.72.0'
|
data/lib/iex/api/client.rb
CHANGED
@@ -5,12 +5,17 @@ module IEX
|
|
5
5
|
|
6
6
|
class Client
|
7
7
|
include Endpoints::AdvancedStats
|
8
|
+
include Endpoints::BalanceSheet
|
9
|
+
include Endpoints::CashFlow
|
8
10
|
include Endpoints::Chart
|
9
11
|
include Endpoints::Company
|
10
12
|
include Endpoints::Crypto
|
11
13
|
include Endpoints::Dividends
|
12
14
|
include Endpoints::Earnings
|
15
|
+
include Endpoints::FX
|
16
|
+
include Endpoints::HistoricalPrices
|
13
17
|
include Endpoints::Income
|
18
|
+
include Endpoints::KeyStat
|
14
19
|
include Endpoints::KeyStats
|
15
20
|
include Endpoints::LargestTrades
|
16
21
|
include Endpoints::Logo
|
data/lib/iex/api.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require_relative 'endpoints/advanced_stats'
|
2
|
+
require_relative 'endpoints/balance_sheet'
|
3
|
+
require_relative 'endpoints/cash_flow'
|
2
4
|
require_relative 'endpoints/chart'
|
3
5
|
require_relative 'endpoints/company'
|
4
6
|
require_relative 'endpoints/dividends'
|
5
7
|
require_relative 'endpoints/earnings'
|
8
|
+
require_relative 'endpoints/fx'
|
9
|
+
require_relative 'endpoints/historial_prices'
|
6
10
|
require_relative 'endpoints/income'
|
7
11
|
require_relative 'endpoints/largest_trades'
|
8
12
|
require_relative 'endpoints/logo'
|
13
|
+
require_relative 'endpoints/key_stat'
|
9
14
|
require_relative 'endpoints/key_stats'
|
10
15
|
require_relative 'endpoints/news'
|
11
16
|
require_relative 'endpoints/ohlc'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module BalanceSheet
|
4
|
+
def balance_sheet(symbol, options = {})
|
5
|
+
(get("stock/#{symbol}/balance-sheet", { token: publishable_token }.merge(options))['balancesheet'] || []).map do |data|
|
6
|
+
IEX::Resources::BalanceSheet.new(data)
|
7
|
+
end
|
8
|
+
rescue Faraday::ResourceNotFound => e
|
9
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module CashFlow
|
4
|
+
def cash_flow(symbol, options = {})
|
5
|
+
(get("stock/#{symbol}/cash-flow", { token: publishable_token }.merge(options))['cashflow'] || []).map do |data|
|
6
|
+
IEX::Resources::CashFlow.new(data)
|
7
|
+
end
|
8
|
+
rescue Faraday::ResourceNotFound => e
|
9
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module FX
|
4
|
+
def fx_latest(symbols, options = {})
|
5
|
+
symbols = Array(symbols)
|
6
|
+
response = get('fx/latest', { token: publishable_token, symbols: symbols.join(',') }.merge(options))
|
7
|
+
response.map { |row| IEX::Resources::CurrencyRate.new(row) }
|
8
|
+
rescue Faraday::ResourceNotFound => e
|
9
|
+
raise IEX::Errors::InvalidSymbolsList.new(symbols, e.response[:body])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module HistoricalPrices
|
4
|
+
def historical_prices(symbol, options = {})
|
5
|
+
if options[:range] == 'date'
|
6
|
+
raise ArgumentError unless options[:date]
|
7
|
+
raise ArgumentError unless options[:chartByDay]
|
8
|
+
end
|
9
|
+
|
10
|
+
options = options.dup
|
11
|
+
# Historical prices IEX endpoint expects dates passed in a specific format - YYYYMMDD
|
12
|
+
options[:date] = options[:date].strftime('%Y%m%d') if options[:date].is_a?(Date)
|
13
|
+
|
14
|
+
path = "stock/#{symbol}/chart"
|
15
|
+
path += "/#{options[:range]}" if options.key?(:range)
|
16
|
+
path += "/#{options[:date]}" if options[:range] == 'date'
|
17
|
+
|
18
|
+
# We only want options to include query params at this point, remove :range and :date
|
19
|
+
options.delete(:range)
|
20
|
+
options.delete(:date)
|
21
|
+
|
22
|
+
(get(path, { token: publishable_token }.merge(options)) || []).map do |data|
|
23
|
+
IEX::Resources::HistorialPrices.new(data)
|
24
|
+
end
|
25
|
+
rescue Faraday::ResourceNotFound => e
|
26
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module KeyStat
|
4
|
+
def key_stat(symbol, stat, options = {})
|
5
|
+
result = get("stock/#{symbol}/stats/#{stat}", { token: publishable_token }.merge(options))
|
6
|
+
raise IEX::Errors::StatNotFoundError.new(stat, result) if result.is_a?(Hash)
|
7
|
+
|
8
|
+
result
|
9
|
+
rescue Faraday::ResourceNotFound => e
|
10
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -17,6 +17,11 @@ module IEX
|
|
17
17
|
response = get('ref-data/symbols', { token: publishable_token }.merge(options))
|
18
18
|
response.map { |row| IEX::Resources::Symbols.new(row) }
|
19
19
|
end
|
20
|
+
|
21
|
+
def ref_data_symbols_for_exchange(exchange, options = {})
|
22
|
+
response = get("ref-data/exchange/#{exchange}/symbols", { token: publishable_token }.merge(options))
|
23
|
+
response.map { |row| IEX::Resources::Symbols.new(row) }
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IEX
|
2
|
+
module Errors
|
3
|
+
class InvalidSymbolsList < StandardError
|
4
|
+
attr_reader :symbols
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(symbols, response)
|
8
|
+
@response = response
|
9
|
+
@symbols = symbols
|
10
|
+
super "Invalid symbol list: #{symbols.join(',')}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/iex/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
require_relative 'errors/symbol_not_found_error'
|
2
1
|
require_relative 'errors/client_error'
|
2
|
+
require_relative 'errors/invalid_symbols_list'
|
3
3
|
require_relative 'errors/permission_denied_error'
|
4
|
+
require_relative 'errors/stat_not_found_error'
|
5
|
+
require_relative 'errors/symbol_not_found_error'
|
@@ -28,11 +28,53 @@ module IEX
|
|
28
28
|
property 'forward_pe_ratio', from: 'forwardPERatio'
|
29
29
|
property 'pe_high', from: 'peHigh'
|
30
30
|
property 'pe_low', from: 'peLow'
|
31
|
-
property 'avg_30_volume', from: 'avg30Volume'
|
32
31
|
property 'peg_ratio', from: 'pegRatio'
|
33
32
|
property 'week_52_high_date', from: 'week52highDate'
|
34
33
|
property 'week_52_low_date', from: 'week52lowDate'
|
35
34
|
property 'beta'
|
35
|
+
property 'put_call_ratio', from: 'putCallRatio'
|
36
|
+
property 'company_name', from: 'companyName'
|
37
|
+
property 'market_cap', from: 'marketcap'
|
38
|
+
property 'market_cap_dollar', from: 'marketcap', with: ->(v) { Resource.to_dollar(amount: v) }
|
39
|
+
property 'week_52_high', from: 'week52high'
|
40
|
+
property 'week_52_high_dollar', from: 'week52high', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
41
|
+
property 'week_52_low', from: 'week52low'
|
42
|
+
property 'week_52_low_dollar', from: 'week52low', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
43
|
+
property 'week_52_change', from: 'week52change'
|
44
|
+
property 'week_52_change_dollar', from: 'week52change', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
45
|
+
property 'dividend_yield', from: 'dividendYield'
|
46
|
+
property 'ex_dividend_date', from: 'exDividendDate'
|
47
|
+
property 'shares_outstanding', from: 'sharesOutstanding'
|
48
|
+
property 'float'
|
49
|
+
property 'ttm_eps', from: 'ttmEPS'
|
50
|
+
property 'day_200_moving_avg', from: 'day200MovingAvg'
|
51
|
+
property 'day_50_moving_avg', from: 'day50MovingAvg'
|
52
|
+
property 'year_5_change_percent', from: 'year5ChangePercent'
|
53
|
+
property 'year_5_change_percent_s', from: 'year5ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
54
|
+
property 'year_2_change_percent', from: 'year2ChangePercent'
|
55
|
+
property 'year_2_change_percent_s', from: 'year2ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
56
|
+
property 'year_1_change_percent', from: 'year1ChangePercent'
|
57
|
+
property 'year_1_change_percent_s', from: 'year1ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
58
|
+
property 'ytd_change_percent', from: 'ytdChangePercent'
|
59
|
+
property 'ytd_change_percent_s', from: 'ytdChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
60
|
+
property 'month_6_change_percent', from: 'month6ChangePercent'
|
61
|
+
property 'month_6_change_percent_s', from: 'month6ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
62
|
+
property 'month_3_change_percent', from: 'month3ChangePercent'
|
63
|
+
property 'month_3_change_percent_s', from: 'month3ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
64
|
+
property 'month_1_change_percent', from: 'month1ChangePercent'
|
65
|
+
property 'month_1_change_percent_s', from: 'month1ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
66
|
+
property 'day_5_change_percent', from: 'day5ChangePercent'
|
67
|
+
property 'day_5_change_percent_s', from: 'day5ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
68
|
+
property 'employees'
|
69
|
+
property 'avg_10_volume', from: 'avg10Volume'
|
70
|
+
property 'avg_30_volume', from: 'avg30Volume'
|
71
|
+
property 'ttm_dividend_rate', from: 'ttmDividendRate'
|
72
|
+
property 'max_change_percent', from: 'maxChangePercent'
|
73
|
+
property 'day_30_change_percent', from: 'day30ChangePercent'
|
74
|
+
property 'day_30_change_percent_s', from: 'day30ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
75
|
+
property 'next_dividend_date', from: 'nextDividendDate'
|
76
|
+
property 'next_earnings_date', from: 'nextEarningsDate'
|
77
|
+
property 'pe_ratio', from: 'peRatio'
|
36
78
|
|
37
79
|
def initialize(data = {})
|
38
80
|
super
|