Question: We begin with the simple case where we know the bond yield and wish to calculate the bond price. We also begin with the simple
We begin with the simple case where we know the bond yield and wish to calculate the bond price. We also begin with the simple case of a newly issued bond. Recall the formula is B = 1/2 c/1 + 1/2 y + 1/2 c/(1 + 1/2 y)^2 + ... + 1/2 c/(1 + 1/2 y)^n - 1 + F + 1/2 c/(1 + 1/2 y)^ . Write a function to calculate the above sum. The inputs are (i) double F, (ii) double e, (iii) double y, (iv) int n. The output is (v) double & B. The input value of the yield y is a percentage, so if the yield is 5% then y = 5, Hence remember to compute an internal variable y_decimal = 0.01 y in your code, to avoid "factor of 100" errors. The function signature is void price_from_yield(double F. double c, double y, int n, double k B): Write the function and call it with some sample inputs. (You must write a main program.) Here are some tips to help you to check that your code is working correctly. To keep things simple, the F = 100 in all your tests. There is no point in being too clever. If F = = 100, then if the yield equals the coupon y = c, you should obtain B = F = (= 100). Put y = 0. Then the value of B is a straight sum of the values of the cashflows. Since there are n cashflows of the coupons, obviously B = F + nc/2. Your program should give this value. The bond price B decreases as the yield y increases. (This is in fact a general theorem. It was proved in the 1930s, I think.) Put c = 0. This is known as a zero coupon bond and they do exist. A zero coupon bond pays only one cashflow, which is to pay the face value at maturity, In that case the formula is B_ = F/(1 + 1/2 y)^n. This is a very simple formula and you should be able to calculate the above formula independently (use Excel, for example). Hence you should be able to validate your function, for a zero coupon bond
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
