### C++代写 | MATH5350M: Computations in Finance

这个作业是用C++完成投资风险评估

MATH5350M: Computations in Finance (Year 2019/20) Jitse Niesen

Coursework 1 (30%): Due 24 February

Pricing complex options using a binomial tree

Your work should be submitted on MINERVA before 14:00 on Monday 24 February. Late

coursework will be marked down.

You must use templates (files CW1-main.cc and CW1-student.cc) provided in the Assessed

Assignment Submissions area within the module resource on MINERVA. You may change

CW1-main.cc, but the CW1-student.cc that you submit must work with the CW1-main.cc

file originally provided. 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.

Further details on how to submit are given at the end.

The market consists of two instruments: one stock with the price denoted by St and a

bond with the price at time t equal to Bt = e

rt, where r is the risk-free interest rate. The

stock price follows the Black–Scholes model with the volatility σ.

Your task is to price a vanilla American put option in this model. Ultimately, you will

prize the option using a binomial tree with Richardson extrapolation. Along the way, you

should make plots similar to the ones shown in the lecture about binomial trees.

Your task is to write a program that price an American put option using a binomial tree

method. You have to implement the three functions described in Parts 1, 2, 5 and 6 using

templates given in the file CW1-student.cc.

1

MATH5350M: Computations in Finance (Year 2019/20) Jitse Niesen

Part 1. Inputting data (15 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, S0 ≤ 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& r, double& sigma,

double& T, double& K, int& n);

The meaning of parameters is as follows:

• S_0 – initial price of the stock, i.e. S0,

• r – risk-free interest rate (per annum),

• sigma – the volatility of the stock price σ (per annum),

• T – expiry time of the option that expires last,

• K – strike price K of the American put option,

• n – number of periods in the binomial tree (M in the slides).

Part 2. The approximate CRR method (20 marks)

Implement the pricing of the American put option on a recombining binomial tree. Use the

approximate CRR method for the calibration of the binomial model. The computed price

should be returned by the function. The header of the function that you will implement is

provided in the file CW1-student.cc and below for your convenience:

double compute_price_approx_CRR(double S_0, double r, double sigma,

double T, double K, int n);

The parameters have the same meaning as in Part 1. 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 call function error(…).

2

MATH5350M: Computations in Finance (Year 2019/20) Jitse Niesen

Part 3. Verification (15 marks)

An important (and difficult) part of computations in finance is verification: How can you

be sure that you can rely on your program? Imagine that you are planning to do some big

trades based on the results of your program.

Verify (as well as you can) that your program produces correct prices. Think about whether

there are parameter values when you know the result, perhaps only approximately or in

certain limits. Document your verification process so that your hypothetical manager may

be sure that she can rely on your code. Your documentation must be concise (don’t produce

20 screenshots) but detailed enough to give your manager confidence.

Part 4. Results (15 marks)

Compute the price of a 10-month American put option with strike price 45 when the

underlying stock price is 51, the risk-free interest rate is 4% per annum and the volatility

is 30% per annum. Use a binomial tree with 100 periods.

Make a plot showing how the computed price varies as you change the number of periods,

similar to page 45 of the slides of Lecture 1. Based on your results, what is the price of

the option? Give a rough estimate of the accuracy of your answer and explain how you

arrived at it.

Part 5. Centring the tree (15 marks)

As discussed during the lectures, we can slightly modify the tree so that the strike price

is always in the middle of the tree to eliminate the oscillations in the plot. Implement

a function compute_price_centred_tree with the same arguments as the function

compute_price_approx_CRR in Part 2. This function should compute the price of an

American put option using a centred binomial tree. Plot the price computed using this

function, similar to page 47 of the slides.

Part 6. Richardson extrapolation (20 marks)

Show that the prices computed in the previous part satisfy P(M) ≈ P +AM−1

for large M,

where P(M) denotes the price computed a binomial tree with M periods, P is the true

price, and A is a constant. This suggests the use of Richardson extrapolation.

Implement a function compute_price_extrapolation with the same arguments as in

Part 2 and 5 which computes the price of an American put option using Richardson extrapolation.

Plot the price computed using this function, similar to page 50 of the slides.

Based on your results, what is the price of the option? Give a rough estimate of the

accuracy of your answer and explain how you arrived at it.

3

MATH5350M: Computations in Finance (Year 2019/20) Jitse Niesen

Directions for submission

You need to submit a report and the code.

Report: Your report must be typed in Microsoft Word or Latex. Hand-written reports

or reports containing photos of hand-written notes will not be accepted. Do not include

the code in your report. Structure your report as the assignment (Part 3, Part 4, Part 5,

Part 6), leaving out Part 1 and Part 2 which do not require an answer.

Your report (as a pdf file) must be uploaded in the Submit My Work area using the

TurnitIn submission tool entitled “Report submission for Coursework 1”.

Code: 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.

The C++ file CW1-student.cc (NO pdf, doc, ps, etc.) must be uploaded in the Submit

My Work area using the assignment submission tool entitled “CW1-student.cc submission

for Coursework 1”

Marking: The following aspects of your report are important in the marking: quality of

the answers, presentation (easy to understand, looking professional), relevance, conciseness

(you can do good work in two pages, five is probably more than necessary).

The following aspects of your programme are important in the marking: correctness (the

programme does what it is supposed to do), quality of code (e.g. meaningful names for

variables, comments that facilitate understanding of the code) and efficiency (speed and

memory usage).

Deadline: Both the report and the code have to be submitted by the deadline. 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 finish the whole submission process by the deadline.

It is your responsibility to ensure you upload the correct file to MINERVA, and that it has

uploaded successfully.

Anonymity: Do not include your name anywhere, not in your report, nor your code, nor

your filenames. Only include your student ID. Your work will be marked anonymously,

but this can only be done if your name does not appear in your submission.

4

## 发表评论