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:
dr(t) =
(
a1 + b1(`(t)− r(t))
)
dt+ σ1dW1(t) (1)
d`(t) = `(t)
(
a2 − b2r(t) + c2`(t))
)
dt+ σ2dW2(t) (2)
where:
• a1, b1, σ1, a2, b2, c2 and σ2 are all constants, usually obtained through callibration techniques;
• W1(t) and W2(t) are standard Brownian motions with correlation factor ρ (here ρ is another
constant of the model).
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.
a1 b1 σ1 a2 b2 c2 σ2 ρ
-0.01 0.1102 0.1133 0.0089 0.00358 -0.0037 0.0298 0.2063
1
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 ∈ {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?
1The displacement of a function f over an interval [t1, t2] is simply the absolute value |f(t2)− f(t1)|.
2
5 Submission instructions
In the dedicated “Coursework 2 submission” Assignment activity on the Learning Mall Online, you
will need to submit the following two (2) documents.
• A plaintext .txt file, into which you have copied the source code of your entire BrennanSchwarz
Java class. This file should be named “CPT206 CW2 Code studentId.txt”.
• Your report from Section 4, typed into for instance a Word document, and converted into
a PDF file. This file should be named “CPT206 CW2 Report studentId.pdf”.
The submission deadline is: Sunday, 24 April, 2022, 10pm.
This assignment is individual work. Plagiarism (e.g. copying materials from other sources
without proper acknowledgement) is a serious academic offence. Plagiarism and collusion will not
be tolerated and will be dealt with in accordance with the University Code of Practice on Academic
Integrity. Submitting work created by others, whether paid for or not, is a serious offence, and
will be prosecuted vigorously. Individual students may be invited to explain parts of their code in
person during a dedicated BBB session, and if they fail to demonstrate an understanding of the
code, no credit will be given for that part of the code.
Late submissions. The standard University policy on late submissions will apply: 5% of
the total marks available for the component shall be deducted from the assessment mark for each
working day after the submission date, up to a maximum of five working days, so long as this does
not reduce the mark below the pass mark (40%); submissions more than five working days late will
not be accepted.
Good luck!
3