Price-to-Earnings Ratio (P/E Ratio) Calculator
:root {
–primary-blue: #004a99;
–success-green: #28a745;
–light-background: #f8f9fa;
–card-background: #ffffff;
–text-color: #333;
–border-color: #ddd;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(–light-background);
color: var(–text-color);
line-height: 1.6;
margin: 0;
padding: 20px;
}
.loan-calc-container {
max-width: 700px;
margin: 40px auto;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.calculator-header {
background-color: var(–primary-blue);
color: white;
padding: 20px;
text-align: center;
font-size: 1.8em;
font-weight: bold;
border-bottom: 1px solid var(–border-color);
}
.calculator-inputs {
padding: 30px 25px;
}
.input-group {
margin-bottom: 20px;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.input-group label {
font-size: 1.1em;
margin-bottom: 8px;
color: var(–primary-blue);
font-weight: 600;
}
.input-group input[type="number"] {
width: 100%;
padding: 12px 15px;
border: 1px solid var(–border-color);
border-radius: 4px;
font-size: 1em;
box-sizing: border-box; /* Important for consistent sizing */
transition: border-color 0.3s ease;
}
.input-group input[type="number"]:focus {
border-color: var(–primary-blue);
outline: none;
}
.btn-calculate {
display: block;
width: 100%;
background-color: var(–success-green);
color: white;
border: none;
padding: 15px 20px;
font-size: 1.2em;
font-weight: bold;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
margin-top: 10px;
}
.btn-calculate:hover {
background-color: #218838;
transform: translateY(-2px);
}
.result-container {
background-color: var(–primary-blue);
color: white;
padding: 30px 25px;
text-align: center;
}
.result-title {
font-size: 1.3em;
margin-bottom: 15px;
font-weight: 600;
}
#peRatioResult {
font-size: 2.5em;
font-weight: bold;
color: #fff;
display: block;
margin-top: 10px;
}
#peRatioResult.low { color: #FFC107; } /* Yellow for low P/E */
#peRatioResult.medium { color: #28a745; } /* Green for medium P/E */
#peRatioResult.high { color: #DC3545; } /* Red for high P/E */
.explanation-section {
max-width: 700px;
margin: 40px auto;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
padding: 30px;
}
.explanation-section h2 {
color: var(–primary-blue);
border-bottom: 2px solid var(–primary-blue);
padding-bottom: 10px;
margin-bottom: 20px;
font-size: 1.6em;
}
.explanation-section h3 {
color: var(–primary-blue);
margin-top: 25px;
margin-bottom: 10px;
font-size: 1.3em;
}
.explanation-section p, .explanation-section ul {
margin-bottom: 15px;
color: #555;
}
.explanation-section li {
margin-bottom: 8px;
}
.code-example {
background-color: #e9ecef;
padding: 15px;
border-radius: 4px;
font-family: 'Courier New', Courier, monospace;
font-size: 0.95em;
white-space: pre-wrap;
word-break: break-all;
}
@media (max-width: 600px) {
.calculator-header {
font-size: 1.5em;
}
.input-group label {
font-size: 1em;
}
.btn-calculate {
font-size: 1.1em;
}
.result-title {
font-size: 1.1em;
}
#peRatioResult {
font-size: 2em;
}
.explanation-section {
padding: 20px;
}
}
Your Calculated P/E Ratio
–
Understanding the Price-to-Earnings (P/E) Ratio
The Price-to-Earnings (P/E) Ratio is a fundamental valuation metric used by investors to compare the relative stock prices of different companies within an industry or across the market. It essentially tells you how much investors are willing to pay for each dollar of a company's earnings.
How is the P/E Ratio Calculated?
The calculation is straightforward and uses two key figures:
- Current Stock Price: The current market price of one share of a company's stock.
- Earnings Per Share (EPS): The company's total profit divided by the number of outstanding shares. EPS represents the portion of a company's profit allocated to each outstanding share of common stock.
The formula is:
P/E Ratio = Current Stock Price / Earnings Per Share (EPS)
How to Interpret the P/E Ratio
Interpreting the P/E ratio requires context. There's no single "good" or "bad" P/E ratio; it depends on several factors:
- Industry Averages: A P/E ratio is often compared to the average P/E ratio of companies in the same industry. A higher P/E might suggest the company is overvalued relative to its peers, while a lower P/E might indicate undervaluation or potential problems.
- Growth Prospects: Companies with high expected future growth rates often command higher P/E ratios. Investors are willing to pay a premium for anticipated earnings growth.
- Market Conditions: Overall market sentiment and economic conditions can influence P/E ratios. During bull markets, P/E ratios tend to be higher, and during bear markets, they tend to be lower.
- Company Specifics: Factors like management quality, competitive advantage, and financial stability also play a role.
General Guidelines (Use with Caution):
- Low P/E (e.g., < 10-15): May indicate a company is undervalued or facing significant challenges.
- Average P/E (e.g., 15-25): Often considered a reasonable valuation in many mature markets.
- High P/E (e.g., > 25-30): May suggest the company is overvalued or has very strong growth expectations priced in.
Example Calculation
Let's say a company, "TechInnovate Inc.", has the following:
- Current Stock Price: $75.50
- Earnings Per Share (EPS): $4.15
Using the P/E Ratio calculator:
P/E Ratio = $75.50 / $4.15 ≈ 18.19
An investor would then compare this P/E of 18.19 to the average P/E of other technology companies and TechInnovate's own historical P/E ratios to make an informed decision.
Limitations of the P/E Ratio
While useful, the P/E ratio is not a perfect metric. It doesn't account for debt levels, and different accounting methods can affect EPS. It is best used in conjunction with other financial ratios and qualitative analysis.
function calculatePERatio() {
var stockPriceInput = document.getElementById("stockPrice");
var earningsPerShareInput = document.getElementById("earningsPerShare");
var peRatioResultElement = document.getElementById("peRatioResult");
var stockPrice = parseFloat(stockPriceInput.value);
var earningsPerShare = parseFloat(earningsPerShareInput.value);
if (isNaN(stockPrice) || isNaN(earningsPerShare)) {
peRatioResultElement.textContent = "Invalid Input";
peRatioResultElement.className = ""; // Reset class
return;
}
if (earningsPerShare <= 0) {
peRatioResultElement.textContent = "EPS must be positive";
peRatioResultElement.className = ""; // Reset class
return;
}
var peRatio = stockPrice / earningsPerShare;
// Round to two decimal places
peRatio = peRatio.toFixed(2);
peRatioResultElement.textContent = peRatio;
// Add styling based on P/E value for better visualization
// These thresholds are general and can be adjusted based on industry/market
if (peRatio = 15 && peRatio <= 25) {
peRatioResultElement.className = "medium";
} else {
peRatioResultElement.className = "high";
}
}