iex-ruby-client 1.4.1 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd85bc6a798e1c37eb803200aed631db1d1ff3fb6090714cceb01bb5d12c6c9f
4
- data.tar.gz: 0e483fa9cf10d511714de9563034309c463278931628d077c580a33bbdbf32d0
3
+ metadata.gz: ab2cf9c9b5a300629e51b810e4f556ba5d3113a226faa0b2a9293be2939cdb24
4
+ data.tar.gz: cbab6366388a36eddac8a9e55c4eb4e9e5254cd883f0fe135bdb63d7e359f137
5
5
  SHA512:
6
- metadata.gz: fe22b477b65f4ade43d1c0f9b44c07dc99664744f4d8fc0081aec8b29053e54c06d3c290e47a27a37c8452c81557f5d2c371d39e936ecd19d5ac0dbd68cd2124
7
- data.tar.gz: 14b3664d77a34096534dc9c46fadfa8f7056c7d8bfe82bd5264ee390817363619ccc7de809e1bd8c80e9d7d5cce04e8e5d33b1f8ab8d88f86cf81d1f40e59027
6
+ metadata.gz: 3a08d8c90fdc3a1ac756321711a76d2b65f01d8c5935b160125fcb41751452da65588d5b29ab1f3f000026171c61ceafdb9ce270af62c342c701512e83a706e0
7
+ data.tar.gz: b6cbac7f892c7e1ce514cb5906180d60d73b66b5a80edb777eb7ac754fad309b9ce8745b08e8ce1c5f4cc27c109f84b558025f70bc53b754c1ef2e0ac4ccd3e4
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  .DS_Store
5
5
  .bundle
6
6
  .idea
7
+ .irbrc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 1.5.0 (2021/08/15)
2
+ * [#105](https://github.com/dblock/iex-ruby-client/pull/105): Added support for fetching latest foreign exchange rates - [@mathu97](https://github.com/mathu97).
3
+ * [#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).
4
+ * [#107](https://github.com/dblock/iex-ruby-client/pull/107): Added `./script/console` for ease of local development - [@agrberg](https://github.com/agrberg).
5
+
1
6
  ### 1.4.1 (2021/05/15)
2
7
  * [#103](https://github.com/dblock/iex-ruby-client/pull/103): Added support for fetching symbols for an exchange - [@mathu97](https://github.com/mathu97).
3
8
  * [#99](https://github.com/dblock/iex-ruby-client/pull/99): Added `image` and `paywalled` to news - [@reddavis](https://github.com/reddavis).
data/README.md CHANGED
@@ -33,6 +33,7 @@ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
33
33
  - [ISIN Mapping](#isin-mapping)
34
34
  - [Get Symbols](#get-symbols)
35
35
  - [Get Symbols for an Exchange](#get-symbols-for-an-exchange)
36
+ - [Get Latest Foreign Exchange Rates](#get-latest-foreign-exchange-rates)
36
37
  - [Get List](#get-list)
37
38
  - [Other Requests](#other-requests)
38
39
  - [Configuration](#configuration)
@@ -157,23 +158,23 @@ NOTE: If you use the `date` value for the `range` parameter:
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.
158
159
 
159
160
  ```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
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
168
169
  ...
169
170
  ```
170
171
 
171
172
  Once you have the data over the preferred time period, you can access the following fields
172
173
 
173
174
  ```ruby
174
- historial_prices = client.historical_prices('MSFT') # One month of data
175
+ historical_prices = client.historical_prices('MSFT') # One month of data
175
176
 
176
- historial_price = historial_prices.first
177
+ historical_price = historical_prices.first
177
178
  historical_price.date # 2020-10-07
178
179
  historical_price.open #207.06
179
180
  historical_price.open_dollar # '$207.06'
@@ -322,6 +323,12 @@ key_stats.pe_ratio # 29.47
322
323
  key_stats.beta # 1.4135449089973444
323
324
  ```
324
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
+
325
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.
326
333
 
327
334
  ### Get Advanced Stats
@@ -555,7 +562,7 @@ See [#ISIN Mapping](https://iexcloud.io/docs/api/#isin-mapping) for detailed doc
555
562
 
556
563
  ### Get Symbols
557
564
 
558
- Returns an array of symbols
565
+ Returns an array of symbols.
559
566
 
560
567
  ```ruby
561
568
  symbols = client.ref_data_symbols()
@@ -571,7 +578,7 @@ See [#symbols](https://iexcloud.io/docs/api/#symbols) for detailed documentation
571
578
 
572
579
  ### Get Symbols for an Exchange
573
580
 
574
- Returns an array of symbols for a given exchange
581
+ Returns an array of symbols for a given exchange.
575
582
 
576
583
  ```ruby
577
584
  symbols = client.ref_data_symbols_for_exchange('TSX')
@@ -583,7 +590,22 @@ symbol.region # CA
583
590
  symbol.symbol # A-CV
584
591
  ```
585
592
 
586
- See [#international-symbols](https://iexcloud.io/docs/api/#international-symbols).
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.
587
609
 
588
610
  ### Get List
589
611
 
data/RELEASING.md CHANGED
@@ -11,7 +11,7 @@ bundle install
11
11
  rake
12
12
  ```
13
13
 
14
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/iex-ruby-client) for all supported platforms.
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
 
data/lib/iex/api.rb CHANGED
@@ -5,10 +5,12 @@ require_relative 'endpoints/chart'
5
5
  require_relative 'endpoints/company'
6
6
  require_relative 'endpoints/dividends'
7
7
  require_relative 'endpoints/earnings'
8
+ require_relative 'endpoints/fx'
8
9
  require_relative 'endpoints/historial_prices'
9
10
  require_relative 'endpoints/income'
10
11
  require_relative 'endpoints/largest_trades'
11
12
  require_relative 'endpoints/logo'
13
+ require_relative 'endpoints/key_stat'
12
14
  require_relative 'endpoints/key_stats'
13
15
  require_relative 'endpoints/news'
14
16
  require_relative 'endpoints/ohlc'
@@ -12,8 +12,10 @@ module IEX
12
12
  include Endpoints::Crypto
13
13
  include Endpoints::Dividends
14
14
  include Endpoints::Earnings
15
+ include Endpoints::FX
15
16
  include Endpoints::HistoricalPrices
16
17
  include Endpoints::Income
18
+ include Endpoints::KeyStat
17
19
  include Endpoints::KeyStats
18
20
  include Endpoints::LargestTrades
19
21
  include Endpoints::Logo
@@ -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,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
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'
@@ -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
@@ -0,0 +1,13 @@
1
+ module IEX
2
+ module Errors
3
+ class StatNotFoundError < StandardError
4
+ attr_reader :response, :stat
5
+
6
+ def initialize(stat, response)
7
+ @response = response
8
+ @stat = stat
9
+ super "Stat #{stat} Not Found"
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/iex/resources.rb CHANGED
@@ -4,6 +4,7 @@ require_relative 'resources/advanced_stats'
4
4
  require_relative 'resources/balance_sheet'
5
5
  require_relative 'resources/cash_flow'
6
6
  require_relative 'resources/chart'
7
+ require_relative 'resources/currency_rate'
7
8
  require_relative 'resources/company'
8
9
  require_relative 'resources/dividends'
9
10
  require_relative 'resources/earnings'
@@ -0,0 +1,9 @@
1
+ module IEX
2
+ module Resources
3
+ class CurrencyRate < Resource
4
+ property 'symbol'
5
+ property 'rate'
6
+ property 'timestamp', transform_with: ->(v) { Date.strptime((v.to_f / 1000).to_s, '%s') }
7
+ end
8
+ end
9
+ end
data/lib/iex/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IEX
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  end
data/script/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << './lib'
4
+
5
+ require 'dotenv/load'
6
+ require 'iex-ruby-client'
7
+ require 'irb'
8
+
9
+ IRB.start
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/fx/latest?symbols=INVALID&token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 404
19
+ message: Not Found
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 05 Apr 2019 02:59:49 GMT
25
+ Content-Type:
26
+ - text/html; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=333d7c703c954832b14c34cb8cca7b3a; Max-Age=43200; Path=/; Expires=Fri,
33
+ 05 Apr 2019 14:59:49 GMT
34
+ Content-Security-Policy:
35
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
36
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
37
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
38
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
39
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
40
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
41
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
42
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
43
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
44
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
45
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
46
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
47
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
48
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
49
+ X-Content-Security-Policy:
50
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
51
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
52
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
53
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
54
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
55
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
56
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
57
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
58
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
59
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
60
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
61
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
62
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
63
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
64
+ Frame-Options:
65
+ - SAMEORIGIN
66
+ X-Frame-Options:
67
+ - SAMEORIGIN
68
+ Strict-Transport-Security:
69
+ - max-age=15768000
70
+ Access-Control-Allow-Origin:
71
+ - "*"
72
+ Access-Control-Allow-Credentials:
73
+ - "true"
74
+ Access-Control-Allow-Methods:
75
+ - GET, OPTIONS
76
+ Access-Control-Allow-Headers:
77
+ - Origin, X-Requested-With, Content-Type, Accept
78
+ body:
79
+ encoding: ASCII-8BIT
80
+ string: Unknown symbol
81
+ http_version:
82
+ recorded_at: Fri, 05 Apr 2019 02:59:49 GMT
83
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/fx/latest?symbols=USDCAD,USDGBP,USDJPY&token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 05 Apr 2019 02:59:48 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - "6"
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=3859f7adf5e24bb0ac6a2283b1d2c588; Max-Age=43200; Path=/; Expires=Fri,
33
+ 05 Apr 2019 14:59:48 GMT
34
+ Content-Security-Policy:
35
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
36
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
37
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
38
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
39
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
40
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
41
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
42
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
43
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
44
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
45
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
46
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
47
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
48
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
49
+ X-Content-Security-Policy:
50
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
51
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
52
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
53
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
54
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
55
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
56
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
57
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
58
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
59
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
60
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
61
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
62
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
63
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
64
+ Frame-Options:
65
+ - SAMEORIGIN
66
+ X-Frame-Options:
67
+ - SAMEORIGIN
68
+ X-Content-Type-Options:
69
+ - nosniff
70
+ Strict-Transport-Security:
71
+ - max-age=15768000
72
+ Access-Control-Allow-Origin:
73
+ - "*"
74
+ Access-Control-Allow-Credentials:
75
+ - "true"
76
+ Access-Control-Allow-Methods:
77
+ - GET, OPTIONS
78
+ Access-Control-Allow-Headers:
79
+ - Origin, X-Requested-With, Content-Type, Accept
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '[{"symbol":"USDCAD","rate":1.25674,"timestamp":1627045829863,"isDerived":false},{"symbol":"USDGBP","rate":0.7262111386264443,"timestamp":1627045780863,"isDerived":false},{"symbol":"USDJPY","rate":110.426,"timestamp":1627045825365,"isDerived":false}]'
83
+ http_version:
84
+ recorded_at: Fri, 05 Apr 2019 02:59:48 GMT
85
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,85 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/fx/latest?symbols=USDCAD&token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 05 Apr 2019 02:59:48 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Content-Length:
28
+ - "6"
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - ctoken=3859f7adf5e24bb0ac6a2283b1d2c588; Max-Age=43200; Path=/; Expires=Fri,
33
+ 05 Apr 2019 14:59:48 GMT
34
+ Content-Security-Policy:
35
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
36
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
37
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
38
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
39
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
40
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
41
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
42
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
43
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
44
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
45
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
46
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
47
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
48
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
49
+ X-Content-Security-Policy:
50
+ - "default-src 'self'; child-src 'none'; object-src 'self'; style-src
51
+ 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self'
52
+ https://js.intercomcdn.com/fonts/ https://fonts.gstatic.com; frame-src 'self'
53
+ https://portal.productboard.com/ https://js.stripe.com/; img-src 'self'
54
+ data: https://*.intercomcdn.com/ https://static.intercomassets.com/ https://www.google-analytics.com
55
+ https://downloads.intercomcdn.com/; connect-src 'self' https://auth.iexcloud.io
56
+ https://api.iexcloud.io https://api.iexcloud.io https://cloud.iexapis.com
57
+ wss://iexcloud.io wss://tops.iexcloud.io wss://api.iexcloud.io wss://iexcloud.io
58
+ https://api-iam.intercom.io/messenger/ https://nexus-websocket-a.intercom.io/
59
+ https://nexus-websocket-b.intercom.io/ wss://nexus-websocket-a.intercom.io/
60
+ wss://nexus-websocket-b.intercom.io/ https://www.google-analytics.com; script-src
61
+ 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/api.js
62
+ https://www.google-analytics.com https://js.stripe.com/v3/ https://widget.intercom.io/widget/lhos563b
63
+ https://js.intercomcdn.com/ https://www.googletagmanager.com;"
64
+ Frame-Options:
65
+ - SAMEORIGIN
66
+ X-Frame-Options:
67
+ - SAMEORIGIN
68
+ X-Content-Type-Options:
69
+ - nosniff
70
+ Strict-Transport-Security:
71
+ - max-age=15768000
72
+ Access-Control-Allow-Origin:
73
+ - "*"
74
+ Access-Control-Allow-Credentials:
75
+ - "true"
76
+ Access-Control-Allow-Methods:
77
+ - GET, OPTIONS
78
+ Access-Control-Allow-Headers:
79
+ - Origin, X-Requested-With, Content-Type, Accept
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '[{"symbol":"USDCAD","rate":1.25674,"timestamp":1627045829863}]'
83
+ http_version:
84
+ recorded_at: Fri, 05 Apr 2019 02:59:48 GMT
85
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/stock/VTI/stats/ttmDividendRate?token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ Content-Type:
13
+ - application/json; charset=utf-8
14
+ User-Agent:
15
+ - IEX Ruby Client/1.4.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 12 Aug 2021 20:04:24 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Content-Length:
30
+ - '18'
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - ctoken=8df9fdfb440744638edd9bfdc8e0d27b; Max-Age=43200; Path=/; Expires=Fri,
35
+ 13 Aug 2021 08:04:24 GMT
36
+ Iexcloud-Messages-Used:
37
+ - '2'
38
+ Iexcloud-Credits-Used:
39
+ - '2'
40
+ Iexcloud-Premium-Messages-Used:
41
+ - '0'
42
+ Iexcloud-Premium-Credits-Used:
43
+ - '0'
44
+ X-Content-Type-Options:
45
+ - nosniff
46
+ Strict-Transport-Security:
47
+ - max-age=15768000
48
+ Access-Control-Allow-Origin:
49
+ - "*"
50
+ Access-Control-Allow-Credentials:
51
+ - 'true'
52
+ Access-Control-Allow-Methods:
53
+ - GET, OPTIONS
54
+ Access-Control-Allow-Headers:
55
+ - Origin, X-Requested-With, Content-Type, Accept, Request-Source
56
+ body:
57
+ encoding: UTF-8
58
+ string: '2.7887693754001748'
59
+ recorded_at: Thu, 12 Aug 2021 20:04:24 GMT
60
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/stock/VTI/stats/INVALID?token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ Content-Type:
13
+ - application/json; charset=utf-8
14
+ User-Agent:
15
+ - IEX Ruby Client/1.4.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 13 Aug 2021 17:45:21 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - ctoken=f9f32af4b36f4a1bac8e9b2ff9018275; Max-Age=43200; Path=/; Expires=Sat,
35
+ 14 Aug 2021 05:45:21 GMT
36
+ Iexcloud-Messages-Used:
37
+ - '6'
38
+ Iexcloud-Credits-Used:
39
+ - '6'
40
+ Iexcloud-Premium-Messages-Used:
41
+ - '0'
42
+ Iexcloud-Premium-Credits-Used:
43
+ - '0'
44
+ X-Content-Type-Options:
45
+ - nosniff
46
+ Strict-Transport-Security:
47
+ - max-age=15768000
48
+ Access-Control-Allow-Origin:
49
+ - "*"
50
+ Access-Control-Allow-Credentials:
51
+ - 'true'
52
+ Access-Control-Allow-Methods:
53
+ - GET, OPTIONS
54
+ Access-Control-Allow-Headers:
55
+ - Origin, X-Requested-With, Content-Type, Accept, Request-Source
56
+ body:
57
+ encoding: ASCII-8BIT
58
+ string: '{"companyName":"Vanguard Group, Inc.","marketcap":260737447690,"week52high":230.02,"week52low":160.5,"week52highSplitAdjustOnly":230.02,"week52lowSplitAdjustOnly":162.85,"week52change":0.3645993202513256,"sharesOutstanding":1133542508,"float":0,"avg10Volume":2888645,"avg30Volume":3320395,"day200MovingAvg":213.89,"day50MovingAvg":225.73,"employees":0,"ttmEPS":0,"ttmDividendRate":2.788769375400175,"dividendYield":0.012124029977394032,"nextDividendDate":"","exDividendDate":"2021-06-24","nextEarningsDate":"","peRatio":0,"beta":1.0132372909433216,"maxChangePercent":3.578068183401369,"year5ChangePercent":1.249480952953752,"year2ChangePercent":0.6180018710916342,"year1ChangePercent":0.3635630717574918,"ytdChangePercent":0.1893429658290111,"month6ChangePercent":0.1156861042707178,"month3ChangePercent":0.10073637646122013,"month1ChangePercent":0.015496004591408763,"day30ChangePercent":0.021176470588235352,"day5ChangePercent":0.006255741720985197}'
59
+ recorded_at: Fri, 13 Aug 2021 17:45:21 GMT
60
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cloud.iexapis.com/v1/stock/INVALID/stats/ttmDividendRate?token=test-iex-api-publishable-token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json; charset=utf-8
12
+ Content-Type:
13
+ - application/json; charset=utf-8
14
+ User-Agent:
15
+ - IEX Ruby Client/1.4.2
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Fri, 13 Aug 2021 17:45:20 GMT
27
+ Content-Type:
28
+ - text/html; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - ctoken=8e6f76d57e134a4ca1be468312f5f33c; Max-Age=43200; Path=/; Expires=Sat,
35
+ 14 Aug 2021 05:45:20 GMT
36
+ Strict-Transport-Security:
37
+ - max-age=15768000
38
+ Access-Control-Allow-Origin:
39
+ - "*"
40
+ Access-Control-Allow-Credentials:
41
+ - 'true'
42
+ Access-Control-Allow-Methods:
43
+ - GET, OPTIONS
44
+ Access-Control-Allow-Headers:
45
+ - Origin, X-Requested-With, Content-Type, Accept, Request-Source
46
+ body:
47
+ encoding: ASCII-8BIT
48
+ string: Unknown symbol
49
+ recorded_at: Fri, 13 Aug 2021 17:45:20 GMT
50
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Endpoints::FX do
4
+ include_context 'client'
5
+
6
+ context 'known symbol', vcr: { cassette_name: 'fx/latest_one_symbol' } do
7
+ subject do
8
+ client.fx_latest('USDCAD')
9
+ end
10
+ it 'retrieves a list of CurrencyRates' do
11
+ expect(subject.length).to eq 1
12
+
13
+ expect(subject[0].symbol).to eq 'USDCAD'
14
+ expect(subject[0].rate).to eq 1.25674
15
+ expect(subject[0].timestamp).to eq Date.strptime('1627045829.863', '%s')
16
+ end
17
+ end
18
+
19
+ context 'known symbols', vcr: { cassette_name: 'fx/latest' } do
20
+ subject do
21
+ client.fx_latest(%w[USDCAD USDGBP USDJPY])
22
+ end
23
+ it 'retrieves a list of CurrencyRates' do
24
+ expect(subject.length).to eq 3
25
+
26
+ expect(subject[0].symbol).to eq 'USDCAD'
27
+ expect(subject[0].rate).to eq 1.25674
28
+ expect(subject[0].timestamp).to eq Date.strptime('1627045829.863', '%s')
29
+
30
+ expect(subject[1].symbol).to eq 'USDGBP'
31
+ expect(subject[1].rate).to eq 0.7262111386264443
32
+ expect(subject[1].timestamp).to eq Date.strptime('1627045780.863', '%s')
33
+
34
+ expect(subject[2].symbol).to eq 'USDJPY'
35
+ expect(subject[2].rate).to eq 110.426
36
+ expect(subject[2].timestamp).to eq Date.strptime('1627045825.365', '%s')
37
+ end
38
+ end
39
+
40
+ context 'invalid symbol', vcr: { cassette_name: 'fx/invalid' } do
41
+ subject do
42
+ client.fx_latest(%w[INVALID])
43
+ end
44
+ it 'fails with InvalidSymbolsList' do
45
+ expect { subject }.to raise_error IEX::Errors::InvalidSymbolsList, 'Invalid symbol list: INVALID'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe IEX::Endpoints::KeyStat do
4
+ include_context 'client'
5
+
6
+ let(:stat) { 'ttmDividendRate' }
7
+ let(:symbol) { 'VTI' }
8
+
9
+ context 'when asking for a single stat', vcr: { cassette_name: 'key_stat/individual' } do
10
+ subject { client.key_stat(symbol, stat) }
11
+
12
+ it 'returns that stat in the type provided by the API' do
13
+ expect(subject).to be_within(0.0001).of(2.7887)
14
+ end
15
+ end
16
+
17
+ context 'invalid symbol', vcr: { cassette_name: 'key_stat/invalid_symbol' } do
18
+ subject { client.key_stat('INVALID', stat) }
19
+
20
+ it 'fails with SymbolNotFoundError' do
21
+ expect { subject }.to raise_error IEX::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
22
+ end
23
+ end
24
+
25
+ context 'invalid stat', vcr: { cassette_name: 'key_stat/invalid_stat' } do
26
+ subject { client.key_stat(symbol, 'INVALID') }
27
+
28
+ it 'fails with StatNotFoundError' do
29
+ expect { subject }.to raise_error IEX::Errors::StatNotFoundError, 'Stat INVALID Not Found'
30
+ end
31
+
32
+ it 'keeps the API response so it can be used if caught' do
33
+ response = begin
34
+ subject
35
+ rescue IEX::Errors::StatNotFoundError => e
36
+ e.response
37
+ end
38
+
39
+ expect(response).to be_a(Hash)
40
+ expect(response).to have_key(stat)
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iex-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-15 00:00:00.000000000 Z
11
+ date: 2021-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email: dblock@dblock.org
141
141
  executables: []
142
142
  extensions: []
@@ -176,8 +176,10 @@ files:
176
176
  - lib/iex/endpoints/crypto.rb
177
177
  - lib/iex/endpoints/dividends.rb
178
178
  - lib/iex/endpoints/earnings.rb
179
+ - lib/iex/endpoints/fx.rb
179
180
  - lib/iex/endpoints/historial_prices.rb
180
181
  - lib/iex/endpoints/income.rb
182
+ - lib/iex/endpoints/key_stat.rb
181
183
  - lib/iex/endpoints/key_stats.rb
182
184
  - lib/iex/endpoints/largest_trades.rb
183
185
  - lib/iex/endpoints/logo.rb
@@ -190,7 +192,9 @@ files:
190
192
  - lib/iex/endpoints/stock_market.rb
191
193
  - lib/iex/errors.rb
192
194
  - lib/iex/errors/client_error.rb
195
+ - lib/iex/errors/invalid_symbols_list.rb
193
196
  - lib/iex/errors/permission_denied_error.rb
197
+ - lib/iex/errors/stat_not_found_error.rb
194
198
  - lib/iex/errors/symbol_not_found_error.rb
195
199
  - lib/iex/logger.rb
196
200
  - lib/iex/resources.rb
@@ -200,6 +204,7 @@ files:
200
204
  - lib/iex/resources/chart.rb
201
205
  - lib/iex/resources/company.rb
202
206
  - lib/iex/resources/crypto.rb
207
+ - lib/iex/resources/currency_rate.rb
203
208
  - lib/iex/resources/dividends.rb
204
209
  - lib/iex/resources/earnings.rb
205
210
  - lib/iex/resources/historical_prices.rb
@@ -215,6 +220,7 @@ files:
215
220
  - lib/iex/resources/symbol.rb
216
221
  - lib/iex/resources/symbols.rb
217
222
  - lib/iex/version.rb
223
+ - script/console
218
224
  - spec/fixtures/iex/advanced_stats/invalid.yml
219
225
  - spec/fixtures/iex/advanced_stats/msft.yml
220
226
  - spec/fixtures/iex/balance_sheet/invalid.yml
@@ -239,6 +245,9 @@ files:
239
245
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
240
246
  - spec/fixtures/iex/earnings/invalid.yml
241
247
  - spec/fixtures/iex/earnings/msft.yml
248
+ - spec/fixtures/iex/fx/invalid.yml
249
+ - spec/fixtures/iex/fx/latest.yml
250
+ - spec/fixtures/iex/fx/latest_one_symbol.yml
242
251
  - spec/fixtures/iex/historical_prices/abcd.yml
243
252
  - spec/fixtures/iex/historical_prices/invalid.yml
244
253
  - spec/fixtures/iex/historical_prices/invalid_date.yml
@@ -250,6 +259,9 @@ files:
250
259
  - spec/fixtures/iex/income/invalid.yml
251
260
  - spec/fixtures/iex/income/msft.yml
252
261
  - spec/fixtures/iex/income/nsrgy.yml
262
+ - spec/fixtures/iex/key_stat/individual.yml
263
+ - spec/fixtures/iex/key_stat/invalid_stat.yml
264
+ - spec/fixtures/iex/key_stat/invalid_symbol.yml
253
265
  - spec/fixtures/iex/key_stats/invalid.yml
254
266
  - spec/fixtures/iex/key_stats/msft.yml
255
267
  - spec/fixtures/iex/largest-trades/aapl.yml
@@ -283,8 +295,10 @@ files:
283
295
  - spec/iex/endpoints/crypto_spec.rb
284
296
  - spec/iex/endpoints/dividends_spec.rb
285
297
  - spec/iex/endpoints/earnings_spec.rb
298
+ - spec/iex/endpoints/fx_spec.rb
286
299
  - spec/iex/endpoints/historical_prices_spec.rb
287
300
  - spec/iex/endpoints/income_spec.rb
301
+ - spec/iex/endpoints/key_stat_spec.rb
288
302
  - spec/iex/endpoints/key_stats_spec.rb
289
303
  - spec/iex/endpoints/largest_trades_spec.rb
290
304
  - spec/iex/endpoints/logo_spec.rb
@@ -304,7 +318,7 @@ homepage: http://github.com/dblock/iex-ruby-client
304
318
  licenses:
305
319
  - MIT
306
320
  metadata: {}
307
- post_install_message:
321
+ post_install_message:
308
322
  rdoc_options: []
309
323
  require_paths:
310
324
  - lib
@@ -319,8 +333,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
333
  - !ruby/object:Gem::Version
320
334
  version: 1.3.6
321
335
  requirements: []
322
- rubygems_version: 3.1.4
323
- signing_key:
336
+ rubygems_version: 3.1.6
337
+ signing_key:
324
338
  specification_version: 4
325
339
  summary: IEX Finance API Ruby client with support for retrieving stock quotes.
326
340
  test_files:
@@ -348,6 +362,9 @@ test_files:
348
362
  - spec/fixtures/iex/dividends/msft_invalid_range.yml
349
363
  - spec/fixtures/iex/earnings/invalid.yml
350
364
  - spec/fixtures/iex/earnings/msft.yml
365
+ - spec/fixtures/iex/fx/invalid.yml
366
+ - spec/fixtures/iex/fx/latest.yml
367
+ - spec/fixtures/iex/fx/latest_one_symbol.yml
351
368
  - spec/fixtures/iex/historical_prices/abcd.yml
352
369
  - spec/fixtures/iex/historical_prices/invalid.yml
353
370
  - spec/fixtures/iex/historical_prices/invalid_date.yml
@@ -359,6 +376,9 @@ test_files:
359
376
  - spec/fixtures/iex/income/invalid.yml
360
377
  - spec/fixtures/iex/income/msft.yml
361
378
  - spec/fixtures/iex/income/nsrgy.yml
379
+ - spec/fixtures/iex/key_stat/individual.yml
380
+ - spec/fixtures/iex/key_stat/invalid_stat.yml
381
+ - spec/fixtures/iex/key_stat/invalid_symbol.yml
362
382
  - spec/fixtures/iex/key_stats/invalid.yml
363
383
  - spec/fixtures/iex/key_stats/msft.yml
364
384
  - spec/fixtures/iex/largest-trades/aapl.yml
@@ -392,8 +412,10 @@ test_files:
392
412
  - spec/iex/endpoints/crypto_spec.rb
393
413
  - spec/iex/endpoints/dividends_spec.rb
394
414
  - spec/iex/endpoints/earnings_spec.rb
415
+ - spec/iex/endpoints/fx_spec.rb
395
416
  - spec/iex/endpoints/historical_prices_spec.rb
396
417
  - spec/iex/endpoints/income_spec.rb
418
+ - spec/iex/endpoints/key_stat_spec.rb
397
419
  - spec/iex/endpoints/key_stats_spec.rb
398
420
  - spec/iex/endpoints/largest_trades_spec.rb
399
421
  - spec/iex/endpoints/logo_spec.rb