Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Yahoo Stock quotes

  • Loading branch information...
commit 621af1ae1aeb0a24d1500c2ee56505735aabf4c3 0 parents
@SatishTalim authored
Showing with 42 additions and 0 deletions.
  1. +20 −0 README.txt
  2. +22 −0 asqfy.rb
20 README.txt
@@ -0,0 +1,20 @@
+Accessing Stock Data from Yahoo
+
+A neat way to download stock data from Yahoo is using a URL like:
+
+http://finance.yahoo.com/d/quotes.csv?s= a BUNCH of STOCK SYMBOLS separated by "+" &f=a bunch of special tags
+
+(Refer http://www.gummy-stuff.org/Yahoo-data.htm for more details on the special tags.)
+
+asqfy.rb program accesses the stock data and displays the same.
+
+To run the program, type:
+
+ruby asqfy.rb INTC
+
+where INTC is the Stock symbol of the company Intel Corporation.
+
+Remember, that the stock symbols are the Nasdaq Stock Symbols - http://www.nasdaq.com/asp/comlookup.asp?page=empty
+
+
+Have fun!
22 asqfy.rb
@@ -0,0 +1,22 @@
+# asqfy.rb
+require 'open-uri'
+require 'csv'
+
+unless ARGV.length == 1
+ puts "Usage: ruby asqfy.rb INTC"
+ exit
+end
+
+url = "http://download.finance.yahoo.com/d/quotes.csv?s=#{ARGV[0]}&f=snl1d1t1c1ohgv&e=.csv"
+csv = CSV.parse(open(url).read)
+result = Array.new
+#parse csv data
+csv.each do |row|
+ result += row
+end
+
+puts "Information current as of " + result[4] + " on " + result[3]
+puts result[0] +"'s (" + result[1] + ") last trade was - $" + result[2] + " (increase of " + result[5] + ")"
+puts
+puts "Opened at $" + result[6]
+puts "Range for the day $" + result[8] + " - $" + result[7]
Please sign in to comment.
Something went wrong with that request. Please try again.