-
Develop a small library implementing B-splines. This library should be capable of calculating the derivatives and integrals of the basis functions. Make sure that you take a full advantage of the recursive properties of the basis functions.
- Please refer to python script:
Assignment1/splines.py
Spline
Class: with methodssplrep()
,splint()
,spldev()
, be capable of the derivatives and integrals of the basis functions.- Use cache in the function to take a full advantage of the recursive properties of the basis functions.
- Please refer to python script:
-
Build a function that computes the discount factor between any two dates.
- Please refer to python script:
Assignment1/curves.py
- Inside the
Curve
Class,disc_factor()
is implemented, and bothOIS
andLIBOR
classes will be derived fromCurve
.
- Please refer to python script:
-
Build a function that computes the forward LIBOR rate for any settlement and underlying tenor.
- Please refer to python script:
Assignment1/curves.py
- Inside the
Curve
Class,forwards()
is implemented, andLIBOR
Class will inheritant this method.
- Please refer to python script:
-
Build a function that computes the (spot or forward) swap rate for any settlement and underlying tenor.
- Please refer to python script:
Assignment1/swaps.py
- Inside the
Swap
Class,SwapRates()
is to compute the swap rate for given settlement and underlying tenor.
- Please refer to python script:
-
Use the enclosed market data sheet and the method described in class to build the instantaneous OIS and LIBOR curves.
- Please refer to python script:
Assignment1/curves.py
- Inside the
LIBOR
andOIS
classes, they both inheritantr()
method inCurve
base class, and this method is building the instantaneous curves.
- Please refer to python script:
-
Build a function that calculates the PV of any spot or forward starting swap based on your curves.
- Please refer to the main file:
Assignment1/main.py
- Please refer to the main file:
-
Step 1: Please make sure your computer has installed python2 and required modules, if not and you want to test this assignment by running the program, please go https://github.com/weiyialanchen/MacInstallation and follow the installation guide.
-
Step 2: Download the repository by
git clone https://github.com/weiyialanchen/InterestRate.git
-
Step 3: Go to Assignment 1 directory and run the main file
cd ~/InterestRate/Assignment1 python main.py
-
Implement the model using Euler’s scheme (note that for the normal LMM, Euler’s and Milstein’s schemes are identical). For drift term calculations, implement the ability to do both: the exact calculation and the frozen curve approximation.
- Please refer to python script:
Assignment2/libor_market.py
- The exact calculation: set the parameter
b_frozenCurve
asFalse
- The frozen curve approximation: set the paramter
b_frozenCurve
asTrue
- Please refer to python script:
-
Apply your model to a spot starting 10 year knock-out swap. A knock-out swap is an interest rate swap with a special termination feature. Namely, if, on a fixed leg coupon date (or more precisely, two business days before), the 10 year swap rate sets below a preset barrier B, the swap is terminated. Notice that this is a path dependent derivative and Monte Carlo simulations are an appropriate approach to pricing this product. Use 2000 simulated paths to carry out the calculation. As a variance reducing method, you may also consider using antithetic variables.
- Knock-out swap:
Knock_Out_Swap
class inAssignment2/swaps.py
derived fromSwap
class implemented in Assignment1 - Monte Carlo Simulation: please refer to
Knock_Out_Swap.simulate()
- Knock-out swap:
-
2000 simulated paths calculation, assuming B = 0.95%, determine the break-even rate on the fixed leg of the swap.
- Please refer to
calc_swapRate()
inAssignment2/main.py
, see output for 2000 paths below
Use 2,000 simulated paths to carry out the calculation (the exact calculation) - The break-even rate on the fixed leg of the swap: 0.0222146461996 Use 2,000 simulated paths to carry out the calculation (the frozen curve approximation) - The break-even rate on the fixed leg of the swap: 0.0221701123552
- Please refer to
-
How accurate is your calculation? Compare against a run with 5,000 simulated paths.
- Please refer to
calc_swapRate()
inAssignment2/main.py
, see output for 5000 paths below
Compare against a run with 5,000 simulated paths - The break-even rate on the fixed leg of the swap: 0.0227748459579
It's very accurate, with error around
2%
. - Please refer to
-
Analyse the performance of each of the drift terms calculation methods, and the accuracy of the frozen curve approximation.
- The performance between different methods is very close, though the exact calculation is more accurate in theory.
- But the error of frozen curve approximation method is smaller than 0.01 digits / 2% error, a good enough approximation.
-
Step 1: Please make sure your computer has installed python2 and required modules, if not and you want to test this assignment by running the program, please go https://github.com/weiyialanchen/MacInstallation and follow the installation guide.
-
Step 2: Download the repository by
git clone https://github.com/weiyialanchen/InterestRate.git
-
Step 3: Go to Assignment 2 directory and run the main file
cd ~/InterestRate/Assignment2 python main.py