16:642:612-02 Selected Topics in Applied Mathematics – Computational Finance (Spring 2007)

 


           
Home page of the course at Rutgers University web site
           University Academic Calendar
           Quantitative Finance Software on the Web
           Prof.
Paul M. N. Feehan course 16:642:621

Notation:
   QMDF -
Domingo Tavella, Quantitative Methods in Derivatives Pricing: An Introduction to Computational Finance, Wiley 2002, ISBN 0471394475.
   IDM  - L. Clewlow and C. Strickland, Implementing Derivative Models, Wiley, 1998
   MDC -
J. London, Modeling Derivatives in C++, Wiley, 2004 


  1. In Matlab using financial toolbox get knowledge about functions blsprice, blsdelta, blsgamma, blstheta, blsvega, blsrho.

  1. This is an example of C++ code that computes a price of European call option using the Black Scholes formula (Financial Numerical Recipes in C++. Bernt Arne  Odegaard)

#include <cmath>                                                         // mathematical C library
#include "normdist.h"                                                    // the calculation of the cumularive normal distribution
double option price call black scholes(
      const double& S,                                                    // spot (underlying) price
      const double& K,                                                   // strike (exercise) price,
      const double& r,                                                     // interest rate
      const double& sigma,                                              // volatility
      const double& time)                                                // time to maturity
 {
     double time sqrt = sqrt(time);
     double d1 = (log(S/K)+r*time)/(sigma*time sqrt)+0.5*sigma*time sqrt;
     double d2 = d1 - (sigma*time sqrt);
     double c = S*N(d1) - K*exp(-r*time)*N(d2);
     return c;
}

Code 1: Price of European call option using the Black Scholes formula

Answer the following questions:

If you experiance problems with writing C++ code at this time, write these functions in Matlab!


  1. This is an example of C++ code that computes a price of European call option using one period binomial tree (Financial Numerical Recipes in C++. Bernt Arne  Odegaard)

#include <cmath>                        // standard mathematical library
#include <algorithm>                    // defining the max() operator

using namespace std;

double option price call european binomial (
        const double& S,                                // spot price
        const double& X,                                // exercice price
        const double& r,                                // interest rate (per period)
        const double& u,                                // up movement
        const double& d)                                // down movement
{
        double p_up = (exp(r) - d)/(u - d);
        double p_down = 1.0 - p_up;
        double c_u = max(0.0,(u*S - X));
        double c_d = max(0.0,(d*S - X));
        double call_price = exp(-r)*(p_up*c_u + p_down*c_d);
        return call_price;
};

 

Code 2. Binomial European, one period

#include <vector>
#include <cmath>

using namespace std;

vector< vector<double> > binomial tree(
        const double& S0,
        const double& u,
        const double& d,
        const int& no steps)
{
        vector< vector<double> > tree;
        for (int i=1;i<=no steps;++i) {
                vector<double> S(i);
                for (int j=0;j<i;++j) {
                        S[j] = S0*pow(u,j)*pow(d,i..j..1);
                }
                tree.push back(S);
        }
        return tree;
}

Code 3: Building a binomial tree.

In terms of computational eficiency the approcach of code 2 will not be optimal, since it requires a lot of calls to the pow() functional call. More e cient would be to carry out the tree building by doing the multiplication from the previous node, for example the j th vector is the j-1 th vector times u, and then one need to add one more node by multiplying the lowest element by d. Therefore, implement such an alternative tree building procedure.

Implement a function that computes European option call and put prices using binomial tree.

Run the test from the previous exercise to compute European option call and put prices as well as greeks. Compare results with the closed form solution. Explain the difference.

Do same in Matlab using financial toolbox, get knowledge about function binprice.