|
|
|
|
|
|
Posted: Sun Feb 16, 2025 6:04 pm
|
|
|
|
|
|
|
Posted: Sun Feb 16, 2025 6:04 pm
|
|
|
|
|
|
|
|
|
Posted: Sun Feb 16, 2025 6:06 pm
|
|
|
|
|
|
|
Posted: Sun Feb 16, 2025 6:06 pm
run a reverse discounted cash flow model on axon to find the market's expectations for revenue growth, adjusted gross margin, and EPS for FY2025
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Sun Feb 16, 2025 6:08 pm
run a reverse discounted cash flow model on axon to find the market's expectations for revenue growth, adjusted gross margin, and EPS for FY2025
|
 |
 |
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:30 am
Practical Tips: Ensure your model is structured logically with inputs clearly separated from calculations and outputs for ease of analysis. Use named ranges or cell references to make your scenarios easier to manage, especially with complex models. Regularly review and update your scenarios to reflect current data or market changes for more accurate forecasting.
What-If Analysis tools provide a dynamic way to explore the implications of financial decisions, helping analysts and traders like you to make more informed decisions based on potential outcomes.
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:41 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:42 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:43 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:44 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", " Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", " Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", " Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", " Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:46 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:47 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:48 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:49 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
|
|
|
|
Posted: Mon Feb 17, 2025 4:51 am
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Risky Debtn", "n", "Debt is not always from the government, sometimes it is raised by companies. In this case, the debt is no longer risk-free, there is now risk of default so we have to look at the debt differently.n", "n", "### Adjusting Debt for Riskn", "n", "When we have corporate debt we need to include a term to capture the potential loss from a company not being able to fulfill it's debt obligations. The equation is: n", "n", "Return on Debt = Yield to Maturity – (Probability of default) * Expected Loss Raten", "n", "The way we judge the risk of default is through credit rating agencies. These agencies give ratings to bonds, and through these ratings we are able to judge how risky it is.n", "n", "Example:n", "n", "If AAA rated bonds have 0% chance of default, BBB has 1%, and CCC has 10%, what would the expected yield to maturities be with an average loss of 50% of the value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unlevering Equityn", "n", "What rate do we use to discount a project's expected cash flows? This rate called the cost of capital tends to be different for each company, and even each department/project within a company. Here we will show that it is about first finding the rate of equity we want to use.n", "n", "If a company was going to be all equity financed. The way we might determine our “r” is to look at other companies and what their r is for equity. There is one problem, however. Debt tends to make equity riskier. This is because debt holders have first dibs to any assets if a company were to go bankrupt; additionally large amounts of debt can be dangerous for companies.n", "n", "The way we get rid of the effects of debt on equity is through a process called unlevering. Before we begin with unlevering, let’s look at how the rate of return on assets is defined.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E}$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "Theoretically our rate for debt shouldn’t be changing, so as you can see from this equation the more debt you take on, the higher the return on equity will have to be to balance the lower return on debt. This same idea applies to betas as well. n", "n", "$B_a = B_e \times \dfrac{E}{D+E} + B_d \times \dfrac{D}{D+E} $n", "n", "$B_a = Beta \ for \ Assets \\n", "B_e = Beta \ for \ Equity \\n", "B_d = Beta \ for \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value$n", "n", "To unlever the rate and the beta, it would be a simple re-arrangement of these equations." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.08n", "0.12n", "0.16n", "0.2n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.08,.04,100,0))n", "print(unlever(.08,.04,100,100))n", "print(unlever(.08,.04,100,200))n", "print(unlever(.08,.02,100,200))n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that the required return on equity is 8% when there is no debt, and that it keeps going up as we take more debt on and/or the rate of debt goes down.n", "n", "How do we include taxes? There is a tax shield associated with debt interest payments & we need to include it in our analysis by multiplying the above equations with a $(1 - T)$ where T refers to the tax." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## WACCn", "n", "The weighted average cost of capital is what a rate a company needs to pay out to the shareholders of the company. It is the “r” term that is used for discounting for projects when a company is comparing cash flows. It is also referred to as the cost of capital.n", "n", "$r_a = r_e \times \dfrac{E}{D+E} + r_d \times \dfrac{D}{D+E} \times (1 - T)$n", "n", "$r_a = Return \ on \ Assets \\n", "r_e = Return \ on \ Equity \\n", "r_d = Return \ on \ Debt \\n", "E = Equity \ Value \\n", "D = Debt \ Value \\n", "T = Taxe Rate$n", "n", "When we use this, we would take our debt yield as the rate of debt, and then our unlevered equity rate that we found before for the rate of equity. This equity rate is likely the average of a few similar companies' unlevered equity rates.n", "n", "Example:n", "n", "Program a function to solve for WACC with the tax shield. Assume that equity rates have been unlevered from other companies, and that's how we get a baseline of what our expected equity return is. n", "n", "Here are the example inputs: n", "n", "Stock Price = 20.0 n", "Stocks Outstanding = 100 n", "Present Value of Debt = 1000.0 n", "Debt Yield = 5 \% n", "Expected Equity Return = 10 \% n", "Tax Rate = 30 \% " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WACC: 0.0783n" ] } ], "source": [ "def WACC(price,outstanding,debtValue,debtYield,stockReturn,taxRate):n", " n", " equity = price*outstandingn", " total = equity+debtValuen", " n", " return (equity/total)*stockReturn+(debtValue/total)*debtYield*(1-taxRate)n", "n", "n", "print('WACC: {:.4f}'.format(WACC(20.0,100,1000.0,.05,.1,.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Debt Effect Analysisn", "n", "It is possible for debt to make equity riskier. The following code will show an example. Returns are cashflows given in each year. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1100.0n" ] } ], "source": [ "import numpy as npn", "n", "returns = [1000,1100,1200]n", "expected = np.mean(returns)n", "n", "print(expected)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assume this is a company's projected payoffs, and given a rate of return of 10%, how much is it worth?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "999.9999999999999n" ] } ], "source": [ "print(expected/1.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, in the following code, we will check to make sure the rate of equity does not need to be unlevered if there is 0 debt." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1n" ] } ], "source": [ "def unlever(r_a,r_d,E,D):n", " n", " return r_a + (r_a-r_d)*(D/E)n", "n", "print(unlever(.1,.04,1000,0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The rate of equity checks out, now what if this project were half debt financed and half equity financed. How much would the equity financers expect?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.16n" ] } ], "source": [ "print(unlever(.1,.04,500,500))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "According to our equation, the equity investors are going to want 16\%. Why is this though? Let's take a look at what happens in the next year. For this example we will pretend the debt matures in one year.n", "n", "The payout in period 1 will be $500 \times 1.04 = 520$. Bond holders have first dibs so all this money gets taken out before equity investors have a shot at a return. The returns after debt payments is:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[480, 580, 680]n" ] } ], "source": [ "returns_after = [x-520 for x in returns]n", "print(returns_after)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find the equity return, we would need to find the expectation and divide it by what the equity investors put in." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "580.0n", "1.16n" ] } ], "source": [ "expected = np.mean(returns_after)n", "print(expected)n", "print(580.0/500.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We get the same number as our equation, 16\%. n", "n", "### Debt VS Equityn", "n", "Modigliana and Miller said that the amount of debt vs. amount of equity does not matter overall for the valuation of a company. The last example we did shows how with or without debt the overall value summed to 1000. The thing is, their theorem assumes there is no taxes, no costs if the company goes bankrupt and no transaction costs. n", "n", "If we just considered taxes, we would find as much debt as possible is the best because of the tax shield. If we added in the cost of bankruptcy (lawyers and dissolving assets), we would find there is a point that too much debt has a negative effect on company value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Forward Contract Basicsn", "n", "Forward contracts are agreements to buy or sell an asset for a specified price. They can either be settled in cash (meaning no assets are actually traded, but instead there is a cash settlement based on the real price versus forward price) or with the actual asset. n", "n", "Companies use these to hedge their risks. If a company takes steel as an input, they might buy a forward contract to buy steel at a designated price to make sure that if there is a spike in steel prices their company is not hurt. Nothing is traded until the execution date, so when you enter into a forward contract you don’t pay anything until the execution date.n", "n", "Examplen", "n", "Now imagine a project that your company is considering. You would put 100 million down in year 0 to buy a drilling station and then get 50 million barrels of oil for the next 4 years. Valuing this project would be somewhat difficult, how much is that worth? You could use the current price of oil but with inflation it could grow, or it might be lower in the future if there was a huge surplus of oil. Let’s first get the NPV of the project if we were to assume the yearly prices were: $1.05, $1.10, $1.15 and $1.20. " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "27.36322655556311n" ] } ], "source": [ "class Cashflow:n", " n", " def __init__(self, val,t,r):n", " n", " self.val = valn", " self.t = tn", " self.r = rn", " self.PV = self.valAt(0)n", " n", " def valAt(self,time):n", " n", " return self.val*(1+self.r)**(time-self.t)n", " n", " n", "def NPV(arr):n", " n", " return sum([x.PV for x in arr])n", "n", "n", "flows = [Cashflow(-150,0,.1), Cashflow(50*1.05,1,.1), Cashflow(50*1.1,2,.1), Cashflow(50*1.15,3,.1), Cashflow(50*1.2,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With an NPV of 27.36 we might be tempted to take the project. If the prices are accurate then it makes sense. But what if we aren't sure about the prices? Let's see how this would differ if we entered into forward contracts to sell. Let's assume the contracts were for prices $0.80, $0.85, $0.90 & $0.95 ." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-12.260091523803048n" ] } ], "source": [ "flows = [Cashflow(-150,0,.1), Cashflow(50*.8,1,.1), Cashflow(50*.85,2,.1), Cashflow(50*.9,3,.1), Cashflow(50*.95,4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strangely, the NPV is now negative & the project will not be pursued. Should we trust the forward prices or our pricing prediction? n", "n", "It turns out there is something else we can do. If we think our prices are correct & the market is wrong then we can make more money by entering into a forward contract where we buy at that price & then sell for the prices we expect. n", "n", "The below code will show us the profit in each period if we buy for the forward price & are able to sell for the predicted price:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "39.62331807936616n" ] } ], "source": [ "flows = [Cashflow(50*(1.05-. cool ,1,.1), Cashflow(50*(1.1-.85),2,.1), Cashflow(50*(1.15-.9),3,.1), Cashflow(50*(1.2-.95),4,.1)]n", "print(NPV(flows))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The NPV here is 39.62 & we don't even need to put any money down. n", "n", "Of course the issue is that if we are wrong about the prices we might end up taking a loss, but if we are correct we get a higher NPV. We can also scale this to be more than 50 million gallons each year, it can be as much as we want if we are using contracts because we don't put any money down (technically we would need to pay the money first before we sell it but we will pretend we could pay & then instantly sell it after.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" } }, "nbformat": 4, "nbformat_minor": 2 }
|
 |
 |
|
|
|
|
|
|
 |
|
|
|
|
|