Credit Spread In Finance And Their Probability Distributions In Data ScienceUsing Python To Demonstrate Financial Credit Spreads And Hazard RatesFarhad MalikBlockedUnblockFollowFollowingJun 11One of the famous areas in finance is about using and modeling credit spreads.

Credit spreads are used every day by large financial institutions to price the transactions.

This is a special article that will explain the famous credit spread risk and will explain how data science can help there.

If an investor wants to take more risk then it is only natural for the investor to expect to gain higher return.

You can invest your money in a local company and buy its corporate bond or you can invest in buying a government bond.

Government bonds are less riskier than the local companies.

The riskier the company, the higher the yield interest rate it would offer to attract you into buy its product.

Credit spread is the difference in yields between your target security such as a corporate bond and a reference security such as a government bond.

Please read disclaimerPhoto by Sharon McCutcheon on UnsplashThis article will explain what credit spread is, what hazard rates are and it will also explain the underlying probability distribution in detail.

I will start by explaining the financial concept.

Then I will provide an overview of how we can utilise the statistical measures that are widely used in the field of data science.

Scenario For The ArticleThis article will explain the concepts that revolve around this scenario:Let’s assume you have £1000 to invest.

You come across two securities with identical time to maturity.

The first security is a high rated instrument such as a government bond and the second security is a corporate bond offered by your local high street bank.

The government bond will be referred to as the benchmark security.

Spread is all about interest rates.

Photo by Magda Fou on UnsplashWhat Is Credit Spread?Now the way plain vanilla bond works is that you lend your money for a period of time and you get timely payments in return.

On the time of maturity, you get all of your original money back.

The timely (monthly, semi-annually, annually) payments are based on the yield rate that the borrower offers.

The borrower of the money is known as the issuer as it is issuing the bond.

Now you have considered the buy two bonds in the scenario above.

Each of these financial institutions would offer the yield rates over a period of time.

If you were to plot the yield rates of a government bond and a corporate bond for a time then the difference between the two yields will be known as the credit spread.

It’s important to note that the maturity of both of the instruments is identical but the credit quality is different.

The credit spread is therefore the difference in risk premiums of the instruments with same maturity and different credit quality.

If you want to understand credit risk, read this article:Risk Management: Understanding Credit RiskThis article serves as an overview of counterparty credit risk and outlines terminology used in credit risk management…medium.

comWhat Are The Different Spread Measures?There are a number of spread measures.

I am going to briefly outline the common measures:Yield Spread: It is the difference between the yield to maturity of a risky and the benchmark bond.

The maturities of the instruments is the same.

i-Spread: The “i” refers to the mechanism of interpolation.

It is the difference between the yield to maturity of a risky and linearly interpolated yield to maturity on the benchmark bond.

It is calculated when the maturities of the instruments is not the same.

z-Spread: The z-spread is constructed by adding the basis points on the spot rate of the benchmark curve to get the desired bond price.

CDS Spread: This is the premium of CDS of issuer bond to protect from any of the credit events.

CDS spreads are observable in market.

Plus, liquid CDS contracts are available in market for a large number of maturities.

Hence CDS spreads are commonly used.

Option Adjusted Spread (OAS): If you take the z-Spread and adjust it for the optionality of the options then it becomes OAS.

Photo by Vidar Nordli-Mathisen on UnsplashWhat Is Spread’01 In Finance?Spread’01 is known as DVCS.

We want to investigate how sensitive our bond is to the z-spread.

We can do that by computing DVCS.

The way it works is that the z-spread is shocked up by 0.

5 basis points and the corporate bond is priced.

Then the z-spread is shocked down by 0.

5 basis points and the corporate bond is priced.

The difference in the price tells you how sensitive the bond is to the z-spread by 1 basis point.

This measure is known as Spread’01 or DVCS.

Spread’01 measures the credit spread sensitivity.

The marginal change in the spread ’01 decreases when the spread is increased.

It is very similar to DV01.

Read this article to get a good understand of the DV01 Bond Risk concepts:Understanding Bond RiskIn my article “Understanding Bonds”, I explained what bonds are and how their price is calculated.

I will provide an…medium.

comWhat Are Hazard Rates?Now that you have bought the corporate bond, there is always a risk that the corporate might default before the maturity date of the bond.

The analysts in the financial firms estimate the probability of default and the probability of survival.

The probability of default is the chance that the issuer of the bond might default.

On the other hand, the probability of survival is the opposite.

It represents the chance that the issuer of the bond will not default.

The probability of default over time dt is λdt.

The probability of survival over time dt is 1-λdt.

λ is known as the hazard rate.

The hazard rate is the rate of the default of the company.

The sum of probability of default and probability of survival is 1.

We can compute the hazard rate from the recovery rate and z-spread.

Usually the probability of default increases with time.

Often the governments of stable countries have a very low (or 0) probability of default.

Photo by Louis Reed on UnsplashLet’s Concentrate On Data Science AspectNow that we have gained the foundation understanding of the credit spread, let’s analyse its distribution and see if we can model it correctly.

Data Science Field Revolves Around Probability Distributions Of The VariablesHow Binomial Distribution Can Be Used To Measure Default RiskA binomial distribution is the distribution where the values in a sample can only take one of the two values.

It is binary in nature, such as success or failure.

Furthermore, the Bernoulli trial is the experiment of generating outcomes of a variable with binomial distribution.

It is important to note that the trials are conditionally independent, therefore the outcome of the previous attempt cannot alter the outcome of the current event.

Bernoulli trial is memory-less just like a flip of coin isWe know that a company can default.

The default of a company over time can be modeled using the binomial distribution.

If we represent the default as π then the the mean and variance of a Bernoulli distribution is equal to π and π(1 − π).

Binomial Distribution In PythonNumpy offers a module that can generate samples drawn from the binomial distribution:samples = numpy.

random.

binomial(number_of_trials, probability_of_success, size)Exponential Distribution And Company DefaultThe exponential distribution is not mentioned as often as the other distributions.

Exponential distribution is used to model the events where the time dimension is involved.

For example, we would use exponential distribution to model the time it would take for the company to default.

The distribution is dependent on a rate parameter λ.

The rate measures the rate of an event from occurring, just like the hazard rate measures the rate of default of a company.

The mean of exponential distribution is:The variance of the exponential distribution is:In a nutshell, we can use the exponential distribution to measure the time it would take for the company to default.

Exponential Distribution In PythonNumpy offers an exponential module that can generate samples drawn from the exponential distribution:numpy.

random.

exponential(rate_inverse, size=None)Note, rate_inverse above is 1/λBut how will we measure the total number of defaults over a time?Use Poisson DistributionPoisson distribution, on the other hand, can measure the total number of defaults over a specified time.

The Poisson distribution relies on a variable which is referred to as lambda λ.

It measures the average number of successes per unit.

Given λ, we can measure the number of successes for a variable with Poisson distribution.

The mean and variance of a Poisson distributed random variable is equal to λ .

Note how related the mean and variance of Poisson and Exponential Distributions are.

Poisson Distribution In PythonNumpy offers an Poisson module that can generate samples drawn from the Poisson distribution:numpy.

random.

poisson(interval_expectation, size=None)If you want to get a good understanding of Numpy, then read this article:Why Should We Use NumPy?Understanding NumPy Features Before Re-Inventing The Wheelmedium.

comPhoto by Ksenia Makagonova on UnsplashSummaryThe publication FinTechExplained is created to explain complex financial, mathematical and technological concepts in simple terms.

It also aims to concentrate on the intersection of the three fields.

This article explained what credit spreads are.

It then demonstrated what hazard rates are.

Finally it provided an overview of the three distributions, known as binomial, exponential and poisson distribution.

Hope it helps.

.