Get Stock Information (Tcl program by Luis F. Guzman)

Get Stock Information (gesi): Tcl program by Luis F. Guzmán.

This was my first Tcl program, but it has proven to be quite useful. It extracts information about stocks from yahoo.com , and it prints it to the standard output. The user can specify the information required through command options. Below are the synopsis and the options supported by gesi:

    SYNOPSIS: gesi ?-s? ?-l? ?-d? ?-t? ?-c? ?-o? ?-h? ?-g? ?-v? symbol ?symbol...?
        where:
            s = stock symbol
            l = last price
            d = last price date
            t = last price time
            c = change since yesterday
            o = open
            h = high for today
            g = low for today
            v = volume
    
The order in which the options are provided is also important. For example:
    $ gesi -s -p -v -t -d rhat
    
will result in:
    "RHAT",71.625,2065800,"4:00PM","2/22/2000"
    
while
    $ gesi -d -t -s -p -v rhat
    
will result in:
    "2/22/2000","4:00PM","RHAT",71.625,2065800
    

Also, gesi is case independent. The stock symbols can be typed with either upper or lower case. If more than one stock symbol is entered, gesi will print a stock record per line. The order in which the symbols are typed also counts. These features and the default options are illustrated below.

    $ gesi RHAT MSFT GE
    "RHAT",71.625,"2/22/2000","4:00PM",+0.125,73,73.875,67,2065800
    "MSFT",93.8125,"2/22/2000","4:01PM",-1.25,95.125,97.125,92.8125,33148100
    "GE",129.625,"2/22/2000","4:25PM",+4.5,126.25,130,125.0625,9077000
    
or
    $ gesi -s -p GE RHAT MSFT
    "GE",129.625
    "RHAT",71.625
    "MSFT",93.8125
    

I haven't written a man page for gesi yet, but if an invalid option is typed or if gesi is typed without arguments, the synopsis and options are typed to the standard output. This page should also be useful.

Finally, I want to mention that my inspiration for writing this program was a five line similar example in a book by Brian W. Kernighan and Rob Pike: The Practice of Programming . It is a good book.

View the Tcl code.
Download gesi (gz) or gesi (zip).


Go to Author's home page Luis F. Guzmán
Mar. 27, 2004 1:26 pm US/Eastern