(Coursework 2) MATH 5350MThis question paper
consists of 4 printed pages,
each of which is identified
by the Code Number MATH 5350M
c©UNIVERSITY OF LEEDS
(Semester 2, 2016/2017)
Assessed Coursework 2
MATH 5350M Computations in Finance
(35% of the total coursework mark)
Submission deadline: 12 noon on Monday, 13th March 2017
You must use templates (files CW2-main.cc, CW2-student.cc) provided in the Assessed Assignment Sub-
missions area within the module resource on the VLE. File CW2-main.cc must not be changed. Make sure
you do not share your code or a piece of thereof with anyone else as this qualifies as plagiarism for both of
you.
Pricing of options under stochastic interest rates
Consider a model with two assets: a riskless money-market account with the price process Bt and a risky
stock with the price process St. Their dynamics follow
dBt = rtBtdt,
dSt = Strtdt+ Stσ2
(
ρdW
(1)
t +
√
1− ρ2dW (2)t
)
,
where the short rate rt evolves according to
drt = κ(0.05− rt)dt+ β
√
rtdW
(1)
t .
Above, W (1) and W (2) are two independent Wiener processes and ρ ∈ [−1, 1] is the correlation coefficient
(it is responsible for modelling dependence between random moves of the interest rate and the stock).
Your task is to design and implement two algorithms for pricing of a vanilla European put option. The first
algorithm will use plain Monte Carlo while the second will employ a control variate to reduce the variance
of the price estimator. For solution of stochastic differential equations numerically, apply Euler-Maruyama
scheme.
Part 1. (10 marks)
Implement a function responsible for inputting data. This function should be informative, user friendly and
must verify correctness of arguments. You are expected to deal with situations when an inputted parameter
is clearly wrong: for example, S(1)0 ≤ 0. Don’t try to deal with situations when a user inputs a letter when a
number is needed. The header of the function is given below:
void input_data (double& S_0, double& sigma, double& rho, double& r_0, double& beta,
double& kappa, double& K, double& T, int& m, int& n);
Page 1 of 4
(Coursework 2) MATH 5350M
The meaning of parameters is as follows:
• S 0 – initial price of the stock, i.e. S0,
• sigma – volatility component of the stock σ,
• rho – the correlation coefficient ρ,
• r 0 – initial value of the interest rate (per annum), i.e. r0,
• beta – the volatility component of the interest rate β,
• kappa – the mean-reversion speed κ,
• K – the exercise price K,
• T – exercise time in years,
• m – number of Monte Carlo iterations,
• n – number of steps of the numerical scheme to solve SDEs.
Hint: realistic values for the interest rate parameters are β ∈ (0.08, 0.2) and κ ∈ (0.3, 1).
Part 2. (50 marks)
Write a C++ function which implements a simple Monte Carlo algorithm for pricing of the option. Do not use
any variance reduction techniques. Use a template given in the file CW2-student.cc:
void compute_MonteCarlo_put_price (double& price, double& left, double& right,
double S_0, double sigma, double rho, double r_0, double beta,
double kappa, double K, double T, int m, int n);
This function should be standalone (ready to use in other programmes without your function input data),
so it must perform its own verification of parameters. It does not mean that you are relieved from checking
correctness of parameters in the function input data! The above function must not communicate with a
user or print anything on the screen. The only way to inform about errors is to use exceptions (a call to a
function error(…) throws an exception for you).
Parameters:
• S 0, sigma, rho, r 0, beta, kappa, K, T, m, n – as in Part 1
• price – the estimated price (output),
• left, right – the 99% confidence interval for the price (output).
If you have doubts about the exact meaning of the output variables, check how they are used in CW2-main.cc.
Part 3. (20 marks)
Write an algorithm for using control variates that lowers the variance of the option price estimator. Explain
your choice of the control variate. Use a simple version of the control variate without the parameter θ. Marks
awarded for part 3 and part 4 will be partly based on the quality of your estimator, i.e., how much it reduced
the variance.
Page 2 of 4
(Coursework 2) MATH 5350M
Part 4. (20 marks)
Implement the ideas from Part 3 in a C++ function using a template given in the file CW2-student.cc:
void compute_MonteCarlo_CV_put_price (double& price, double& left, double& right,
double S_0, double sigma, double rho, double r_0, double beta,
double kappa, double K, double T, int m, int n);
The meaning of parameters and requirements for the implementation are the same as in Part 2.
This function should be standalone (ready to use in other programmes without your function input data),
so it must perform its own verification of parameters. It does not mean that you are relieved from checking
correctness of parameters in the function input data! The above function must not communicate with a
user or print anything on the screen. The only way to inform about errors is to use exceptions (a call to a
function error(…) throws an exception for you).
Directions for submission
Report: Your report must be typed in Microsoft Word or Latex using an 11pt font with single (normal) line
spacing. Hand-written reports or reports containing photos of hand-written notes will not be accepted. Do
not include any code in your report. Your report (doc, docx or pdf file) must be uploaded in the Assessed
Assignment Submission area using the TurnitIn submission tool entitled ”Report submission for ACW 2”
Code: The file CW2-student.cc (NO pdf, doc, ps, etc.) must be upoaded in the Assessed Assignment
Submission area using the assignment submission tool entitled ”CW2-student.cc submission for ACW
2”
Before submission: Clean up the code, make sure that comments in the programme make following the
code easy, check that the programme compiles. Make sure you have not shared your code or a piece of
thereof with anyone else as this qualifies as plagiarism.
Marking: The following aspects of your programme are important in the marking: correctness (the pro-
gramme does what it is supposed to do), quality of code (e.g. meaningful names for variables, fool-
proofness for input data), comments (whether they facilitate understanding of the code) and efficiency
(speed and memory usage).
An electronic copy of the assignment must be submitted to the Assignment Submission area within the module resource
on the Blackboard VLE website no later than 12 noon on the deadline date. Faxed, emailed or hard copies of the
assignment will not be accepted. Failure to meet this initial deadline will result in a reduction of marks, details of which
can be found at the following place: https://lubswww.leeds.ac.uk/TSG/coursework/
SUBMISSION
Please ensure that you leave sufficient time to complete the online submission process, as upload times can vary.
Accessing the submission link before the deadline does NOT constitute completion of submission. You MUST click
the ‘CONFIRM’ button before 12 noon for your assignment to be classed as submitted on time, if not you will need to
submit to the Late Area and your assignment will be marked as late. It is your responsibility to ensure you upload the
correct file to the VLE, and that it has uploaded successfully. It is important that the submission of your report follows
the conventions stated below:
FILE NAME
The name of the report file that you upload must be your student ID only.
ASSIGNMENT TITLE
During the submission process the system will ask you to enter the title of your submission. This should also be your
student ID only.
Page 3 of 4
https://lubswww.leeds.ac.uk/TSG/coursework/
(Coursework 2) MATH 5350M
FRONT COVER
The first page of your report should always be the Assessed Coursework Coversheet (individual), which is available to
download from the following location https://lubswww.leeds.ac.uk/code-of-practice/downloadable-forms/
STUDENT NAME
You should NOT include your name anywhere on your assignment
END
Page 4 of 4
https://lubswww.leeds.ac.uk/code-of-practice/downloadable-forms/