How to Calculate Fair Value of a Stock | Fair Value Calculator
:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–light-gray: #e9ecef;
–white: #fff;
–dark-text: #212529;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: var(–text-color);
background-color: var(–background-color);
margin: 0;
padding: 0;
}
.container {
max-width: 1000px;
margin: 20px auto;
padding: 20px;
background-color: var(–white);
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
header {
background-color: var(–primary-color);
color: var(–white);
padding: 20px 0;
text-align: center;
margin-bottom: 30px;
border-radius: 8px 8px 0 0;
}
header h1 {
margin: 0;
font-size: 2.5em;
}
.calculator-wrapper {
margin-bottom: 40px;
padding: 25px;
border: 1px solid var(–light-gray);
border-radius: 8px;
background-color: var(–white);
}
.calculator-wrapper h2 {
text-align: center;
color: var(–primary-color);
margin-bottom: 20px;
font-size: 1.8em;
}
.input-group {
margin-bottom: 18px;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: var(–dark-text);
}
.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
width: calc(100% – 20px);
padding: 10px;
border: 1px solid var(–light-gray);
border-radius: 4px;
font-size: 1em;
box-sizing: border-box;
}
.input-group input[type="number"]:focus,
.input-group input[type="text"]:focus,
.input-group select:focus {
outline: none;
border-color: var(–primary-color);
box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}
.input-group .helper-text {
font-size: 0.85em;
color: #6c757d;
margin-top: 5px;
}
.error-message {
color: #dc3545;
font-size: 0.85em;
margin-top: 5px;
height: 1.2em; /* Reserve space */
}
button {
background-color: var(–primary-color);
color: var(–white);
border: none;
padding: 12px 25px;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
margin-right: 10px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #003366;
}
button.reset-button {
background-color: #6c757d;
}
button.reset-button:hover {
background-color: #5a6268;
}
button.copy-button {
background-color: var(–success-color);
}
button.copy-button:hover {
background-color: #218838;
}
#results {
margin-top: 30px;
padding: 20px;
border: 1px solid var(–light-gray);
border-radius: 8px;
background-color: var(–white);
}
#results h3 {
color: var(–primary-color);
margin-bottom: 15px;
text-align: center;
}
.primary-result {
font-size: 2.2em;
font-weight: bold;
color: var(–primary-color);
text-align: center;
margin-bottom: 20px;
padding: 15px;
background-color: #e0f2f7;
border-radius: 4px;
border-left: 5px solid var(–primary-color);
}
.intermediate-results div,
.key-assumptions div {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
padding-bottom: 8px;
border-bottom: 1px dashed var(–light-gray);
font-size: 0.95em;
}
.intermediate-results div:last-child,
.key-assumptions div:last-child {
border-bottom: none;
}
.intermediate-results span:first-child,
.key-assumptions span:first-child {
font-weight: bold;
color: var(–dark-text);
}
.intermediate-results span:last-child,
.key-assumptions span:last-child {
color: #007bff;
}
.formula-explanation {
margin-top: 15px;
font-size: 0.9em;
color: #555;
text-align: center;
padding: 10px;
background-color: var(–light-gray);
border-radius: 4px;
}
table {
width: 100%;
margin-top: 25px;
border-collapse: collapse;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}
th, td {
padding: 12px 15px;
text-align: left;
}
thead {
background-color: var(–primary-color);
color: var(–white);
}
th {
font-weight: bold;
}
tbody tr:nth-child(even) {
background-color: #f2f7fc;
}
caption {
caption-side: top;
font-weight: bold;
font-size: 1.1em;
color: var(–dark-text);
margin-bottom: 10px;
text-align: left;
}
#chartContainer {
margin-top: 30px;
text-align: center;
padding: 20px;
background-color: var(–white);
border-radius: 8px;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}
#chartContainer canvas {
max-width: 100%;
height: auto;
}
.article-section {
margin-top: 40px;
padding: 25px;
border: 1px solid var(–light-gray);
border-radius: 8px;
background-color: var(–white);
}
.article-section h2 {
color: var(–primary-color);
margin-bottom: 20px;
font-size: 1.8em;
border-bottom: 2px solid var(–primary-color);
padding-bottom: 10px;
}
.article-section h3 {
color: var(–primary-color);
margin-top: 25px;
margin-bottom: 12px;
font-size: 1.4em;
}
.article-section p {
margin-bottom: 15px;
color: var(–dark-text);
}
.article-section ul,
.article-section ol {
margin-left: 20px;
margin-bottom: 15px;
color: var(–dark-text);
}
.article-section li {
margin-bottom: 8px;
}
.faq-item {
margin-bottom: 15px;
border-left: 3px solid var(–primary-color);
padding-left: 10px;
background-color: #f2f7fc;
padding-top: 8px;
padding-bottom: 8px;
border-radius: 4px;
}
.faq-item strong {
display: block;
color: var(–dark-text);
margin-bottom: 5px;
}
.faq-item p {
margin-bottom: 0;
color: #555;
}
a {
color: var(–primary-color);
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.internal-links-section ul {
list-style: none;
padding: 0;
}
.internal-links-section li {
margin-bottom: 10px;
border-bottom: 1px dashed var(–light-gray);
padding-bottom: 8px;
}
.internal-links-section li:last-child {
border-bottom: none;
padding-bottom: 0;
}
.internal-links-section a {
font-weight: bold;
}
.internal-links-section p {
font-size: 0.9em;
color: #555;
margin-top: 5px;
margin-bottom: 0;
}
.calculation-summary {
font-size: 0.9em;
color: #555;
text-align: center;
margin-top: 15px;
padding: 10px;
background-color: var(–light-gray);
border-radius: 4px;
}
.button-group {
text-align: center;
margin-top: 20px;
}
@media (min-width: 768px) {
.container {
margin: 30px auto;
padding: 30px;
}
.input-group {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.input-group label {
margin-bottom: 0;
width: 40%;
}
.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
width: 55%;
}
}
How to Calculate Fair Value of a Stock
Fair Value Stock Calculator
This calculator helps you estimate the fair value of a stock using the Dividend Discount Model (DDM). Input the required financial data to get an estimated intrinsic value.
Calculation Results
—
Key Assumptions:
Current Stock Price
—
Last Paid Dividend
—
The Fair Value is calculated using the Gordon Growth Model (a form of DDM): Fair Value = D1 / (r – g)
Where D1 is the next expected dividend, r is the required rate of return, and g is the dividend growth rate.
What is Fair Value?
{primary_keyword} is a fundamental concept in investing, representing the intrinsic worth of an asset, most commonly a stock. Unlike its market price, which fluctuates based on supply, demand, and investor sentiment, fair value is derived from an analysis of the asset's underlying financial health and future earning potential. It's the price at which an investor would consider buying or selling the stock if they had perfect knowledge of the company's future performance and the overall economic environment. Investors use this concept to identify undervalued stocks (where market price is below fair value) or overvalued stocks (where market price is above fair value).
Who Should Use It?
Any investor looking to make informed decisions, particularly those employing a value investing strategy, should understand and utilize the concept of fair value. This includes:
- Long-term investors seeking to buy fundamentally sound companies at a discount.
- Fundamental analysts who dissect financial statements to assess a company's true worth.
- Portfolio managers aiming to optimize asset allocation based on intrinsic value rather than market trends.
Common Misconceptions:
- Fair Value is a Single, Precise Number: In reality, fair value is an estimate. Different models and assumptions will yield different fair value figures.
- Fair Value Guarantees Profit: While helpful, fair value doesn't predict market movements. The market can remain irrational longer than an investor can remain solvent.
- Market Price Always Converges to Fair Value: While there's a tendency, convergence isn't guaranteed, especially in the short to medium term.
{primary_keyword} Formula and Mathematical Explanation
One of the most common methods to estimate the {primary_keyword} of a stock is the Dividend Discount Model (DDM), specifically the Gordon Growth Model (or Constant Growth DDM). This model assumes that a company's dividends will grow at a constant rate indefinitely.
The formula is as follows:
Fair Value = D1 / (r – g)
Let's break down the variables:
- D1 (Next Expected Dividend): This is the dividend per share that the company is expected to pay over the next year. It's calculated by taking the last paid dividend (D0) and growing it by the expected dividend growth rate (g). D1 = D0 * (1 + g).
- r (Required Rate of Return): This represents the minimum annual rate of return an investor expects to receive from an investment, considering its risk. It's influenced by factors like prevailing interest rates, inflation, and the specific risk associated with the stock.
- g (Expected Dividend Growth Rate): This is the rate at which the company's dividends are expected to grow each year, indefinitely. This rate should be realistic and sustainable, often based on the company's historical growth, industry trends, and payout ratio. It must be less than 'r' for the formula to yield a positive result.
The DDM calculates fair value by discounting all future expected dividends back to their present value. The Gordon Growth Model simplifies this by assuming constant growth, making the calculation straightforward.
Variable Explanations and Ranges
DDM Variables and Their Characteristics
| Variable |
Meaning |
Unit |
Typical Range/Considerations |
| Current Stock Price |
The prevailing market price of the stock. |
Currency (e.g., $) |
Market determined. Used for comparison. |
| Last Paid Dividend (D0) |
Total dividend paid per share in the last fiscal year. |
Currency (e.g., $) |
Positive value. From company financial reports. |
| Expected Dividend Growth Rate (g) |
The projected annual percentage increase in dividends. |
% |
Typically 1% to 10%. Must be less than 'r'. Lower for mature companies, higher for growth companies (if sustainable). |
| Required Rate of Return (r) |
Investor's minimum expected annual return. |
% |
Typically 8% to 15%. Influenced by risk-free rate, market risk premium, and beta. |
| Next Expected Dividend (D1) |
Projected dividend per share for the next year. |
Currency (e.g., $) |
Calculated: D0 * (1 + g). |
| Fair Value |
The estimated intrinsic value per share of the stock. |
Currency (e.g., $) |
Result of the DDM calculation. |
Practical Examples (Real-World Use Cases)
Example 1: Stable, Mature Company
Let's analyze "UtilityCo," a stable utility company known for consistent dividend payouts.
- Current Stock Price: $75.00
- Last Paid Dividend (D0): $3.00
- Expected Dividend Growth Rate (g): 3.0% (reflecting modest growth)
- Required Rate of Return (r): 8.0% (reflecting low risk)
Calculation Steps:
- Calculate Next Expected Dividend (D1): D1 = $3.00 * (1 + 0.03) = $3.09
- Calculate Fair Value: Fair Value = $3.09 / (0.08 – 0.03) = $3.09 / 0.05 = $61.80
Interpretation: In this scenario, the calculated fair value of $61.80 is significantly lower than the current market price of $75.00. This suggests that UtilityCo might be overvalued by the market according to the DDM. Investors might consider waiting for the price to drop closer to its fair value or looking for better opportunities.
Example 2: Growing Technology Company
Now consider "TechGrowth Inc.," a company reinvesting heavily but starting to pay dividends.
- Current Stock Price: $120.00
- Last Paid Dividend (D0): $1.00
- Expected Dividend Growth Rate (g): 15.0% (reflecting high growth potential)
- Required Rate of Return (r): 12.0% (reflecting higher risk)
Calculation Steps:
- Calculate Next Expected Dividend (D1): D1 = $1.00 * (1 + 0.15) = $1.15
- Check Condition: Here, g (15%) is GREATER than r (12%). This means the Gordon Growth Model is NOT applicable. The model assumes 'g' is constant and less than 'r'. A high growth rate suggests the company is likely reinvesting earnings rather than distributing them sustainably at that rate indefinitely.
Interpretation & Alternative: Because g > r, the Gordon Growth Model breaks down. This indicates that TechGrowth Inc.'s growth is too high for this simplified model. Investors would need to use more sophisticated DDM variations (like a two-stage or multi-stage model) that account for a period of supernormal growth followed by a stable growth phase, or use other valuation methods like discounted cash flow (DCF).
This highlights a critical limitation: the {primary_keyword} calculation is only as good as the model and its assumptions. For companies with rapidly changing growth profiles, alternative valuation methods are essential.
How to Use This {primary_keyword} Calculator
Our interactive calculator simplifies the process of estimating a stock's fair value using the Gordon Growth Model. Follow these steps to leverage its capabilities:
- Input Current Stock Price: Enter the current trading price of the stock in the "Current Stock Price" field. This serves as a benchmark for comparison.
- Enter Last Paid Dividend: Input the total amount of dividend per share the company paid out over its last full fiscal year into the "Last Paid Dividend" field.
- Estimate Dividend Growth Rate: Provide your best estimate for the annual percentage growth rate of future dividends in the "Expected Dividend Growth Rate (%)" field. Ensure this rate is sustainable and less than your required rate of return.
- Set Required Rate of Return: Enter your minimum acceptable annual return for this investment in the "Required Rate of Return (%)" field. This should reflect the riskiness of the stock and your personal investment goals.
- Click 'Calculate Fair Value': Once all fields are populated, click the button.
How to Read Results:
- Primary Result (Fair Value): This is the main output, showing the calculated intrinsic value per share.
- Intermediate Values: You'll see the calculated "Next Expected Dividend (D1)", your input "Dividend Growth Rate (g)", and your input "Required Rate of Return (r)".
- Key Assumptions: These reiterate the primary inputs you provided (Current Stock Price, Last Paid Dividend) for clarity.
Decision-Making Guidance:
- Fair Value > Current Price: The stock may be undervalued. This could signal a potential buying opportunity.
- Fair Value < Current Price: The stock may be overvalued. Consider avoiding it or selling if you own it.
- Fair Value ≈ Current Price: The stock is trading near its estimated intrinsic value, suggesting it might be fairly priced.
Remember, this is just one tool. Always conduct thorough due diligence and consider other valuation methods.
Key Factors That Affect {primary_keyword} Results
The accuracy of any {primary_keyword} calculation, especially using the DDM, is heavily dependent on the inputs and assumptions. Several factors can significantly influence the outcome:
-
Accuracy of Dividend Growth Rate (g): This is arguably the most sensitive input. Overestimating 'g' can lead to a wildly inflated fair value, while underestimating it can make a stock seem less attractive. Sustainable growth is key; overly optimistic projections are unrealistic for the long term. Consider company earnings growth too.
-
Investor's Required Rate of Return (r): A higher 'r' (demanding more return for higher risk) will decrease the calculated fair value. Conversely, a lower 'r' will increase it. This rate should reflect current interest rates, inflation expectations, and the specific risks of the company and its industry.
-
Company Profitability and Payout Ratio: For DDM, a company must pay dividends. If a company has low profits or a very low payout ratio (meaning it retains most earnings), the DDM might not be suitable. A high payout ratio might limit future growth potential if the company needs to reinvest earnings.
-
Economic Conditions and Interest Rates: Broader economic factors influence both company growth prospects and the required rate of return. Rising interest rates generally increase 'r', thus lowering fair value estimates. A recession can impact 'g'.
-
Industry Trends and Competitive Landscape: A company's long-term viability and growth prospects are tied to its industry. Disruptive technologies, regulatory changes, or intense competition can alter future dividend growth potential, making historical 'g' unreliable.
-
Management Quality and Capital Allocation: Effective management is crucial for achieving sustainable growth. Poor capital allocation decisions can hinder a company's ability to grow its earnings and dividends, impacting fair value negatively. Assessing management is vital.
-
Inflation: Inflation erodes the purchasing power of future dividends. While 'g' and 'r' should ideally incorporate inflation expectations, persistent unexpected inflation can skew results if not properly accounted for in either variable.
-
Share Buybacks vs. Dividends: Some companies return capital to shareholders via share buybacks instead of dividends. The DDM, in its basic form, doesn't account for buybacks, potentially misstating the total return to shareholders and thus the "fair value" from a shareholder perspective.
Frequently Asked Questions (FAQ)
Q1: What is the difference between market price and fair value?
Market price is the current price at which a stock is trading on an exchange, driven by supply and demand. Fair value is an estimated intrinsic worth based on fundamental analysis and financial models, representing what the stock *should* be worth.
Q2: Can a stock's fair value change over time?
Yes, absolutely. Fair value is not static. It changes as a company's financial performance, growth prospects, dividend policies, and the overall economic environment evolve. Regular recalculation is necessary.
Q3: Is the Gordon Growth Model the only way to calculate fair value?
No. It's one of the simplest DDM variations. Other methods include the Two-Stage DDM (for companies with initially high growth), Multi-Stage DDM, Discounted Cash Flow (DCF) analysis, asset-based valuation, and relative valuation (using P/E ratios, etc.). Each has its strengths and weaknesses.
Q4: What happens if the expected growth rate (g) is higher than the required rate of return (r)?
If g ≥ r, the Gordon Growth Model formula breaks down and yields an infinite or negative result, which is meaningless. This indicates the model's limitations for high-growth companies and suggests that a different valuation model (like a multi-stage DDM or DCF) is more appropriate.
Q5: How reliable is the fair value calculated by this tool?
The reliability depends entirely on the accuracy of the inputs you provide (especially 'g' and 'r') and the suitability of the Gordon Growth Model for the specific stock. It provides an estimate, not a guarantee. Think of it as a guide, not gospel.
Q6: Should I always buy a stock when its market price is below its fair value?
It's a strong indicator, but not the sole reason to buy. Consider qualitative factors like management quality, competitive advantages, and industry outlook. Also, ensure your 'fair value' calculation is robust and based on realistic assumptions. Sometimes a low price indicates underlying problems the model doesn't capture.
Q7: What if a company doesn't pay dividends?
The basic Dividend Discount Model (DDM) cannot be used for non-dividend-paying stocks. You would need to employ other valuation methods, such as the Discounted Cash Flow (DCF) model, which analyzes future free cash flows instead of dividends.
Q8: How do I determine my required rate of return (r)?
It's a personal figure based on risk tolerance and opportunity cost. Often, it's estimated using the Capital Asset Pricing Model (CAPM), which considers the risk-free rate, the stock's beta (volatility relative to the market), and the expected market return. Alternatively, investors might use a simpler benchmark like 10-15% depending on their goals.
Related Tools and Internal Resources
var currentStockPriceInput = document.getElementById('currentStockPrice');
var lastDividendInput = document.getElementById('lastDividend');
var expectedDividendGrowthRateInput = document.getElementById('expectedDividendGrowthRate');
var requiredRateOfReturnInput = document.getElementById('requiredRateOfReturn');
var fairValueResultDisplay = document.getElementById('fairValueResult');
var nextDividendDisplay = document.getElementById('nextDividend');
var growthRateDisplay = document.getElementById('growthRateDisplay');
var requiredReturnDisplay = document.getElementById('requiredReturnDisplay');
var currentPriceAssumptionDisplay = document.getElementById('currentPriceAssumption');
var lastDividendAssumptionDisplay = document.getElementById('lastDividendAssumption');
var currentStockPriceError = document.getElementById('currentStockPriceError');
var lastDividendError = document.getElementById('lastDividendError');
var expectedDividendGrowthRateError = document.getElementById('expectedDividendGrowthRateError');
var requiredRateOfReturnError = document.getElementById('requiredRateOfReturnError');
var chart;
var chartContext;
var chartData = {
labels: [],
datasets: [
{ label: 'Market Price', data: [], borderColor: 'var(–primary-color)', backgroundColor: 'rgba(0, 74, 153, 0.1)', fill: false },
{ label: 'Calculated Fair Value', data: [], borderColor: 'var(–success-color)', backgroundColor: 'rgba(40, 167, 69, 0.1)', fill: false }
]
};
var chartOptions = {
responsive: true,
maintainAspectRatio: false,
scales: {
y: { beginAtZero: false }
},
plugins: {
title: { display: true, text: 'Market Price vs. Fair Value Over Time (Hypothetical)' }
}
};
function initializeChart() {
var canvas = document.getElementById('fairValueChart');
if (canvas) {
chartContext = canvas.getContext('2d');
chart = new Chart(chartContext, {
type: 'line',
data: chartData,
options: chartOptions
});
}
}
function updateChart(price, fairValue, label) {
if (!chart) initializeChart();
chartData.labels.push(label);
chartData.datasets[0].data.push(price);
chartData.datasets[1].data.push(fairValue);
// Limit data points to prevent performance issues and keep chart readable
var maxDataPoints = 10;
if (chartData.labels.length > maxDataPoints) {
chartData.labels.shift();
chartData.datasets[0].data.shift();
chartData.datasets[1].data.shift();
}
if (chart) {
chart.update();
}
}
function validateInput(value, id, errorElement, min, max, fieldName) {
var errorDiv = document.getElementById(errorElement);
errorDiv.textContent = ";
var numValue = parseFloat(value);
if (value === ") {
errorDiv.textContent = fieldName + ' cannot be empty.';
return false;
}
if (isNaN(numValue)) {
errorDiv.textContent = fieldName + ' must be a number.';
return false;
}
if (numValue max) {
errorDiv.textContent = fieldName + ' cannot be greater than ' + max + '.';
return false;
}
return true;
}
function calculateFairValue() {
var price = parseFloat(currentStockPriceInput.value);
var d0 = parseFloat(lastDividendInput.value);
var g = parseFloat(expectedDividendGrowthRateInput.value) / 100;
var r = parseFloat(requiredRateOfReturnInput.value) / 100;
var isValid = true;
isValid = validateInput(currentStockPriceInput.value, 'currentStockPrice', 'currentStockPriceError', 0, undefined, 'Current Stock Price') && isValid;
isValid = validateInput(lastDividendInput.value, 'lastDividend', 'lastDividendError', 0, undefined, 'Last Paid Dividend') && isValid;
isValid = validateInput(expectedDividendGrowthRateInput.value, 'expectedDividendGrowthRate', 'expectedDividendGrowthRateError', 0, 100, 'Expected Dividend Growth Rate') && isValid;
isValid = validateInput(requiredRateOfReturnInput.value, 'requiredRateOfReturn', 'requiredRateOfReturnError', 0.01, 100, 'Required Rate of Return') && isValid;
if (!isValid) {
fairValueResultDisplay.textContent = '–';
nextDividendDisplay.textContent = '–';
growthRateDisplay.textContent = '–';
requiredReturnDisplay.textContent = '–';
currentPriceAssumptionDisplay.textContent = '–';
lastDividendAssumptionDisplay.textContent = '–';
return;
}
if (g >= r) {
fairValueResultDisplay.textContent = 'Invalid (g >= r)';
nextDividendDisplay.textContent = '–';
growthRateDisplay.textContent = (expectedDividendGrowthRateInput.value || '0') + '%';
requiredReturnDisplay.textContent = (requiredRateOfReturnInput.value || '0') + '%';
currentPriceAssumptionDisplay.textContent = '$' + price.toFixed(2);
lastDividendAssumptionDisplay.textContent = '$' + d0.toFixed(2);
return;
}
var d1 = d0 * (1 + g);
var fairValue = d1 / (r – g);
fairValueResultDisplay.textContent = '$' + fairValue.toFixed(2);
nextDividendDisplay.textContent = '$' + d1.toFixed(2);
growthRateDisplay.textContent = (expectedDividendGrowthRateInput.value || '0') + '%';
requiredReturnDisplay.textContent = (requiredRateOfReturnInput.value || '0') + '%';
currentPriceAssumptionDisplay.textContent = '$' + price.toFixed(2);
lastDividendAssumptionDisplay.textContent = '$' + d0.toFixed(2);
updateChart(price, fairValue, 'Current');
}
function resetCalculator() {
currentStockPriceInput.value = '50.00';
lastDividendInput.value = '1.50';
expectedDividendGrowthRateInput.value = '5.0';
requiredRateOfReturnInput.value = '10.0';
// Clear errors
document.getElementById('currentStockPriceError').textContent = ";
document.getElementById('lastDividendError').textContent = ";
document.getElementById('expectedDividendGrowthRateError').textContent = ";
document.getElementById('requiredRateOfReturnError').textContent = ";
calculateFairValue();
}
function copyResults() {
var fairValue = fairValueResultDisplay.textContent;
var nextDividend = nextDividendDisplay.textContent;
var growthRate = growthRateDisplay.textContent;
var requiredReturn = requiredReturnDisplay.textContent;
var currentPrice = currentPriceAssumptionDisplay.textContent;
var lastDividend = lastDividendAssumptionDisplay.textContent;
if (fairValue === '–') {
alert("No results to copy yet.");
return;
}
var resultText = "Fair Value Calculation Results:\n\n" +
"Fair Value: " + fairValue + "\n" +
"—————————-\n" +
"Key Metrics:\n" +
" Next Expected Dividend (D1): " + nextDividend + "\n" +
" Dividend Growth Rate (g): " + growthRate + "\n" +
" Required Rate of Return (r): " + requiredReturn + "\n" +
"—————————-\n" +
"Assumptions:\n" +
" Current Stock Price: " + currentPrice + "\n" +
" Last Paid Dividend (D0): " + lastDividend + "\n\n" +
"Formula Used: Fair Value = D1 / (r – g)";
try {
navigator.clipboard.writeText(resultText).then(function() {
alert('Results copied to clipboard!');
}, function(err) {
console.error('Failed to copy: ', err);
alert('Failed to copy results. Please copy manually.');
});
} catch (e) {
console.error('Clipboard API not available: ', e);
alert('Clipboard API not available. Please copy manually.');
}
}
// Initial calculation and chart setup on page load
document.addEventListener('DOMContentLoaded', function() {
resetCalculator(); // Load with default values
initializeChart();
// Mock initial chart update if needed, or wait for first calculation
var price = parseFloat(currentStockPriceInput.value);
var d0 = parseFloat(lastDividendInput.value);
var g = parseFloat(expectedDividendGrowthRateInput.value) / 100;
var r = parseFloat(requiredRateOfReturnInput.value) / 100;
if (g < r) {
var d1 = d0 * (1 + g);
var fairValue = d1 / (r – g);
updateChart(price, fairValue, 'Initial');
}
// Add event listeners for real-time updates
currentStockPriceInput.addEventListener('input', calculateFairValue);
lastDividendInput.addEventListener('input', calculateFairValue);
expectedDividendGrowthRateInput.addEventListener('input', calculateFairValue);
requiredRateOfReturnInput.addEventListener('input', calculateFairValue);
});