See Share Quotes In Terminal / Geek Tool 4

Trick

Share
See Share Quotes In Terminal / Geek Tool

Hey

This is a quick Terminal trick that I think is quite useful, especially if you are into stocks and shares and want to know the latest price of your portfolio. This tip is going to show you how you can pull a stock/share quote into Terminal. I’ll then go a bit further and show you how you can put the price in a form that is easily read for use in GeekTool or something similar.

To pull the price the trick is going to use a Terminal program called curl. Its used to download web pages off the Internet. To get the stock price we are going to use Yahoo Finance, they provide stock quotes in an easy format that can be read easily by Terminal, an added bonus is that it doesn’t need any formatting which makes our lives a bit easier.

To grab a share quote simply type or copy and paste the following into Terminal:

curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1'

Just replace “aapl” with the quote you are looking at. Yahoo Finance pulls quote from the NASDAQ, so stocks on other markets need to have the market identifier so a stock like HSBC is “hsba.l” within the URL. If you are stuck search for your quote within Yahoo and find the quote next to the name on the correct page.

The code, so far, just displays the stock quote. This at the moment isn’t that useful and in something like GeekTool you need a little bit more information. To do this we are just going to add the stock name to the quote.

echo Apple: $`curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1'`

When the code runs is should display something similar to the following:

Apple: $249.10

Just replace the name, currency symbol if needed and the quote and you can customise it to everything you need. Simple.

If you have any questions or comments, please leave one below.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips

4 Responses to “See Share Quotes In Terminal / Geek Tool”

  1. 1

    Thanks dude, for all the awesome tricks ;)

    Comment By Emanuel Martinez on August 18th, at 1:49 am

  2. 2

    James: Do you know the equivalent URL for Futures (such as Gold and Oil)? Also the big numbers like the N&P or Dow? In your investigations did you find a good way to access the underlining data base to take a good look at it?

    Comment By Paul on August 18th, at 7:26 pm

  3. 3

    The Dow is ^dji and gold is GCQ10.CMX . Those two quotes will get you both quotes respectidly. If you want to find more quotes. Use Yahoo Finance as usual and find your respected quote. Then copy the code (in brackets next to the name) and use that in the Terminal script.

    Comment By admin on August 18th, at 7:34 pm

  4. 4

    Anyone know how to use this for historical data? I want to just pull some quotes for a few days in the past….

    Comment By Sean on December 18th, at 8:22 pm