Module: YahooFinance
- Defined in:
- lib/finmodeling/yahoo_finance_helpers.rb
Class Method Summary collapse
Class Method Details
.get_market_cap(stock_symbol) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/finmodeling/yahoo_finance_helpers.rb', line 2 def YahooFinance.get_market_cap(stock_symbol) quote = YahooFinance::get_quotes(YahooFinance::ExtendedQuote, stock_symbol).values.first m = /([0-9\.]*)([MB])/.match(quote.marketCap) mkt_cap = m[1].to_f case when m[2]=="M" mkt_cap *= 1000*1000 when m[2]=="B" mkt_cap *= 1000*1000*1000 end mkt_cap end |
.get_num_shares(stock_symbol) ⇒ Object
15 16 17 18 19 |
# File 'lib/finmodeling/yahoo_finance_helpers.rb', line 15 def YahooFinance.get_num_shares(stock_symbol) mkt_cap = YahooFinance.get_market_cap(stock_symbol) share_price = YahooFinance::get_quotes(YahooFinance::StandardQuote, stock_symbol).values.last.lastTrade.to_f mkt_cap / share_price end |