HW 3-无代写
时间:2022-12-12
HW 3 (Individual Portion)
Computational Finance | Vadim Elenev | Fall 2022
Question 1
This question asks you to numerically solve a system of equations (that I provide) to the market-implied probability
that a corporate bond will default. But first, some context:
Corporate Bond Pricing
We know from Corporate Finance class that the relationship between a one-year, \$100, zero-coupon Treasury bill's
price, $P$, and its yield is: $$\textrm{Eq1: } P = \frac{100}{(1+y)}$$ where y is one-year Treasury yield.
Now consider an equivalent one-year, zero-coupon corporate bond. Unlike Treasury bonds, corporate bonds can
default, i.e. the cash flows they produce are uncertain. Sometimes the bond will repay the full \$100. But other times,
it will default and only pay some fraction $B$ of the \\$100 that gets recovered in bankruptcy.
If we assume that the only additional risk in the corporate bond is default risk, then we can write the expected cash
flows of the bond as $100(1-\lambda) + B*100*\lambda$ where $\lambda$ is the probability of default in one year
(i.e., before the bond matures).
A risk-neutral investor would be willing to pay for this bond the discounted value of the expected cash flow:
$$\textrm{Eq2: } P^* = \frac{100(1-\lambda) + B*100*\lambda}{(1+y)}$$ Of course, we know that most investors
are risk-averse, but we can define $\lambda$ to be the risk-neutral probability of default, or the probability of
default that would need to be true for observed bond price $P^\ast$ in the data to be consistent with risk-neutral
pricing in Eq2.
The other way we can think about pricing a risky corporate bond is in terms of its yields. The corporate bond yield
is defined as the rate $y^\ast$ at which one would need to discount the promised cash flow of \$100 to get the
observed price of the bond $P^\ast$. The yield on a corporate bond and the risk-neutral probability of default
$\lambda$ are two ways to measure default risk. After some algebra, we can find the risk-neutral probability from
the yields of the two bonds: $$\textrm{Eq3: } \lambda = \frac{1-\frac{1+y}{1+y^*}}{1-B}$$ As you can see from
this formula, $y = y^\ast$ implies a corporate bond as safe as Treasury (i.e. default probability of zero). The higher
the higher corporate bond yield is, the higher its risk-neutral default probability.
Assignment
From the WRDS bond pricing database and Moody's Historical Recovery Rates databases, we obtained the
following:
The one-year treasury bill price, $P=\$95.46$
The one-year corporate bond price, $P^*=\$94.50$
The expected recovery rate on the corporate bond, $B=52\%$
Solve the above three equations for the three unknowns: $y$, $y^*$ and $\lambda$, which are the yield on the
Treasury bill, the yield on the corporate bond, and the implied default probability, respectively:
1. On paper, put equations 1, 2 and 3 in canonical form (i.e., rearrange
so they each equal zero)
o Hint: You should subtract the simplest side of each equation from
both sides of that equation to make it easier to read/code correctly
2. Define a function that takes a three-element array as an argument
(each element is an unknown in your system) and returns a three-element
array (each element is the result of one of the three canonical equations,
which should be 0 at the solution).
o Hint 1: See the Week5 fsolve_example.ipynb notebook for an
example (the f_system function is much like what you should do here)
o Hint 2: You may want to "unpack" the 3-element argument array x
into separate variables y, y_star, and lambda instead of using x[0],
x[1] and x[2] directly in equations. This would make your code easier
to read.
3. Use fsolve() to solve for the unknowns. Choose reasonable initial
guesses.
4. Print your appropriately labeled results, all in percent, with two
digits after the decimal.
Question 2
In this question you will identify the largest company (by market capitalization) for each month from 2016 to March
2022.
Please use the file six_stocks_since_2016.csv, which contains some monthly CRSP data (from
WRDS) for six firms from 2016 to March of 2022, to perform the following steps.
1. Import and prepare the data
2. Calculate size of each firm on each date
o The size is the firm's market capitalization (i.e. total price of the firm),
measured as the price per share (PRC) times shares outstanding (SHROUT)
3. Get the largest firm in each month
o Hint: the groupby, sort_values and last() functions can be
helpful here.
4. Answer the following questions, displaying DataFrames that illustrate the
answers (just becuase they look nicer than Series) as appropriate or printing out
your answer in words at the end:
o How many different firms have ever held the top spot as largest
firm?Which are they?
o How many times did the top firm change?
 Hint: The shiftmethod can be helpful here
essay、essay代写