The Price-to-Earnings (P/E) ratio is a fundamental valuation metric used by investors to compare the relative worth of a company's stock. It essentially tells you how much investors are willing to pay for each dollar of a company's earnings.
How to Calculate the P/E Ratio
The calculation is straightforward:
P/E Ratio = Current Stock Price / Earnings Per Share (EPS)
Formula Explained:
Current Stock Price: This is the most recent trading price of one share of a company's stock.
Earnings Per Share (EPS): This represents a company's net profit divided by the number of outstanding shares of its common stock. It's a key indicator of a company's profitability. You can typically find EPS reported quarterly and annually by companies in their financial statements or on financial news websites.
Interpreting the P/E Ratio:
High P/E Ratio: A high P/E ratio might suggest that investors expect higher earnings growth in the future, or that the stock is overvalued.
Low P/E Ratio: A low P/E ratio could indicate that a company is undervalued, or that investors have lower expectations for its future growth.
Comparison: The P/E ratio is most useful when compared to the company's historical P/E ratios, the P/E ratios of its competitors in the same industry, or the P/E ratio of the broader market.
Use Cases:
Stock Valuation: Helps investors gauge whether a stock is trading at a reasonable price relative to its earnings.
Industry Comparison: Allows for comparisons between companies within the same sector.
Growth Expectations: Can provide insight into market sentiment and future growth expectations for a company.
Disclaimer: The P/E ratio is just one of many tools for stock analysis. It should not be used in isolation. Always conduct thorough research before making investment decisions.
function calculatePEratio() {
var stockPriceInput = document.getElementById("stockPrice");
var earningsPerShareInput = document.getElementById("earningsPerShare");
var resultDisplay = document.getElementById("result");
var stockPrice = parseFloat(stockPriceInput.value);
var earningsPerShare = parseFloat(earningsPerShareInput.value);
// Clear previous error messages or results if inputs are invalid
resultDisplay.innerHTML = "P/E Ratio: –";
resultDisplay.style.backgroundColor = "#28a745"; // Reset to success green
if (isNaN(stockPrice) || isNaN(earningsPerShare)) {
resultDisplay.innerHTML = "Please enter valid numbers for both fields.";
resultDisplay.style.backgroundColor = "#dc3545"; // Error red
return;
}
if (earningsPerShare <= 0) {
resultDisplay.innerHTML = "EPS must be a positive number.";
resultDisplay.style.backgroundColor = "#dc3545"; // Error red
return;
}
if (stockPrice <= 0) {
resultDisplay.innerHTML = "Stock price must be a positive number.";
resultDisplay.style.backgroundColor = "#dc3545"; // Error red
return;
}
var peRatio = stockPrice / earningsPerShare;
resultDisplay.innerHTML = "P/E Ratio: " + peRatio.toFixed(2);
resultDisplay.style.backgroundColor = "#28a745"; // Success green
}