We know from finance that a coupon bond can be priced as follows:

𝑃𝑟𝑖𝑐𝑒=𝑃(𝑐𝑜𝑢𝑝𝑜𝑛𝑠)+𝑃𝑉(𝑓𝑎𝑐𝑒 𝑣𝑎𝑙𝑢𝑒) , where the discount rate is known as the yield to maturity (YTM).

It is a known problem in finance that we cannot use a closed form solution to solve for the YTM but that we need to rely on an optimizer. Similarly to the code for how to optimize a portfolio you can use scipy’s minimize() to compute the YTM of a bond with certain parameters.

Task 1 [5 marks]
Write a function that takes the following inputs and computes and returns the YTM for a coupon bond with annual coupons:
Price
Coupon amount
Face value
Number of years until maturity

When you optimize for the YTM, you need to set the objective function to minimize. Use the following error definition:

〖√((calculated) price from optimisation-reference price)〗^2
The reference price is what you are trying to get the optimizer to arrive at and the calculated price is the price the optimizer is computing with different values of YTM. Explain what is the advantage of this error function? Use your function on these parameters: Price = 1054; Coupon = 100; Face value = 1000; N = 10. (You should only provide the code).

Task 2 [5 marks]
Perform a sensitivity analysis on:
a. Price: varying from 900 to 1100 in steps of 1.
b. Number of years until maturity (N): varying from 1 to 50.

Use the parameters from part 1. Show your results graphically (Price or N on x-axis and YTM on y-axis) and explain why you see what you see from an economic perspective. Provide at least 1 paragraph of text per graph! (Max 100 words per paragraph)

 

 

 

This question has been answered.

Get Answer