Intrinsic Value of Stock Calculator

Intrinsic Value of Stock Calculator & Guide :root { –primary-color: #004a99; –success-color: #28a745; –background-color: #f8f9fa; –text-color: #333; –border-color: #ddd; –card-background: #fff; –shadow: 0 2px 5px rgba(0,0,0,0.1); } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(–background-color); color: var(–text-color); line-height: 1.6; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: var(–card-background); border-radius: 8px; box-shadow: var(–shadow); } header { background-color: var(–primary-color); color: white; padding: 20px 0; text-align: center; margin-bottom: 20px; border-radius: 8px 8px 0 0; } header h1 { margin: 0; font-size: 2.5em; } h1, h2, h3 { color: var(–primary-color); } .calculator-section { margin-bottom: 40px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: var(–shadow); } .calculator-section h2 { text-align: center; margin-top: 0; margin-bottom: 25px; } .loan-calc-container { display: flex; flex-direction: column; gap: 15px; } .input-group { display: flex; flex-direction: column; gap: 5px; } .input-group label { font-weight: bold; color: var(–primary-color); } .input-group input[type="number"], .input-group input[type="text"], .input-group select { padding: 10px; border: 1px solid var(–border-color); border-radius: 4px; font-size: 1em; width: calc(100% – 22px); /* Adjust for padding and border */ } .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 2px rgba(0, 74, 153, 0.2); } .input-group .helper-text { font-size: 0.85em; color: #666; margin-top: 5px; } .input-group .error-message { color: red; font-size: 0.8em; margin-top: 5px; display: none; /* Hidden by default */ } .button-group { display: flex; gap: 10px; margin-top: 20px; justify-content: center; flex-wrap: wrap; } button { padding: 12px 25px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s ease; } .btn-calculate { background-color: var(–primary-color); color: white; } .btn-calculate:hover { background-color: #003366; } .btn-reset { background-color: #6c757d; color: white; } .btn-reset:hover { background-color: #5a6268; } .btn-copy { background-color: var(–success-color); color: white; } .btn-copy:hover { background-color: #218838; } #results-container { margin-top: 30px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: var(–shadow); text-align: center; } #results-container h3 { margin-top: 0; color: var(–primary-color); } .primary-result { font-size: 2.2em; font-weight: bold; color: var(–success-color); margin: 15px 0; padding: 15px; background-color: #e9f7ef; border-radius: 5px; display: inline-block; } .intermediate-results div, .formula-explanation { margin-bottom: 15px; font-size: 1.1em; } .intermediate-results span { font-weight: bold; color: var(–primary-color); } .formula-explanation { font-style: italic; color: #555; border-top: 1px dashed var(–border-color); padding-top: 15px; margin-top: 20px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; box-shadow: var(–shadow); } th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(–border-color); } thead { background-color: var(–primary-color); color: white; } tbody tr:nth-child(even) { background-color: #f2f2f2; } caption { font-size: 1.1em; font-weight: bold; color: var(–primary-color); margin-bottom: 10px; text-align: left; } canvas { display: block; margin: 20px auto; max-width: 100%; border: 1px solid var(–border-color); border-radius: 4px; } .article-section { margin-top: 40px; padding: 25px; border: 1px solid var(–border-color); border-radius: 8px; background-color: var(–card-background); box-shadow: var(–shadow); } .article-section h2, .article-section h3 { margin-bottom: 15px; } .article-section p { margin-bottom: 15px; } .article-section ul, .article-section ol { margin-left: 20px; margin-bottom: 15px; } .article-section li { margin-bottom: 8px; } .faq-item { margin-bottom: 15px; border-bottom: 1px dashed var(–border-color); padding-bottom: 10px; } .faq-item:last-child { border-bottom: none; } .faq-item strong { color: var(–primary-color); display: block; margin-bottom: 5px; } .internal-links-section ul { list-style: none; padding: 0; } .internal-links-section li { margin-bottom: 10px; } .internal-links-section a { color: var(–primary-color); text-decoration: none; font-weight: bold; } .internal-links-section a:hover { text-decoration: underline; } .internal-links-section span { font-size: 0.9em; color: #555; display: block; margin-top: 3px; } .highlight { background-color: yellow; font-weight: bold; } @media (min-width: 768px) { .container { margin: 30px auto; } .calculator-section, .article-section { padding: 30px; } .button-group { justify-content: flex-start; } }

Intrinsic Value of Stock Calculator

Calculate Intrinsic Value

The company's profit allocated to each outstanding share of common stock.
The anticipated annual increase in EPS. Enter as a percentage (e.g., 10 for 10%).
Your minimum acceptable annual return on investment. Enter as a percentage (e.g., 12 for 12%).
The stable, long-term growth rate of the company beyond the explicit forecast period. Enter as a percentage (e.g., 3 for 3%).
The number of years for which you will explicitly forecast EPS growth.

Calculation Results

The intrinsic value is calculated using a Discounted Cash Flow (DCF) model, specifically the Gordon Growth Model for terminal value. It sums the present values of projected future earnings and the present value of the company's terminal value.

Projected EPS and Present Values

Projected EPS Growth and Present Value of Forecasted Earnings
Year Projected EPS Discount Factor Present Value of EPS

What is Intrinsic Value of Stock?

The intrinsic value of stock represents the true, underlying worth of a company's stock, independent of its current market price. It's what an investor believes a stock is worth based on fundamental analysis, considering factors like earnings, assets, dividends, and future growth prospects. Unlike the market price, which can fluctuate due to speculation, sentiment, or short-term news, intrinsic value aims to reflect the company's long-term earning power and financial health. It's a cornerstone concept for value investors who seek to buy stocks trading below their perceived intrinsic value, believing the market will eventually recognize the true worth.

Who Should Use It:

  • Long-term investors seeking undervalued assets.
  • Fundamental analysts performing due diligence.
  • Portfolio managers assessing stock attractiveness.
  • Anyone wanting to understand a stock's true worth beyond its ticker price.

Common Misconceptions:

  • Intrinsic Value = Market Price: This is incorrect. Intrinsic value is an estimate, while market price is the current trading price. The goal is often to find discrepancies.
  • It's a Single, Fixed Number: Intrinsic value is an estimate that changes based on assumptions about future performance, economic conditions, and discount rates. Different analysts will arrive at different intrinsic values for the same stock.
  • It Guarantees Profit: While buying below intrinsic value increases the probability of profit, it doesn't guarantee it. Unforeseen events can impact even fundamentally sound companies.

Intrinsic Value of Stock Formula and Mathematical Explanation

The most common method for calculating the intrinsic value of stock is the Discounted Cash Flow (DCF) model. A popular variation is the Dividend Discount Model (DDM), but for a broader application, we'll focus on a DCF approach that uses Earnings Per Share (EPS) as a proxy for cash flow, especially when dividends are not consistently paid or are reinvested.

The core idea is to project the company's future earnings (or cash flows) and then discount them back to their present value using a required rate of return. This accounts for the time value of money – a dollar today is worth more than a dollar in the future.

The Formula (Simplified DCF using EPS):

Intrinsic Value = PV(Projected EPS for Year 1) + PV(Projected EPS for Year 2) + … + PV(Projected EPS for Year N) + PV(Terminal Value)

Where:

  • PV(X) = Present Value of X
  • N = Number of forecast years

Step-by-Step Derivation:

  1. Project Future EPS: Estimate the EPS for each year over a defined forecast period (e.g., 5 years). This is typically done by taking the current EPS and applying an expected annual growth rate.
    EPS(Year t) = Current EPS * (1 + Growth Rate)^(t)
  2. Calculate Discount Factor: For each year, determine the factor by which to discount future earnings. This is based on the required rate of return (discount rate).
    Discount Factor(Year t) = 1 / (1 + Discount Rate)^(t)
  3. Calculate Present Value of Projected EPS: Multiply the projected EPS for each year by its corresponding discount factor.
    PV(EPS Year t) = EPS(Year t) * Discount Factor(Year t)
  4. Calculate Terminal Value: Estimate the value of the company beyond the explicit forecast period. A common method is the Gordon Growth Model (a form of perpetual growth DCF), assuming earnings grow at a stable rate indefinitely.
    Terminal Value = [EPS(Year N+1) * (1 + Terminal Growth Rate)] / (Discount Rate – Terminal Growth Rate)
    Where EPS(Year N+1) = EPS(Year N) * (1 + Growth Rate)
  5. Calculate Present Value of Terminal Value: Discount the calculated terminal value back to the present.
    PV(Terminal Value) = Terminal Value / (1 + Discount Rate)^(N)
  6. Sum Present Values: Add the present values of all projected EPSs and the present value of the terminal value to arrive at the estimated intrinsic value per share.

Variables Table:

Variable Meaning Unit Typical Range
Current EPS Company's earnings per share in the most recent period. Currency per Share (e.g., USD/Share) Varies widely by industry and company size. Positive values expected.
Expected Annual Growth Rate Anticipated rate at which EPS will increase annually during the forecast period. Percentage (%) 0% to 30% (highly dependent on company stage and industry)
Required Rate of Return (Discount Rate) Minimum acceptable annual return an investor expects from an investment. Reflects risk. Percentage (%) 8% to 20% (higher for riskier stocks)
Terminal Growth Rate Stable, long-term growth rate assumed for the company beyond the explicit forecast period. Should not exceed the long-term economic growth rate. Percentage (%) 2% to 5%
Forecast Years (N) Number of years for explicit EPS projections. Years 3 to 10 years
Terminal Value Estimated value of the company beyond the explicit forecast period. Currency per Share (e.g., USD/Share) Varies widely.
Present Value (PV) The current worth of a future sum of money or stream of cash flows given a specified rate of return. Currency per Share (e.g., USD/Share) Varies widely.
Intrinsic Value Estimated true value of the stock based on fundamental analysis. Currency per Share (e.g., USD/Share) Varies widely.

Practical Examples (Real-World Use Cases)

Understanding the intrinsic value of stock is crucial for making informed investment decisions. Here are two practical examples:

Example 1: Stable Growth Tech Company

Scenario: An investor is analyzing "TechCorp," a mature software company with a history of consistent earnings growth.

Inputs:

  • Current EPS: $8.00
  • Expected Annual Growth Rate: 12% (for the next 5 years)
  • Required Rate of Return: 15%
  • Terminal Growth Rate: 4%
  • Forecast Years: 5

Calculation Steps (Illustrative):

  • EPS Year 1: $8.00 * (1 + 0.12)^1 = $8.96
  • EPS Year 2: $8.00 * (1 + 0.12)^2 = $10.04
  • … and so on for 5 years.
  • EPS Year 5: $8.00 * (1 + 0.12)^5 = $14.16
  • EPS Year 6 (for Terminal Value): $14.16 * (1 + 0.12) = $15.86
  • Terminal Value = ($15.86 * (1 + 0.04)) / (0.15 – 0.04) = $16.496 / 0.11 = $149.96
  • Sum of PV of EPS (Years 1-5): Approximately $45.50 (calculated by the tool)
  • PV of Terminal Value = $149.96 / (1 + 0.15)^5 = $149.96 / 2.011 = $74.57
  • Intrinsic Value = $45.50 + $74.57 = $120.07

Interpretation: The investor estimates TechCorp's intrinsic value to be approximately $120.07 per share. If the stock is currently trading at $100, it might be considered undervalued, presenting a potential buying opportunity. If it's trading at $130, it might be considered overvalued.

Example 2: High-Growth Startup (Hypothetical)

Scenario: An investor is evaluating "InnovateX," a rapidly growing tech startup with high but volatile earnings growth.

Inputs:

  • Current EPS: $1.50
  • Expected Annual Growth Rate: 25% (for the next 5 years)
  • Required Rate of Return: 20% (higher due to risk)
  • Terminal Growth Rate: 5%
  • Forecast Years: 5

Calculation Steps (Illustrative):

  • EPS Year 1: $1.50 * (1 + 0.25)^1 = $1.88
  • … and so on for 5 years.
  • EPS Year 5: $1.50 * (1 + 0.25)^5 = $4.58
  • EPS Year 6 (for Terminal Value): $4.58 * (1 + 0.25) = $5.73
  • Terminal Value = ($5.73 * (1 + 0.05)) / (0.20 – 0.05) = $6.0165 / 0.15 = $40.11
  • Sum of PV of EPS (Years 1-5): Approximately $15.20 (calculated by the tool)
  • PV of Terminal Value = $40.11 / (1 + 0.20)^5 = $40.11 / 2.488 = $16.12
  • Intrinsic Value = $15.20 + $16.12 = $31.32

Interpretation: InnovateX's estimated intrinsic value is $31.32. Given the high growth rate and higher risk (reflected in the discount rate), the investor needs to compare this to the current market price. If the stock trades significantly above $31.32, the investor might deem it too risky or overvalued despite the high growth potential.

How to Use This Intrinsic Value of Stock Calculator

Our intrinsic value of stock calculator is designed to be intuitive and provide a quick estimate based on the Discounted Cash Flow (DCF) model. Follow these steps:

  1. Gather Key Financial Data: Before using the calculator, you'll need the following information for the stock you're analyzing:
    • Current Earnings Per Share (EPS)
    • Your estimate for the company's expected annual EPS growth rate over the next few years.
    • Your required rate of return (discount rate), reflecting the risk you perceive in the investment.
    • Your assumption for the company's long-term, stable growth rate (terminal growth rate).
    • The number of years you want to explicitly forecast earnings for.
  2. Input the Data: Enter the gathered figures into the corresponding fields in the calculator. Ensure you enter percentages as whole numbers (e.g., 12 for 12%).
  3. Calculate: Click the "Calculate Intrinsic Value" button.
  4. Review Results: The calculator will display:
    • Primary Result: The estimated intrinsic value per share.
    • Intermediate Values: Key components like the projected EPS for each forecast year, the calculated terminal value, and the present value of future cash flows.
    • Chart: A visual representation of projected EPS growth and the present value of those earnings over time.
    • Table: A detailed breakdown of yearly projections, discount factors, and present values.
    • Formula Explanation: A brief description of the methodology used.
  5. Interpret the Findings: Compare the calculated intrinsic value to the stock's current market price.
    • If Intrinsic Value > Market Price: The stock may be undervalued.
    • If Intrinsic Value < Market Price: The stock may be overvalued.
    • If Intrinsic Value ≈ Market Price: The stock may be fairly valued.
    Remember, this is an estimate. Consider it alongside other qualitative factors (management quality, competitive landscape, industry trends) and quantitative metrics.
  6. Reset or Copy: Use the "Reset" button to clear fields and start over. Use the "Copy Results" button to easily transfer the key figures for your records or reports.

Decision-Making Guidance: Use the intrinsic value as a guide, not a definitive answer. A significant margin of safety (the difference between intrinsic value and market price) is often sought by value investors to account for estimation errors and unforeseen risks.

Key Factors That Affect Intrinsic Value Results

The calculation of the intrinsic value of stock is highly sensitive to the assumptions made. Several key factors significantly influence the outcome:

  1. Earnings Per Share (EPS) Accuracy: The starting point, current EPS, must be accurate and representative. Using adjusted EPS or normalized EPS can sometimes provide a more stable base than reported EPS, which might be affected by one-off events.
  2. Growth Rate Assumptions: This is arguably the most critical input. Overestimating the growth rate will inflate the intrinsic value, while underestimating it will depress it. Realistic, sustainable growth rates based on historical performance, industry trends, and company strategy are essential. High-growth phases are often followed by slower, more stable growth.
  3. Discount Rate (Required Rate of Return): This reflects the riskiness of the investment. A higher discount rate (due to higher perceived risk, market volatility, or interest rates) will significantly reduce the present value of future earnings, thus lowering the intrinsic value. Conversely, a lower discount rate increases intrinsic value. It should align with the investor's opportunity cost and the specific risks of the company and sector.
  4. Terminal Growth Rate: This assumption dictates the value of the company beyond the explicit forecast period. It should be conservative, typically reflecting long-term economic growth rates. An overly optimistic terminal growth rate can disproportionately inflate the total intrinsic value, especially for companies expected to grow indefinitely.
  5. Forecast Period Length: A longer explicit forecast period allows for more aggressive growth assumptions before transitioning to the stable terminal growth rate. However, projections become less reliable further into the future. The choice of forecast years impacts the weighting of explicit forecasts versus the terminal value.
  6. Reinvestment Rate and Return on Invested Capital (ROIC): While not explicit inputs in this simplified calculator, the underlying drivers of EPS growth are a company's ability to reinvest earnings effectively and generate high returns on that capital. A company that reinvests heavily but earns low returns may not see its EPS grow sustainably or profitably, impacting future intrinsic value.
  7. Economic Conditions and Inflation: Broader economic factors influence both company growth prospects and the appropriate discount rate. High inflation might necessitate higher discount rates and could impact a company's ability to grow earnings in real terms.
  8. Industry Dynamics and Competitive Landscape: The long-term viability and growth potential of a company are heavily influenced by its industry. Disruptive technologies, regulatory changes, and competitive pressures can alter future earnings potential and thus intrinsic value.

Frequently Asked Questions (FAQ)

Q1: What is the difference between intrinsic value and market price?

Intrinsic value is an estimate of a stock's true worth based on fundamental analysis, while market price is the current price at which the stock is trading on an exchange. Value investors aim to buy stocks when the market price is significantly below their estimated intrinsic value.

Q2: Is intrinsic value a fixed number?

No, intrinsic value is an estimate that depends heavily on the assumptions used in the calculation (e.g., growth rates, discount rates). Different analysts using different assumptions will arrive at different intrinsic values for the same stock.

Q3: How reliable is the intrinsic value calculation?

The reliability depends on the quality of the inputs and the chosen valuation model. The DCF model, while widely used, is sensitive to assumptions. It's best used as one tool among many for investment analysis.

Q4: Can a stock's intrinsic value decrease?

Yes. If a company's fundamentals deteriorate (e.g., declining earnings, increased debt, poor management decisions, adverse industry changes), its intrinsic value can decrease. Changes in market interest rates or investor risk appetite can also lower intrinsic value by increasing the discount rate.

Q5: What is a good margin of safety?

A margin of safety is the difference between the estimated intrinsic value and the market price. A common rule of thumb is to seek a margin of safety of 20-30% or more. This buffer helps protect against errors in estimation and unforeseen negative events.

Q6: Should I use dividends or EPS for intrinsic value calculation?

Both can be used. The Dividend Discount Model (DDM) uses projected future dividends. The DCF model using EPS (as in this calculator) is often more applicable for companies that reinvest earnings rather than paying them out as dividends, or for growth companies where dividends are minimal.

Q7: How does the terminal growth rate affect the intrinsic value?

The terminal value often represents a significant portion of the total intrinsic value. Therefore, the terminal growth rate assumption has a substantial impact. It should be conservative and reflect long-term economic prospects, not short-term company growth spurts.

Q8: Can this calculator be used for all types of stocks?

This calculator, based on a DCF model using EPS and a perpetual growth assumption, is most suitable for mature, stable companies with predictable earnings growth. It may be less accurate for early-stage startups with erratic earnings, cyclical companies, or companies with negative earnings.

Related Tools and Internal Resources

© 2023 Your Financial Website. All rights reserved. This calculator and information are for educational purposes only and do not constitute financial advice.
var chartInstance = null; // Global variable to hold chart instance function validateInput(id, min, max, message) { var input = document.getElementById(id); var errorElement = document.getElementById(id + 'Error'); var value = parseFloat(input.value); errorElement.style.display = 'none'; // Hide error by default if (isNaN(value)) { errorElement.textContent = "Please enter a valid number."; errorElement.style.display = 'block'; return false; } if (value max) { errorElement.textContent = message || `Value cannot exceed ${max}.`; errorElement.style.display = 'block'; return false; } return true; } function calculateIntrinsicValue() { // Clear previous errors document.getElementById('currentEpsError').style.display = 'none'; document.getElementById('growthRateError').style.display = 'none'; document.getElementById('discountRateError').style.display = 'none'; document.getElementById('terminalGrowthRateError').style.display = 'none'; document.getElementById('forecastYearsError').style.display = 'none'; // Get input values var currentEps = parseFloat(document.getElementById('currentEps').value); var growthRate = parseFloat(document.getElementById('growthRate').value) / 100; var discountRate = parseFloat(document.getElementById('discountRate').value) / 100; var terminalGrowthRate = parseFloat(document.getElementById('terminalGrowthRate').value) / 100; var forecastYears = parseInt(document.getElementById('forecastYears').value); // Input Validations var isValid = true; if (!validateInput('currentEps', 0, Infinity, 'EPS cannot be negative.')) isValid = false; if (!validateInput('growthRate', 0, 100, 'Growth rate must be between 0% and 100%.')) isValid = false; if (!validateInput('discountRate', 0.01, 1, 'Discount rate must be greater than 0% and less than or equal to 100%.')) isValid = false; if (!validateInput('terminalGrowthRate', 0, 0.99, 'Terminal growth rate must be between 0% and 99%.')) isValid = false; if (!validateInput('forecastYears', 1, 50, 'Forecast years must be between 1 and 50.')) isValid = false; // Specific validation for discount rate vs terminal growth rate if (discountRate <= terminalGrowthRate) { document.getElementById('terminalGrowthRateError').textContent = "Terminal growth rate must be less than the discount rate."; document.getElementById('terminalGrowthRateError').style.display = 'block'; isValid = false; } if (!isValid) { document.getElementById('intrinsicValue').innerHTML = 'Please correct the errors above.'; document.getElementById('epsForecasts').innerHTML = "; document.getElementById('terminalValue').innerHTML = "; document.getElementById('presentValueFcf').innerHTML = "; clearChart(); clearTable(); return; } var projectedEpsValues = []; var pvEpsValues = []; var discountFactors = []; var totalPvEps = 0; var epsYearN = currentEps; // Calculate projected EPS and PV of EPS for forecast years for (var i = 1; i <= forecastYears; i++) { epsYearN = epsYearN * (1 + growthRate); projectedEpsValues.push(epsYearN); var discountFactor = 1 / Math.pow(1 + discountRate, i); discountFactors.push(discountFactor); var pvEps = epsYearN * discountFactor; pvEpsValues.push(pvEps); totalPvEps += pvEps; } // Calculate Terminal Value var epsYearNPlus1 = epsYearN * (1 + growthRate); var terminalValue = (epsYearNPlus1 * (1 + terminalGrowthRate)) / (discountRate – terminalGrowthRate); var pvTerminalValue = terminalValue / Math.pow(1 + discountRate, forecastYears); // Calculate Intrinsic Value var intrinsicValue = totalPvEps + pvTerminalValue; // Display Results document.getElementById('epsForecasts').innerHTML = 'Projected EPS (Year ' + forecastYears + '): ' + epsYearN.toFixed(2) + ' per share'; document.getElementById('terminalValue').innerHTML = 'Present Value of Terminal Value: $' + pvTerminalValue.toFixed(2); document.getElementById('presentValueFcf').innerHTML = 'Total Present Value of Forecasted EPS: $' + totalPvEps.toFixed(2); document.getElementById('intrinsicValue').innerHTML = '$' + intrinsicValue.toFixed(2); // Update Table updateProjectionTable(projectedEpsValues, discountFactors, pvEpsValues, forecastYears); // Update Chart updateChart(projectedEpsValues, pvEpsValues, forecastYears); } function updateProjectionTable(projectedEps, pvEps, discountFactors, forecastYears) { var tableBody = document.getElementById('projectionTableBody'); tableBody.innerHTML = "; // Clear existing rows for (var i = 0; i < forecastYears; i++) { var row = tableBody.insertRow(); var year = i + 1; row.insertCell(0).textContent = year; row.insertCell(1).textContent = '$' + projectedEps[i].toFixed(2); row.insertCell(2).textContent = (discountFactors[i] * 100).toFixed(2) + '%'; row.insertCell(3).textContent = '$' + pvEps[i].toFixed(2); } } function updateChart(projectedEps, pvEps, forecastYears) { var ctx = document.getElementById('epsChart').getContext('2d'); // Destroy previous chart instance if it exists if (chartInstance) { chartInstance.destroy(); } var labels = []; for (var i = 1; i <= forecastYears; i++) { labels.push('Year ' + i); } chartInstance = new Chart(ctx, { type: 'line', data: { labels: labels, datasets: [{ label: 'Projected EPS', data: projectedEps, borderColor: 'var(–primary-color)', backgroundColor: 'rgba(0, 74, 153, 0.1)', fill: true, tension: 0.1 }, { label: 'Present Value of EPS', data: pvEps, borderColor: 'var(–success-color)', backgroundColor: 'rgba(40, 167, 69, 0.1)', fill: true, tension: 0.1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, title: { display: true, text: 'Value (per share)' } }, x: { title: { display: true, text: 'Forecast Year' } } }, plugins: { legend: { position: 'top', }, title: { display: true, text: 'Projected EPS vs. Present Value of EPS' } } } }); } function clearChart() { var canvas = document.getElementById('epsChart'); var ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, canvas.width, canvas.height); if (chartInstance) { chartInstance.destroy(); chartInstance = null; } } function clearTable() { document.getElementById('projectionTableBody').innerHTML = ''; } function resetCalculator() { document.getElementById('currentEps').value = '5.25'; document.getElementById('growthRate').value = '10'; document.getElementById('discountRate').value = '12'; document.getElementById('terminalGrowthRate').value = '3'; document.getElementById('forecastYears').value = '5'; // Clear errors document.getElementById('currentEpsError').style.display = 'none'; document.getElementById('growthRateError').style.display = 'none'; document.getElementById('discountRateError').style.display = 'none'; document.getElementById('terminalGrowthRateError').style.display = 'none'; document.getElementById('forecastYearsError').style.display = 'none'; // Clear results document.getElementById('intrinsicValue').innerHTML = ''; document.getElementById('epsForecasts').innerHTML = ''; document.getElementById('terminalValue').innerHTML = ''; document.getElementById('presentValueFcf').innerHTML = ''; clearChart(); clearTable(); } function copyResults() { var intrinsicValue = document.getElementById('intrinsicValue').innerText; var epsForecasts = document.getElementById('epsForecasts').innerText; var terminalValue = document.getElementById('terminalValue').innerText; var presentValueFcf = document.getElementById('presentValueFcf').innerText; var assumptions = "Assumptions:\n"; assumptions += "Current EPS: $" + document.getElementById('currentEps').value + "\n"; assumptions += "Growth Rate: " + document.getElementById('growthRate').value + "%\n"; assumptions += "Discount Rate: " + document.getElementById('discountRate').value + "%\n"; assumptions += "Terminal Growth Rate: " + document.getElementById('terminalGrowthRate').value + "%\n"; assumptions += "Forecast Years: " + document.getElementById('forecastYears').value + "\n"; var resultsText = "Intrinsic Value Calculation Results:\n\n"; resultsText += intrinsicValue + "\n"; resultsText += epsForecasts + "\n"; resultsText += terminalValue + "\n"; resultsText += presentValueFcf + "\n\n"; resultsText += assumptions; // Use a temporary textarea to copy text var textArea = document.createElement("textarea"); textArea.value = resultsText; textArea.style.position = "fixed"; textArea.style.left = "-9999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Results copied successfully!' : 'Failed to copy results.'; // Optionally show a temporary message to the user console.log(msg); } catch (err) { console.error('Unable to copy results', err); } document.body.removeChild(textArea); } // Initialize calculator with default values on load window.onload = function() { resetCalculator(); // Add Chart.js library dynamically if not already present if (typeof Chart === 'undefined') { var script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/chart.js@3.7.0/dist/chart.min.js'; script.onload = function() { console.log('Chart.js loaded.'); // Recalculate after chart library is loaded to ensure chart is drawn calculateIntrinsicValue(); }; document.head.appendChild(script); } else { calculateIntrinsicValue(); // Calculate if Chart.js is already available } };

Leave a Comment