# BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

# C++代写 | MATH5360M Optimisation Methods for Finance

### C++代写 | MATH5360M Optimisation Methods for Finance

MATH5360M01
This question paper
consists of 4 printed pages,
each of which is identified
by the Code Number MATH5360M01
Semester 1 2019/2020
Assessed Coursework 2 (25% of total module mark)
MATH5360M Optimisation Methods for Finance
Submission deadline: 10am on Thursday 12th of December 2019
Question 1 (20% marks)
(a) Write a C++ function that reads an n × n matrix A from a txt file.
A =

a11 a12 . . . a1n
a21
.
.
.
.
.
.
.
.
.
an1 . . . . . . ann

The txt file takes the following format:
• The first line lists n (the number of rows and the number of columns) in the n×n matrix.
• For the k
th line, k = 2, 3, . . . , n + 1, it lists the entries aij for i = k − 1 and j = 1, 2, . . . , n
(b) For A, if there exists a λ ∈ R and a non-zero x ∈ R
n
such that
Ax = λx
then the scalar λ is referred to as the eigenvalue of A and the vector x is the eigenvector of A.
Given that A is a 2 × 2 square matrix, write a programme which uses the function in (a) to
read the file “cw2q1.txt” for matrix A and computes, using the characteristic polynomial of
A, all real eigenvalues for A, λ, if they exist.
Note that “cw2q1.txt” is available on Minerva and it takes the format given in (a).
Page 1
MATH5360M01
Question 2 (30% marks)
Consider a T year European option with a strike price K and the current stock price S0. Let r be
the continuously compounded risk-free interest rate. Assume that the stock price only changes at
times ∆t, 2∆t, … n∆t, where ∆t =
T
n
and n is the number of periods between 0 and T. Assume
that in each period, the stock price goes either up by a factor of u or down by a factor of d where
u > d.
The payoff, VT , at maturity for a European call option is:
VT = max((ST − K), 0)
and the payoff, VT , at maturity for a European put option is:
VT = max((K − ST ), 0)
where ST is the stock price at time T years.
• Write a C++ programme that allows the user to choose between a European call and a
European put option and compute the price of the option chosen.
Encapsulate all the input functionality into a void type function e.g.
void inputs (some input parameters here)
and consider carefully if your model is arbitrage-free.
• Run out programme with S0 = 160, T = 5, n = 10, r = 0.085, u = 1.4, d = 0.8 and K = 135.
Include the output of a binomial tree of stock prices, another binomial tree of values of the
option for t = ∆t, 2∆t, …n∆t and the price of the option.
Page 2
MATH5360M01
Question 3 (50% marks)
When a firm is presented with a capital budgeting decision, the most important task is to determine
whether a project will prove to be profitable. The net present value (NPV), internal rate of return
(IRR) and the payback period (PP) methods are the most common approaches to project selection.
Your task is to write a C++ programme that computes NPV, IRR and PP for different projects
and helps the firm manager to select the right project.
For simplicity, we assume that the cash flows of all projects happen at the beginning of every year
from year zero. The cash flows for the projects and their net present values are discounted at the
same annually compounded rate r > 0.
(a) Define NPV, IRR and PP carefully. Provide an algorithm (pseudocode) for each of the computations. Your algorithms for IRR and PP need to be able to handle the following issues:
• the precision of a unique IRR. Implement a numerical method to compute the IRR (with
precision of 10−6
) if it is unique.
• the possibility of no IRR or multiple IRRs. In both cases, you can skip the computation
of IRR and output an error message e.g. “No IRR or multiple IRRs may exist, skipping
IRR computation! ”. [Hint: a project can have more than one IRR if its cashflows exhibit
more than one sign reversal, e.g. from year 0 to 4, the signs of cash flows are “− + −+”.
If your programme detects these circumstances, an error message will be displayed.]
• the possibility that the PP may not be appropriate or a modified PP method is required.
For example, this may happen when the initial cash flow is positive, or when the cash flows
exhibit more than one sign reversal. If your programme detects the above situations, for
simplicity, the computation of PP can be skipped and the error message, “PP is N/A”,
should be output.
(b) Based on your algorithms, write a C++ programme that:
• allows the user to input the interest rate, r, to be applied for discounting and the number
of cash flows in the projects;
• allows the user to input the cash flows starting from year zero;
• computes NPV, IRR and PP for all projects
• for each computed measure, gives a suggestion to the user on which project should be
selected.
(c) Run your programme for the following two projects with interest rate at 5% and report your
Project Year 0 Year 1 Year 2 Year 3 Year 4 Year 5 Year 6 Year 7
1 -6420 2500 3020 1200 950 800 N/A N/A
2 -4500 1050 790 850 1150 810 800 1300
Page 3
MATH5360M01
Directions for submission
Electronic submission only: You are required to submit two files electronically to the Assessment
Area within the module resource on Minerva no later than 10 am on the deadline date. Failure
to meet the initial deadline stated will result in a reduction of marks. The electronic submission
should include:
• The report should contain the answers to the questions and any explanation you deem
necessary. All C++ code should be included as appendices. State the compiler you use to
• All C++ code should also be submitted separately. Gather all your C++ files as they are
stored by Visual C++ or other compilers (.cpp or .cc; NOT pdf, doc, ps, etc.) and store them
in a zip file or some other common archive format (like rar or tar). Use the link “ Coursework
2 Code” to upload the archive file.
Please ensure that you leave sufficient time to complete the online submission process, as upload
time can vary. Accessing the submission link before the deadline does not constitute completion of
submission. You must click the “confirm” button for both files before 10 am for your assignment
to be classified 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 Minerva, and that it has uploaded successfully.
It is important that any file submitted follows the conventions stated below:
• File name – The name of the 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
• 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: 