CPT206 Computer Programming for Financial Mathematics:
Coursework 2 Task Specification
Thomas Selig
Due date: Sunday, 24 April, 2022, 10pm
This is the specification task sheet for the Coursework 2 assessment component of your CPT206 module. This is worth 15% of your final grade for this module. The submission deadline for this assignment is Sunday, 24 April, 2022, at 10pm. Detailed submission instructions are provided in Section 5.
The aim of this coursework is to implement the Brennan-Schwartz model, a two factors model that simulates the dynamics of short and long term interest rates. The model was first introduced by Michael Brennan and Eduardo Schwarz in 1982, and has been widely used as a financial model of interest rates since then. It has also been used to model apparently unrelated phenomena, such as population growth rates. As part of this task, you will also produce a report documenting your design choices, detailed in Section 4.
1 Model dynamics
The model is a two factors model of both short-term and long-term interest rates over a given time period. We write r(t) for the short-term rate, also called the spot rate, and `(t) for the long-term rate, also called the consol rate. The dynamics of the model are given by the following equations:
See https://quant.stackexchange.com/questions/24472/two-correlated-brownian-motions for an indication on how to simulate the two random variables dW1(t) and dW2(t). For simplicity, we will choose the values supplied by Brennan and Schwartz in their original paper for the constants of the model, given in the table below.
2 Task description (60 marks)
You will write a Java program that simulates the Brennan-Schwarz model over a given time period. Your Java program should be written in a single Main class called BrennanSchwarz. As well as the constants above, your program should take the following input paramters:
• initial rates r0, `0 > 0;
• a time period T > 0 and a positive integer n indicating the number of increment intervals.
The idea is to break down the time period [0, T] into n increment intervals of length dt = Tn , and apply the Euler method to Equations (1) and (2) to simulate the model over that time period. In other words, we should have: r(t = 0) = r0 and `(t = 0) = `0, and for any given time t = kTn for some k 2 {0, . . . , n − 1}, r(t + dt) = r(t) + dr(t) and `(t + dt) = `(t) + d`(t), where the increments dr(t) and d`(t) are is given by Equations (1) and (2).
On executing, your program should calculate and display the following information:
1. the values of the rate functions r(t) and `(t) over the chosen time period (i.e. should show the values of r(t) and `(t) for all t of the form t = kTn as above);
2. the minimum and maximum values of the rate functions, and the time(s) at which these are achieved;
3. the maximum displacements r and ` of the rate functions over all intervals of length dt1, and the time period(s) in which these are achieved;
4. the average values of the rate functions.
The display should be readable, and informative. Values should be rounded to a sensible length (e.g. five digits after the decimal point).
3 Code quality (20 marks)
The remaining marks (20) for the coding part will be awarded for general code quality as seen in the course materials to date. Here is some guidance.
• Keep your code neat and tidy; make sure it is properly indented throughout.
• Choose suitable names for variables and methods.
• Comment your code as needed.
• Split your code into separate methods as appropriate; code in the main method should be
kept to a minimum; methods overall should not be too long.
4 Report (20 marks)
You will write a short report (no more than three pages in length) providing some details on how you designed and implemented your program, as described in Section 2. You should explain the design choices you made for your Java program. You should consider the following questions.
• What are the different members (class variables or methods) of your Java class? What is their purpose?
• How did you proceed in implementing the model’s dynamics as described by Equations (1) and (2)? How did you calculate the various statistics associated with the rate functions?