I don't know how to convert decimal to fractions (haven't had a need to yet), but I did explore a bit more with pulling down financial info via command line from finance.yahoo<dot>com and came across
this interesting page. It lists all the format options (something I was wondering about where to find) and has an example using wget instead of curl. The nice thing about the wget example is that it doesn't require any
for loops to handle multiple command line args.
Output was comma separated and I didn't care for that, but couldn't figure out how to change that output other than to pipe things into sed. Much simpler. New code:
Code:
#!/bin/bash
wget -q -O - "http://download.finance.yahoo.com/d/quotes.csv?f=nsl1&s='`echo ${@}`'" | \
sed 's/\,/\t/g'
And the result:
Code:
BASH:~/-> ./stock-quote2 cvx duk jnj
"Chevron Corporati" "CVX" 104.47
"Duke Energy Corpo" "DUK" 63.98
"Johnson & Johnson" "JNJ" 69.41
My only gripe is that on some securities, the quote is delayed a bit too much. While watching prices and trades in "real time" on several stocks this morning, I kept fetching the "last trade" quote from yahoo finance via the command line curl script. Some stock quotes were more than a half hour stale, maybe OK for casual "ball park" monitoring, but not so much on checking for any sudden and fast movements. Oddly, getting a quote directly from Yahoo's webpage was very close to real time (even said so.. "2:26PM EST - Nasdaq Real Time Price".