iex-ruby-client 1.1.0 → 1.4.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/.env.sample +2 -0
- data/.github/FUNDING.yml +1 -0
- data/.rubocop_todo.yml +0 -8
- data/CHANGELOG.md +48 -10
- data/Dangerfile +2 -2
- data/Gemfile +3 -2
- data/README.md +260 -11
- 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/request.rb +1 -1
- 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/chart.rb +1 -1
- 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/historial_prices.rb +30 -0
- data/lib/iex/endpoints/income.rb +1 -1
- 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 +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/chart.rb +8 -13
- 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/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/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/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/invalid.yml +47 -47
- data/spec/fixtures/iex/income/msft.yml +54 -51
- data/spec/fixtures/iex/income/nsrgy.yml +55 -0
- 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 +97 -14
- 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/chart_spec.rb +7 -7
- data/spec/iex/endpoints/historical_prices_spec.rb +206 -0
- data/spec/iex/endpoints/income_spec.rb +41 -30
- data/spec/iex/endpoints/key_stats_spec.rb +1 -0
- data/spec/iex/endpoints/quote_spec.rb +2 -0
- data/spec/iex/endpoints/ref_data_spec.rb +76 -0
- 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 -2
- data/spec/support/vcr.rb +3 -0
- metadata +82 -14
- data/lib/iex/api/config.rb +0 -45
- data/spec/iex/config_spec.rb +0 -22
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: 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
|
+
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
@@ -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
|
@@ -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
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class CashFlow < Resource
|
4
|
+
property 'report_date', from: 'reportDate'
|
5
|
+
property 'fiscal_date', from: 'fiscalDate'
|
6
|
+
property 'currency'
|
7
|
+
property 'net_income', from: 'netIncome'
|
8
|
+
property 'net_income_dollar', from: 'netIncome', with: ->(v) { to_dollar(amount: v) }
|
9
|
+
property 'depreciation'
|
10
|
+
property 'depreciation_dollar', from: 'depreciation', with: ->(v) { to_dollar(amount: v) }
|
11
|
+
property 'changes_in_receivables', from: 'changesInReceivables'
|
12
|
+
property 'changes_in_receivables_dollar', from: 'changesInReceivables', with: ->(v) { to_dollar(amount: v) }
|
13
|
+
property 'changes_in_inventories', from: 'changesInInventories'
|
14
|
+
property 'changes_in_inventories_dollar', from: 'changesInInventories', with: ->(v) { to_dollar(amount: v) }
|
15
|
+
property 'cash_change', from: 'cashChange'
|
16
|
+
property 'cash_change_dollar', from: 'cashChange', with: ->(v) { to_dollar(amount: v) }
|
17
|
+
property 'cash_flow', from: 'cashFlow'
|
18
|
+
property 'cash_flow_dollar', from: 'cashFlow', with: ->(v) { to_dollar(amount: v) }
|
19
|
+
property 'capital_expenditures', from: 'capitalExpenditures'
|
20
|
+
property 'capital_expenditures_dollar', from: 'capitalExpenditures', with: ->(v) { to_dollar(amount: v) }
|
21
|
+
property 'investments'
|
22
|
+
property 'investments_dollar', from: 'investments', with: ->(v) { to_dollar(amount: v) }
|
23
|
+
property 'investing_activity_other', from: 'investingActivityOther'
|
24
|
+
property 'investing_activity_other_dollar', from: 'investingActivityOther', with: ->(v) { to_dollar(amount: v) }
|
25
|
+
property 'total_investing_cash_flows', from: 'totalInvestingCashFlows'
|
26
|
+
property 'total_investing_cash_flows_dollar', from: 'totalInvestingCashFlows', with: ->(v) { to_dollar(amount: v) }
|
27
|
+
property 'dividends_paid', from: 'dividendsPaid'
|
28
|
+
property 'dividends_paid_dollar', from: 'dividendsPaid', with: ->(v) { to_dollar(amount: v) }
|
29
|
+
property 'net_borrowings', from: 'netBorrowings'
|
30
|
+
property 'net_borrowings_dollar', from: 'netBorrowings', with: ->(v) { to_dollar(amount: v) }
|
31
|
+
property 'other_financing_cash_flows', from: 'otherFinancingCashFlows'
|
32
|
+
property 'other_financing_cash_flows_dollar', from: 'otherFinancingCashFlows', with: ->(v) { to_dollar(amount: v) }
|
33
|
+
property 'cash_flow_financing', from: 'cashFlowFinancing'
|
34
|
+
property 'cash_flow_financing_dollar', from: 'cashFlowFinancing', with: ->(v) { to_dollar(amount: v) }
|
35
|
+
property 'exchange_rate_effect', from: 'exchangeRateEffect'
|
36
|
+
property 'exchange_rate_effect_dollar', from: 'exchangeRateEffect', with: ->(v) { to_dollar(amount: v) }
|
37
|
+
|
38
|
+
def initialize(data = {})
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/iex/resources/chart.rb
CHANGED
@@ -5,15 +5,18 @@ 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|
|
@@ -23,22 +26,14 @@ module IEX
|
|
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,31 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class HistorialPrices < Resource
|
4
|
+
property 'date'
|
5
|
+
property 'open'
|
6
|
+
property 'open_dollar', from: 'open', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
7
|
+
property 'close'
|
8
|
+
property 'close_dollar', from: 'close', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
9
|
+
property 'high'
|
10
|
+
property 'high_dollar', from: 'high', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
11
|
+
property 'low'
|
12
|
+
property 'low_dollar', from: 'low', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
13
|
+
property 'volume'
|
14
|
+
property 'u_open', from: 'uOpen'
|
15
|
+
property 'u_open_dollar', from: 'uOpen', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
16
|
+
property 'u_close', from: 'uClose'
|
17
|
+
property 'u_close_dollar', from: 'uClose', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
18
|
+
property 'u_low', from: 'uLow'
|
19
|
+
property 'u_low_dollar', from: 'uLow', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
20
|
+
property 'u_high', from: 'uHigh'
|
21
|
+
property 'u_high_dollar', from: 'uHigh', with: ->(v) { to_dollar(amount: v, ignore_cents: false) }
|
22
|
+
property 'u_volume', from: 'uVolume'
|
23
|
+
property 'change'
|
24
|
+
property 'change_percent', from: 'changePercent'
|
25
|
+
property 'change_percent_s', from: 'changePercent', with: ->(v) { percentage_to_string(v) }
|
26
|
+
property 'label'
|
27
|
+
property 'change_over_time', from: 'changeOverTime'
|
28
|
+
property 'change_over_time_s', from: 'changeOverTime', with: ->(v) { percentage_to_string(v) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/iex/resources/income.rb
CHANGED
@@ -2,6 +2,8 @@ module IEX
|
|
2
2
|
module Resources
|
3
3
|
class Income < Resource
|
4
4
|
property 'report_date', from: 'reportDate'
|
5
|
+
property 'fiscal_date', from: 'fiscalDate'
|
6
|
+
property 'currency'
|
5
7
|
property 'total_revenue', from: 'totalRevenue'
|
6
8
|
property 'total_revenue_dollar', from: 'totalRevenue', with: ->(v) { to_dollar(amount: v) }
|
7
9
|
property 'cost_of_revenue', from: 'costOfRevenue'
|
@@ -8,7 +8,7 @@ module IEX
|
|
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'
|
data/lib/iex/resources/quote.rb
CHANGED
@@ -24,8 +24,18 @@ module IEX
|
|
24
24
|
property 'iex_last_updated_t', from: 'iexLastUpdated', with: ->(v) { v&.positive? ? Time.at(v / 1000) : nil } # last update time of the data
|
25
25
|
property 'delayed_price', from: 'delayedPrice' # 15 minute delayed market price
|
26
26
|
property 'delayed_price_time', from: 'delayedPriceTime' # time of the delayed market price
|
27
|
-
property 'extended_price', from: 'extendedPrice' #
|
28
|
-
property '
|
27
|
+
property 'extended_price', from: 'extendedPrice' # the pre market and post market price
|
28
|
+
property 'extended_change_percent', from: 'extendedChangePercent' # price change percent between extended_price and latest_price
|
29
|
+
property 'extended_change_percent_s', from: 'extendedChangePercent', with: lambda { |v|
|
30
|
+
if v
|
31
|
+
[
|
32
|
+
v.positive? ? '+' : '',
|
33
|
+
format('%.2f', v * 100),
|
34
|
+
'%'
|
35
|
+
].join
|
36
|
+
end
|
37
|
+
} # change in percent as a String with a leading + or - sign
|
38
|
+
property 'extended_price_time', from: 'extendedPriceTime' # the last update time of extended_price
|
29
39
|
property 'previous_close', from: 'previousClose' # adjusted close price of the last trading day of the stock
|
30
40
|
property 'change' # change in value, calculated using calculation_price from previous_close
|
31
41
|
property 'change_percent', from: 'changePercent' # change in percent, calculated using calculation_price from previous_close
|
@@ -14,6 +14,18 @@ module IEX
|
|
14
14
|
].join
|
15
15
|
end
|
16
16
|
|
17
|
+
# Useful for values that are already a percent but we want to convert into a 2 decimal place string
|
18
|
+
def self.percentage_to_string(float_percent)
|
19
|
+
return unless float_percent.is_a? Numeric
|
20
|
+
return '+0.00%' if float_percent.zero?
|
21
|
+
|
22
|
+
[
|
23
|
+
float_percent.positive? ? '+' : '',
|
24
|
+
format('%.2f', float_percent),
|
25
|
+
'%'
|
26
|
+
].join
|
27
|
+
end
|
28
|
+
|
17
29
|
def self.to_dollar(amount:, ignore_cents: true)
|
18
30
|
MoneyHelper.money_to_text(amount, 'USD', nil, no_cents: ignore_cents)
|
19
31
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module IEX
|
2
|
+
module Resources
|
3
|
+
class Symbols < Resource
|
4
|
+
property 'symbol'
|
5
|
+
property 'exchange'
|
6
|
+
property 'name'
|
7
|
+
property 'date', transform_with: ->(v) { Date.parse(v) }
|
8
|
+
property 'enabled', from: 'isEnabled'
|
9
|
+
property 'type'
|
10
|
+
property 'region'
|
11
|
+
property 'currency'
|
12
|
+
property 'iex_id', from: 'iexId'
|
13
|
+
property 'figi'
|
14
|
+
property 'cik'
|
15
|
+
|
16
|
+
alias :enabled? enabled
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|