iex-ruby-client 0.4.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +8 -36
- data/CHANGELOG.md +5 -0
- data/LICENSE.md +1 -1
- data/README.md +113 -160
- data/UPGRADING.md +55 -3
- data/iex-ruby-client.gemspec +1 -1
- data/lib/iex-ruby-client.rb +2 -0
- data/lib/iex/api.rb +15 -31
- data/lib/iex/api/client.rb +30 -0
- data/lib/iex/api/config.rb +45 -0
- data/lib/iex/cloud.rb +3 -0
- data/lib/iex/cloud/connection.rb +37 -0
- data/lib/iex/cloud/request.rb +38 -0
- data/lib/iex/cloud/response.rb +20 -0
- data/lib/iex/endpoints/chart.rb +39 -0
- data/lib/iex/endpoints/company.rb +11 -0
- data/lib/iex/endpoints/crypto.rb +11 -0
- data/lib/iex/endpoints/dividends.rb +18 -0
- data/lib/iex/endpoints/earnings.rb +13 -0
- data/lib/iex/endpoints/key_stats.rb +11 -0
- data/lib/iex/endpoints/largest_trades.rb +13 -0
- data/lib/iex/endpoints/logo.rb +11 -0
- data/lib/iex/endpoints/news.rb +19 -0
- data/lib/iex/endpoints/ohlc.rb +17 -0
- data/lib/iex/endpoints/price.rb +11 -0
- data/lib/iex/endpoints/quote.rb +11 -0
- data/lib/iex/endpoints/sectors.rb +17 -0
- data/lib/iex/errors.rb +1 -0
- data/lib/iex/errors/client_error.rb +13 -1
- data/lib/iex/errors/permission_denied_error.rb +5 -0
- data/lib/iex/logger.rb +13 -0
- data/lib/iex/resources.rb +0 -1
- data/lib/iex/resources/chart.rb +38 -21
- data/lib/iex/resources/company.rb +2 -8
- data/lib/iex/resources/crypto.rb +10 -18
- data/lib/iex/resources/dividends.rb +5 -15
- data/lib/iex/resources/earnings.rb +1 -15
- data/lib/iex/resources/key_stats.rb +11 -57
- data/lib/iex/resources/largest_trades.rb +0 -10
- data/lib/iex/resources/logo.rb +0 -8
- data/lib/iex/resources/news.rb +1 -11
- data/lib/iex/resources/ohlc.rb +8 -16
- data/lib/iex/resources/quote.rb +0 -8
- data/lib/iex/resources/resource.rb +19 -2
- data/lib/iex/resources/sectors.rb +0 -10
- data/lib/iex/version.rb +1 -1
- data/spec/fixtures/iex/chart/1d.yml +472 -444
- data/spec/fixtures/iex/chart/20190306.yml +475 -0
- data/spec/fixtures/iex/chart/bad_option.yml +80 -62
- data/spec/fixtures/iex/chart/chartInterval.yml +121 -98
- data/spec/fixtures/iex/chart/dynamic/1m.yml +106 -81
- data/spec/fixtures/iex/chart/invalid.yml +80 -58
- data/spec/fixtures/iex/chart/msft.yml +106 -81
- data/spec/fixtures/iex/client/access_denied.yml +49 -0
- data/spec/fixtures/iex/company/invalid.yml +80 -58
- data/spec/fixtures/iex/company/msft.yml +87 -65
- data/spec/fixtures/iex/crypto/btcusdt.yml +87 -0
- data/spec/fixtures/iex/dividends/invalid.yml +80 -62
- data/spec/fixtures/iex/dividends/msft.yml +88 -66
- data/spec/fixtures/iex/dividends/msft_1y.yml +92 -68
- data/spec/fixtures/iex/dividends/msft_default_range.yml +85 -65
- data/spec/fixtures/iex/dividends/msft_invalid_range.yml +82 -64
- data/spec/fixtures/iex/earnings/invalid.yml +80 -62
- data/spec/fixtures/iex/earnings/msft.yml +84 -68
- data/spec/fixtures/iex/key_stats/invalid.yml +80 -62
- data/spec/fixtures/iex/key_stats/msft.yml +84 -65
- data/spec/fixtures/iex/largest-trades/aapl.yml +91 -73
- data/spec/fixtures/iex/largest-trades/invalid.yml +80 -62
- data/spec/fixtures/iex/logo/msft.yml +82 -64
- data/spec/fixtures/iex/news/invalid.yml +80 -58
- data/spec/fixtures/iex/news/msft.yml +83 -61
- data/spec/fixtures/iex/news/msft_7.yml +83 -61
- data/spec/fixtures/iex/ohlc/market.yml +82 -65
- data/spec/fixtures/iex/ohlc/msft.yml +82 -64
- data/spec/fixtures/iex/price/invalid.yml +80 -58
- data/spec/fixtures/iex/price/msft.yml +82 -60
- data/spec/fixtures/iex/quote/invalid.yml +80 -62
- data/spec/fixtures/iex/quote/msft.yml +84 -66
- data/spec/fixtures/iex/sectors/invalid.yml +80 -62
- data/spec/fixtures/iex/sectors/sectors-performance.yml +88 -69
- data/spec/iex/client_spec.rb +138 -0
- data/spec/iex/config_spec.rb +22 -0
- data/spec/iex/{resources → endpoints}/chart_spec.rb +23 -21
- data/spec/iex/{resources → endpoints}/company_spec.rb +11 -7
- data/spec/iex/endpoints/crypto_spec.rb +66 -0
- data/spec/iex/{resources → endpoints}/dividends_spec.rb +17 -14
- data/spec/iex/endpoints/earnings_spec.rb +36 -0
- data/spec/iex/endpoints/key_stats_spec.rb +62 -0
- data/spec/iex/{resources → endpoints}/largest_trades_spec.rb +8 -6
- data/spec/iex/{resources → endpoints}/logo_spec.rb +3 -1
- data/spec/iex/endpoints/news_spec.rb +36 -0
- data/spec/iex/{resources → endpoints}/ohlc_spec.rb +15 -13
- data/spec/iex/{resources → endpoints}/price_spec.rb +6 -4
- data/spec/iex/endpoints/quote_spec.rb +38 -0
- data/spec/iex/{resources → endpoints}/sectors_spec.rb +7 -6
- data/spec/iex/resources/{base_spec.rb → resource_spec.rb} +6 -6
- data/spec/spec_helper.rb +2 -0
- data/spec/support/client.rb +6 -0
- metadata +66 -59
- data/lib/iex/api/chart.rb +0 -24
- data/lib/iex/api/company.rb +0 -13
- data/lib/iex/api/crypto.rb +0 -13
- data/lib/iex/api/dividends.rb +0 -17
- data/lib/iex/api/earnings.rb +0 -13
- data/lib/iex/api/key_stats.rb +0 -13
- data/lib/iex/api/largest_trades.rb +0 -13
- data/lib/iex/api/logo.rb +0 -13
- data/lib/iex/api/news.rb +0 -18
- data/lib/iex/api/ohlc.rb +0 -17
- data/lib/iex/api/price.rb +0 -13
- data/lib/iex/api/quote.rb +0 -13
- data/lib/iex/api/sectors.rb +0 -16
- data/lib/iex/resources/base.rb +0 -27
- data/lib/iex/resources/chart/base.rb +0 -14
- data/lib/iex/resources/chart/default.rb +0 -21
- data/lib/iex/resources/chart/one_day.rb +0 -20
- data/lib/iex/resources/ohlc/base.rb +0 -14
- data/lib/iex/resources/ohlc/timed_price.rb +0 -12
- data/lib/iex/resources/price.rb +0 -13
- data/spec/fixtures/iex/chart/20180227.yml +0 -452
- data/spec/fixtures/iex/crypto.yml +0 -101
- data/spec/fixtures/iex/news/market.yml +0 -64
- data/spec/iex/resources/crypto_spec.rb +0 -65
- data/spec/iex/resources/earnings_spec.rb +0 -38
- data/spec/iex/resources/key_stats_spec.rb +0 -94
- data/spec/iex/resources/news_spec.rb +0 -44
- data/spec/iex/resources/quote_spec.rb +0 -38
data/UPGRADING.md
CHANGED
@@ -1,5 +1,58 @@
|
|
1
1
|
Upgrading iex-ruby-client
|
2
|
-
|
2
|
+
=========================
|
3
|
+
|
4
|
+
### Upgrading to >= 1.0.0
|
5
|
+
|
6
|
+
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).
|
7
|
+
|
8
|
+
Set the environment variable `IEX_API_PUBLISHABLE_TOKEN` to the token value, or configure the client via `IEX::Api::Client.new` or `IEX::Api.configure`.
|
9
|
+
|
10
|
+
Before:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
IEX::Resources::Price.get('MSFT')
|
14
|
+
```
|
15
|
+
|
16
|
+
After:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
client = IEX::Api::Client.new(publishable_token: 'token')
|
20
|
+
|
21
|
+
client.price('MSFT')
|
22
|
+
```
|
23
|
+
|
24
|
+
See [#46](https://github.com/dblock/iex-ruby-client/pull/46) for more information.
|
25
|
+
|
26
|
+
### API Changes
|
27
|
+
|
28
|
+
The IEX Cloud API has come with a number of changes.
|
29
|
+
|
30
|
+
#### Company
|
31
|
+
|
32
|
+
* Added `security_name` `employees` properties.
|
33
|
+
|
34
|
+
#### Dividends
|
35
|
+
|
36
|
+
* Added `ex_date` `currency` `description` `frequency` properties.
|
37
|
+
* Removed `flag` `type` `qualified` `indicated` properties.
|
38
|
+
|
39
|
+
#### Earnings
|
40
|
+
|
41
|
+
* Removed `estimated_eps` `estimated_change_percent` `estimated_change_percent_s` `symbol_id` properties.
|
42
|
+
|
43
|
+
#### KeyStats
|
44
|
+
|
45
|
+
* Removed `beta` `short_interest` `short_date` `dividend_rate` `latest_eps` `latest_eps_date` `return_on_equity` `consensus_eps` `number_of_estimates` `symbol` `ebitda` `revenue` `revenue_dollar` `gross_profit` `gross_profit_dollar` `cash` `cash_dollar` `dept` `dept_dollar` `revenue_per_share` `revenue_per_employee` `pe_ratio_high` `pe_ratio_low` `eps_surprise_dollar` `eps_surprise_percent` `eps_surprise_percent_s` `return_on_assets` `return_on_capital` `profit_margin` `price_to_sales` `price_to_book` `price_to_sales_dollar` `price_to_book_dollar` `institution_percent` `institution_percent_s` `insider_percent` `insider_percent_s` `short_ratio` properties.
|
46
|
+
|
47
|
+
#### News
|
48
|
+
|
49
|
+
* Removed market news.
|
50
|
+
|
51
|
+
#### Crypto
|
52
|
+
|
53
|
+
* Added `crypto` api to get a quote for crypto currency, eg. `client.crypto('BTCUSDT')`.
|
54
|
+
|
55
|
+
See [#42](https://github.com/dblock/iex-ruby-client/pull/42) for more information.
|
3
56
|
|
4
57
|
### Upgrading to >= 0.4.0
|
5
58
|
|
@@ -15,7 +68,7 @@ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, invalid_option: 'foo
|
|
15
68
|
> Faraday::ClientError: the server responded with status 400
|
16
69
|
```
|
17
70
|
|
18
|
-
After:
|
71
|
+
After:
|
19
72
|
|
20
73
|
```ruby
|
21
74
|
IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, invalid_option: 'foo')
|
@@ -23,4 +76,3 @@ IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10, invalid_option: 'foo
|
|
23
76
|
```
|
24
77
|
|
25
78
|
See [#9](https://github.com/dblock/iex-ruby-client/pull/9) for more information.
|
26
|
-
|
data/iex-ruby-client.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency 'money_helper'
|
22
22
|
s.add_development_dependency 'rake', '~> 10'
|
23
23
|
s.add_development_dependency 'rspec'
|
24
|
-
s.add_development_dependency 'rubocop', '0.
|
24
|
+
s.add_development_dependency 'rubocop', '0.67.2'
|
25
25
|
s.add_development_dependency 'vcr'
|
26
26
|
s.add_development_dependency 'webmock'
|
27
27
|
end
|
data/lib/iex-ruby-client.rb
CHANGED
data/lib/iex/api.rb
CHANGED
@@ -1,32 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative 'endpoints/chart'
|
2
|
+
require_relative 'endpoints/company'
|
3
|
+
require_relative 'endpoints/dividends'
|
4
|
+
require_relative 'endpoints/earnings'
|
5
|
+
require_relative 'endpoints/largest_trades'
|
6
|
+
require_relative 'endpoints/logo'
|
7
|
+
require_relative 'endpoints/key_stats'
|
8
|
+
require_relative 'endpoints/news'
|
9
|
+
require_relative 'endpoints/ohlc'
|
10
|
+
require_relative 'endpoints/price'
|
11
|
+
require_relative 'endpoints/quote'
|
12
|
+
require_relative 'endpoints/sectors'
|
13
|
+
require_relative 'endpoints/crypto'
|
4
14
|
|
5
|
-
|
6
|
-
|
7
|
-
url: "#{ROOT_URI}/#{path}",
|
8
|
-
request: {
|
9
|
-
params_encoder: Faraday::FlatParamsEncoder
|
10
|
-
}
|
11
|
-
) do |c|
|
12
|
-
c.use ::FaradayMiddleware::ParseJson
|
13
|
-
c.use Faraday::Response::RaiseError
|
14
|
-
c.use Faraday::Adapter::NetHttp
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require_relative 'api/chart'
|
21
|
-
require_relative 'api/company'
|
22
|
-
require_relative 'api/dividends'
|
23
|
-
require_relative 'api/earnings'
|
24
|
-
require_relative 'api/largest_trades'
|
25
|
-
require_relative 'api/logo'
|
26
|
-
require_relative 'api/key_stats'
|
27
|
-
require_relative 'api/news'
|
28
|
-
require_relative 'api/ohlc'
|
29
|
-
require_relative 'api/price'
|
30
|
-
require_relative 'api/quote'
|
31
|
-
require_relative 'api/sectors'
|
32
|
-
require_relative 'api/crypto'
|
15
|
+
require_relative 'api/config'
|
16
|
+
require_relative 'api/client'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module IEX
|
2
|
+
module Api
|
3
|
+
class Client
|
4
|
+
include Endpoints::Chart
|
5
|
+
include Endpoints::Company
|
6
|
+
include Endpoints::Crypto
|
7
|
+
include Endpoints::Dividends
|
8
|
+
include Endpoints::Earnings
|
9
|
+
include Endpoints::KeyStats
|
10
|
+
include Endpoints::LargestTrades
|
11
|
+
include Endpoints::Logo
|
12
|
+
include Endpoints::News
|
13
|
+
include Endpoints::Ohlc
|
14
|
+
include Endpoints::Price
|
15
|
+
include Endpoints::Quote
|
16
|
+
include Endpoints::Sectors
|
17
|
+
|
18
|
+
include Cloud::Connection
|
19
|
+
include Cloud::Request
|
20
|
+
|
21
|
+
include Config
|
22
|
+
|
23
|
+
def initialize(options = {})
|
24
|
+
Config::ATTRIBUTES.each do |key|
|
25
|
+
send("#{key}=", options[key] || IEX::Api.config.send(key))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module IEX
|
2
|
+
module Api
|
3
|
+
module Config
|
4
|
+
extend self
|
5
|
+
|
6
|
+
ATTRIBUTES = %i[
|
7
|
+
proxy
|
8
|
+
user_agent
|
9
|
+
ca_path
|
10
|
+
ca_file
|
11
|
+
logger
|
12
|
+
timeout
|
13
|
+
open_timeout
|
14
|
+
endpoint
|
15
|
+
publishable_token
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
attr_accessor(*Config::ATTRIBUTES)
|
19
|
+
|
20
|
+
def reset!
|
21
|
+
self.endpoint = 'https://cloud.iexapis.com/v1'
|
22
|
+
self.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
|
23
|
+
self.user_agent = "IEX Ruby Client/#{IEX::VERSION}"
|
24
|
+
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
|
25
|
+
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
|
26
|
+
self.proxy = nil
|
27
|
+
self.logger = nil
|
28
|
+
self.timeout = nil
|
29
|
+
self.open_timeout = nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def configure
|
35
|
+
block_given? ? yield(Config) : Config
|
36
|
+
end
|
37
|
+
|
38
|
+
def config
|
39
|
+
Config
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
IEX::Api::Config.reset!
|
data/lib/iex/cloud.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module IEX
|
2
|
+
module Cloud
|
3
|
+
module Connection
|
4
|
+
private
|
5
|
+
|
6
|
+
def headers
|
7
|
+
{}
|
8
|
+
end
|
9
|
+
|
10
|
+
def connection
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
options[:headers] = {}
|
14
|
+
options[:headers]['Accept'] = 'application/json; charset=utf-8'
|
15
|
+
options[:headers]['User-Agent'] = user_agent if user_agent
|
16
|
+
options[:proxy] = proxy if proxy
|
17
|
+
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file
|
18
|
+
options[:params] = { token: publishable_token } if publishable_token
|
19
|
+
|
20
|
+
request_options = {}
|
21
|
+
request_options[:timeout] = timeout if timeout
|
22
|
+
request_options[:open_timeout] = open_timeout if open_timeout
|
23
|
+
request_options[:params_encoder] = Faraday::FlatParamsEncoder
|
24
|
+
options[:request] = request_options if request_options.any?
|
25
|
+
|
26
|
+
::Faraday::Connection.new(endpoint, options) do |connection|
|
27
|
+
connection.use ::Faraday::Request::Multipart
|
28
|
+
connection.use ::Faraday::Request::UrlEncoded
|
29
|
+
connection.use ::IEX::Cloud::Response::RaiseError
|
30
|
+
connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
31
|
+
connection.response :logger, logger if logger
|
32
|
+
connection.adapter ::Faraday.default_adapter
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module IEX
|
2
|
+
module Cloud
|
3
|
+
module Request
|
4
|
+
def get(path, options = {})
|
5
|
+
request(:get, path, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
def post(path, options = {})
|
9
|
+
request(:post, path, options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def put(path, options = {})
|
13
|
+
request(:put, path, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(path, options = {})
|
17
|
+
request(:delete, path, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def request(method, path, options)
|
23
|
+
path = [endpoint, path].join('/')
|
24
|
+
response = connection.send(method) do |request|
|
25
|
+
case method
|
26
|
+
when :get, :delete
|
27
|
+
request.url(path, options)
|
28
|
+
when :post, :put
|
29
|
+
request.path = path
|
30
|
+
request.body = options unless options.empty?
|
31
|
+
end
|
32
|
+
request.options.merge!(options.delete(:request)) if options.key?(:request)
|
33
|
+
end
|
34
|
+
response.body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module IEX
|
2
|
+
module Cloud
|
3
|
+
module Response
|
4
|
+
class RaiseError < ::Faraday::Response::RaiseError
|
5
|
+
def on_complete(env)
|
6
|
+
case env[:status]
|
7
|
+
when 404
|
8
|
+
raise Faraday::Error::ResourceNotFound, response_values(env)
|
9
|
+
when 403
|
10
|
+
raise IEX::Errors::PermissionDeniedError, response_values(env)
|
11
|
+
when ClientErrorStatuses
|
12
|
+
raise IEX::Errors::ClientError, response_values(env)
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Chart
|
4
|
+
def chart(symbol, range = nil, options = {})
|
5
|
+
url = [
|
6
|
+
'stock',
|
7
|
+
symbol,
|
8
|
+
'chart',
|
9
|
+
range && range.respond_to?(:strftime) ? "date/#{range.strftime('%Y%m%d')}" : range
|
10
|
+
].compact.join('/')
|
11
|
+
|
12
|
+
params = {}
|
13
|
+
if options
|
14
|
+
options.each_pair do |k, v|
|
15
|
+
k = k.to_s.split('_').map(&:capitalize).join.sub(/^[A-Z]/, &:downcase)
|
16
|
+
params[k.to_sym] = v
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
response = get(url, params)
|
21
|
+
|
22
|
+
if range && range.to_s == 'dynamic'
|
23
|
+
range = response['range']
|
24
|
+
response = response['data']
|
25
|
+
end
|
26
|
+
response.map do |data|
|
27
|
+
case range
|
28
|
+
when '1d', Date, DateTime
|
29
|
+
IEX::Resources::Chart::OneDay.new data
|
30
|
+
else
|
31
|
+
IEX::Resources::Chart::Default.new data
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue Faraday::ResourceNotFound => e
|
35
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Company
|
4
|
+
def company(symbol, options = {})
|
5
|
+
IEX::Resources::Company.new(get("stock/#{symbol}/company", options))
|
6
|
+
rescue Faraday::ResourceNotFound => e
|
7
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Crypto
|
4
|
+
def crypto(symbol, options = {})
|
5
|
+
IEX::Resources::Crypto.new(get("crypto/#{symbol}/quote", options))
|
6
|
+
rescue Faraday::ResourceNotFound => e
|
7
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Dividends
|
4
|
+
def dividends(symbol, range = nil, options = {})
|
5
|
+
get([
|
6
|
+
'stock',
|
7
|
+
symbol,
|
8
|
+
'dividends',
|
9
|
+
range
|
10
|
+
].compact.join('/'), options).map do |data|
|
11
|
+
IEX::Resources::Dividends.new(data)
|
12
|
+
end
|
13
|
+
rescue Faraday::ResourceNotFound => e
|
14
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Earnings
|
4
|
+
def earnings(symbol, options = {})
|
5
|
+
get("stock/#{symbol}/earnings", options)['earnings'].map do |data|
|
6
|
+
IEX::Resources::Earnings.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,11 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module KeyStats
|
4
|
+
def key_stats(symbol, options = {})
|
5
|
+
IEX::Resources::KeyStats.new(get("stock/#{symbol}/stats", options))
|
6
|
+
rescue Faraday::ResourceNotFound => e
|
7
|
+
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module LargestTrades
|
4
|
+
def largest_trades(symbol, options = {})
|
5
|
+
get("stock/#{symbol}/largest-trades", options).map do |data|
|
6
|
+
IEX::Resources::LargestTrades.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
|