iex-ruby-client 1.1.1 → 1.4.1
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/.github/FUNDING.yml +1 -0
- data/.rubocop_todo.yml +0 -8
- data/CHANGELOG.md +49 -12
- data/Dangerfile +2 -2
- data/Gemfile +3 -2
- data/README.md +276 -20
- data/RELEASING.md +2 -2
- data/iex-ruby-client.gemspec +2 -1
- 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 +22 -19
- data/lib/iex/cloud/response.rb +1 -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/historial_prices.rb +30 -0
- data/lib/iex/endpoints/ref_data.rb +27 -0
- data/lib/iex/endpoints/stock_market.rb +11 -0
- data/lib/iex/resources.rb +6 -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/historical_prices.rb +31 -0
- data/lib/iex/resources/income.rb +2 -0
- data/lib/iex/resources/key_stats.rb +1 -1
- data/lib/iex/resources/news.rb +3 -0
- data/lib/iex/resources/quote.rb +12 -2
- data/lib/iex/resources/resource.rb +12 -0
- 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/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/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/ref-data/exchange_symbols.yml +1926 -0
- data/spec/fixtures/iex/ref-data/isin.yml +9 -9
- 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 +96 -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/historical_prices_spec.rb +206 -0
- data/spec/iex/endpoints/income_spec.rb +31 -29
- data/spec/iex/endpoints/key_stats_spec.rb +1 -0
- data/spec/iex/endpoints/news_spec.rb +3 -0
- data/spec/iex/endpoints/quote_spec.rb +2 -0
- data/spec/iex/endpoints/ref_data_spec.rb +103 -8
- data/spec/iex/endpoints/stock_market_spec.rb +14 -0
- data/spec/iex/resources/resource_spec.rb +36 -0
- data/spec/spec_helper.rb +3 -3
- metadata +74 -9
- data/lib/iex/api/config.rb +0 -47
- data/spec/iex/config_spec.rb +0 -22
data/RELEASING.md
CHANGED
|
@@ -16,10 +16,10 @@ Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/
|
|
|
16
16
|
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
### 0.2.2 (
|
|
19
|
+
### 0.2.2 (2015/10/07)
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
|
22
|
+
Remove the line with "* Your contribution here.", since there will be no more contributions to this release.
|
|
23
23
|
|
|
24
24
|
Commit your changes.
|
|
25
25
|
|
data/iex-ruby-client.gemspec
CHANGED
|
@@ -9,13 +9,14 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.email = 'dblock@dblock.org'
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
|
11
11
|
s.required_rubygems_version = '>= 1.3.6'
|
|
12
|
+
s.required_ruby_version = '>= 2.3.0'
|
|
12
13
|
s.files = `git ls-files`.split("\n")
|
|
13
14
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
14
15
|
s.require_paths = ['lib']
|
|
15
16
|
s.homepage = 'http://github.com/dblock/iex-ruby-client'
|
|
16
17
|
s.licenses = ['MIT']
|
|
17
18
|
s.summary = 'IEX Finance API Ruby client with support for retrieving stock quotes.'
|
|
18
|
-
s.add_dependency 'faraday', '>= 0.
|
|
19
|
+
s.add_dependency 'faraday', '>= 0.17'
|
|
19
20
|
s.add_dependency 'faraday_middleware'
|
|
20
21
|
s.add_dependency 'hashie'
|
|
21
22
|
s.add_dependency 'money_helper'
|
data/lib/iex/api.rb
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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/historial_prices'
|
|
5
9
|
require_relative 'endpoints/income'
|
|
6
10
|
require_relative 'endpoints/largest_trades'
|
|
7
11
|
require_relative 'endpoints/logo'
|
|
@@ -12,6 +16,9 @@ require_relative 'endpoints/price'
|
|
|
12
16
|
require_relative 'endpoints/quote'
|
|
13
17
|
require_relative 'endpoints/sectors'
|
|
14
18
|
require_relative 'endpoints/crypto'
|
|
19
|
+
require_relative 'endpoints/ref_data'
|
|
20
|
+
require_relative 'endpoints/stock_market'
|
|
15
21
|
|
|
16
|
-
require_relative 'api/config'
|
|
22
|
+
require_relative 'api/config/logger'
|
|
23
|
+
require_relative 'api/config/client'
|
|
17
24
|
require_relative 'api/client'
|
data/lib/iex/api/client.rb
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
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::HistoricalPrices
|
|
9
16
|
include Endpoints::Income
|
|
10
17
|
include Endpoints::KeyStats
|
|
11
18
|
include Endpoints::LargestTrades
|
|
@@ -15,16 +22,22 @@ module IEX
|
|
|
15
22
|
include Endpoints::Price
|
|
16
23
|
include Endpoints::Quote
|
|
17
24
|
include Endpoints::Sectors
|
|
25
|
+
include Endpoints::RefData
|
|
26
|
+
include Endpoints::StockMarket
|
|
18
27
|
|
|
19
28
|
include Cloud::Connection
|
|
20
29
|
include Cloud::Request
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
attr_accessor(*Config::Client::ATTRIBUTES)
|
|
32
|
+
|
|
33
|
+
attr_reader :logger
|
|
23
34
|
|
|
24
35
|
def initialize(options = {})
|
|
25
|
-
Config::ATTRIBUTES.each do |key|
|
|
36
|
+
Config::Client::ATTRIBUTES.each do |key|
|
|
26
37
|
send("#{key}=", options[key] || IEX::Api.config.send(key))
|
|
27
38
|
end
|
|
39
|
+
@logger = Config::Logger.dup
|
|
40
|
+
@logger.instance = options[:logger] if options.key?(:logger)
|
|
28
41
|
end
|
|
29
42
|
end
|
|
30
43
|
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
|
@@ -8,28 +8,31 @@ 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[:headers]['Referer'] = referer if referer
|
|
19
|
+
options[:proxy] = proxy if proxy
|
|
20
|
+
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
request_options = {}
|
|
23
|
+
request_options[:timeout] = timeout if timeout
|
|
24
|
+
request_options[:open_timeout] = open_timeout if open_timeout
|
|
25
|
+
request_options[:params_encoder] = Faraday::FlatParamsEncoder
|
|
26
|
+
options[:request] = request_options if request_options.any?
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
::Faraday::Connection.new(endpoint, options) do |connection|
|
|
29
|
+
connection.use ::Faraday::Request::Multipart
|
|
30
|
+
connection.use ::Faraday::Request::UrlEncoded
|
|
31
|
+
connection.use ::IEX::Cloud::Response::RaiseError
|
|
32
|
+
connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/
|
|
33
|
+
connection.response(:logger, logger.instance, logger.options, &logger.proc) if logger.instance
|
|
34
|
+
connection.adapter ::Faraday.default_adapter
|
|
35
|
+
end
|
|
33
36
|
end
|
|
34
37
|
end
|
|
35
38
|
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
|
|
@@ -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,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,27 @@
|
|
|
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: Array(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
|
+
|
|
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
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -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
|
@@ -1,9 +1,13 @@
|
|
|
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'
|
|
4
7
|
require_relative 'resources/company'
|
|
5
8
|
require_relative 'resources/dividends'
|
|
6
9
|
require_relative 'resources/earnings'
|
|
10
|
+
require_relative 'resources/historical_prices'
|
|
7
11
|
require_relative 'resources/income'
|
|
8
12
|
require_relative 'resources/key_stats'
|
|
9
13
|
require_relative 'resources/largest_trades'
|
|
@@ -13,3 +17,5 @@ require_relative 'resources/ohlc'
|
|
|
13
17
|
require_relative 'resources/quote'
|
|
14
18
|
require_relative 'resources/sectors'
|
|
15
19
|
require_relative 'resources/crypto'
|
|
20
|
+
require_relative 'resources/symbol'
|
|
21
|
+
require_relative 'resources/symbols'
|
|
@@ -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
|