Tracking your stock portfolio using Google Docs

Posted on September 12th, 2008 in Learn Excel , ideas , personal finance - 11 comments

By integrating services like Google Finance, Search in to spreadsheet functions, google docs has paved the way for endless possibilities.

google-docs-stock-portfolio-historical-quotes

Google spreadsheet function GoogleFinance() can be used to build stock portfolio tracker sheet that can fetch historical stock quotes to tell how your money is doing.

Click here to see the stock portfolio tracker sheet on Google docs.

Here is how you can create a simple stock / mutual fund / asset tracker application using Google docs:

1. Create the stock portfolio tracker table structure

A typical portfolio tracker has the following columns:

  • Name of the asset – Stock name, MF name etc.
  • # of units / shares held
  • stock-mf-portfolio-tracker-outline

  • Purchase date
  • Purchase price (will be fetched from GoogleFinance using formulas)
  • Current price (also fetched from GoogleFinance)
  • Gain / Loss % and values

2. The formulas to fetch current and historical quotes

Assuming the stock / company symbol as per the listing exchange is in cell B2 and purchase date is in cell C2, we can fetch historical stock price for that symbol on purchase date by the formula,

=GoogleFinance(B2,"price",C2)

But there is a problem with this formula as result is not single cell, but a 2×2 range as shown on the right. historic-stock-quotes-google-finance-howto-speadsheetIt returns date and price in 2 columns. We are only interested in the price of the stock on that date (ie bottom right cell in the returned range). We can fetch that value by using concatenate(), find() and mid() functions to parse out the required text. So the formula now becomes:

historical-stock-pricesFirst in cell M2 we enter =concatenate(GoogleFinance(B2,"price",C2)) and then in the cell where the historical price is needed we enter =value(mid(M2,3+find(":",M2,1+find(":",M2)),99))

In order to fetch the current stock price we just need to enter =googlefinance(B2)

Note: Make sure that you use correct symbols for stocks / mutual funds and mm/dd/yyyy date formats for purchase date.

3. Finally add Gain / Loss calculations

This is a simple step where in we compute value on purchase and value today and then use them to compute Gain / Loss. We can modify the table to add some conditional formatting so that when a loss is made the numbers are in red color.

4. Enhancing the Portfolio Tracker

That is all. This is how we can create a simple stock portfolio tracker. But there are several interesting ways in which you can extend this.

  • Add a spreadsheet form and use that to record stock purchases.
  • Perform a thorough analysis of your holdings, research the companies, price trends etc. without leaving the spreadsheet.
  • Get alerts when a price threshold is met, through RSS / email updates
  • Add some graphs to see how / where your money going

Looking for a way to track stock / MF performance from excel, read this.

| More
Subscribe for PHD Email updates and get a free excel e-book with 95 tips & tricks

Comments
Sal September 12, 2008

For step 2 try =index(googlefinance(…),2,2).

Much cleaner.

Chandoo September 12, 2008

@Sai… thanks for that. I totally forgot about index, tried vlookup but it wouldn’t accept googlefinance output as an input. I have made this change to the shared google doc. thanks for that wonderful tip once again.

Mike September 13, 2008

I think this stuff is cool BUT, too much personal information is being trusted online with Google. Too many docs and spreadsheets that have personal information – being trusted to Google. There is something unnerving about that.

Gokul September 22, 2008

Gr8 info … Does this also give live prices for Indian stock market .. or is this only for the US …

Abhishek October 18, 2009

How can this be done??
Get alerts when a price threshold is met, through RSS / email updates

Chandoo October 19, 2009

@Gokul.. you can do this with Indian stock markets as well. Google finance supports BSE codes…

@Abhishek..you can use the same approach. Add an extra column for price thresholds. And use IF formula to check if the threshold is met. Then publish the IF results column as a text or RSS and subscribe to it. However, the stock quotes are not real time and docs publishing options slow it down even more. If I were you, I wouldnt use this approach. Rather, I would write a small PHP script or java snippet to monitor the market.

Manish February 11, 2010

Chandoo,
Any help with the PHP script or java snippet ?
Thanks

Chandoo February 12, 2010

@Manish.. nopes, I never experimented with it. You can give it a try and tell us how to do it.

Arun Singla March 15, 2010

Chandoo:
Google docs supporting BSE. Any way to tracking live stock data on excel ? (just the data that I need)
Also, I would be interested in tracking bond market data such a short rates, long rates, TED spread & some smart money indicators. Do let me know if you have pointers.

Take care
Singla

RSS feed for comments on this post. TrackBack URI

Leave a comment

   Name (required)

   E-mail (required, never displayed)

   URL


If you have a question, please ask in the forums

Recommended Excel, Charting, VBA books