iex-ruby-client 1.2.0 → 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 +4 -4
- data/.env.sample +2 -0
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +0 -8
- data/CHANGELOG.md +27 -0
- data/Gemfile +1 -0
- data/README.md +237 -18
- data/RELEASING.md +3 -3
- data/lib/iex/api.rb +8 -1
- data/lib/iex/api/client.rb +15 -2
- data/lib/iex/api/config/client.rb +52 -0
- data/lib/iex/api/config/logger.rb +35 -0
- data/lib/iex/cloud/connection.rb +2 -1
- data/lib/iex/endpoints/advanced_stats.rb +11 -0
- data/lib/iex/endpoints/balance_sheet.rb +13 -0
- data/lib/iex/endpoints/cash_flow.rb +13 -0
- data/lib/iex/endpoints/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 +6 -1
- data/lib/iex/errors.rb +3 -1
- data/lib/iex/errors/invalid_symbols_list.rb +14 -0
- data/lib/iex/errors/stat_not_found_error.rb +13 -0
- data/lib/iex/resources.rb +5 -0
- data/lib/iex/resources/advanced_stats.rb +84 -0
- data/lib/iex/resources/balance_sheet.rb +60 -0
- data/lib/iex/resources/cash_flow.rb +43 -0
- data/lib/iex/resources/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 +12 -0
- data/lib/iex/version.rb +1 -1
- data/script/console +9 -0
- data/spec/fixtures/iex/advanced_stats/invalid.yml +50 -0
- data/spec/fixtures/iex/advanced_stats/msft.yml +57 -0
- data/spec/fixtures/iex/balance_sheet/invalid.yml +50 -0
- data/spec/fixtures/iex/balance_sheet/msft.yml +56 -0
- data/spec/fixtures/iex/cash_flow/invalid.yml +50 -0
- data/spec/fixtures/iex/cash_flow/msft.yml +56 -0
- data/spec/fixtures/iex/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/client_spec.rb +91 -13
- data/spec/iex/config/client_spec.rb +49 -0
- data/spec/iex/config/logger_spec.rb +46 -0
- data/spec/iex/endpoints/advanced_stats_spec.rb +110 -0
- data/spec/iex/endpoints/balance_sheet_spec.rb +80 -0
- data/spec/iex/endpoints/cash_flow_spec.rb +59 -0
- data/spec/iex/endpoints/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 +57 -12
- data/spec/iex/resources/resource_spec.rb +36 -0
- data/spec/spec_helper.rb +3 -3
- metadata +78 -6
- data/lib/iex/api/config.rb +0 -47
- data/spec/iex/config_spec.rb +0 -22
data/lib/iex/api.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
require_relative 'endpoints/advanced_stats'
|
2
|
+
require_relative 'endpoints/balance_sheet'
|
3
|
+
require_relative 'endpoints/cash_flow'
|
1
4
|
require_relative 'endpoints/chart'
|
2
5
|
require_relative 'endpoints/company'
|
3
6
|
require_relative 'endpoints/dividends'
|
4
7
|
require_relative 'endpoints/earnings'
|
8
|
+
require_relative 'endpoints/fx'
|
9
|
+
require_relative 'endpoints/historial_prices'
|
5
10
|
require_relative 'endpoints/income'
|
6
11
|
require_relative 'endpoints/largest_trades'
|
7
12
|
require_relative 'endpoints/logo'
|
13
|
+
require_relative 'endpoints/key_stat'
|
8
14
|
require_relative 'endpoints/key_stats'
|
9
15
|
require_relative 'endpoints/news'
|
10
16
|
require_relative 'endpoints/ohlc'
|
@@ -15,5 +21,6 @@ require_relative 'endpoints/crypto'
|
|
15
21
|
require_relative 'endpoints/ref_data'
|
16
22
|
require_relative 'endpoints/stock_market'
|
17
23
|
|
18
|
-
require_relative 'api/config'
|
24
|
+
require_relative 'api/config/logger'
|
25
|
+
require_relative 'api/config/client'
|
19
26
|
require_relative 'api/client'
|
data/lib/iex/api/client.rb
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
module IEX
|
2
2
|
module Api
|
3
|
+
extend Config::Client::Accessor
|
4
|
+
extend Config::Logger::Accessor
|
5
|
+
|
3
6
|
class Client
|
7
|
+
include Endpoints::AdvancedStats
|
8
|
+
include Endpoints::BalanceSheet
|
9
|
+
include Endpoints::CashFlow
|
4
10
|
include Endpoints::Chart
|
5
11
|
include Endpoints::Company
|
6
12
|
include Endpoints::Crypto
|
7
13
|
include Endpoints::Dividends
|
8
14
|
include Endpoints::Earnings
|
15
|
+
include Endpoints::FX
|
16
|
+
include Endpoints::HistoricalPrices
|
9
17
|
include Endpoints::Income
|
18
|
+
include Endpoints::KeyStat
|
10
19
|
include Endpoints::KeyStats
|
11
20
|
include Endpoints::LargestTrades
|
12
21
|
include Endpoints::Logo
|
@@ -21,12 +30,16 @@ module IEX
|
|
21
30
|
include Cloud::Connection
|
22
31
|
include Cloud::Request
|
23
32
|
|
24
|
-
|
33
|
+
attr_accessor(*Config::Client::ATTRIBUTES)
|
34
|
+
|
35
|
+
attr_reader :logger
|
25
36
|
|
26
37
|
def initialize(options = {})
|
27
|
-
Config::ATTRIBUTES.each do |key|
|
38
|
+
Config::Client::ATTRIBUTES.each do |key|
|
28
39
|
send("#{key}=", options[key] || IEX::Api.config.send(key))
|
29
40
|
end
|
41
|
+
@logger = Config::Logger.dup
|
42
|
+
@logger.instance = options[:logger] if options.key?(:logger)
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module IEX
|
2
|
+
module Api
|
3
|
+
module Config
|
4
|
+
module Client
|
5
|
+
ATTRIBUTES = %i[
|
6
|
+
ca_file
|
7
|
+
ca_path
|
8
|
+
endpoint
|
9
|
+
open_timeout
|
10
|
+
proxy
|
11
|
+
publishable_token
|
12
|
+
referer
|
13
|
+
secret_token
|
14
|
+
timeout
|
15
|
+
user_agent
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
class << self
|
19
|
+
include Config::Logger::Accessor
|
20
|
+
|
21
|
+
attr_accessor(*ATTRIBUTES)
|
22
|
+
|
23
|
+
def reset!
|
24
|
+
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
|
25
|
+
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
|
26
|
+
self.endpoint = 'https://cloud.iexapis.com/v1'
|
27
|
+
self.publishable_token = ENV['IEX_API_PUBLISHABLE_TOKEN']
|
28
|
+
self.secret_token = ENV['IEX_API_SECRET_TOKEN']
|
29
|
+
self.user_agent = "IEX Ruby Client/#{IEX::VERSION}"
|
30
|
+
|
31
|
+
self.open_timeout = nil
|
32
|
+
self.proxy = nil
|
33
|
+
self.referer = nil
|
34
|
+
self.timeout = nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Accessor
|
39
|
+
def configure
|
40
|
+
block_given? ? yield(Config::Client) : Config::Client
|
41
|
+
end
|
42
|
+
|
43
|
+
def config
|
44
|
+
Config::Client
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
IEX::Api::Config::Client.reset!
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module IEX
|
2
|
+
module Api
|
3
|
+
module Config
|
4
|
+
module Logger
|
5
|
+
ATTRIBUTES = %i[
|
6
|
+
instance
|
7
|
+
options
|
8
|
+
proc
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor(*ATTRIBUTES)
|
13
|
+
|
14
|
+
def reset!
|
15
|
+
self.instance = nil
|
16
|
+
self.options = {}
|
17
|
+
self.proc = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Accessor
|
22
|
+
def logger
|
23
|
+
block_given? ? yield(Config::Logger) : Config::Logger
|
24
|
+
end
|
25
|
+
|
26
|
+
def logger=(instance)
|
27
|
+
logger.instance = instance
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
IEX::Api::Config::Logger.reset!
|
data/lib/iex/cloud/connection.rb
CHANGED
@@ -15,6 +15,7 @@ module IEX
|
|
15
15
|
options[:headers]['Accept'] = 'application/json; charset=utf-8'
|
16
16
|
options[:headers]['Content-Type'] = 'application/json; charset=utf-8'
|
17
17
|
options[:headers]['User-Agent'] = user_agent if user_agent
|
18
|
+
options[:headers]['Referer'] = referer if referer
|
18
19
|
options[:proxy] = proxy if proxy
|
19
20
|
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file
|
20
21
|
|
@@ -29,7 +30,7 @@ module IEX
|
|
29
30
|
connection.use ::Faraday::Request::UrlEncoded
|
30
31
|
connection.use ::IEX::Cloud::Response::RaiseError
|
31
32
|
connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
32
|
-
connection.response
|
33
|
+
connection.response(:logger, logger.instance, logger.options, &logger.proc) if logger.instance
|
33
34
|
connection.adapter ::Faraday.default_adapter
|
34
35
|
end
|
35
36
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module IEX
|
2
|
+
module Endpoints
|
3
|
+
module AdvancedStats
|
4
|
+
def advanced_stats(symbol, options = {})
|
5
|
+
IEX::Resources::AdvancedStats.new(get("stock/#{symbol}/advanced-stats", { token: publishable_token }.merge(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 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].present?
|
7
|
+
raise ArgumentError unless options[:chartByDay].present?
|
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
|
@@ -2,7 +2,7 @@ module IEX
|
|
2
2
|
module Endpoints
|
3
3
|
module RefData
|
4
4
|
def ref_data_isin(isins, options = {})
|
5
|
-
response = get('ref-data/isin', { token: publishable_token, isin: isins.join(',') }.merge(options))
|
5
|
+
response = get('ref-data/isin', { token: publishable_token, isin: Array(isins).join(',') }.merge(options))
|
6
6
|
|
7
7
|
if response.is_a?(Hash) # mapped option was set
|
8
8
|
response.transform_values do |rows|
|
@@ -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
|
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
|
data/lib/iex/resources.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
require_relative 'resources/resource'
|
2
2
|
|
3
|
+
require_relative 'resources/advanced_stats'
|
4
|
+
require_relative 'resources/balance_sheet'
|
5
|
+
require_relative 'resources/cash_flow'
|
3
6
|
require_relative 'resources/chart'
|
7
|
+
require_relative 'resources/currency_rate'
|
4
8
|
require_relative 'resources/company'
|
5
9
|
require_relative 'resources/dividends'
|
6
10
|
require_relative 'resources/earnings'
|
11
|
+
require_relative 'resources/historical_prices'
|
7
12
|
require_relative 'resources/income'
|
8
13
|
require_relative 'resources/key_stats'
|
9
14
|
require_relative 'resources/largest_trades'
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class AdvancedStats < Resource
|
4
|
+
property 'total_cash', from: 'totalCash'
|
5
|
+
property 'total_cash_dollars', from: 'totalCash', with: ->(v) { Resource.to_dollar(amount: v) }
|
6
|
+
property 'current_debt', from: 'currentDebt'
|
7
|
+
property 'current_debt_dollars', from: 'currentDebt', with: ->(v) { Resource.to_dollar(amount: v) }
|
8
|
+
property 'revenue'
|
9
|
+
property 'revenue_dollars', from: 'revenue', with: ->(v) { Resource.to_dollar(amount: v) }
|
10
|
+
property 'gross_profit', from: 'grossProfit'
|
11
|
+
property 'gross_profit_dollar', from: 'grossProfit', with: ->(v) { Resource.to_dollar(amount: v) }
|
12
|
+
property 'total_revenue', from: 'totalRevenue'
|
13
|
+
property 'total_revenue_dollar', from: 'totalRevenue', with: ->(v) { Resource.to_dollar(amount: v) }
|
14
|
+
property 'ebitda', from: 'EBITDA'
|
15
|
+
property 'ebitda_dollar', from: 'EBITDA', with: ->(v) { Resource.to_dollar(amount: v) }
|
16
|
+
property 'revenue_per_share', from: 'revenuePerShare'
|
17
|
+
property 'revenue_per_share_dollars', from: 'revenuePerShare', with: ->(v) { Resource.to_dollar(amount: v) }
|
18
|
+
property 'revenue_per_employee', from: 'revenuePerEmployee'
|
19
|
+
property 'revenue_per_employee_dollar', from: 'revenuePerEmployee', with: ->(v) { Resource.to_dollar(amount: v) }
|
20
|
+
property 'debt_to_equity', from: 'debtToEquity'
|
21
|
+
property 'profit_margin', from: 'profitMargin'
|
22
|
+
property 'enterprise_value', from: 'enterpriseValue'
|
23
|
+
property 'enterprise_value_dollar', from: 'enterpriseValue', with: ->(v) { Resource.to_dollar(amount: v) }
|
24
|
+
property 'enterprise_value_to_revenue', from: 'enterpriseValueToRevenue'
|
25
|
+
property 'price_to_sales', from: 'priceToSales'
|
26
|
+
property 'price_to_sales_dollar', from: 'priceToSales', with: ->(v) { Resource.to_dollar(amount: v) }
|
27
|
+
property 'price_to_book', from: 'priceToBook'
|
28
|
+
property 'forward_pe_ratio', from: 'forwardPERatio'
|
29
|
+
property 'pe_high', from: 'peHigh'
|
30
|
+
property 'pe_low', from: 'peLow'
|
31
|
+
property 'peg_ratio', from: 'pegRatio'
|
32
|
+
property 'week_52_high_date', from: 'week52highDate'
|
33
|
+
property 'week_52_low_date', from: 'week52lowDate'
|
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'
|
78
|
+
|
79
|
+
def initialize(data = {})
|
80
|
+
super
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class BalanceSheet < Resource
|
4
|
+
property 'report_date', from: 'reportDate'
|
5
|
+
property 'fiscal_date', from: 'fiscalDate'
|
6
|
+
property 'currency'
|
7
|
+
property 'current_cash', from: 'currentCash'
|
8
|
+
property 'current_cash_dollar', from: 'currentCash', with: ->(v) { to_dollar(amount: v) }
|
9
|
+
property 'short_term_investments', from: 'shortTermInvestments'
|
10
|
+
property 'short_term_investments_dollar', from: 'shortTermInvestments', with: ->(v) { to_dollar(amount: v) }
|
11
|
+
property 'receivables'
|
12
|
+
property 'receivables_dollar', from: 'receivables', with: ->(v) { to_dollar(amount: v) }
|
13
|
+
property 'inventory'
|
14
|
+
property 'inventory_dollar', from: 'inventory', with: ->(v) { to_dollar(amount: v) }
|
15
|
+
property 'other_current_assets', from: 'otherCurrentAssets'
|
16
|
+
property 'other_current_assets_dollar', from: 'otherCurrentAssets', with: ->(v) { to_dollar(amount: v) }
|
17
|
+
property 'current_assets', from: 'currentAssets'
|
18
|
+
property 'current_assets_dollar', from: 'currentAssets', with: ->(v) { to_dollar(amount: v) }
|
19
|
+
property 'long_term_investments', from: 'longTermInvestments'
|
20
|
+
property 'long_term_investments_dollar', from: 'longTermInvestments', with: ->(v) { to_dollar(amount: v) }
|
21
|
+
property 'property_plant_equipment', from: 'propertyPlantEquipment'
|
22
|
+
property 'property_plant_equipment_dollar', from: 'propertyPlantEquipment', with: ->(v) { to_dollar(amount: v) }
|
23
|
+
property 'goodwill'
|
24
|
+
property 'goodwill_dollar', from: 'goodwill', with: ->(v) { to_dollar(amount: v) }
|
25
|
+
property 'intangible_assets', from: 'intangibleAssets'
|
26
|
+
property 'intangible_assets_dollar', from: 'intangibleAssets', with: ->(v) { to_dollar(amount: v) }
|
27
|
+
property 'other_assets', from: 'otherAssets'
|
28
|
+
property 'other_assets_dollar', from: 'otherAssets', with: ->(v) { to_dollar(amount: v) }
|
29
|
+
property 'total_assets', from: 'totalAssets'
|
30
|
+
property 'total_assets_dollar', from: 'totalAssets', with: ->(v) { to_dollar(amount: v) }
|
31
|
+
property 'accounts_payable', from: 'accountsPayable'
|
32
|
+
property 'accounts_payable_dollar', from: 'accountsPayable', with: ->(v) { to_dollar(amount: v) }
|
33
|
+
property 'current_long_term_debt', from: 'currentLongTermDebt'
|
34
|
+
property 'current_long_term_debt_dollar', from: 'currentLongTermDebt', with: ->(v) { to_dollar(amount: v) }
|
35
|
+
property 'other_current_liabilities', from: 'otherCurrentLiabilities'
|
36
|
+
property 'other_current_liabilities_dollar', from: 'otherCurrentLiabilities', with: ->(v) { to_dollar(amount: v) }
|
37
|
+
property 'total_current_liabilities', from: 'totalCurrentLiabilities'
|
38
|
+
property 'total_current_liabilities_dollar', from: 'totalCurrentLiabilities', with: ->(v) { to_dollar(amount: v) }
|
39
|
+
property 'long_term_debt', from: 'longTermDebt'
|
40
|
+
property 'long_term_debt_dollar', from: 'longTermDebt', with: ->(v) { to_dollar(amount: v) }
|
41
|
+
property 'other_liabilities', from: 'otherLiabilities'
|
42
|
+
property 'other_liabilities_dollar', from: 'otherLiabilities', with: ->(v) { to_dollar(amount: v) }
|
43
|
+
property 'minority_interest', from: 'minorityInterest'
|
44
|
+
property 'minority_interest_dollar', from: 'minorityInterest', with: ->(v) { to_dollar(amount: v) }
|
45
|
+
property 'total_liabilities', from: 'totalLiabilities'
|
46
|
+
property 'total_liabilities_dollar', from: 'totalLiabilities', with: ->(v) { to_dollar(amount: v) }
|
47
|
+
property 'common_stock', from: 'commonStock'
|
48
|
+
property 'retained_earnings', from: 'retainedEarnings'
|
49
|
+
property 'retained_earnings_dollar', from: 'retainedEarnings', with: ->(v) { to_dollar(amount: v) }
|
50
|
+
property 'treasury_stock', from: 'treasuryStock'
|
51
|
+
property 'treasury_stock_dollar', from: 'treasuryStock', with: ->(v) { to_dollar(amount: v) }
|
52
|
+
property 'capital_surplus', from: 'capitalSurplus'
|
53
|
+
property 'capital_surplus_dollar', from: 'capitalSurplus', with: ->(v) { to_dollar(amount: v) }
|
54
|
+
property 'shareholder_equity', from: 'shareholderEquity'
|
55
|
+
property 'shareholder_equity_dollar', from: 'shareholderEquity', with: ->(v) { to_dollar(amount: v) }
|
56
|
+
property 'net_tangible_assets', from: 'netTangibleAssets'
|
57
|
+
property 'net_tangible_assets_dollar', from: 'netTangibleAssets', with: ->(v) { to_dollar(amount: v) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|