Created
August 31, 2013 06:43
-
-
Save nickdesaulniers/6396604 to your computer and use it in GitHub Desktop.
coffee yahoo.coffee tsla 08-27-2013 08-29-2013
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
http = require 'http' | |
csv = require 'csv' | |
if process.argv.length is 2 | |
url = 'http://ichart.finance.yahoo.com/table.csv?s=TSLA&a=07&b=28&c=2013&d=07&e=29&f=2013&g=d' | |
else if process.argv.length is 5 | |
[_, _, symbol, start, end] = process.argv | |
[[a, b, c], [d, e, f]] = [start.split('-'), end.split('-')] | |
console.log a, b, c, d, e, f | |
url = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=#{--a}&b=#{b}&c=#{c}&d=#{--d}&e=#{e}&f=#{f}&g=d" | |
else | |
console.log 'usage: coffee yahoo.coffee [symbol] [start date] [end date]' | |
process.exit 1 | |
console.log "hitting #{url}\n" | |
http.get url, (res) -> | |
if res.statusCode is 200 | |
console.log "#{symbol.toUpperCase()} : #{new Date()}" | |
csv().from(res).transform (row, rowNum) -> | |
console.log row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment