Python代写|MN50374 Quiz 2

这是一篇来自英国的关于使用Python作为计算器计算8只上市债券的债券收益率以及绘制收益率曲线的Python代写

 

On 28 November 2022, at 10:39 GMT the following bid and ask prices are quoted for GB bills and bonds with maturities from 1 month to 5 years:

Name  Coupon Maturity Date Next Coupon  Last Coupon Currency Bid Ask

GB 1M T-BILL 0 19-Dec-22 GBP 99.849 99.855

GB 3M T-BILL 0 20-Feb-23 GBP 99.29 99.313

GB 6M T-BILL 0 22-May-23 GBP 98.206 98.252

GB 1Y GILT 0.75 22-Jul-23 22-Jan-23 22-Jan-23 GBP 98.434 98.503

GB 2Y GILT 1 22-Apr-24 22-Apr-23 22-Oct-23 GBP 96.904 96.964

GB 3Y GILT 0.625 07-Jun-25 07-Dec-22 07-Dec-24 GBP 93.779 93.86

GB 4Y GILT 0.375 22-Oct-26 22-Apr-23 22-Apr-26 GBP 89.489 89.537

GB 5Y GILT 1.25 22-Jul-27 22-Jan-23 22-Jan-27 GBP 91.337 91.381

All instruments are standard plain vanilla fixed coupon paying and the day count convention is Actual/365. The settlement date for all cases is 1 working day after trade. At maturity 100% par value + coupon will be redeemed. For instance, in case of 1-year Gilt, on 24th July 2023, a total amount of £100.3750 is redeemable.

You can access the table above through the accompanying csv file titled “GB Curve Quotes.csv”

Required:

Using Python as your calculator and the knowledge from Lecture 6:

1) Calculate bond yields for Ask Price of 8 listed gilts using continuous compounding rates to at least 4 digits precision. §

[8×10 points]

2) Plot a yield curve for gilts with maturity date from 1 month to 5 years

[20 points]

  • The calculated yields shall correspond clearly to the underlying bonds. A suggestion is for you to add a column (“Yield”) in the data-frame you import from the csv file containing your calculated figures.

Additional points:

  • Alternative practical assumptions can be made if necessary.
  • Your codes need to run.
  • To facilitate processing dates in Python, you can use the datetime library.
  • To calculate natural logarithm, you can use numpy. log () function.
  • You can convert date strings to datetime items using pandas. to_datetime() function.