Guaranteed Higher Grade!

Free Quote
MATLAB Assignment Project: Implementing Black-Scholes Equation through Finite Difference Method

You are asked to implement the following programming tasks (1-5), using good coding practice (point 6 below) and to write MATLAB and PDF documentation (task 7).

1. (1 mark) Consider the following domain: x interval [a,b], t interval [0,T]. Generate the grid in the x, t coordinates as follows:

â€¢ Space interval divided into N equal parts (N+1 boundary points). The index values should be consistent with MATLAB array index convention running from 1 to N+1.

â€¢ Time interval divided into M equal parts (M+1 boundary points). The index values should be consistent with MATLAB array index convention running from 1 to M+1.

Â

2. (4 marks) Using the change of variables described in the lectures (going from the unknown function V(S,t) to the unknown function v(x, ?) and then to the unknown function u(x, ?)), calculate the FDM grid corresponding to the conversion of the BS equation to the heat equation:

Use the values Smin = 0.001, Smax = 4 K . Write the MATLAB code to generate the x interval and the ? interval (from the values of Smin , Smax and T calculate the range of the x variable and the ? variable). Note that the change of variables is and that the above time variable is different by a factor from the time variable used in the

Â

Background section (where we used the change of time variable ? = T â€“ t ). Calculate the corresponding grid.

3. (4 marks) Translate the initial and boundary conditions (1) and (2) in the correct initial and boundary conditions for the new unknown function u(x, ?).

Â

4. (3 marks) Use a scheme of your choice (Implicit, Explicit, or Crank-Nicholson) to solve the heat equation for u(x, ?). In the case of the explicit finite difference scheme, demonstrate that the scheme is conditionally stable and find the condition under which the scheme would be stable.

Â

5. (6 marks, distributed as detailed below) Work your way back from u(x, ?) to V(S,t) to solve the Black-Sholes equation and produce:

a. (3 marks) a 2d plot showing the price of the option at time 0 (on the vertical axis) vs. the stock spot price (on the horizontal axis);

b. (3 marks) a surface plot of the option prices V(S,t) for the whole FDM grid in S and t.

Â

6. (4 marks) You can organise your code in MATLAB scrips as you prefer. Up to two marks will be awarded if: (a) you try to implement the solution as a set of MATLAB functions, wherever it helps to keep your code readable, well structured, and maintainable; (b) include MATLAB scripts calling your functions to demonstrate the code functionalities. The code should be saved as MATLAB scripts in all cases. No code purely included as text in the

documentation (with no accompanying .m file) will be considered for marking code functionalities and correctness.

7. (8 marks, distributed as detailed below) The code should be accompanied by detailed documentation, in the form of MATLAB comments, and as typeset documents in yourfavourite word processing software (LaTeX, Word, etc.). Documents should be saved in PDF format. The documentations has to consist in:

â€¢ (2 marks) MATLAB comments explaining the structure of the code, available functions, main variables and any other information to help to understand the code;

â€¢ developer documentation (as a typeset, not handwritten, PDF document) summarizing:

(2 marks) the structure of the code, available functions, main variables and any other information to help to understand the code, including directions on how to extend the code to handle more general features;

(2 marks) some numerical test runs of your code; you need to check the accuracy of your results comparing them to the values calculated using the online tool at http://www.coggit.com/freetools (left menu â€œFinancial Pricing Tools -> Barrier Option Pricingâ€);

â€¢ (2 marks) end-userâ€™s instructions (as a second typeset, not handwritten, PDF document) explaining how to use the script(s), how to input data and how the results are presented, and a brief description of the methods implemented. Also, the discussions of (a) and (b) should be included here.Â