Last active
September 29, 2015 17:38
-
-
Save captainpete/1639522 to your computer and use it in GitHub Desktop.
Yahoo Finance currency conversion method in Ruby (for prototyping use, budget but works)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
# Cheers to Greg on StackOverflow | |
# http://stackoverflow.com/questions/181990/programmatically-access-currency-exchange-rates | |
class Yahoo | |
def self.fetch(code = 'AUDUSD') | |
csv = `curl -q "http://download.finance.yahoo.com/d/quotes.csv?s=#{code}=X&f=sl1d1t1ba&e=.csv"` | |
values = CSV.parse(csv) | |
values[0][1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment