Cost of Capital Calculation Using Weighted Asset Beta

Cost of Capital Calculation using Weighted Asset Beta – Financial Calculator body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; background-color: #f8f9fa; margin: 0; padding: 0; } .container { max-width: 960px; margin: 20px auto; padding: 20px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } h1, h2, h3 { color: #004a99; } h1 { text-align: center; margin-bottom: 20px; font-size: 2.5em; } h2 { margin-top: 30px; margin-bottom: 15px; border-bottom: 2px solid #004a99; padding-bottom: 5px; } h3 { margin-top: 20px; margin-bottom: 10px; } .calculator-wrapper { background-color: #eef5f9; padding: 25px; border-radius: 8px; margin-bottom: 30px; border: 1px solid #d0e0e9; } .calculator-wrapper h2 { margin-top: 0; text-align: center; border-bottom: none; margin-bottom: 25px; } .input-group { margin-bottom: 20px; text-align: left; } .input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #004a99; } .input-group input[type="number"], .input-group select { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; box-sizing: border-box; } .input-group select { cursor: pointer; } .input-group .helper-text { font-size: 0.85em; color: #555; margin-top: 5px; display: block; } .error-message { color: #dc3545; font-size: 0.8em; margin-top: 5px; display: none; /* Hidden by default */ } .error-message.visible { display: block; } .button-group { display: flex; justify-content: space-between; margin-top: 25px; gap: 10px; } .btn { padding: 12px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s ease; flex: 1; text-align: center; } .btn-primary { background-color: #004a99; color: white; } .btn-primary:hover { background-color: #003b7a; } .btn-secondary { background-color: #6c757d; color: white; } .btn-secondary:hover { background-color: #5a6268; } .btn-copy { background-color: #17a2b8; color: white; } .btn-copy:hover { background-color: #138496; } .results-container { margin-top: 30px; padding: 20px; background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; } .results-container h3 { margin-top: 0; color: #004a99; text-align: center; margin-bottom: 20px; } .result-item { margin-bottom: 15px; font-size: 1.1em; display: flex; justify-content: space-between; align-items: center; } .result-item label { color: #333; font-weight: normal; } .result-value { font-weight: bold; color: #004a99; } .highlight-result { background-color: #28a745; color: white; padding: 15px 20px; border-radius: 5px; margin-top: 15px; margin-bottom: 20px; font-size: 1.3em; text-align: right; font-weight: bold; display: flex; justify-content: space-between; align-items: center; } .highlight-result-label { font-weight: bold; } .formula-explanation { margin-top: 15px; padding: 10px; background-color: #e9ecef; border-left: 4px solid #004a99; font-size: 0.95em; color: #444; } table { width: 100%; border-collapse: collapse; margin-top: 25px; margin-bottom: 25px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #ddd; } thead { background-color: #004a99; color: white; } tbody tr:nth-child(even) { background-color: #f2f2f2; } caption { caption-side: bottom; font-size: 0.9em; color: #666; margin-top: 8px; text-align: left; } .chart-container { position: relative; width: 100%; height: 300px; margin-top: 25px; background-color: #fff; padding: 15px; border-radius: 8px; border: 1px solid #e0e0e0; } .chart-container canvas { width: 100%; height: 100%; } .chart-caption { font-size: 0.9em; color: #666; margin-top: 8px; text-align: center; } .article-content { margin-top: 30px; background-color: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .article-content p { margin-bottom: 15px; } .article-content ul, .article-content ol { margin-bottom: 15px; padding-left: 20px; } .article-content li { margin-bottom: 8px; } .article-content a { color: #004a99; text-decoration: none; font-weight: bold; } .article-content a:hover { text-decoration: underline; } .faq-item { margin-bottom: 15px; padding: 10px; border: 1px solid #e0e0e0; border-radius: 4px; background-color: #fefefe; } .faq-item strong { color: #004a99; display: block; margin-bottom: 5px; } .related-links ul { list-style: none; padding: 0; } .related-links li { margin-bottom: 10px; } .related-links a { font-weight: bold; } .related-links span { font-size: 0.9em; color: #555; display: block; margin-top: 3px; }

Cost of Capital Calculation using Weighted Asset Beta

Calculate and understand your company's Weighted Average Cost of Capital (WACC) with our comprehensive tool and guide.

Weighted Average Cost of Capital (WACC) Calculator

This calculator helps estimate your company's cost of capital by considering the proportion and cost of its debt and equity financing, adjusted by asset beta.

Proportion of equity in your capital structure (e.g., 0.70 for 70%). Must be between 0 and 1.
Expected return on equity (e.g., 12%). Enter as a decimal (0.12 for 12%).
Proportion of debt in your capital structure (e.g., 0.30 for 30%). Must be between 0 and 1.
Interest rate on debt (e.g., 5%). Enter as a decimal (0.05 for 5%).
Your company's effective corporate tax rate (e.g., 25%). Enter as a decimal (0.25 for 25%).
The unlevered beta reflecting the systematic risk of the company's assets (e.g., 1.1). Typically between 0.5 and 2.0.
Return on a risk-free investment (e.g., 3%). Enter as a decimal (0.03 for 3%).
Expected return of the market minus the risk-free rate (e.g., 6%). Enter as a decimal (0.06 for 6%).

Calculation Results

Weighted Average Cost of Capital (WACC):
Formula Used:
WACC = (We * Re) + (Wd * Rd * (1 – T))

The cost of equity (Re) is often estimated using the Capital Asset Pricing Model (CAPM): Re = Rf + βa * MRP. This calculator uses the provided Re, but the asset beta, risk-free rate, and market risk premium are provided for context and can influence Re in a full CAPM calculation. The primary WACC formula used here is the weighted average of the costs of equity and after-tax debt.
Comparison of Equity Cost, Debt Cost, and WACC
Key Variables and Their Impact
Variable Meaning Unit Typical Range
Weight of Equity (We) Proportion of equity financing. Decimal (0-1) 0.40 – 0.90
Cost of Equity (Re) Required return for equity investors. Decimal (e.g., 0.12 for 12%) 0.08 – 0.20
Weight of Debt (Wd) Proportion of debt financing. Decimal (0-1) 0.10 – 0.60
Cost of Debt (Rd) Interest rate paid on debt. Decimal (e.g., 0.05 for 5%) 0.03 – 0.10
Corporate Tax Rate (T) Company's effective tax rate. Decimal (e.g., 0.25 for 25%) 0.15 – 0.35
Asset Beta (βa) Systematic risk of company assets (unlevered). Number 0.50 – 2.00
Risk-Free Rate (Rf) Return on risk-free asset. Decimal (e.g., 0.03 for 3%) 0.01 – 0.05
Market Risk Premium (MRP) Additional return for investing in market over risk-free rate. Decimal (e.g., 0.06 for 6%) 0.04 – 0.08

What is Cost of Capital Calculation using Weighted Asset Beta?

The cost of capital calculation using weighted asset beta is a method used to determine a company's overall cost of financing. It's often referred to as the Weighted Average Cost of Capital (WACC). This metric represents the blended cost of all the different types of capital a company uses, primarily debt and equity, weighted by their proportion in the company's capital structure. The inclusion of "asset beta" in the description highlights a nuanced approach where the inherent business risk of the company's assets is considered, even when calculating the overall WACC. While WACC is typically calculated using the market values of debt and equity and their respective costs, understanding asset beta is crucial for deriving the cost of equity, especially when market data is volatile or unavailable.

Who should use it: This calculation is vital for financial managers, corporate strategists, investors, and analysts. Businesses use WACC to:

  • Evaluate potential investment projects and capital budgeting decisions (a project's expected return must exceed the WACC to be considered value-adding).
  • Determine the appropriate discount rate for future cash flows in valuation models.
  • Assess the company's overall financial risk and efficiency.
  • Benchmark against industry peers.

Common misconceptions: A frequent misunderstanding is that WACC is simply the average of the cost of debt and cost of equity. This is incorrect because it ignores the differing proportions (weights) of debt and equity and the tax shield provided by debt. Another misconception is that the asset beta is directly plugged into the WACC formula; instead, asset beta is primarily used to determine the cost of equity through models like CAPM, which is then used in the WACC calculation.

Cost of Capital Calculation using Weighted Asset Beta Formula and Mathematical Explanation

The core of the cost of capital calculation using weighted asset beta lies in determining the Weighted Average Cost of Capital (WACC). While asset beta (βa) is a crucial component in estimating the cost of equity, the WACC formula itself is a weighted average of the costs of each capital component.

Step 1: Determine the Cost of Equity (Re)

The cost of equity is the return required by equity investors. A common method to estimate this is the Capital Asset Pricing Model (CAPM):

Re = Rf + βa * MRP
  • Rf (Risk-Free Rate): The theoretical rate of return of an investment with zero risk. Typically, the yield on long-term government bonds is used as a proxy.
  • βa (Asset Beta): Also known as unlevered beta, this measures the systematic risk of the company's underlying assets, independent of its capital structure. It reflects the business risk inherent in the company's operations. To use asset beta in CAPM, it must first be used to calculate the equity beta (levered beta) if needed, or sometimes directly if the model is adapted for asset beta. For simplicity in this calculator, we provide inputs for Rf and MRP, and assume Re is provided directly, but acknowledge asset beta's role in its derivation.
  • MRP (Market Risk Premium): The excess return that investors expect to receive for investing in the stock market over the risk-free rate.

Step 2: Determine the Cost of Debt (Rd)

This is the effective interest rate a company pays on its current debt. It can be calculated by dividing the total annual interest expense by the total debt amount.

Step 3: Calculate the After-Tax Cost of Debt

Interest payments on debt are usually tax-deductible, creating a "tax shield" that reduces the effective cost of debt.

After-Tax Cost of Debt = Rd * (1 - T)
  • Rd: Cost of Debt.
  • T (Corporate Tax Rate): The company's effective corporate income tax rate.

Step 4: Determine the Weights of Debt and Equity

These weights represent the proportion of debt and equity in the company's total capital structure, typically calculated using market values.

We = Market Value of Equity / (Market Value of Equity + Market Value of Debt) Wd = Market Value of Debt / (Market Value of Equity + Market Value of Debt)

Note: We + Wd must equal 1.

Step 5: Calculate WACC

Combine the costs and weights of each component.

WACC = (We * Re) + (Wd * Rd * (1 - T))

Variables Table

Variable Meaning Unit Typical Range
Weight of Equity (We) Proportion of equity in capital structure. Decimal (0-1) 0.40 – 0.90
Cost of Equity (Re) Required return for equity investors. Decimal (e.g., 0.12 for 12%) 0.08 – 0.20
Weight of Debt (Wd) Proportion of debt in capital structure. Decimal (0-1) 0.10 – 0.60
Cost of Debt (Rd) Interest rate on debt. Decimal (e.g., 0.05 for 5%) 0.03 – 0.10
Corporate Tax Rate (T) Company's effective tax rate. Decimal (e.g., 0.25 for 25%) 0.15 – 0.35
Asset Beta (βa) Systematic risk of company assets (unlevered). Used in Re calculation. Number 0.50 – 2.00
Risk-Free Rate (Rf) Return on risk-free asset. Used in Re calculation. Decimal (e.g., 0.03 for 3%) 0.01 – 0.05
Market Risk Premium (MRP) Expected market return minus risk-free rate. Used in Re calculation. Decimal (e.g., 0.06 for 6%) 0.04 – 0.08

Practical Examples (Real-World Use Cases)

Understanding the cost of capital calculation using weighted asset beta is best illustrated with examples:

Example 1: Technology Startup Expansion

A fast-growing tech startup is considering a major expansion. They need to determine their WACC to evaluate if the projected returns from the expansion exceed their cost of capital.

  • Equity Weight (We): 75% (0.75)
  • Cost of Equity (Re): 15% (0.15) – derived from CAPM with an asset beta of 1.3.
  • Debt Weight (Wd): 25% (0.25)
  • Cost of Debt (Rd): 6% (0.06)
  • Corporate Tax Rate (T): 21% (0.21)

Calculation:

  • After-Tax Cost of Debt = 0.06 * (1 – 0.21) = 0.06 * 0.79 = 0.0474 (4.74%)
  • WACC = (0.75 * 0.15) + (0.25 * 0.0474)
  • WACC = 0.1125 + 0.01185
  • WACC = 0.12435 or 12.44%

Interpretation: The startup's cost of capital is approximately 12.44%. Any expansion project must aim to generate returns higher than this rate to create shareholder value. The high cost of equity reflects the startup's risk profile, while the lower after-tax cost of debt benefits from the tax shield.

Example 2: Mature Manufacturing Company Acquisition

A large, stable manufacturing company is acquiring a smaller competitor. They need to calculate their WACC to properly discount the target company's projected cash flows for valuation.

  • Equity Weight (We): 60% (0.60)
  • Cost of Equity (Re): 10% (0.10) – derived from CAPM with an asset beta of 0.9.
  • Debt Weight (Wd): 40% (0.40)
  • Cost of Debt (Rd): 4% (0.04)
  • Corporate Tax Rate (T): 28% (0.28)

Calculation:

  • After-Tax Cost of Debt = 0.04 * (1 – 0.28) = 0.04 * 0.72 = 0.0288 (2.88%)
  • WACC = (0.60 * 0.10) + (0.40 * 0.0288)
  • WACC = 0.0600 + 0.01152
  • WACC = 0.07152 or 7.15%

Interpretation: This mature company has a lower cost of capital (7.15%) due to its stable operations (lower asset beta) and significant debt financing, which is cheaper due to its lower risk and tax deductibility. This lower WACC will result in a higher valuation for the target acquisition compared to if they had a higher cost of capital.

How to Use This Cost of Capital Calculation using Weighted Asset Beta Calculator

Our WACC calculator simplifies the process of determining your company's cost of capital. Follow these steps:

  1. Input Capital Structure Weights: Enter the proportion (as a decimal, e.g., 0.70 for 70%) of equity (We) and debt (Wd) in your company's total financing. Ensure We + Wd = 1.
  2. Enter Cost of Equity (Re): Input the required rate of return for your equity investors. This is often calculated using CAPM (Re = Rf + βa * MRP), where βa (asset beta) is a measure of your company's business risk.
  3. Enter Cost of Debt (Rd): Input the current interest rate your company pays on its debt, as a decimal (e.g., 0.05 for 5%).
  4. Enter Corporate Tax Rate (T): Input your company's effective corporate tax rate, as a decimal (e.g., 0.25 for 25%).
  5. Input CAPM Components (for context): Enter the Risk-Free Rate (Rf), Asset Beta (βa), and Market Risk Premium (MRP). While not directly used in the primary WACC calculation presented here (as Re is inputted directly), these values are critical for deriving Re via CAPM and understanding the underlying risk.
  6. Click "Calculate WACC": The calculator will display the calculated WACC, along with key intermediate values like the after-tax cost of debt and the input values for clarity.
  7. Interpret Results: The highlighted WACC is your company's overall cost of capital. Use this figure as a hurdle rate for investment decisions and valuations.
  8. Use the Chart and Table: The accompanying chart visually compares the costs of different capital components, and the table provides context on typical variable ranges.
  9. Reset or Copy: Use the "Reset" button to clear fields and start over, or "Copy Results" to easily transfer the calculated values and assumptions.

Key Factors That Affect Cost of Capital Calculation using Weighted Asset Beta Results

Several factors significantly influence a company's calculated WACC. Understanding these is crucial for accurate analysis:

  1. Capital Structure (Weights We and Wd): The mix of debt and equity is fundamental. Higher debt levels generally increase financial risk, potentially raising both Rd and Re, but the tax deductibility of interest lowers the overall WACC up to a certain point. A company's target capital structure is key.
  2. Cost of Equity (Re): This is often the largest component and is heavily influenced by systematic risk. A higher asset beta (βa) or a higher market risk premium (MRP) will increase the cost of equity, thereby increasing WACC. Market sentiment and investor risk aversion also play a role.
  3. Cost of Debt (Rd): The interest rate a company pays on its borrowings directly impacts WACC. Higher credit risk, rising market interest rates, or increased leverage can increase Rd. Companies with strong credit ratings benefit from lower borrowing costs.
  4. Corporate Tax Rate (T): The tax deductibility of interest expense reduces the effective cost of debt. A higher tax rate magnifies this benefit, lowering the after-tax cost of debt and consequently the WACC. Changes in tax policy can therefore impact a company's cost of capital.
  5. Market Conditions (Rf and MRP): Fluctuations in the risk-free rate (e.g., government bond yields) and the market risk premium affect the cost of equity calculation (CAPM). During economic uncertainty, Rf may decrease, but MRP might increase, leading to complex effects on Re.
  6. Business Risk (Asset Beta – βa): The inherent riskiness of the company's operations, independent of financing, is captured by asset beta. Companies in volatile industries (e.g., technology, commodities) tend to have higher asset betas than stable ones (e.g., utilities, mature manufacturing), leading to a higher cost of equity and WACC.
  7. Inflation Expectations: Inflation influences both interest rates (cost of debt) and the required return on equity. Higher expected inflation generally leads to higher nominal rates across the board, increasing the cost of capital.
  8. Company Size and Growth Prospects: Smaller companies or those with high growth expectations often have higher asset betas and may face higher costs of debt and equity due to perceived greater risk.

Frequently Asked Questions (FAQ)

Q1: What is the difference between asset beta and equity beta?

Asset beta (unlevered beta) measures the systematic risk of a company's assets, reflecting its business risk. Equity beta (levered beta) measures the systematic risk of a company's stock, incorporating both business risk and financial risk (from leverage). Asset beta is used to isolate the core business risk.

Q2: Can WACC be negative?

No, WACC cannot be negative. Both the cost of equity and the after-tax cost of debt are positive values. Therefore, their weighted average must also be positive.

Q3: How often should WACC be recalculated?

WACC should be recalculated whenever there are significant changes in the company's capital structure, market conditions (interest rates, risk premiums), or the company's risk profile (reflected in its beta). Annually is a common practice for stable companies, but more frequent updates may be needed during periods of high volatility or strategic shifts.

Q4: Does WACC apply to private companies?

Yes, WACC is applicable to private companies, but calculating it can be more challenging. Estimating the cost of equity and the market values of debt and equity often requires using comparable public companies and making adjustments.

Q5: What is the role of market values versus book values in WACC calculation?

Market values are preferred for determining the weights of debt and equity in WACC calculations because they reflect the current economic value and investor expectations. Book values can be misleading as they represent historical costs.

Q6: How does WACC relate to the hurdle rate for projects?

WACC serves as the minimum acceptable rate of return, or hurdle rate, for investments and projects that have a similar risk profile to the company as a whole. If a project's expected return is less than the WACC, it is expected to destroy shareholder value.

Q7: What if a company has multiple classes of debt or equity?

If a company has multiple types of debt (e.g., bank loans, bonds) or equity (e.g., preferred stock, common stock), their respective costs and market values should be calculated individually and then aggregated to find the overall cost of debt and cost of equity before calculating the WACC.

Q8: Why is the asset beta important if the calculator uses the provided Cost of Equity (Re)?

While this calculator directly takes the Cost of Equity (Re) as input, the asset beta (βa) is a fundamental input for calculating Re using the CAPM formula (Re = Rf + βa * MRP). Understanding and accurately estimating asset beta is crucial for a reliable Re, which in turn is essential for an accurate WACC. It reflects the intrinsic business risk.

© 2023 Financial Calculator Suite. All rights reserved.

var chartInstance = null; // Global variable to hold chart instance function calculateWACC() { // Clear previous error messages document.getElementById('equityWeightError').classList.remove('visible'); document.getElementById('costOfEquityError').classList.remove('visible'); document.getElementById('debtWeightError').classList.remove('visible'); document.getElementById('costOfDebtError').classList.remove('visible'); document.getElementById('taxRateError').classList.remove('visible'); document.getElementById('assetBetaError').classList.remove('visible'); document.getElementById('riskFreeRateError').classList.remove('visible'); document.getElementById('marketRiskPremiumError').classList.remove('visible'); // Get input values var equityWeight = parseFloat(document.getElementById('equityWeight').value); var costOfEquity = parseFloat(document.getElementById('costOfEquity').value); var debtWeight = parseFloat(document.getElementById('debtWeight').value); var costOfDebt = parseFloat(document.getElementById('costOfDebt').value); var taxRate = parseFloat(document.getElementById('taxRate').value); var assetBeta = parseFloat(document.getElementById('assetBeta').value); var riskFreeRate = parseFloat(document.getElementById('riskFreeRate').value); var marketRiskPremium = parseFloat(document.getElementById('marketRiskPremium').value); var isValid = true; // — Input Validation — if (isNaN(equityWeight) || equityWeight 1) { document.getElementById('equityWeightError').innerText = "Equity weight must be a number between 0 and 1."; document.getElementById('equityWeightError').classList.add('visible'); isValid = false; } if (isNaN(costOfEquity) || costOfEquity < 0) { document.getElementById('costOfEquityError').innerText = "Cost of equity must be a non-negative number."; document.getElementById('costOfEquityError').classList.add('visible'); isValid = false; } if (isNaN(debtWeight) || debtWeight 1) { document.getElementById('debtWeightError').innerText = "Debt weight must be a number between 0 and 1."; document.getElementById('debtWeightError').classList.add('visible'); isValid = false; } if (isNaN(costOfDebt) || costOfDebt < 0) { document.getElementById('costOfDebtError').innerText = "Cost of debt must be a non-negative number."; document.getElementById('costOfDebtError').classList.add('visible'); isValid = false; } if (isNaN(taxRate) || taxRate 1) { document.getElementById('taxRateError').innerText = "Tax rate must be a number between 0 and 1."; document.getElementById('taxRateError').classList.add('visible'); isValid = false; } // Asset Beta, Rf, MRP validation for context, not strict for WACC calculation if Re is provided if (isNaN(assetBeta) || assetBeta <= 0) { document.getElementById('assetBetaError').innerText = "Asset beta should be a positive number."; // Don't set isValid to false if Re is provided, but show warning } if (isNaN(riskFreeRate) || riskFreeRate < 0) { document.getElementById('riskFreeRateError').innerText = "Risk-free rate must be non-negative."; } if (isNaN(marketRiskPremium) || marketRiskPremium 0.001) { document.getElementById('equityWeightError').innerText = "Sum of Equity Weight and Debt Weight must be 1."; document.getElementById('equityWeightError').classList.add('visible'); document.getElementById('debtWeightError').innerText = "Sum of Equity Weight and Debt Weight must be 1."; document.getElementById('debtWeightError').classList.add('visible'); isValid = false; } if (!isValid) { document.getElementById('resultsContainer').style.display = 'none'; document.getElementById('chartContainer').style.display = 'none'; document.getElementById('variablesTable').style.display = 'none'; return; } // — Calculations — var afterTaxDebtCost = costOfDebt * (1 – taxRate); var wacc = (equityWeight * costOfEquity) + (debtWeight * afterTaxDebtCost); // — Display Results — document.getElementById('resultsContainer').style.display = 'block'; document.getElementById('variablesTable').style.display = 'table'; // Show the table document.getElementById('resultEquityWeight').innerText = (equityWeight * 100).toFixed(2) + '%'; document.getElementById('resultDebtWeight').innerText = (debtWeight * 100).toFixed(2) + '%'; document.getElementById('resultAfterTaxDebtCost').innerText = (afterTaxDebtCost * 100).toFixed(2) + '%'; document.getElementById('resultCalculatedCostOfEquity').innerText = (costOfEquity * 100).toFixed(2) + '%'; document.getElementById('finalWACC').innerText = (wacc * 100).toFixed(2) + '%'; // — Chart Update — document.getElementById('chartContainer').style.display = 'block'; updateChart(wacc, costOfEquity, afterTaxDebtCost); } function resetCalculator() { document.getElementById('equityWeight').value = '0.70'; document.getElementById('costOfEquity').value = '0.12'; document.getElementById('debtWeight').value = '0.30'; document.getElementById('costOfDebt').value = '0.05'; document.getElementById('taxRate').value = '0.25'; document.getElementById('assetBeta').value = '1.1'; document.getElementById('riskFreeRate').value = '0.03'; document.getElementById('marketRiskPremium').value = '0.06'; // Clear results and errors document.getElementById('resultsContainer').style.display = 'none'; document.getElementById('chartContainer').style.display = 'none'; document.getElementById('variablesTable').style.display = 'none'; document.getElementById('equityWeightError').classList.remove('visible'); document.getElementById('costOfEquityError').classList.remove('visible'); document.getElementById('debtWeightError').classList.remove('visible'); document.getElementById('costOfDebtError').classList.remove('visible'); document.getElementById('taxRateError').classList.remove('visible'); document.getElementById('assetBetaError').classList.remove('visible'); document.getElementById('riskFreeRateError').classList.remove('visible'); document.getElementById('marketRiskPremiumError').classList.remove('visible'); if(chartInstance){ chartInstance.destroy(); // Destroy previous chart if exists chartInstance = null; } } function copyResults() { var waccValue = document.getElementById('finalWACC').innerText; var equityWeight = document.getElementById('resultEquityWeight').innerText; var debtWeight = document.getElementById('resultDebtWeight').innerText; var afterTaxDebtCost = document.getElementById('resultAfterTaxDebtCost').innerText; var calculatedCostOfEquity = document.getElementById('resultCalculatedCostOfEquity').innerText; var assumptions = [ "Equity Weight (We): " + document.getElementById('equityWeight').value, "Cost of Equity (Re): " + document.getElementById('costOfEquity').value, "Debt Weight (Wd): " + document.getElementById('debtWeight').value, "Cost of Debt (Rd): " + document.getElementById('costOfDebt').value, "Corporate Tax Rate (T): " + document.getElementById('taxRate').value, "Asset Beta (βa): " + document.getElementById('assetBeta').value, "Risk-Free Rate (Rf): " + document.getElementById('riskFreeRate').value, "Market Risk Premium (MRP): " + document.getElementById('marketRiskPremium').value ]; var textToCopy = "Calculation Results:\n"; textToCopy += "Weighted Average Cost of Capital (WACC): " + waccValue + "\n"; textToCopy += "—————————————-\n"; textToCopy += "Intermediate Values:\n"; textToCopy += "Equity Weight (We): " + equityWeight + "\n"; textToCopy += "Debt Weight (Wd): " + debtWeight + "\n"; textToCopy += "After-Tax Cost of Debt: " + afterTaxDebtCost + "\n"; textToCopy += "Calculated Cost of Equity: " + calculatedCostOfEquity + "\n"; textToCopy += "—————————————-\n"; textToCopy += "Key Assumptions:\n"; textToCopy += assumptions.join("\n"); navigator.clipboard.writeText(textToCopy).then(function() { // Success feedback var originalText = document.querySelector('.btn-copy').innerText; document.querySelector('.btn-copy').innerText = 'Copied!'; setTimeout(function() { document.querySelector('.btn-copy').innerText = originalText; }, 1500); }).catch(function(err) { console.error('Failed to copy text: ', err); // Fallback for older browsers or environments without clipboard API var textArea = document.createElement("textarea"); textArea.value = textToCopy; textArea.style.position = "fixed"; textArea.style.opacity = 0; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'Copied!' : 'Failed!'; var originalText = document.querySelector('.btn-copy').innerText; document.querySelector('.btn-copy').innerText = msg; setTimeout(function() { document.querySelector('.btn-copy').innerText = originalText; }, 1500); } catch (err) { console.error('Fallback: Oops, unable to copy', err); var originalText = document.querySelector('.btn-copy').innerText; document.querySelector('.btn-copy').innerText = 'Error'; setTimeout(function() { document.querySelector('.btn-copy').innerText = originalText; }, 1500); } document.body.removeChild(textArea); }); } // — Charting Logic — function updateChart(wacc, costOfEquity, afterTaxDebtCost) { var ctx = document.getElementById('waccChart').getContext('2d'); // Define colors var primaryColor = '#004a99'; // WACC color var successColor = '#28a745'; // Cost of Equity color var secondaryColor = '#6c757d'; // After-Tax Cost of Debt color // Destroy previous chart if it exists if (chartInstance) { chartInstance.destroy(); } chartInstance = new Chart(ctx, { type: 'bar', data: { labels: ['Cost of Equity (Re)', 'After-Tax Cost of Debt (Rd(1-T))', 'WACC'], datasets: [{ label: 'Cost Component', data: [ costOfEquity, afterTaxDebtCost, wacc ], backgroundColor: [ successColor, // Cost of Equity secondaryColor, // After-Tax Cost of Debt primaryColor // WACC ], borderColor: [ successColor, secondaryColor, primaryColor ], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return (value * 100).toFixed(1) + '%'; } } } }, plugins: { legend: { display: false // Labels are in the x-axis }, tooltip: { callbacks: { label: function(context) { var label = context.dataset.label || "; if (label) { label += ': '; } if (context.parsed.y !== null) { label += (context.parsed.y * 100).toFixed(2) + '%'; } return label; } } } } } }); } // Initial calculation on load if inputs have default values document.addEventListener('DOMContentLoaded', function() { // Optional: Trigger calculation if default values are present // calculateWACC(); });

Leave a Comment