#!/usr/bin/env python2 import os, sys, re, traceback, getopt, time, urllib, string Y2KCUTOFF=60 __version__ = "0.1" def showVersion(): print 'pyQ v'+__version__+', by Rimon Barr:' print 'Python Yahoo Quote fetching utility' def showUsage(): print showVersion() print print 'Usage: pyQ [-i] [start_date [end_date]] ticker [ticker...]' print ' rimdu -h | -v' print print ' -h, -?, --help display this help information' print ' -v, --version display version' print ' -i, --stdin tickers fed on stdin, one per line' print print ' date formats are yyyymmdd' print ' if enddate is omitted, it is assume to be the same as startdate' print ' if startdate is omitted, we use *current* stock tables' print ' and otherwise, use historical stock tables.' print ' (current stock tables will give previous close price before' print ' market closing time.)' print ' tickers are exactly what you would type at finance.yahoo.com' print ' output format: "ticker, date (yyyymmdd), open, high, low, close, vol"' print ' date formats are yyyymmdd' print ' tickers are exactly what you would type at finance.yahoo.com' print ' output format: ticker, date, open, high, low, close, volume' print print 'Send comments, suggestions and bug reports to .' print def usageError(): print 'rimdu: command syntax error' print 'Try `rimdu --help\' for more information.' def isInt(i): try: int(i) return 1 except: return 0 # convert yyyymmdd string to tuple (yyyy, mm, dd) def parseDate(d): return (d[-6:-4], d[-4:-2], d[-2:]) def yy2yyyy(yy): global Y2KCUTOFF; yy=int(yy) % 100 if yy