Get Stock Quotes From Command Line
When I conned my way into my first professional programming gig, I didn't really think much about money -- just that I was getting my foot in the door. But as my career has gone on, I've been more aware of money, investing, and retirement. I've recently
regretfully gotten into stock trading -- you can imagine how many times a day I hit the ole F5 to see updated quotes, praying my investments push higher.
I also spend a large part of my day in iTerm, so switching back and forth between the browser and the terminal is time-consuming and annoying. I looked for a way to get stock quotes from the command line, and thanks to Yahoo, it's a simple process!
Get Current Price
Since cURL is amazing and easy to use, we'll roll with that:
#One stock curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1' #Multiple stocks, separated by comma curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl,meip&f=l1'
Yahoo! Finance's information, which is fairly "real time", provides quotes within the
s parameter and the
f parameter of
l1 provides the formatted result.
Get Current Price with Change
If you'd like to know the amount changed on the day, tag
c1 to the
curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1c1'
Not needing to jump over to the browser to get stock quotes has been nice...especially if the market is having a down day and you don't want to see a screen of red. Booooo.