class Arbolito::Exchange::YahooFinance
Public Class Methods
find_current_rate(quote)
click to toggle source
DEPRECATED Yahoo Finance is not supported anymore by Yahoo so use Alpha Vantage API
# File lib/arbolito/exchange/yahoo_finance.rb, line 8 def find_current_rate(quote) warn "[DEPRECATION] Yahoo Finance `find_current_rate` is deprecated. Please use AlphaVantage `find_current_rate` instead." data = response(build_uri(quote)) values = { quote: quote, price: data[1], } build_rate(values) end
Private Class Methods
build_rate(values)
click to toggle source
# File lib/arbolito/exchange/yahoo_finance.rb, line 31 def build_rate(values) Currency::Rate.new( values[:price], values[:quote].to_hash ) end
build_uri(quote)
click to toggle source
# File lib/arbolito/exchange/yahoo_finance.rb, line 26 def build_uri(quote) param = "#{quote.from.upcase}#{quote.to.upcase}" URI("http://download.finance.yahoo.com/d/quotes.csv?s=#{param}=X&f=nl1d1t1") end
response(uri)
click to toggle source
# File lib/arbolito/exchange/yahoo_finance.rb, line 21 def response(uri) response = Net::HTTP.get(uri) data = response.gsub(/"|\\n/,'').split(',') end