Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CPT206 Computer Programming for Financial Mathematics:

Coursework 2 Task Specification

2022

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 e(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 (e(t) _ r(t))dt + σ1dW1(t)

de(t) = e(t) /a2 _ b2r(t) + c2e(t))dt + σ2dW2(t)

where:

(1)

(2)

  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-motionsfor 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.

1

1

1

2

2

2

2

ρ

-0.01

0.1102

0.1133

0.0089

0.00358

-0.0037

0.0298

0.2063

 

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 , e0  > 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 =  n(女) ,

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 e(t = 0) = e0 , and for any given time t = n(A女)  for

some k e (0, . . . , n _ 1}, r(t + dt) = r(t) + dr(t) and e(t + dt) = e(t) + de(t), where the increments

dr(t) and de(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 e(t) over the chosen time period (i.e.  should show the values of r(t) and e(t) for all t of the form t = n(A女)  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 ∆e 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?

1 The displacement of a function f over an interval [t1 , t2 ] is simply the absolute value |f (t2 ) [ f (t1 )|.

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 le. 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.