[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [RT] Downloading Yahoo Quotes



PureBytes Links

Trading Reference Links

Hi Gary,

I don't have Linux, but thanks for the info.  I'm a VB guy and read a little
C.

Let me ask a followup question:

How do you know and where do you find out what the various parameters mean
when invoking http://chart.yahoo.com/table.csv?  For instance what do &g &q
&y &z &x mean and where would you find out if you didn't know?  I've
searched Yahoo for 'quote specifications', 'quote format', 'download
specifications', etc. and find nothing.  Its obvious &a ... &f are the mo,
da, yr of the starting and ending dates, but I'm not sure on the rest.

I had another question but it escapes me right now ...

Brooks

-----Original Message-----
From: Gary Funck [mailto:gary@xxxxxxxxxxxx]
Sent: Friday, July 20, 2001 3:17 AM
To: realtraders@xxxxxxxxxxxxxxx
Subject: RE: [RT] Downloading Yahoo Quotes


Got Linux?


The `get_daily' script below takes one or more Yahoo! stock/index
symbols on the command line, and builds a data file, $sym.dat, for each
symbol, containing the data downloaded from Yahoo! It doesn't first
check to see if the data file already, exists, and to begin where it
left off - it downloads the entire file again.

---- get_daily ----
#!/bin/csh -f
# get_daily symbols ...
set dt = `date +"&d=%m&e=%d&f=%Y"`
foreach x ($*)
    set sym = `echo $x | sed -e 's/^^//' | tr "[A-Z]" "[a-z]"`
    lynx -dump
'http://chart.yahoo.com/table.csv?s='"$x"'&a=1&b=10&c=28'"$dt"'&g=d&q=q&
y=0&z='"$x"'&x=.csv'  | awk -f yahoo_data.awk > $sym.dat
end

---- yahoo_data.awk ---
BEGIN { FS = ","; mnames = "JanFebMarAprMayJunJulAugSepOctNovDec" }
NR > 1 {
#Date,Open,High,Low,Close,Volume
ddate = $1; dopen = $2; dhigh = $3; dlow = $4; dclose = $5; dvolume = $6
   nf = split(ddate, fld, "-")
   if (nf == 1) {
       nf = split(ddate, fld, " ")
       if (nf == 2) {
           fld[3] = fld[2]
           fld[2] = fld[1]
           fld[1] = "01"
           nf = 3
       }
   }
   if (nf != 3) {
      printf "date in error on line %d\n", NR
      printf "|%s|\n", $0
      next
   }
   dd = fld[1] + 0
   mm = int((index(mnames, fld[2]) + 2) / 3)
   if (mm < 1 || mm > 12) {
      printf "date in error on line %d\n", NR
      printf "|%s|\n", $0
      next
   }
   yy = fld[3] + 1900
   if (yy < 1920) yy += 100
   yymmdd = yy * 10000 + mm * 100  + dd
   printf "%8d%12.4f%12.4f%12.4f%12.4f%12d\n", \
       yymmdd, dopen, dhigh, dlow, dclose, dvolume | "sort +0n"
}


To unsubscribe from this group, send an email to:
realtraders-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/