Skip to content

Instantly share code, notes, and snippets.

@captainpete
Last active September 29, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captainpete/1639522 to your computer and use it in GitHub Desktop.
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)
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