iex-ruby-client 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +1 -0
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +37 -7
- data/Dangerfile +2 -2
- data/Gemfile +2 -2
- data/README.md +159 -37
- data/iex-ruby-client.gemspec +3 -2
- data/lib/iex-ruby-client.rb +1 -0
- data/lib/iex/api.rb +3 -0
- data/lib/iex/api/client.rb +3 -0
- data/lib/iex/api/config.rb +2 -0
- data/lib/iex/cloud/connection.rb +21 -19
- data/lib/iex/cloud/request.rb +1 -1
- data/lib/iex/cloud/response.rb +1 -1
- data/lib/iex/endpoints/chart.rb +5 -6
- 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/income.rb +13 -0
- 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 +3 -0
- data/lib/iex/resources/chart.rb +9 -14
- data/lib/iex/resources/company.rb +1 -0
- data/lib/iex/resources/income.rb +36 -0
- data/lib/iex/resources/key_stats.rb +14 -2
- data/lib/iex/resources/quote.rb +15 -5
- data/lib/iex/resources/resource.rb +1 -1
- 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/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/income/invalid.yml +49 -0
- data/spec/fixtures/iex/income/msft.yml +53 -0
- data/spec/fixtures/iex/income/nsrgy.yml +55 -0
- data/spec/fixtures/iex/key_stats/invalid.yml +7 -41
- data/spec/fixtures/iex/key_stats/msft.yml +11 -43
- 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 +6 -1
- data/spec/iex/endpoints/chart_spec.rb +7 -7
- data/spec/iex/endpoints/company_spec.rb +1 -0
- data/spec/iex/endpoints/income_spec.rb +68 -0
- data/spec/iex/endpoints/key_stats_spec.rb +42 -29
- data/spec/iex/endpoints/quote_spec.rb +2 -0
- data/spec/iex/endpoints/ref_data_spec.rb +66 -0
- data/spec/iex/endpoints/stock_market_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/vcr.rb +3 -0
- metadata +41 -13
data/lib/iex/api/client.rb
CHANGED
@@ -6,6 +6,7 @@ module IEX
|
|
6
6
|
include Endpoints::Crypto
|
7
7
|
include Endpoints::Dividends
|
8
8
|
include Endpoints::Earnings
|
9
|
+
include Endpoints::Income
|
9
10
|
include Endpoints::KeyStats
|
10
11
|
include Endpoints::LargestTrades
|
11
12
|
include Endpoints::Logo
|
@@ -14,6 +15,8 @@ module IEX
|
|
14
15
|
include Endpoints::Price
|
15
16
|
include Endpoints::Quote
|
16
17
|
include Endpoints::Sectors
|
18
|
+
include Endpoints::RefData
|
19
|
+
include Endpoints::StockMarket
|
17
20
|
|
18
21
|
include Cloud::Connection
|
19
22
|
include Cloud::Request
|
data/lib/iex/api/config.rb
CHANGED
@@ -13,6 +13,7 @@ module IEX
|
|
13
13
|
open_timeout
|
14
14
|
endpoint
|
15
15
|
publishable_token
|
16
|
+
secret_token
|
16
17
|
].freeze
|
17
18
|
|
18
19
|
attr_accessor(*Config::ATTRIBUTES)
|
@@ -20,6 +21,7 @@ module IEX
|
|
20
21
|
def reset!
|
21
22
|
self.endpoint = 'https://cloud.iexapis.com/v1'
|
22
23
|
self.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
|
24
|
+
self.secret_token = ENV['IEX_API_SECRET_TOKEN']
|
23
25
|
self.user_agent = "IEX Ruby Client/#{IEX::VERSION}"
|
24
26
|
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
|
25
27
|
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
|
data/lib/iex/cloud/connection.rb
CHANGED
@@ -8,28 +8,30 @@ module IEX
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def connection
|
11
|
-
|
11
|
+
@connection ||= begin
|
12
|
+
options = {}
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
options[:headers] = {}
|
15
|
+
options[:headers]['Accept'] = 'application/json; charset=utf-8'
|
16
|
+
options[:headers]['Content-Type'] = 'application/json; charset=utf-8'
|
17
|
+
options[:headers]['User-Agent'] = user_agent if user_agent
|
18
|
+
options[:proxy] = proxy if proxy
|
19
|
+
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
request_options = {}
|
22
|
+
request_options[:timeout] = timeout if timeout
|
23
|
+
request_options[:open_timeout] = open_timeout if open_timeout
|
24
|
+
request_options[:params_encoder] = Faraday::FlatParamsEncoder
|
25
|
+
options[:request] = request_options if request_options.any?
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
::Faraday::Connection.new(endpoint, options) do |connection|
|
28
|
+
connection.use ::Faraday::Request::Multipart
|
29
|
+
connection.use ::Faraday::Request::UrlEncoded
|
30
|
+
connection.use ::IEX::Cloud::Response::RaiseError
|
31
|
+
connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
32
|
+
connection.response :logger, logger if logger
|
33
|
+
connection.adapter ::Faraday.default_adapter
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
data/lib/iex/cloud/request.rb
CHANGED
@@ -27,7 +27,7 @@ module IEX
|
|
27
27
|
request.url(path, options)
|
28
28
|
when :post, :put
|
29
29
|
request.path = path
|
30
|
-
request.body = options unless options.empty?
|
30
|
+
request.body = options.to_json unless options.empty?
|
31
31
|
end
|
32
32
|
request.options.merge!(options.delete(:request)) if options.key?(:request)
|
33
33
|
end
|
data/lib/iex/cloud/response.rb
CHANGED
@@ -5,7 +5,7 @@ module IEX
|
|
5
5
|
def on_complete(env)
|
6
6
|
case env[:status]
|
7
7
|
when 404
|
8
|
-
raise Faraday::
|
8
|
+
raise Faraday::ResourceNotFound, response_values(env)
|
9
9
|
when 403
|
10
10
|
raise IEX::Errors::PermissionDeniedError, response_values(env)
|
11
11
|
when ClientErrorStatuses
|
data/lib/iex/endpoints/chart.rb
CHANGED
@@ -10,14 +10,13 @@ module IEX
|
|
10
10
|
].compact.join('/')
|
11
11
|
|
12
12
|
params = {}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
13
|
+
|
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
|
18
17
|
end
|
19
18
|
|
20
|
-
response = get(url, params)
|
19
|
+
response = get(url, { token: publishable_token }.merge(params))
|
21
20
|
|
22
21
|
if range && range.to_s == 'dynamic'
|
23
22
|
range = response['range']
|
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Company
|
4
4
|
def company(symbol, options = {})
|
5
|
-
IEX::Resources::Company.new(get("stock/#{symbol}/company", options))
|
5
|
+
IEX::Resources::Company.new(get("stock/#{symbol}/company", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
data/lib/iex/endpoints/crypto.rb
CHANGED
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Crypto
|
4
4
|
def crypto(symbol, options = {})
|
5
|
-
IEX::Resources::Crypto.new(get("crypto/#{symbol}/quote", options))
|
5
|
+
IEX::Resources::Crypto.new(get("crypto/#{symbol}/quote", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Earnings
|
4
4
|
def earnings(symbol, options = {})
|
5
|
-
get("stock/#{symbol}/earnings", options)['earnings'].map do |data|
|
5
|
+
get("stock/#{symbol}/earnings", { token: publishable_token }.merge(options))['earnings'].map do |data|
|
6
6
|
IEX::Resources::Earnings.new(data)
|
7
7
|
end
|
8
8
|
rescue Faraday::ResourceNotFound => e
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module Income
|
4
|
+
def income(symbol, options = {})
|
5
|
+
(get("stock/#{symbol}/income", { token: publishable_token }.merge(options))['income'] || []).map do |data|
|
6
|
+
IEX::Resources::Income.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
|
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module KeyStats
|
4
4
|
def key_stats(symbol, options = {})
|
5
|
-
IEX::Resources::KeyStats.new(get("stock/#{symbol}/stats", options))
|
5
|
+
IEX::Resources::KeyStats.new(get("stock/#{symbol}/stats", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module LargestTrades
|
4
4
|
def largest_trades(symbol, options = {})
|
5
|
-
get("stock/#{symbol}/largest-trades", options).map do |data|
|
5
|
+
get("stock/#{symbol}/largest-trades", { token: publishable_token }.merge(options)).map do |data|
|
6
6
|
IEX::Resources::LargestTrades.new(data)
|
7
7
|
end
|
8
8
|
rescue Faraday::ResourceNotFound => e
|
data/lib/iex/endpoints/logo.rb
CHANGED
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Logo
|
4
4
|
def logo(symbol, options = {})
|
5
|
-
IEX::Resources::Logo.new(get("stock/#{symbol.downcase}/logo", options))
|
5
|
+
IEX::Resources::Logo.new(get("stock/#{symbol.downcase}/logo", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
data/lib/iex/endpoints/news.rb
CHANGED
@@ -8,7 +8,7 @@ module IEX
|
|
8
8
|
'news',
|
9
9
|
range ? 'last' : nil,
|
10
10
|
range
|
11
|
-
].compact.join('/'), options).map do |data|
|
11
|
+
].compact.join('/'), { token: publishable_token }.merge(options)).map do |data|
|
12
12
|
IEX::Resources::News.new(data)
|
13
13
|
end
|
14
14
|
rescue Faraday::ResourceNotFound => e
|
data/lib/iex/endpoints/ohlc.rb
CHANGED
@@ -2,13 +2,13 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Ohlc
|
4
4
|
def ohlc(symbol, options = {})
|
5
|
-
IEX::Resources::OHLC.new(get("stock/#{symbol}/ohlc", options))
|
5
|
+
IEX::Resources::OHLC.new(get("stock/#{symbol}/ohlc", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
9
9
|
|
10
10
|
def market(options = {})
|
11
|
-
Hash[get('stock/market/ohlc', options).map do |k, v|
|
11
|
+
Hash[get('stock/market/ohlc', { token: publishable_token }.merge(options)).map do |k, v|
|
12
12
|
[k, IEX::Resources::OHLC.new(v)]
|
13
13
|
end]
|
14
14
|
end
|
data/lib/iex/endpoints/price.rb
CHANGED
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Price
|
4
4
|
def price(symbol, options = {})
|
5
|
-
get("stock/#{symbol}/price", options)
|
5
|
+
get("stock/#{symbol}/price", { token: publishable_token }.merge(options))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
data/lib/iex/endpoints/quote.rb
CHANGED
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module Quote
|
4
4
|
def quote(symbol, options = {})
|
5
|
-
IEX::Resources::Quote.new(get("stock/#{symbol}/quote", options))
|
5
|
+
IEX::Resources::Quote.new(get("stock/#{symbol}/quote", { token: publishable_token }.merge(options)))
|
6
6
|
rescue Faraday::ResourceNotFound => e
|
7
7
|
raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body])
|
8
8
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module RefData
|
4
|
+
def ref_data_isin(isins, options = {})
|
5
|
+
response = get('ref-data/isin', { token: publishable_token, isin: isins.join(',') }.merge(options))
|
6
|
+
|
7
|
+
if response.is_a?(Hash) # mapped option was set
|
8
|
+
response.transform_values do |rows|
|
9
|
+
rows&.map { |row| IEX::Resources::Symbol.new(row) }
|
10
|
+
end
|
11
|
+
else
|
12
|
+
response.map { |row| IEX::Resources::Symbol.new(row) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def ref_data_symbols(options = {})
|
17
|
+
response = get('ref-data/symbols', { token: publishable_token }.merge(options))
|
18
|
+
response.map { |row| IEX::Resources::Symbols.new(row) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -6,7 +6,7 @@ module IEX
|
|
6
6
|
'stock',
|
7
7
|
symbol,
|
8
8
|
'sector-performance'
|
9
|
-
].compact.join('/'), options).map do |data|
|
9
|
+
].compact.join('/'), { token: publishable_token }.merge(options)).map do |data|
|
10
10
|
IEX::Resources::Sectors.new(data)
|
11
11
|
end
|
12
12
|
rescue Faraday::ResourceNotFound => e
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module StockMarket
|
4
|
+
def stock_market_list(list_type, options = {})
|
5
|
+
get("stock/market/list/#{list_type}", { token: publishable_token }.merge(options)).map do |data|
|
6
|
+
IEX::Resources::Quote.new(data)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/iex/resources.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'resources/chart'
|
|
4
4
|
require_relative 'resources/company'
|
5
5
|
require_relative 'resources/dividends'
|
6
6
|
require_relative 'resources/earnings'
|
7
|
+
require_relative 'resources/income'
|
7
8
|
require_relative 'resources/key_stats'
|
8
9
|
require_relative 'resources/largest_trades'
|
9
10
|
require_relative 'resources/logo'
|
@@ -12,3 +13,5 @@ require_relative 'resources/ohlc'
|
|
12
13
|
require_relative 'resources/quote'
|
13
14
|
require_relative 'resources/sectors'
|
14
15
|
require_relative 'resources/crypto'
|
16
|
+
require_relative 'resources/symbol'
|
17
|
+
require_relative 'resources/symbols'
|
data/lib/iex/resources/chart.rb
CHANGED
@@ -5,40 +5,35 @@ module IEX
|
|
5
5
|
property 'high'
|
6
6
|
property 'low'
|
7
7
|
property 'volume'
|
8
|
+
property 'open'
|
9
|
+
property 'close'
|
8
10
|
property 'label'
|
9
|
-
property 'change_over_time', from: 'changeOverTime'
|
10
11
|
property 'date', transform_with: ->(v) { Date.parse(v) }
|
11
12
|
end
|
12
13
|
|
13
14
|
class Default < Base
|
14
|
-
property '
|
15
|
-
property '
|
16
|
-
property '
|
15
|
+
property 'u_high', from: 'uHigh'
|
16
|
+
property 'u_low', from: 'uLow'
|
17
|
+
property 'u_volume', from: 'uVolume'
|
18
|
+
property 'u_open', from: 'uOpen'
|
19
|
+
property 'u_close', from: 'uClose'
|
17
20
|
property 'change'
|
18
21
|
property 'change_percent', from: 'changePercent'
|
19
22
|
property 'change_percent_s', from: 'changePercent', with: lambda { |v|
|
20
23
|
[
|
21
|
-
v
|
24
|
+
v.positive? ? '+' : '',
|
22
25
|
format('%.2f', v),
|
23
26
|
'%'
|
24
27
|
].join
|
25
28
|
} # change in percent as a String with a leading + or - sign
|
26
|
-
property '
|
29
|
+
property 'change_over_time', from: 'changeOverTime'
|
27
30
|
end
|
28
31
|
|
29
32
|
class OneDay < Base
|
30
33
|
property 'minute'
|
31
|
-
property 'market_average', from: 'marketAverage'
|
32
|
-
property 'market_notional', from: 'marketNotional'
|
33
|
-
property 'market_number_of_trades', from: 'marketNumberOfTrades'
|
34
|
-
property 'market_high', from: 'marketHigh'
|
35
|
-
property 'market_low', from: 'marketLow'
|
36
|
-
property 'market_volume', from: 'marketVolume'
|
37
|
-
property 'market_change_over_time', from: 'marketChangeOverTime'
|
38
34
|
property 'average'
|
39
35
|
property 'notional'
|
40
36
|
property 'number_of_trades', from: 'numberOfTrades'
|
41
|
-
property 'simplify_factor', from: 'simplifyFactor'
|
42
37
|
end
|
43
38
|
end
|
44
39
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class Income < Resource
|
4
|
+
property 'report_date', from: 'reportDate'
|
5
|
+
property 'total_revenue', from: 'totalRevenue'
|
6
|
+
property 'total_revenue_dollar', from: 'totalRevenue', with: ->(v) { to_dollar(amount: v) }
|
7
|
+
property 'cost_of_revenue', from: 'costOfRevenue'
|
8
|
+
property 'cost_of_revenue_dollar', from: 'costOfRevenue', with: ->(v) { to_dollar(amount: v) }
|
9
|
+
property 'gross_profit', from: 'grossProfit'
|
10
|
+
property 'gross_profit_dollar', from: 'grossProfit', with: ->(v) { to_dollar(amount: v) }
|
11
|
+
property 'research_and_development', from: 'researchAndDevelopment'
|
12
|
+
property 'research_and_development_dollar', from: 'researchAndDevelopment', with: ->(v) { to_dollar(amount: v) }
|
13
|
+
property 'selling_general_and_admin', from: 'sellingGeneralAndAdmin'
|
14
|
+
property 'selling_general_and_admin_dollar', from: 'sellingGeneralAndAdmin', with: ->(v) { to_dollar(amount: v) }
|
15
|
+
property 'operating_expense', from: 'operatingExpense'
|
16
|
+
property 'operating_expense_dollar', from: 'operatingExpense', with: ->(v) { to_dollar(amount: v) }
|
17
|
+
property 'operating_income', from: 'operatingIncome'
|
18
|
+
property 'operating_income_dollar', from: 'operatingIncome', with: ->(v) { to_dollar(amount: v) }
|
19
|
+
property 'other_income_expense_net', from: 'otherIncomeExpenseNet'
|
20
|
+
property 'other_income_expense_net_dollar', from: 'otherIncomeExpenseNet', with: ->(v) { to_dollar(amount: v) }
|
21
|
+
property 'ebit'
|
22
|
+
property 'ebit_dollar', from: 'ebit', with: ->(v) { to_dollar(amount: v) }
|
23
|
+
property 'interest_income', from: 'interestIncome'
|
24
|
+
property 'interest_income_dollar', from: 'interestIncome', with: ->(v) { to_dollar(amount: v) }
|
25
|
+
property 'pretax_income', from: 'pretaxIncome'
|
26
|
+
property 'pretax_income_dollar', from: 'pretaxIncome', with: ->(v) { to_dollar(amount: v) }
|
27
|
+
property 'income_tax', from: 'incomeTax'
|
28
|
+
property 'income_tax_dollar', from: 'incomeTax', with: ->(v) { to_dollar(amount: v) }
|
29
|
+
property 'minority_interest', from: 'minorityInterest'
|
30
|
+
property 'net_income', from: 'netIncome'
|
31
|
+
property 'net_income_dollar', from: 'netIncome', with: ->(v) { to_dollar(amount: v) }
|
32
|
+
property 'net_income_basic', from: 'netIncomeBasic'
|
33
|
+
property 'net_income_basic_dollar', from: 'netIncomeBasic', with: ->(v) { to_dollar(amount: v) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -3,12 +3,12 @@ module IEX
|
|
3
3
|
class KeyStats < Resource
|
4
4
|
property 'company_name', from: 'companyName'
|
5
5
|
property 'market_cap', from: 'marketcap'
|
6
|
-
property '
|
6
|
+
property 'market_cap_dollar', from: 'marketcap', with: ->(v) { Resource.to_dollar(amount: v) }
|
7
7
|
property 'week_52_high', from: 'week52high'
|
8
8
|
property 'week_52_high_dollar', from: 'week52high', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
9
9
|
property 'week_52_low', from: 'week52low'
|
10
10
|
property 'week_52_low_dollar', from: 'week52low', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
11
|
-
property 'week_52_change'
|
11
|
+
property 'week_52_change', from: 'week52change'
|
12
12
|
property 'week_52_change_dollar', from: 'week52change', with: ->(v) { Resource.to_dollar(amount: v, ignore_cents: false) }
|
13
13
|
property 'dividend_yield', from: 'dividendYield'
|
14
14
|
property 'ex_dividend_date', from: 'exDividendDate'
|
@@ -24,6 +24,7 @@ module IEX
|
|
24
24
|
property 'year_1_change_percent', from: 'year1ChangePercent'
|
25
25
|
property 'year_1_change_percent_s', from: 'year1ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
26
26
|
property 'ytd_change_percent', from: 'ytdChangePercent'
|
27
|
+
property 'ytd_change_percent_s', from: 'ytdChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
27
28
|
property 'month_6_change_percent', from: 'month6ChangePercent'
|
28
29
|
property 'month_6_change_percent_s', from: 'month6ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
29
30
|
property 'month_3_change_percent', from: 'month3ChangePercent'
|
@@ -32,6 +33,17 @@ module IEX
|
|
32
33
|
property 'month_1_change_percent_s', from: 'month1ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
33
34
|
property 'day_5_change_percent', from: 'day5ChangePercent'
|
34
35
|
property 'day_5_change_percent_s', from: 'day5ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
36
|
+
property 'employees'
|
37
|
+
property 'avg_10_volume', from: 'avg10Volume'
|
38
|
+
property 'avg_30_volume', from: 'avg30Volume'
|
39
|
+
property 'ttm_dividend_rate', from: 'ttmDividendRate'
|
40
|
+
property 'max_change_percent', from: 'maxChangePercent'
|
41
|
+
property 'day_30_change_percent', from: 'day30ChangePercent'
|
42
|
+
property 'day_30_change_percent_s', from: 'day30ChangePercent', with: ->(v) { Resource.float_to_percentage(v) }
|
43
|
+
property 'next_dividend_date', from: 'nextDividendDate'
|
44
|
+
property 'next_earnings_date', from: 'nextEarningsDate'
|
45
|
+
property 'pe_ratio', from: 'peRatio'
|
46
|
+
property 'beta'
|
35
47
|
|
36
48
|
def initialize(data = {})
|
37
49
|
super
|