Search

Share

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

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.

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
• 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. It 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:

First 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.
• Add some graphs to see how / where your money going

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

### Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

### Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

### How to calculate WEEKNUMBER in Month / Quarter / Year with Excel?

Let’s say you have daily data and your boss wants to see the trends by week in month or week in quarter? How do you calculate the week number in a month or quarter? In this article, let me explain the logic and formulas we can use Excel for this.

## Related Tips

Charts and Graphs

Learn Excel

Learn Excel

Learn Excel

Excel Howtos

### How to fix SPILL Error in Excel Tables (3 easy solutions)

Financial Modeling

### Loan Amortization Schedule in Excel – FREE Template

1. Sal says:

Much cleaner.

2. Chandoo says:

@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.

3. Mike says:

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.

4. Gokul says:

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

6. Abhishek says:

How can this be done??

7. Chandoo says:

@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.

• Jay says:

Hi Chandoo,

How are emails sent with that IF formula? I am very familiar with the IF formula but not with auto e-mails. For me the delay is okay.

Jay

8. [...] Tracking Stock Quotes and Other investments using Google Spreadsheets [...]

9. Manish says:

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

10. Chandoo says:

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

11. Arun Singla says:

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

12. [...] Stock Portfolio Tracker using Google Docs [...]

13. Amit says:

or you can simply use this

where attribute can be price.

14. Benjamin says:

Hey Chandoo (Hey Everyone),

I wanted to let you know that I just carved off a big chunk of code from my latest project. It lets you bulk download historical stock quotes and current quantitative data that might be useful for working in Excel or Google Spreadsheets. It's a little more manual than Amit's comment above, but it'll still work and lets you build your own performance charts.

Enjoy!

15. DR says:

Hi Chandoo

The formulas concatenate, value and mid are very useful and thanks for pointing them out.

While the first step with concatenate works well for all tickers (I'm referring to your formula
concatenate(GoogleFinance(B2,"price",C2)), the 2nd step with the value formula =value(mid(M2,3+find(":",M2,1+find(":",M2)),99)) does not work for some international tickers. For instance, ASX:IFM or ASX:MPO. Please let me know if you have any thoughts on an appropriate fix. Thanks!

16. Bernaard says:

Yo,

Yahoo stock portfolio tracker is going buggy on me, with their latest
revision.

In any event, I chase dividends, is there any way to get ex-dividend date onto spread sheet?

17. Michael says:

Is there anyway to get equity option quotes in google docs?

18. Peter says:

Nice post, really like these added functionalities that can call API's and websites in Google Docs.

The importhtml() function they have is also pretty handy, i used it to scrape facebook usage numbers and make a nice map out of it: http://spreadsheetpro.net/using-importhtml-to-scrape-facebook-usage-numbers/

19. Peter says:

Great post. Thanks.

I built a similar capability, and added the functionality to import data directly from Quicken so that no manual entry is required. I also created a lot of different output formats. I'd appreciate feedback on it, so if you're interested, please take a look at http://portfoliowatcher.blogspot.com/

Thanks.

20. Harrison Delfino says:

I use MarketXLS for this and it works great for me.?

21. K Naresh Babu says:

How to get the Indian Mutual Codes in google finance to track our MF portfolio ?

22. Praveen says:

Hello,

Appreciate if you can repost it.

Thank you

### Get FREE Excel & Power-BI Newsletter

One email per week with Excel and Power BI goodness. Join 100,000+ others and get it free.