pyq
Syntax:
pyQ v#.##, by Rimon Barr:
Python Yahoo Quote fetching utility
Usage: pyQ [-i] [start_date [end_date]] ticker [ticker...]
rimdu -h | -v
-h, -?, --help display this help information
-v, --version display version
-i, --stdin tickers fed on stdin, one per line
date formats are yyyymmdd
if enddate is omitted, it is assume to be the same as startdate
if startdate is omitted, we use *current* stock tables
and otherwise, use historical stock tables.
(current stock tables will give previous close price before
market closing time.)
tickers are exactly what you would type at finance.yahoo.com
output format is "ticker, date (yyyymmdd), open, high, low, close, volume"
Send comments, suggestions and bug reports to <barr-AT-cs.cornell.edu>.
The stock data is output in the format:
ticker, date (yyyymmdd), open, high, low, close, volume
Sample output:
For example, typing in the following command:
pyq 20010401 20010407 ibm t
retrieves the data for IBM and AT&T for the first week in April 2001:
ibm,20010406,97.6322,99.6247,96.0382,97.5824,13424200
ibm,20010405,95.4404,99.6247,95.1715,97.8414,12506100
ibm,20010404,90.1105,93.697,89.712,91.6547,13515600
ibm,20010403,94.245,94.2948,89.7618,90.0508,13330000
ibm,20010402,97.0843,97.7318,93.2288,94.3047,8787000
t,20010406,15.6928,15.7002,15.1323,15.3191,8679900
t,20010405,15.3565,16.0664,14.9455,16.0664,10263900
t,20010404,14.9754,15.3266,14.9455,14.9679,10020400
t,20010403,15.3938,15.5059,14.8334,14.9754,15605300
t,20010402,15.9169,16.4326,15.5134,15.7525,13925000
The following command takes ticker symbols from a file, and output today's
values.
pyq -i < tickers
Giving a similar kind of output:
ibm,20020110,123.75,124.00,121.76,124.49,2964400
t,20020110,18.70,18.87,18.52,18.70,2349400
f,20020110,15.85,15.90,15.10,16.31,5089300
x,20020110,18.31,18.38,18.01,18.19,100300
Note, that if the market close data is unavailable, the previous
close price is listed. In general, the following two commands do not
necessarily agree, even if yymmdd is today.
pyq yymmdd ibm
pyq ibm
The first command uses Yahoo historical data tables, while the second one uses
Yahoo current stock quotes. When downloading many stock tickers the second
method is much faster as stock requests can be aggregated. However, if you
want to be sure that you have market close conditions, use the first version.
License:
This software is distributed under the terms of the GNU General Public
License.
Download:
The script merely requires python to run. Enjoy.
15/03/07 -
pyq v0.7
06/02/07 -
pyq v0.6
27/01/05 -
pyq v0.5
29/09/04 -
pyq v0.4
31/10/02 -
pyq v0.3
14/10/02 -
pyq v0.02
10/01/02 -
pyq v0.01