# Monte carlo simulation approach to var for non-linear derivatives 2009 Essay

- Words:
**4226** - Category: Database
- Pages:
**16**

Get Full Essay

Get access to this section to get all the help you need with your essay and educational goals.

Get AccessContents

- 0. Introduction
- 1. What are Derived functions?
- 2. Types of fiscal hazards
- 3. Fiscal catastrophes and Regulation
- 4. Specifying Value at Risk
- 5. VaR methods
- 6. Option pricing and Option VaR
- 6.1. Option pricing methodological analysis
- Premises
- 6.2. Option final payment
- 7. Monte Carlo simulation attack to VaR
- 7.1. Stochastic procedures
- 7.2. The riskless rate
- 7.3. Estimating the volatilities and correlativity
- 7.4. Imitating correlative random variables
- 7.5. Monte Carlo Simulation and VaR appraisal
- Premises
- Scenario coevals
- 8. Analysis of Consequences
- Interpretation of the tabular array
- 9. Decision
- 10. Appendix
- 10.1. The information
- 10.2. Cholesky Decomposition
- 10.3. Solution of the Stochastic Differential Equation ( SDE )
- Ito ‘s expression
- There exists a alone solution to SDEs of the signifier:
- 10.4. Excel VBA Code

### 0. Introduction

The value at hazard ( VaR ) methodological analysis is widely used in Risk Management in order to quantify the built-in portfolio hazard that may originate as a consequence of a alteration in market drivers with a pre-determined assurance degree. Different types of hazard can be measured and quantified through the use of the VaR and these include Market and Credit hazard ( Hull, 2003 ) . Over the old ages, there were several methods that were developed to cipher VaR: the most common of these are the Historical Approach, the Delta-Gamma Approach and the Monte Carlo Simulation Approach.

Harmonizing to literature, value at hazard ( VaR ) steps and quantifies the maximal loss over a clip skyline that can be incurred at a given statistical assurance degree ( Javanainen, 2004 ) . For the intent of this paper, a Monte Carlo Simulation attack will be used to mensurate the VaR of a non additive portfolio composed of European type currency options. The reported VaR will be the net VaR taking into history the monetary value paid for the option. This will necessitate the computation of the option monetary value. The monetary value will be derived utilizing the Black-Scholes-Mertonpricing expression for pricing currency options.

The construction of this paper will be as follows. In Section 1 we define what derived functions are and what some of the hazards associated with them are. Section 2 interruptions down the type of fiscal hazard that can incur in a banking environment and provides the definition of each hazard. In Section 3 we outline some of the fiscal catastrophes and the regulative environment, besides touching somewhat on Basel capital demands. Now that we know the environment that we are runing in, subdivision 4 introduces and provides a higher degree definition of VaR. In Section 5 we look at different VaR methods and province the disadvantages of the historical and the variance-covariance method. We so continue by doing a instance for Monte Carlo simulation attack. In Section 6 the option pricing methodological analysis will be outlined and all theoretical premises will be made. On Section7 we will sketch in item the procedure for followed for the development of the Monte Carlo simulation attack. Under this subdivision we will look at the following subjects in item ; Stochastic procedures, finding the riskless rate, appraisal of volatilities and correlativity, imitating correlated random variables and simulation. In Section 8 and Section 9 we will analyze the consequences and conclude the findings. Section 10 is the appendix for this paper. The information, Cholesky decomposition, solution to the stochastic regardful equation and the Excel VBA codification will be outlined here.

### 1. What are Derived functions?

Warren Buffet, one of the most well-thought-of investor in the universe, one time referred to Derived functions as fiscal arms of mass devastation. In his missive to the one-year stockholders, he made the remarks that “the quickly turning trade in derived functions airss a mega-catastrophic hazard for the economy” ( 2009 ) . This was touching to the fact that the fiscal markets were already faced with a crisis ensuing from the sub-prime loaning and the deficiency of apprehension of recognition derived functions and their deductions. A derivative is defined as a contract between two or more parties deducing its value from the implicit in plus ( Jorion, 1997 ) . The assets referenced by derived functions range from stocks ( portions ) , indices, bonds, trade goods, financess, baskets of implicit in assets and currency. Some of the most common derived functions traded today are forward contracts and options. A forward contract on foreign currency gives the purchaser the right to purchase the underlying at an in agreement hereafter rate on a specified hereafter day of the month. The option on the other manus, gives the purchaser the right but non the duty to purchase the underlying at the in agreement monetary value on a specified hereafter day of the month.

The growing in derived functions trading was fuelled by the ability of these instruments to divide ownership from market hazard associated with the underlying ( Jorion, 1997 ) . For illustration, a forward contract on an equity underlying does non give the holder vote rights but exposes the holder to market hazard. Some of the drivers are the addition in uncertainness in the fiscal markets, technological progresss and political developments. Because of these, establishments will ever be looking at a manner to protect themselves against any possible losingss. Without brooding on the mechanics of derived functions, derived functions can supply a manner to fudge this hazard through a combination of assorted instruments.

### 2. Types of fiscal hazards

There are many types of hazards that fiscal establishments and corporates are faced with on a day-to-day footing. Some of the most common hazards are Market hazard, Credit hazard, Liquidity hazard, Operational hazard and Legal hazard. This paper will concentrate chiefly on measurement and describing the market hazard associated with derived functions.

Hazard | Definition |

Market | The hazard originating from alterations in the monetary values of fiscal assets and liabilities. |

Recognition | The hazard originating when client is unable or unwilling to carry through its duties. |

Liquid | Cash flow support liquidness hazard: inability to run into hard currency flow duties which may coerce early settlement. Market liquidness hazard: inability to transact due to deficient market activity. |

Operational | The hazard of losingss ensuing from direction failure, faulty controls, fraud, human mistake or unequal systems. |

Legal | The hazard that the counterparty in the dealing does non hold the legal or regulative blessing to come in into the dealing. |

Beginning ( Jorion, 1997 )

When J.P. Morgan was asked what the market was traveling to make, his reply was: “The stock market will fluctuate” ( Ber09 ) . These fluctuations may take to net incomes or losingss depending on the places taken by the bank. Hazard directors have a immense undertaking in their custodies of measurement, extenuating and pull offing any possible hazard that may ensue from these fluctuations. It is a regulative demand for Bankss that they demonstrate that the systems and theoretical accounts that they use can accurately mensurate the hazard. VaR is one of the methods that are accepted global as a step of market hazard exposure.

### 3. Fiscal catastrophes and Regulation

There are several instance surveies available in fiscal literature detailing the findings of some of the worst fiscal catastrophes of all time experienced. My involvement is that of Metallgesellschaft, 1993 and Orange Country, 1994 because their losingss were attributable chiefly to market hazard. The exponential growing in derivative markets and the much publicized losingss created much concern for regulators ( Jorion, 1997 ) . The debut of the Basel Accord in 1988 was a first measure by the regulators towards tighter hazard direction among establishments by puting minimal capital demand for the hazard in their books. However, the commission recognised that the hazard direction theoretical accounts developed by Bankss are far advanced than those proposed by the regulators which required Bankss to keep more capital than it is deemed necessary ( Supervision, 2006 ) . Therefore, the regulator gave the Bankss the flexibleness to develop internal theoretical accounts that they can utilize to cipher capital demands. Thus VaR is now being recognised as a critical hazard direction tool for the computation of hazard weighted assets and capital demands ( ABSA ) .

### 4. Specifying Value at Risk

Senior direction of most corporates have troubles in groking complex fiscal theoretical accounts that are presented by analyst to quantify and analyze portfolio hazard. Most of these executives are merely interested in a simple figure ( or statistic ) that can be used to stand for the hazard on the books of the company ( Hull, 2003 ) . These steps can so be used in determination devising and to put future strategic ends of the establishment. Traditional steps of hazard such as the volatility do non integrate the way of the investing motion ( Harper ) . Value at hazard ( VaR ) offers such flexibleness in that it represent a individual figure that can be used to quantify portfolio hazard at a given statistical assurance over a given clip skyline. Value at hazard is one of the largely used hazard steps of portfolio hazard. Harmonizing to ( Jorion, 2005 ) , VaR takes into history portfolio variegation and purchase. By definition, VaR is the probabilistic step of mensurating the possible value over a given clip period and for a given clip skyline ( Schweser, 2007 ) .

### 5. VaR methods

The strength of VaR is in its simpleness and easiness of reading ( Schweser, 2007 ) . Like all theoretical accounts, the strength is based on the premises that may non be relevant in the existent universe. However, VaR still remains one of the widely used and understood steps of hazard. There are several theoretical accounts developed in the industry for calculation of VaR. The most popular are the Historical simulation attack, the Variance-covariance attack and the Monte Carlo simulation attack.

The historical simulation method is the attack that is being used within ABSA. This attack relies on historical informations for appraisal of VaR. In order to cipher the 95th percentile VaR for a portfolio of foreign exchange contracts, the user would roll up at least 2-years of historical exchange rates daily informations and so cipher the 95th percentile of these rates. The analyst would so cipher the net income or loss based on this estimation. The deliberate percentile will stand for the benchmark at which we are 95 % confident that the losingss will non transcend. The advantage of this method is that informations are readily available and it is easy to calculate. It besides avoids the demand for cash-flow function. The disadvantage is that it does non let volatility updating strategies ( Hull, 2003 ) .

The chief option to the historical attack is the Variance-covariance attack which is besides known as the model-building attack ( Hull, 2003 ) . This attack takes into history the volatility of the implicit in plus and the premise that the returns on the plus are usually distributed. In order to cipher the 95th percentile VaR, the user would foremost cipher the volatility of the underlying and so utilize the criterion normal distribution tabular arraies to read-off the value matching to the 95th percentile ( this value can be found in most standard normal cumulative distribution tabular arraies and is about 1.645 ) . The merchandise of the volatility and the 1.645 will give VaR as a per centum of nominal. The advantage of this method is that the consequences can be produced rapidly and accommodates volatility updating strategies ( Hull, 2003 ) . The chief drawback of this attack is that it assumes that the implicit in plus returns have a normal distribution and it tends to give hapless consequences for low delta portfolios ( Jorion, 1997 ) .

The Monte Carlo simulation attack is an alternate to the first two attacks. It can give the best consequences if sound procedures and relevant premises are made. The disadvantage of the Monte Carlo attack is that it is clip devouring when you are measuring a portfolio with tonss of instruments ( Hull, 2003 ) . This attack simulates a distribution of exchange rates and so calculates from this distribution the matching 95th percentile ( Hull, 2003 ) . This paper will farther research how to utilize this attack on a portfolio currency options.

### 6. Option pricing and Option VaR

### 6.1. Option pricing methodological analysis

The methodological analysis applied to monetary value currency options will be the methodological analysis as outlined by ( Hull, 2003 ) Ch 13.

### Premises

1. No dealing costs or revenue enhancements.

2. The topographic point exchange rates follow a stochastic procedure given by

dS=r-rfSdt+?Sdz.

Where

R is the domestic riskless involvement rate.

releasing factor is the foreign riskless involvement rate.

s is the exchange rate ‘s volatility.

dz is the Wiener procedure with average 0 and volatility of 1.

The European call monetary value, degree Celsius, is given by

c=Se-rfTNd1-Ke-rTNd2.

And the European put monetary value, P, is given by

p=Ke-rTN-d2-Se-rfTN-d1.

Where T is the term of the trade in old ages and d1 and d2 are given by

d1=lnSK+ ( r-rf+12?2 ) T?T.

And

d2=d1-?T.

3. The riskless rates r and rf will be computed from the domestic and foreign Swap/Forward curves utilizing Bootstrap method.

### 6.2. Option final payment

An option gives the holder the right and non the duty to inquire the marketer to present on the footings of the contract on the option exercising day of the month. The call option gives the holder the right to purchase the implicit in plus at a work stoppage monetary value K, while the put option gives the holder the right to sell the underlying at a given work stoppage monetary value on exercising day of the month.

The pay-off of a long call option is given by:

ft=max? ( 0, St-K ) .

The pay-off of a short call option is given by:

ft=-max? ( 0, St-K ) .

The pay-off of a long put option is given by:

ft=max? ( 0, K-St ) .

The pay-off of a short put option is given by:

ft=-max? ( 0, K-St ) .

### 7. Monte Carlo simulation attack to VaR

### 7.1. Stochastic procedures

Stochastic procedures are statistical random procedures used to pattern the behavior of the implicit in plus. E.g. they can be used to pattern the returns on the stock markets, the return on the foreign currency markets or the return on the trade good markets. All the illustrations have one common factor, the value alterations in an unsure manner with the alteration in clip ( Hull, 2003 ) . There are four chief categorizations of stochastic procedures, viz. the Discrete Space-Discrete Time, Discrete Space-Continuous Time, Continuous Space-Discrete Time and the Continuous Space-Continuous Time. For the intent of this paper, the focal point will be on the latter.

For modeling of foreign exchange returns, we require a procedure that can provide for the riskless returns across different states without compromising the correlativity between fake variables. On the subdivisions that follow, we discuss how the riskless rate, the volatility and the correlativities were determined.

This paper will utilize the premise that the currency exchange rates follow a geometric Brownian gesture procedure similar to that used by Black-Scholes for stocks. If we define the followers:

Sis the topographic point exchange rate

R is the domestic riskless involvement rate.

releasing factor is the foreign riskless involvement rate.

s is the exchange rate ‘s volatility.

dz is the Wiener procedure with average 0 and volatility of 1.

Stis the exchange rate at clip T.

Then, we can state that in a risk-neutral universe, the procedure is: .

This Stochastic differential equation can be shown to hold the undermentioned alone solution.

St=Sexpr-rf-12?2t+z?t.

Where the omega represent the random sample sampled from a standard normal distribution.

### 7.2. The riskless rate

The riskless rate by definition is the rate of return that can be earned without taking any hazard. Some literature compare this rate to the returned earned from a zero voucher authorities bond. For the intent of this paper, the riskless rates are the rates of involvement derived from the Swap curve of several states. With the South African Rand ( ZAR ) as the domestic ( base ) currency, we will curtail the foreign currencies to the Euro ( EUR ) , the British Pound ( GBP ) and the United States of America Dollar ( USD ) .

Table 7.2.1 above lineations the calculated the 1-year riskless rates obtained from the several Swap curves obtained from Front Arena trading system. The 1-year rates were calculated from the ensuing FRA ( Forward Rate Agreement ) rates utilizing the Bootstrap method.

### 7.3. Estimating the volatilities and correlativity

This subdivision explains how the volatilities and correlativities were determined. Estimating volatility is critical in the determining of the expected future exchange rates. There are several methods that are outlined in literature that can be used for appraisal. Some of the most common methods are the Historical method, the EWMA theoretical account, the GARCH theoretical account and the Implied volatility method.

The historical method relies on historical day-to-day monetary values informations to find the volatility on the implicit in currency brace. The EWMA and the GARCH theoretical accounts are much more sophisticated clip series theoretical accounts as they apply different weights to different historical information points with more recent monetary values holding higher weightings. The implied volatility theoretical account is a much better theoretical account as it relies on the option monetary values being quoted in the market. If the monetary value of an option is known, one can easy work out the volatility implied by the pricing in the risk-neutral universe. For simpleness, we will utilize the historical method to gauge foreign exchange day-to-day volatility based on 251 trade yearss. The square root regulation will so be used to generalize the day-to-day volatility to a different clip skyline.

The correlativity will be determined in the usual manner by ciphering the correlativity between two currency braces. The expression used to cipher the correlativity between currency brace is given by:

?ij=?ij?i?j.

Where

?ijis the correlativity between currency I and currency J.

sijis the covariance between currency I and currency J.

Si is the standard divergence of currency I.

E.g. the correlativity between USD and EUR is 86.906 % see table 7.3.1 below.

The tabular array above summarises the day-to-day volatility ( highlighted diagonal ) and correlativity between currency braces.

Using the diagonal entries of the matrix above, one can cipher the t-days volatility in the undermentioned manner:

?t, i=?1, it.

Where

?t, I is the t-day volatility for underlying I.

?1, I is the 1-day volatility for underlying I. It is represented by the diagonal entry on the matrix above.

This is known as the square root regulation.

### 7.4. Imitating correlative random variables

The informations used for this exercising merely includes European manner currency options. This excludes path dependent derived functions like Asian options, Barrier options and American options where the pay-off does non depend merely on the concluding value of the underlying ( Hull, 2003 ) . Because of this simpleness, we are merely required to imitate the concluding values. However, the values simulated for different currencies need to take into history the correlativity between the currencies. This complexness can be modelled in the undermentioned manner:

When we require n correlated samples from a standard normal distribution, the undermentioned process can be followed ( Hull, 2003 ) ;

- Generate n independent variables yi ‘s ( 1?i?n ) , from a Uniform ( 0, 1 ) distribution utilizing the Excel map RAND ( ) . This consequence can be viewed as a chance step from a Normal ( 0, 1 ) distribution. The Lolo ‘s have the undermentioned cumulative chance map:
- In order to imitate samples from the criterion normal distribution, we will utilize the Excel criterion normal reverse map NORMSINV ( ) on the Lolo ‘s from above in order to deduce the eleven ‘s. This will ensue in n independently distributed normal random variable.
- This measure will present correlativity to all the fake eleven ‘s. This will necessitate the lower triangular matrix derived from the Cholesky Decomposition of the Correlation matrix between the exchange rates

yi=-?xifzdz.

Where degree Fahrenheit ( omega ) is the standard normal distribution map given by:

fz=12?e-12z2.

First, we would cipher the correlativity between the foreign currencies. The consequences are presented in table 7.4.1 below. Table 7.4.2 is the ensuing lower triangular matrix obtained utilizing Cholesky decomposition.

CORRELATION MATRIX | |||

USD | EUR | GBP | |

USD | 100.000 % | 86.906 % | 84.691 % |

EUR | 86.906 % | 100.000 % | 85.830 % |

GBP | 84.691 % | 85.830 % | 100.000 % |

Table 7.4.1 Correlation matrix |

CHOLESKY DECOMPOSITION | |||

USD | EUR | GBP | |

USD | 1.991 % | ||

EUR | 1.482 % | 0.844 % | |

GBP | 1.531 % | 0.447 % | 0.505 % |

Table 7.4.2 Cholesky Decomposition |

Let the zi represent the correlativity adjusted xi ‘s. This accommodation can be represented by the undermentioned matrix generation:

ZT=AX.

Where

ZT is the transpose of a column vector if zi ‘s

A is a lower trigon matrix derived from the Cholesky Decomposition.

Ten is a column vector of eleven ‘s

The fake zi ‘s will be correlated standard normal variables.

- Using the stochastic procedure from subdivision 7.1. , we will utilize the zi ‘s from above in the undermentioned equation to imitate the foreign exchange rates:

St, i=S0, iexprd-ri-12?2t+zi?it.

Where I = USD, UER, GBP

And d=ZAR

### 7.5. Monte Carlo Simulation and VaR appraisal

This paper will utilize the Monte Carlo simulation attack to gauging VaR. The undermentioned stairss will be followed in order to deduce the concluding VaR estimation.

### Premises

- Gauze of long and short places will be allowed.
- The clip skyline T will be set to be to 10-days. For trades that have adulthood less than 10-days, we are presuming that the trade will be rolled-over guaranting that all exposures will hold the same adulthood.
- We will utilize the Direct-Jump to simulation day of the month methodinstead of Path-Dependant simulation method

### Scenario coevals

- Using the procedure outlined in subdivision 7.4 above, imitate the topographic point exchange monetary values over different clip skylines.
- Generate 1,000 simulations for each foreign exchange rate for clip skyline T = 10.
- Calculate the a-percentile and the ( 1- a ) -percentile of the generated exchange rates. The a-percentile will be used for put options as losingss will happen with the strengthening of the domestic currency. Likewise, we will utilize the ( 1-a ) -percentile for call options as losingss will happen when the domestic currency depreciates.
- The undermentioned expression will be used to deduce the portfolio VaR:

St, i=S0, iexprd-ri-12?2t+zi?it.

VaRp=max? [ Callpayoff+Putpremiums ; Putpayoff+Callpremiums ] .

### 8. Analysis of Consequences

The tabular array below summarises the portfolio VaR over the 10-day clip skyline. Note that this consequence takes into history the derivative monetary value and adjusts it consequently.

### Interpretation of the tabular array

O The first row represents the loss that can non be exceeded with a 95 % assurance degree if the domestic currency depreciates.

O The 2nd row represents the loss that can non be exceeded with a 95 % assurance degree if the domestic currency appreciates.

O Since, the market can non travel in both waies at the same clip, the maximal loss that can non be exceeded with a 95 % assurance will be the upper limit of the loss on depreciation and the loss on grasp.

This derivative consequence will so be reported to the regulator and the bank ‘s hazard commission. One of the determinations that the commission can do is to wind off the places if the exposure is excessively high i.e. greater than the bank ‘s hazard appetency.

### 9. Decision

The result of this paper was to develop a methodological analysis that can be used to mensurate the VaR of a portfolio made up of currency options. The consequences above demonstrate the findings of this exercising. Using the Monte Carlo attack can help in supplying more accurate consequences depending on the figure of simulations and clip required to bring forth such consequences. Most Monte Carlo simulation engines are ran overnight in order to bring forth consequences for a big portfolio of trades.

Although this was limited to currency options, the rule developed here can be extended to cover all non-linear derived functions across different plus category. VaR methods will stay as the most easy understood and widely used step of hazard. With minor alterations in methodological analysis, this can besides be used as a step of possible hereafter exposure

### 10. Appendix

### 10.1. The information

The topographic point exchange rates, the matching work stoppage monetary values and the adulthood day of the months of the options will be taken from the current ABSA Bank Ltd foreign exchange portfolio. In add-on to that, we will utilize at least 251 concern yearss of historical topographic point exchange rate to gauge the volatility. The client existent names will be changed for security grounds. For easiness of calculation, the option types will be restricted to vanilla European call and put options. We will besides curtail the currencies exchanged to the undermentioned currencies ( USD, GBP and EUR ) including the South African Rand ( ZAR ) . Both the long and short places will be considered. The South African Rand will be used as the base currency for all computations. In gauging the riskless involvement rate, the rates will be computed utilizing bootstrap method utilizing the forward/swap curves downloaded from Bloomberg

### 10.2. Cholesky Decomposition

Cholesky Decomposition is a additive algebra procedure of break uping symmetric, positive-definite matrices into a merchandise of lower triangular matrix and its conjugate transpose ( Wikipedia ) . Example, if:

A is the nxn symmetric, positive definite matrix.

L is the lower triangular matrix.

LT is the transpose of the lower triangular matrix.

A=LLT.

Cholesky Decomposition can be used to in the same manner as the LU Decomposition to work out additive systems ( DUR ) . Below are the entries of a 3×3 matrix.

l11=a11 | |

l21=a21l11 | |

l22=a22-l212 | |

l31=a31l11 | |

l32=a32-l21l31l22 | |

l33=a33-l312-l322 |

All the other entries of the matrix L non represented above are zero.

This procedure was used to break up the correlativity matrix ( A ) into the lower triangular matrix ( L ) which is used to imitate the correlative variables.

A=10.8690.8470.86910.8580.8470.8581.

L=1000.8690.49500.8470.2470.471.

It can be easy shown that this consequence is right by summing the square of the row elements. These should sum to 1 for all rows.

### 10.3. Solution of the Stochastic Differential Equation ( SDE )

We made the premise that the currency topographic point exchange follows the undermentioned procedure:

dS=r-rfSdt+?Sdz.

Where

R is the domestic riskless involvement rate.

releasing factor is the foreign riskless involvement rate.

s is the exchange rate ‘s volatility.

dz is the Wiener procedure with average 0 and volatility of 1.

The above stochastic differential equation is additive in S. Harmonizing to ( Bass, 2003 ) , these type of SDEs have a alone solution. We will demo below that the proposed solution is the right solution to the SDE.

We would necessitate the undermentioned consequences that we will province without cogent evidence:

### Ito ‘s expression

If f?C2, so

fWt-fW0=0tf’WsdWs+120tf ” Wsds.

Besides define

Xt=?Wt=?2t.

### There exists a alone solution to SDEs of the signifier:

dXt=?XtdWt+bXtdt, X0=x0

This means that Xt satisfies

Xt=x0+0t? ( Xs ) dWs+0tb ( Xs ) Ds.

Where Wt is the Brownian gesture.

Claim:

There exists a alone solution to the SDE:

dS=r-rfSdt+?Sdz.

Given by:

St=Sexpr-rf-12?2t+z?t.

We will turn out this consequence utilizing Ito ‘s expression.

Let | |

Xt=r-rf-12?2t+?Wt. | |

dXt=r-rf-12?2dt+?dWt. | |

Therefore, | |

St=eX0+0teXsdXs+120teXsdXs | |

eXt=eX0+0tSs?dWs+120tSsr-rfds |

Which is in the format of Ito ‘s expression ( Bass, 2003 ) .

### 10.4. Excel VBA Code

Below is all the VBA codification that was used for this undertaking. The codification is compatible with Microsoft EXCEL 2003 version.