MATH60082 Example Sheet 6 Explicit Finite Difference

Similar documents
Computational Finance Finite Difference Methods

FINITE DIFFERENCE METHODS

MATH6911: Numerical Methods in Finance. Final exam Time: 2:00pm - 5:00pm, April 11, Student Name (print): Student Signature: Student ID:

MASM006 UNIVERSITY OF EXETER SCHOOL OF ENGINEERING, COMPUTER SCIENCE AND MATHEMATICS MATHEMATICAL SCIENCES FINANCIAL MATHEMATICS.

Risk-neutral Binomial Option Valuation

ANALYSIS OF THE BINOMIAL METHOD

Computational Finance Binomial Trees Analysis

MATH3075/3975 FINANCIAL MATHEMATICS TUTORIAL PROBLEMS

The Multistep Binomial Model

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.265/15.070J Fall 2013 Lecture 19 11/20/2013. Applications of Ito calculus to finance

4. Black-Scholes Models and PDEs. Math6911 S08, HM Zhu

Queens College, CUNY, Department of Computer Science Computational Finance CSCI 365 / 765 Fall 2017 Instructor: Dr. Sateesh Mane.

Lab12_sol. November 21, 2017

Final Exam Key, JDEP 384H, Spring 2006

FE610 Stochastic Calculus for Financial Engineers. Stevens Institute of Technology

a*(variable) 2 + b*(variable) + c

Optimal switching problems for daily power system balancing

CHAPTER (r D)S V(S,T)= (S), 2 V 0asS, = 0onS = 0,

Extensions to the Black Scholes Model

Chapter 5 Finite Difference Methods. Math6911 W07, HM Zhu

MATH 425: BINOMIAL TREES

Package multiassetoptions

Real Options and Game Theory in Incomplete Markets

Lecture 4 - Finite differences methods for PDEs

Advanced Stochastic Processes.

Exercise 14 Interest Rates in Binomial Grids

The Intermediate Value Theorem states that if a function g is continuous, then for any number M satisfying. g(x 1 ) M g(x 2 )

Chapter 15: Jump Processes and Incomplete Markets. 1 Jumps as One Explanation of Incomplete Markets

1 Dynamics, initial values, final values

Queens College, CUNY, Department of Computer Science Computational Finance CSCI 365 / 765 Spring 2018 Instructor: Dr. Sateesh Mane.

Derivative Approximation by Finite Differences

American Equity Option Valuation Practical Guide

CONVERGENCE OF NUMERICAL METHODS FOR VALUING PATH-DEPENDENT OPTIONS USING INTERPOLATION

Lecture Quantitative Finance Spring Term 2015

FINANCIAL OPTION ANALYSIS HANDOUTS

MAFS Computational Methods for Pricing Structured Products

Yao s Minimax Principle

Utility Indifference Pricing and Dynamic Programming Algorithm

DRAFT. 1 exercise in state (S, t), π(s, t) = 0 do not exercise in state (S, t) Review of the Risk Neutral Stock Dynamics

American options and early exercise

The Binomial Model. Chapter 3

Accuplacer Review Workshop. Intermediate Algebra. Week Four. Includes internet links to instructional videos for additional resources:

Numerical schemes for SDEs

Factors of 10 = = 2 5 Possible pairs of factors:

Review of Derivatives I. Matti Suominen, Aalto

King s College London

Advanced Corporate Finance. 5. Options (a refresher)

In the previous section, we added and subtracted polynomials by combining like terms. In this section, we extend that idea to radicals.

Pricing theory of financial derivatives

King s College London

Finite difference method for the Black and Scholes PDE (TP-1)

Valuation of Options: Theory

Black-Scholes-Merton Model

MATH4143: Scientific Computations for Finance Applications Final exam Time: 9:00 am - 12:00 noon, April 18, Student Name (print):

AN IMPROVED BINOMIAL METHOD FOR PRICING ASIAN OPTIONS

Section 7.1 Common Factors in Polynomials

Option Pricing. Chapter Discrete Time

CHAPTER 10 OPTION PRICING - II. Derivatives and Risk Management By Rajiv Srivastava. Copyright Oxford University Press

Interpolation. 1 What is interpolation? 2 Why are we interested in this?

A Worst-Case Approach to Option Pricing in Crash-Threatened Markets

The Black-Scholes PDE from Scratch

The two meanings of Factor

5.6 Special Products of Polynomials

The Black-Scholes Equation

Binomial model: numerical algorithm

Numerical Methods in Option Pricing (Part III)

ECON4510 Finance Theory Lecture 10

EC316a: Advanced Scientific Computation, Fall Discrete time, continuous state dynamic models: solution methods

FINANCIAL MATHEMATICS WITH ADVANCED TOPICS MTHE7013A

15 American. Option Pricing. Answers to Questions and Problems

3.1 Properties of Binomial Coefficients

Attempt QUESTIONS 1 and 2, and THREE other questions. Do not turn over until you are told to do so by the Invigilator.

Math Performance Task Teacher Instructions

From Discrete Time to Continuous Time Modeling

Applying the Principles of Quantitative Finance to the Construction of Model-Free Volatility Indices

Week 19 Algebra 2 Assignment:

We begin, however, with the concept of prime factorization. Example: Determine the prime factorization of 12.

Phase Transition in a Log-Normal Interest Rate Model

Lecture 6: Option Pricing Using a One-step Binomial Tree. Thursday, September 12, 13

Research Article Exponential Time Integration and Second-Order Difference Scheme for a Generalized Black-Scholes Equation

Homework Assignments

Math Computational Finance Barrier option pricing using Finite Difference Methods (FDM)

$100 $100 $100 $100 $100 $200 $200 $200 $200 $200 $300 $300 $300 $300 $300 $400 $400 $400 $400 $400 $500 $500 $500 $500 $500

Generalized Binomial Trees

Section 5.6 Factoring Strategies

Practical Hedging: From Theory to Practice. OSU Financial Mathematics Seminar May 5, 2008

Appendix to Supplement: What Determines Prices in the Futures and Options Markets?

Hull, Options, Futures, and Other Derivatives, 9 th Edition

1. In this exercise, we can easily employ the equations (13.66) (13.70), (13.79) (13.80) and

MATH 425 EXERCISES G. BERKOLAIKO

A distributed Laplace transform algorithm for European options

Advanced Numerical Methods

TEACHING NOTE 98-04: EXCHANGE OPTION PRICING

Optimization Models in Financial Mathematics

Deriving the Black-Scholes Equation and Basic Mathematical Finance

Project 1: Double Pendulum

Name Class Date. There are several important things you should remember from multiplying binomials.

Pricing American Options Using a Space-time Adaptive Finite Difference Method

An Adjusted Trinomial Lattice for Pricing Arithmetic Average Based Asian Option

Optimization Models one variable optimization and multivariable optimization

Transcription:

MATH68 Example Sheet 6 Explicit Finite Difference Dr P Johnson Initial Setup For the explicit method we shall need: All parameters for the option, such as X and S etc. The number of divisions in stock, jmax, and divisions in time imax The size of the divisions S = S max /jmax and t = T/iMax A vector to store the stock prices, and two to store the option values at the current and previous time level. It will make things easier if you just declare these at the top of the program before you start doing anything with them. The program structure will look something like: Initialise values Solve with Explicit Setup Loop time i Boundary condition j= Loop option value j A=.. B=... C=... Vj =... Boundary condition j=n Print results The list above should give you an idea of what you need to initialise at the start of the program. The setup stage involves assigning the correct level of storage to your vector (if not already done inside the declaration), then setup the values S and t for your grid and use them to assign initial values to the stock price vector, and the option value vectors. S j = j S, V j = payoff(s j ).

Exercises 6. Create a code with parameter storage as outlined above, choosing σ =.4, r =.5, X =, ds =, T =, dt =.5 and imax = jmax = 4. 6. Use vectors to store stock prices (called S) and option values (called vold and vnew) and update them with their initial values. 6.3 Write stock value and option value to a file initial-conditions.csv. Check that the results are as you would expect them to be by plotting them in excel. Timestep Calculation Next we must setup two loops to count backwards through time, and at each timestep through all stock price values (except the boundaries). Now as stated earlier we wish to use two time levels of storage for V, which we shall call V new and V old. Here let V i be represented by the vector V new, and V i+ be represented by the vector V old. Then at the end of each timestep we must overwrite the old values with the new ones, please refer to the solution at the end to see this in action. This allows us to move recursively through time with only two levels of storage. Since we can often have timestep constraints, it can be extremely inefficient to store all levels of time. Exercises 6.4 In your code, write two loops over i and j, to move backwards through time and through all stock prices (except the boundaries). See binomial code for an example of how this may be done. For your first attempt, use only five nodes in space and five nodes in time, this will allow you to check calculations by hand. 6.5 Using a variable for time t, initialised with t = T, update time at each timestep and print to screen. Check that time starts at T and finishes at. 6.6 Now inside the time step loop, you must first implement the boundary condition at j =. For example, for a put we may write V i = Xe r(t ti), and remember that V new = V i. Then we may declare variables to store the coefficients multiplying V as A, B and C. Now inside the loop through stock price values, we wish to find what V j is. Then simply calculate the values of A, B and C for the current value of j, then write Vj i i+ i+ = (AVj i + BVj + CV i+ j+i + r t ). Finally implement the boundary condition at j = n. Always remember to set the old values equal to new at the end of the timestep. You may wish to print out the value of the option at each timestep to check what is going on. 6.7 Once all code is checked and working try to run grid checks (change the grid size and check the effect on the solution) to satisfy yourself that the code is correct.

Solution Example explicit method on a European call option: j=4 j=3 j= j= j= i= i= i= i=3.975.975.736.736.494.494.48.48.396.396.99.99.597.597.47.47.979.979.375.375.694.694.94.94.5.5.66.66.4.4 sigma =.4 r=.5 X= ds= T= dt=.5 n=4 i=4 3

Interpolation Here we shall go through a simple example on interpolation. We wish to interpolate to find the value of the function y(x) (which has no formula) at an arbitrary position a given the following data: i x i y(x i ).946.4.546.8.57 3..739343 4.6.4548 5.6869 6.4.4687 7.8.799558 8 3..444 9 3.6.75786 4 The first task is to write a program and input the data here into two vectors x and y. Then we wish to write a function interpolate that will take the two vectors, along with the value a and an integer to specify precision as input, then return the interpolated value y(x = a). The method we shall use to interpolate is a simple method using a Lagrange polynomial. Prototype for the function The function prototype should look like: double interpolate(vector<double>& x,vector<double>& y,double a,int degree) { // interpolate in here... } where x and y are vectors containing the data, a is the position at we wish to evaluate the function, and degree is the number of points that we wish to use. Generating a Lagrange polynomial The Lagrange polynomial is defined as the linear combination: where the polynomial l is defined by: n L(a) = y j l j (a) j= l j (a) = Π n a x i i=,i j x j x i Finding where to interpolate The function is to be split into two parts: finding the value of x i closest to a, interpolating using the closest points to a 4

The idea here is that we can let degree be smaller than the size of the vectors x and y. In order to find which points to use in the interpolation, let us assume that (as is the case above, and when interpolating finite difference grids) x i = i x. The value of x here is just the difference between any two nodes in x. Then given the value a, we know that there exists some i such that To find i with using C++ we can simply say istar = a/dx; a i x, and a < (i + ) x However, if we wish to find the closest node to a then write istar = int(a/dx+.5); Try this out to see what the subtle difference between the two is. Example - Linear Interpolation Given the protoype for the function as given above, we shall choose degree equal to as an example. There are two stages: () Given the value a, find i (use the method to find the node below) istar = a/dx; () Evaluate the Lagrange polynomial at x = a double sum=.; sum = sum + (a - x[istar+])/(x[istar]-x[istar+])*y[istar]; sum = sum + (a - x[istar])/(x[istar+]-x[istar])*y[istar+]; return sum; (3) Test and debug the code!!! You can check that the polynomial above is the equation of a line passing through the points (x i, y i ) and (x i +, y i +). Exercises 6.8 Test and implement the example on interpolation given here. 6.9 After testing the code for the linear case, see if you can write the code in loops (see wiki) to be extendible to higher degrees. 6. Depending on whether degree is odd or even, it will be more appropriate to choose the nearest node or the node below a. Think about which one is needed in each case and why. 6. Write the function for the general case and test it with degree equal to 4. The results above are from the European put example from the previous tutorial on Crank-Nicolson. Set a =.8 and see how accurately the results agree with the Black-Scholes formula. Be careful! Don t choose degree too high. It should never need to be greater than 5. 5