When I got into share trading, I found myself bouncing around all over the place to keep track of everything. I had a brokerage account that would give me a snapshot of my account obviously, but I had no control over it. I downloaded software solutions and experimented with them but I still found myself wanting to do more. It was after a good while that I decided to start looking into other ways of going about this and that's when I came across the GOOGLEFINANCE() function in Google Sheets.
The GOOGLEFINANCE() function gives us a whole lot of awesome information about shares. I started playing around with the function and found that I could create myself somewhat of a dashboard, making it easy to see where my portfolio stands but with all the control in the world. After some time, I created what I use to this day still and today I want to give you an introduction to this. Grab a coffee, sit back and let's go through this together right now.
Let's start by opening a Google Sheet, you're going to want to play as you read through this post. Trust me, doing so will make this stick far quicker than if you simply read. Right, you've got your sheet open, so let's get started with a simple example of what the function does.
Type the function below into a cell in Google Sheets and click enter.
=GOOGLEFINANCE("NASDAQ:GOOG", "price")
What we have here is the share price for Google. Breaking this down:
Therefore, the price of a single Google share is $97.33 at the time of writing this article.
It's honestly that easy to pull the data from Google and populate a sheet. But, to understand this better, we need to look at the full extent of this function and all of its properties and attributes. For starters, here's how this function may be used:
GOOGLEFINANCE(ticker, [attribute], [start_date], [end_date|num_days], [interval])
And, here's a breakdown of the properties:
For me, what I feel is most important is the attribute, this opens up all the amazing information we can retrieve from Google. To help you out, below is a list of description of each attribute available:
Now, those are the attributes for real-time data but we can also pull historical data with these attributes:
There are a number of other attributes available for mutual funds but that's a conversation for another day. Today we're going to look at real-time data for then most part as it's what's most important for creating a share portfolio tracker in Google Sheets.
Very quickly we can do this:
Now, in real time, we can look at some important facts about Telsa shares. Each time we visit the Sheet, the data is updated in real-time. We can expand this to include several stocks and thus build ourselves somewhat of a Dashboard:
With a little bit of styling, conditional formatting, and capturing our own share data, we can come to something like this quite easily:
Let's break down what we've got here:
*Average Cost: This is the average price you paid per share and is a value you extract from your brokerage account.
So right now, we have a useful dashboard that tracks how our stocks are doing, that updates in real time. You can stop with this basically but there are a few extra bits and bobs that are really interesting so I want to share those with you too.
Let's take things a step further, how about some graphs that look at periods of time to see how a company's price is doing over intervals such as 200, 50, and 20. I chose these intervals because they're linked to something called moving average in technical trading. Take a look at this:
The SPARKLINE() function is outside of the scope of this article but to assist you, we're essentially starting with the following syntax:
=SPARKLINE(GOOGLEFINANCE("NASDAQ:GOOG", "price", TODAY()-200, TODAY()))
This means we want to look at the price of Google from 200 days ago until today, and represent the data as a chart:
That doesn't look like our example but shows the basics. The SPARKLINE() function has a whole lot of its own attributes so with some experimenting, you can get it to look how I did. Below is the exact syntax I used:
=IFERROR(SPARKLINE(GOOGLEFINANCE($A3,"price",TODAY()-200,TODAY(),"weekly"),{"charttype","line";"linewidth",3;"color", if(googlefinance($A3,"price") <index(googlefinance($A3, "price", today()-200),2,2),"red","green")}),"")
These graphs aren't crucial but they're really nice to have as they tell somewhat of a story and add some additional insight into the sheet. Now, we need to add Column N that we mentioned above, which was the share price... easy, it's what we covered at the start of this article, along these lines: =GOOGLEFINANCE("NASDAQ:GOOG", "price") and let's put the name of the company in:
Now we're talking!
The Sector column doesn't get created through GOOGLEFINANCE(), unfortunately, and is instead done by using an IMPORTXML() function that comes with Google Sheets. The IMPORTXML() function is well outside of the scope for this article so if you're interested, you'll have to turn to Google for an explanation.
So, you want to grab a copy of this tracker for yourself instead of doing the work? Okay sure, click here, make a copy and enjoy!