Skip to content

Instantly share code, notes, and snippets.

@niltonvasques
Created August 25, 2015 02:56
Show Gist options
  • Select an option

  • Save niltonvasques/72936a81546d3234c3fa to your computer and use it in GitHub Desktop.

Select an option

Save niltonvasques/72936a81546d3234c3fa to your computer and use it in GitHub Desktop.
Update investments quotes in a libreoffice spreadsheet using ruby and yahoo finances gem
require 'yahoo-finance'
stocks = ["PETR3.SA"]
yahoo_client = YahooFinance::Client.new
data = yahoo_client.quotes( stocks, [:close])
File.open("quotes.csv", "w+") do |file|
stocks.size.times do |x|
file.puts "\"#{stocks[x]}\",#{data[x].close}"
end
end
exec("libreoffice --calc -o Investimentos.ods")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment