function calculatePWI() {
// Get Inputs for Period 1
var pA1 = parseFloat(document.getElementById('stockA_start').value) || 0;
var pB1 = parseFloat(document.getElementById('stockB_start').value) || 0;
var pC1 = parseFloat(document.getElementById('stockC_start').value) || 0;
var div1 = parseFloat(document.getElementById('divisor_start').value);
// Get Inputs for Period 2
var pA2 = parseFloat(document.getElementById('stockA_end').value) || 0;
var pB2 = parseFloat(document.getElementById('stockB_end').value) || 0;
var pC2 = parseFloat(document.getElementById('stockC_end').value) || 0;
var div2 = parseFloat(document.getElementById('divisor_end').value);
// Validation for Divisors
if (isNaN(div1) || div1 === 0) div1 = 1;
if (isNaN(div2) || div2 === 0) div2 = 1;
// Validation for prices (at least one stock must have a price to make sense)
if ((pA1 + pB1 + pC1) === 0) {
alert("Please enter at least one starting stock price.");
return;
}
// Calculate Sum of Prices
var sum1 = pA1 + pB1 + pC1;
var sum2 = pA2 + pB2 + pC2;
// Calculate Index Values
var indexVal1 = sum1 / div1;
var indexVal2 = sum2 / div2;
// Calculate Return
// Formula: (End Value – Start Value) / Start Value
var change = indexVal2 – indexVal1;
var returnPct = 0;
if (indexVal1 !== 0) {
returnPct = (change / indexVal1) * 100;
}
// Display Results
document.getElementById('res-start-val').innerText = indexVal1.toFixed(2);
document.getElementById('res-end-val').innerText = indexVal2.toFixed(2);
document.getElementById('res-abs-change').innerText = change.toFixed(2);
document.getElementById('res-return-pct').innerText = returnPct.toFixed(2) + "%";
// Color coding for positive/negative return
var resText = document.getElementById('res-return-pct');
if (returnPct > 0) {
resText.style.color = "#27ae60"; // Green
} else if (returnPct < 0) {
resText.style.color = "#c0392b"; // Red
} else {
resText.style.color = "#333";
}
document.getElementById('result-box').style.display = 'block';
}
How to Calculate Rate of Return on a Price Weighted Index
A Price Weighted Index (PWI) is a stock market index in which each component makes up a fraction of the index proportional to its price per share. The most famous example of this is the Dow Jones Industrial Average (DJIA) and the Nikkei 225. Unlike market-capitalization-weighted indices (like the S&P 500), where the size of the company matters most, in a price-weighted index, the stock with the highest price tag has the most influence.
The Basic Formula
Calculating the rate of return involves two main steps: determining the index value at the beginning and end of the period, and then calculating the percentage change.
Index Value = (Sum of Member Stock Prices) / Divisor
Rate of Return = ((Ending Index Value – Beginning Index Value) / Beginning Index Value) × 100
Step-by-Step Calculation Logic
Sum the Prices: Add up the share price of every company in the index for the starting period.
Apply the Divisor: Divide the sum by the index divisor. The divisor is a number used to normalize the index, often adjusted for stock splits, spin-offs, or dividends to ensure continuity.
Repeat for End Period: Calculate the index value for the ending period using the new prices and the current divisor.
Calculate Percentage Change: Use the standard rate of return formula to find the percentage increase or decrease.
Why High-Priced Stocks Matter More
In this type of index, a $200 stock that moves 10% (+$20) has a much larger impact on the index value than a $20 stock that moves 10% (+$2). This is the defining characteristic of price weighting. If the highest-priced stock in the index crashes, it will drag the index down significantly, even if smaller stocks are performing well.
Understanding the Divisor
You might notice the "Divisor" field in the calculator above. In a theoretical simple index, the divisor is equal to the number of stocks (arithmetic average). However, in real-world indices like the Dow, the divisor is frequently adjusted. If a stock splits 2-for-1, its price drops by half. To prevent the index value from artificially dropping, the divisor is lowered mathematically to keep the Index Value constant at the moment of the split.