How to Create an (Accurate) Custom Index
Not all Indexes are Created Equal
An easy way to create a custom index of a basket of stocks, or portfolio, is to simply add them together in what is called a price-weighted index. This generally gives a good indication of how those stocks behaved as a whole, but a key issue is that the stocks in the group with the biggest price have the most impact on the overall index value and those with a small price value are under-represented, regardless of the overall market capitalization of the company.
Most indexes, such as the S&P/ASX 200 ($XJO) in Australia and the S&P500 Index in the US ($SPX) are market capitalization weighted, meaning the biggest companies by value have the biggest impact of the index. One important exception is the Dow Jones Industrial Index ($DJI) which is price-weighted, meaning that those companies with a higher share price have a biggest impact on the index, regardless of the size of the company. Take Boeing ($BA) and Pfizer ($PFE) as examples. Boeing is currently $340 a share with a market cap of $200 billion, whereas Pfizer is only $37 a share but has a higher market cap (around $220 billion), but a 1% change in Boeing’s share price will have 9 times the impact (340/37) on the overall index value than a 1% change in Pfizer even though Pfizer is a bigger company by market cap than Boeing.
To create a simple price-weighted index in Optuma is easy. Let’s take the FANG stocks – or actually the FAANG stocks – the 5 large tech stocks in the US: Facebook, Apple, Amazon, Netflix and Google. In Optuma click on Data > Custom Codes and create a new ticker code of your choice by adding the symbols together in a formula. In this example I created a new symbol FAANGPW, and the name FAANG Price Weighted using the following formula:
FB:NASDAQ + AAPL:NASDAQ + AMZN:NASDAQ + NFLX:NASDAQ + GOOGL:NASDAQ
Once completed, click Open Code to view the chart, and it will display a chart beginning in 2012 (the earliest date when all five companies were trading following Facebook’s IPO). The current value of the five companies added together is $3,213.63, as seen in the watchlist and chart below, with a gain of $101 on the day.
So far so good, but if we take a look at the individual prices of these five stocks then you will see that Amazon is $1,518, and Apple has the smallest at $164. But look at today’s net changes: Facebook rose 9% (or $14.47 in dollar terms) whereas Amazon gained almost $58 per share, but that was less than half of the percentage gain (3.96%) of Facebook. This means that over half the day’s $101 gain in the composite price-weighted FAANGPW index was due to Amazon, even though it makes up only 25% of our custom index by market cap! Another thing to note is the daily percentage change, which was 3.61% in the watchlist, but only 3.26% on a price-weighted basis.
So whilst price-weighted is ok, I was asked by a client if there’s a more accurate way to calculate the performance of a custom basket of stocks. Ideally we would take the market caps for each stock for each day and calculate a market cap weighted index, but that would be too complex. I thought maybe I could use our Market Breadth module to calculate the daily average percentage changes and create a cumulative total, or maybe create a more complex formula in the Custom Code builder, but success was limited and I couldn’t get my head around the maths. The closest I got was a formula that would plot percentage changes on an arithmetic price scale, which led to issues calculating price moves and performance statistics.
Then I had an idea. Whilst studying for the Chartered Market Technician’s exams I learned about geometric averages. Without going too much in to the maths (not my strong point, so feel free to Google!), to calculate a geometric average you multiply the components together (rather than add them) and then raise to the power of 1/n. So in our FAANG example, we multiply the symbols together for each day and raise to the power of 0.2 (or 1/5) and cumulate the total for each day.
Fortunately, our Custom Code builder makes this very easy, as the formulas can include any mathematical function, including POWER(). So here’s the new FAANG Geometric Index formula (symbol FAANGGEO):
POWER(FB:NASDAQ * AAPL:NASDAQ * AMZN:NASDAQ * NFLX:NASDAQ * GOOGL:NASDAQ, POWER=0.20)
Perhaps the first thing you’ll notice is the value of this geometric index, which is nowhere near the $3,213 of the price-weighted chart, but that isn’t the important number. It more the daily changes and shape of the line that is more important, as that give us much better representation of the performance of the underlying stocks bundled together. Usually the average of the Change % column matches the 1 Period Rate of Change value, but today was very close: 3.57% for the chart vs 3.61% for the watchlist (maybe because of the large move in Facebook), but it’s when you look back over longer periods of time that the difference between price-weighted and our new geometric index becomes clear.
As per the watchlist and charts below, year-to-date the Price Weighted index has gained 16.41% vs 15.03% for the more accurate geometric calculation, with the gap widening to 43.54% and 40.95% over the last 12 months.
So if you’re interested in creating your own custom index – particularly if the price of the companies vary widely – take a look at the geometric average calculation using the POWER() function, remembering to adjust it to reflect the number of components it contains, eg 0.25 for 4, 0.125 for 8, 0.1 for 10, etc.
Darren Hawkins, MSTA
Senior Software Specialist at Optuma
Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.
Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, UK and currently USA, Darren has a broad understanding of the individual needs of traders and investors utilising a wide range of methodologies.
In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and in October 2017 passed Level 2 of the CMT Program.
When not looking at charts, Darren keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in Charlotte, North Carolina with wife Wendy and their labrador, Gabba.