10.12.2019 Views

Python for Finance

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5

For this reason, a Python dataset called spreadBasedOnCreditRating.pkl is used

to explain the relationship between the default spread and credit rating. The dataset

could be downloaded from the author's web page at http://canisius.edu/~yany/

python/spreadBasedOnCreditRating.pkl. The following program retrieves and

prints the data. The dataset is assumed to be in the c:/temp/ directory:

>>>import pandas as pd

>>>spread=pd.read_pickle("c:/temp/spreadBasedOnCreditRating.pkl")

>>> spread

1 2 3 5 7 10 30

Rating

Aaa/AAA 5.00 8.00 12.00 18.00 28.00 42.00 65.00

Aa1/AA+ 10.00 18.00 25.00 34.00 42.00 54.00 77.00

Aa2/AA 14.00 29.00 38.00 50.00 57.00 65.00 89.00

Aa3/AA- 19.00 34.00 43.00 54.00 61.00 69.00 92.00

A1/A+ 23.00 39.00 47.00 58.00 65.00 72.00 95.00

A2/A 24.00 39.00 49.00 61.00 69.00 77.00 103.00

A3/A- 32.00 49.00 59.00 72.00 80.00 89.00 117.00

Baa1/BBB+ 38.00 61.00 75.00 92.00 103.00 115.00 151.00

Baa2/BBB 47.00 75.00 89.00 107.00 119.00 132.00 170.00

Baa3/BBB- 83.00 108.00 122.00 140.00 152.00 165.00 204.00

Ba1/BB+ 157.00 182.00 198.00 217.00 232.00 248.00 286.00

Ba2/BB 231.00 256.00 274.00 295.00 312.00 330.00 367.00

Ba3/BB- 305.00 330.00 350.00 372.00 392.00 413.00 449.00

B1/B+ 378.00 404.00 426.00 450.00 472.00 495.00 530.00

B2/B 452.00 478.00 502.00 527.00 552.00 578.00 612.00

B3/B- 526.00 552.00 578.00 604.00 632.00 660.00 693.00

Caa/CCC+ 600.00 626.00 653.00 682.00 712.00 743.00 775.00

Treasury-Yield 0.13 0.45 0.93 1.74 2.31 2.73 3.55

>>>

The index column is the credit rating based on both Moody's and Standard& Poor's

credit rating scales. Except for the last row, US Treasury Yield, the values in the

dataset have a unit of basis point which is worth one hundredth of 1%. In other

words, each value should be divided by 100 twice. For example, for an AA rated

bond, its spread on year 5 is 50 basis points, that is, 0.005 (=50/10000). If the risk-free

rate for a 5-year zero-coupon bond is 2%, the corresponding rate for a corporate

bond, rated as AA, would be 2.5% (2.5%+ 0.5%).

[ 163 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!