Computational Finance
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Computational Finance
Please write a brief Report (and please make it as concise and to-the-point as possible, and please make it use itemising/enumerating whenever possible) that contains the answers to the coming questions.
Please make sure you accompany your Report (containing answers to the below) with a CPP file that contains all your underlying code. (In case, in addition to the Report and the CPP file, you have used a spreadsheet, please include that as well.)
Part One: [65 marks]
(You will find that that the questioning below will direct your programme to carry out not only a pricing, but elements of risk measurement and model-risk assessment too.)
Please write a C++ programme that (contains a specific function, called mainPricer, that) performs the Monte-Carlo pricing of the following structured note. It is a note dependent on an underlying, S. The note pays, for some barrier level B (a pre-specified constant, essentially), on its maturity date T:
[ST – S0]+ . 1{ (max t ∈ [0,T] St) < B }
Where1{E} denotes the indicator function of an event E.
0) [10 marks] In your Report, explain briefly your pricing method (focusing mostly on things that may be less obvious, or a deviation from the in-class approach, in your code).
1) [20 marks] Please produce about 10 selected numerical scenarios (and please include the results in the Report), to illustrate the impact (on this option’s price) of varying the volatility. Does the resulting profile (or possibly profiles) make sense to you? Why?
Please make sure you’ve used a separate function (call it sensitivityAnalysis) that takes charge of this sensitivity analysis task. Please explain in your Report any precaution(s) that you took to minimise the noise in your sensitivity analysis .
2) [10 marks] What does this option (approximately) become, when B is much (much, much) larger than S0?
3) [5 marks] What does this option become when B < S0 ?
4) [10 marks] Use your programme to derive the probability that the payoff of the above option turns out to be > 5$, for the following numerical example: The underlying is a stock that pays no dividends, its spot S0 = 100$, its volatility = 20%, time to maturity = 2 years, discount rate = 2%, B=150$. (Make sure you reference the bit in your code that provided the answer.)
5) [10 marks] Finally, can you think of an approach/trick in implementing mainPricer, that may shorten the computational/simulation effort involved in the pricing (compared eg to a brute- force approach)? But is there a downside to this (pricing) efficient approach when applied to sensitivity analysis?
(Note that the above Part One has not been prescriptive in forcing a particular prototype [eg list of arguments] for your functions mainPricer and sensitivityAnalysis. That is up to your judgment.)
Part Two: [20 marks]
Look at the finite-difference pricer (for a European call option) in Annex1 below. Please modify the code to make it price a European put option, and also try to implement a better way (not necessarily a perfect way) of pinning down the option’s price corresponding to the exact Spot. In your Report, briefly (but clearly) explain this ‘better way’.
Part Three: [15 marks]
Look at the binomial-tree pricer (subject to a possible bug), for a European call option, in Annex2. Please modify the code to make it price a European put option. Is there is a bug in the code? What is it? How did you fix it?
Annex1: (referred to in Part Two) This is (slightly adapted) code from our session2 (completed in session3), a slightly adapted version from our file session02completedOnDay3.cpp:
#include<cmath>
double maxi(double a, double b) { //Helper function
return (a > b) ? a : b;
}
double fdmES_optionPricer (double s0, double k, double r, double vol,
double T) {
int i, j;
double value;
const int I = 100;
const double DELTA_S = 2 * k / I;
double delta_t = 1 / (vol * vol * I * I);
const int J = (int) floor(T / delta_t);
delta_t = T / J;
double* S; S = new double[I+1];
double* Vprev; Vprev = new double[I+1];
double* Vcurr; Vcurr = new double[I + 1];
double* Deltas; Deltas = new double[I + 1];
double* Gammas; Gammas = new double[I + 1];
int iBelow = (int) floor(s0 / DELTA_S);/* A good program
should contain no warnings either!*/
// At maturity (ie for j==0):
for (i = 0; i <= I; i++) {
S[i] = i * DELTA_S; /* Won't change (Is not a function of
j at all ..)*/
Vcurr[i] = maxi(S[i]- k,0); /* Will keep getting updated
in the looping that follows (for j>0), except
for the two at
(two) boundaries (ie the upper & the lower).
Lower boundary: Not
controversial at all!
Upper boundary:
We're assuming the "intrinsic value".
*/
}
/*Now, for j>0: the Big Loop :*/
for (j = 1; j <= J; j++) {
for (i = 0; i <= I; i++)
Vprev[i] = Vcurr[i];
// Now deal with unknowns (of which there are I-1):
for (i = 1; i <= I-1; i++) {
/*Implementing eqn 12 (2 preps, ie the 'notation
management', plus eq 12 itself): */
Deltas[i] = (Vprev[i + 1] - Vprev[i - 1]) / (2 *
DELTA_S);
Gammas[i] = (Vprev[i + 1] - 2 * Vprev[i] + Vprev[i -
1]) / (DELTA_S * DELTA_S);
Vcurr[i] = Vprev[i] + delta_t *
(0.5*vol*vol*S[i]*S[i]*Gammas[i]
+ r*S[i] *Deltas[i] - r*Vprev[i]);
}//end of the i loop
/*Yes we need to worry about the (2) boundaries (the
upper & lower), but this is an example where the best action is to
take no [further] action*/
}//end of the j loop
value = Vcurr [iBelow];
delete[] S; delete[] Vprev; delete[] Vcurr;
delete[] Deltas; delete[] Gammas;
return value;
}
Annex2: (referred to in Part Three) This is (slightly adapted) code from our session1 (completed in session2), a slightly adapted version from our file session01completedOnDay2.cpp:
#include<cmath>
double maxi(double x, double y){ //Helper function
return (x>y)?x:y;
}
double btPricer(double s0, double k, double r, double vol, double T,
int n){
double value;
double dt= T/n, nu = r-0.5*vol*vol,
Delta=sqrt(vol*vol*dt+nu*nu*dt*dt),
p=0.5+0.5*nu*dt/Delta, pd=1-p;
double * St = new double [n+1];//We need a vector of doubles
double * V = new double [n+1];
int i, j;
//At maturity (ie for j==n):
St[0] = s0 * exp(-n*Delta) ;
for(i=1; i<=n; i++)
St[i] = St[i-1]*exp(2*Delta);
for(i=0;
V[i]
option)*/
i<=n; i++)
= maxi(St[i] - k , 0);/*The famous payoff (for a Call
//Travelling backwards (the Journey)
for(j=n-1; j>=0; i--){
for(i=0; i<=j;i++){
//Not needed (for now!): St[i] = St[i] * exp(Delta)
//ie: What is the 'new' St[i] in terms of the 'old' St[i].
V[i] = (p*V[i + 1] + pd*V[i]) * exp(-r*dt);
}
}
value = V[0];
delete[] St; //freeing up the memory
delete[] V; //freeing up the memory
return value;
}
NB:
Please submit both the code (the aforementioned CPP file) and the Report (the latter should preferably be in Word format) plus any spreadsheet you used. You should also include that code file (source file) from your C++ project as an appendix (if possible, preserving the C++ Editor colours) to your Report.
In your Report’s answers, please use the same numbering used in the questions above. Please make sure that any (academic or other) sources are properly referenced.
[To be confirmed:] Please note that the Keats submission facility may not permit the submitting of more than three files.
We are of course asked to highlight plagiarism: Please remember that it is much better to produce your own answers than a colleague’s or anyone else’s. (The College’s plagiarism checks have no ‘expiry date’.) If you obtain results that you believe are incorrect and you point that out (to the best of your honest explanation), you will actually earn marks (maybe not as much as for a fully error-free answer, but certainly much better than copying someone else’s.) And finally: Please submit well ahead of the deadline. (Problems that arose for late submitters in previous years include, among many other incidents, discovering that their login/password had expired. It only took them a few minutes to revive them, but because they left it so close to the deadline, they ended up missing the cut-off time. There are plenty of other incidents reported by later submitters – an unexpected loss of internet connection, etc, etc – so please do not treat the deadline as a target. Rather, it is a cliff edge to stay well clear of.)
2022-02-10