程序代写案例-COMP0041
时间:2022-04-30
University College London
MSc EXAMINATION
COMP0041 Applied Computational Finance (MSc)
MOCK PAPER 2022
TIME ALLOWED: THREE HOURS
You should attempt this paper under timed and exam like conditions when your revision is
complete.
ALL QUESTIONS CARRY EQUAL MARKS.
FULL MARKS WILL BE AWARDED FOR COMPLETE ANSWERS TO ALL FOUR QUESTIONS.
See Next Page
Question 1
a) Let s be a variable holding a string. Write a Python program to print out each character of
s twice, on two separate lines for each character. For example, if s is "xyz", then your
program should output the following
a
a
b
b
c
c
[5 Marks]
b) Write a function to convert a temperature in degrees Fahrenheit to degrees Centigrade.
The user should enter the temperature of their choice the main body of the program.
The converted temperature should be output to a file named temp.txt on your desktop.
[4 Marks]
c) Write a function to compute ∑ =1 . Your code should make use of a for-loop. The
program should prompt the user to enter a positive integer value , in the main body of
the program, where the result should be printed to the screen. [6 Marks]
d) You are required to produce the following graph Using the appropriate library and built-
in functions, solve the following
i. ∫ + +2√1 + 2 10 [2 Marks]
ii.
( + 2) [2 Marks]
iii. The modulus and argument of
3−5
[3 Marks]
iv. Ax = b, for x= �
�, where
A= � −
− −
�, b= �−
� [3 Marks]
See Next Page
Question 2
This question is about option pricing using Monte-Carlo simulation. Consider a European call option
with a strike price and time-to-maturity . The underlying is a stock whose spot price is which
follows a geometric Brownian motion with volatility . The option is to be valued using Monte-Carlo
simulation with a total of independent realisations of the Brownian motion, and a total of time
steps.
a) Using an algorithm/pseudo-code, write down an algorithm to compute an estimate of the present
value of the option using Monte-Carlo simulation using an Euler-Maruyama discretisation. [12 Marks]
b) Write a Python program which implements the algorithm specified in your answer to the previous
part. Your program should make use of vectorization. Use the following parametrisation of the model:
0 = 75, E = 80, = 2, = 0.05, = 0.2, = 100, = 10000. Assume that the following functions have
already been imported:
from numpy import sqrt, exp, cumsum, sum, maximum
from numpy.random import standard_normal
Do
not make use of any other libraries.
[13 Marks]
See Next Page
Question 3 This question is on the Binomial option pricing model.
a) Consider JVC stock that is currently trading at £63 per share. At the end of each three-month
period it will increase by £3 or decrease by £3. The annual risk-free interest rate is 4% with
continuous compounding. Calculate the price of a six-month Asian call option with arithmetic
averaging and fixed strike price = £61. At each time step, also clearly identify the value of the
hedged
portfolio with the above strike price.
[15 Marks]
b)
Repeat the above with geometric averaging.
[10 Marks]
See Next Page
Question 4
Part i. Briefly describe the meaning of the object-oriented programming paradigm. What do object-
oriented programs consist of?
[5 Marks]
Part ii. Consider the design of a date class. The class contains three data members
day
month
year
The day and month are of type string. The year is of type int. The date class also has one member
function called display() of type void. Write a basic class design with three constructors and one
destructor,
and the one-member function.
[10 Marks]
Part iii. Write an overloaded operator function for the output operator << to use cout for displaying
date
objects on the screen.
[6 Marks]
Part iv. How would you create a pointer to an array of objects belonging to class date? [4 Marks]
Final Page