How to monitor stock quotes from the command line on Linux

If you are one of those stock investors or traders, monitoring the stock market will be one of your daily routines. Most likely you will be using an online trading platform which comes with some fancy real-time charts and all sort of advanced stock analysis and tracking tools. While such sophisticated market research tools are a must for any serious stock investors to read the market, monitoring the latest stock quotes still goes a long way toward building a profitable portfolio.

If you are a full-time system admin constantly sitting in front of terminals while trading stocks as a hobby during the day, a simple command-line tool that shows real-time stock quotes will be a blessing for you.

In this tutorial, let me introduce a neat command-line tool that allows you to monitor stock quotes from the command line on Linux.

This tool is called Mop. Written in Go, this lightweight command-line tool is extremely handy for tracking the latest stock quotes from the U.S. markets. You can easily customize the list of stocks to monitor, and it shows the latest stock quotes in ncurses-based, easy-to-read interface.

Note: Mop obtains the latest stock quotes via Yahoo! Finance API. Be aware that their stock quotes are known to be delayed by 15 minutes. So if you are looking for "real-time" stock quotes with zero delay, Mop is not a tool for you. Such "live" stock quote feeds are usually available for a fee via some proprietary closed-door interface. With that being said, let's see how you can use Mop under Linux environment.

Install Mop on Linux

Since Mop is implemented in Go, you will need to install Go language first. If you don't have Go installed, follow this guide to install Go on your Linux platform. Make sure to set GOPATH environment variable as described in the guide.

Once Go is installed, proceed to install Mop as follows.

Debian, Ubuntu or Linux Mint

$ sudo apt-get install git
$ go get github.com/michaeldv/mop
$ cd $GOPATH/src/github.com/michaeldv/mop
$ make install

Fedora, CentOS, RHEL

$ sudo yum install git
$ go get github.com/michaeldv/mop
$ cd $GOPATH/src/github.com/michaeldv/mop
$ make install

The above commands will install Mop under $GOPATH/bin.

Now edit your .bashrc to include $GOPATH/bin in your PATH variable.

export PATH="$PATH:$GOPATH/bin"
$ source ~/.bashrc

Monitor Stock Quotes from the Command Line with Mop

To launch Mod, simply run the command called cmd.

$ cmd

At the first launch, you will see a few stock tickers which Mop comes pre-configured with.

The quotes show information like the latest price, %change, daily low/high, 52-week low/high, dividend, and annual yield. Mop obtains market overview information from CNN, and individual stock quotes from Yahoo! Finance. The stock quote information updates itself within the terminal periodically.

Customize Stock Quotes in Mop

Let's try customizing the stock list. Mop provides easy-to-remember shortcuts for this: '+' to add a new stock, and '-' to remove a stock.

To add a new stock, press '+', and type a stock ticker symbol to add (e.g., MSFT). You can add more than one stock at once by typing a comma-separated list of tickers (e.g., "MSFT, AMZN, TSLA").

Removing stocks from the list can be done similarly by pressing '-'.

Sort Stock Quotes in Mop

You can sort the stock quote list based on any column. To sort, press 'o', and use left/right key to choose the column to sort by. When a particular column is chosen, you can sort the list either in increasing order or in decreasing order by pressing ENTER.

By pressing 'g', you can group your stocks based on whether they are advancing or declining for the day. Advancing issues are represented in green color, while declining issues are colored in white.

If you want to access help page, simply press '?'.

Conclusion

As you can see, Mop is a lightweight, yet extremely handy stock monitoring tool. Of course you can easily access stock quotes information elsewhere, from online websites, your smartphone, etc. However, if you spend a great deal of your time in a terminal environment, Mop can easily fit in to your workspace, hopefully without distracting must of your workflow. Just let it run and continuously update market data in one of your terminals, and be done with it.

Happy trading!

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

7 thoughts on “How to monitor stock quotes from the command line on Linux

    • Thanks. But then you will have to type the command again and again to obtain the current snapshot. For me, something that updates quotes continuously in the background like Mop does is more convenient. Besides Mop is already lightweight enough.

  1. This is pretty helpful, thank you! This solves 70% of what I was trying to achieve. could this be easily extended basically just reading the ofx or cvs file (the format google finance lets you export in) and then also show you day's p/l and overall gain for your portfolio.

  2. server certificate verification failed, got around it by typing the following line
    export GIT_SSL_NO_VERIFY=1

    thanks for this, cool program

Leave a comment

Your email address will not be published. Required fields are marked *