MonteCarloOptions          package:fOptions          R Documentation

_M_o_n_t_e _C_a_r_l_o _V_a_l_u_a_t_i_o_n _o_f _O_p_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     A collection and description of functions to valuate  options by
     Monte Carlo methods. The functions include  beside the main Monte
     Carlo Simulator, example functions  to generate Monte Carlo price
     paths and to compute  Monte Carlo price payoffs. 

     The functions are:

       'sobolInnovations'       Example for scrambled Sobol innovations,
       'wienerPath'             Example for a Wiener price path,
       'plainVanillaPayoff'     Example for the plain vanilla option's payoff,
       'arithmeticAsianPayoff'  Example for the arithmetic Asian option's payoff,
       'MonteCarloOption'       Monte Carlo Simulator for options.

_U_s_a_g_e:

     MonteCarloOption(delta.t, pathLength, mcSteps, mcLoops, init = TRUE, 
         innovations.gen, path.gen, payoff.calc, antithetic = TRUE, 
         standardization = FALSE, trace = TRUE, ...)

_A_r_g_u_m_e_n_t_s:

antithetic: a logical flag, should antithetic variates be used?  By
          default TRUE. 

 delta.t: the time step interval measured as a fraction of one year, by
          default one day, i.e. 'delta.t=1/360'. 

    init: a logical flag, should the random number generator be 
          initialized? By default TRUE. 

innovations.gen: a user defined function to generate the innovations,
          this can  be the normal random number generator
          'rnorm.pseudo' with  mean zero and variance one. For the
          usage of low discrepancy sequences alternativey
          'rnorm.halton' and 'rnorm.sobol' can be called. The generator
          must deliver a normalized matrix of innovations with
          dimension given by the number of Monte Carlo steps and the
          path length. The first three arguments of the generator are
          the the number of Monte Carlo  steps 'mcSteps', the path
          length 'pathLength' and the initialization flag 'init'.
          Optional arguments can be passed through the argument '...',
          e.g. the type of scrambling  for low discrepancy numbers. 

mcLoops, mcSteps: the number of Monte Carlo loops and Monte Carlo
          Steps. In total 'mcLoops*mcSteps' samples are included in one
          MC simulation. 

path.gen: the user defined function to generate the price path. As the
          only input argument serves the matrix of innovations, the
          option parameters must be available as global variables. 

pathLength: the length of the price path. This may be calculated as
          'floor(Time/delta.t)', where 'Time' denotes the  time to
          maturation measured in years. 

payoff.calc: a user defined function to calculate the payoff of the
          option. As the only input argument serves the path matrix as
          returned by the path generator. The option parameters must be
          available  as global variables. 

standardization: a logical flag, should the innovations for one loop be
          standardized? By default TRUE. 

   trace: a logical flag, should the Monte Carlo simulation be traced?
          By default TRUE. 

     ...: additional arguments passed to the innovations generator. 

_D_e_t_a_i_l_s:

     *The Innovations:* 

      The innovations must created by the user defined innovation
     generator. The Generator has to return a numeric matrix of
     (random) innovations  of size 'mcSteps' times the 'pathLength'.
     The example section shows how to write sa function for scrambled
     Quasi Monte Carlo Sobol numbers. The package comes with three
     generators 'rnorm.pseudo', 'rnorm.halton' and 'rnorm.sobol' which
     can easily be used for simulations.  

     *The Price Paths:* 

      The user must provide a function which generates the price paths.
     In the example section the function 'wienerPath' creates a  Wiener
     Monte Carlo path from random innovations. The Wiener price path
     requires as input 'b', the annualized  cost-of-carry rate, and
     'sigma', the annualized volatility of  the underlying security, to
     compute the drift and variance of the  path, these variables must
     be globally defined. 

     *The Payoff Function:* 

      The user must also provide a function which computes the payoff 
     value of the option. The example sections show how to write 
     payoff calculators for the plain vanilla option and for the 
     arithmetic Asian Option. As the only input argument the path
     matrix  is required. Again, the option parameters must be globally
     available. 

     *The Monte Carlo Simulator:* 

         The simulator is the heart of the Monte Carlo valuation
     process.  This simulator performs 'mcLoops' Monte Carlo loops each
     with  'mcSteps' Monte Carlo steps. In each loop the following
     steps are done: first the innovation matrix is created from the
     specified innovation generator (usually build from the normal
     pseudo random  number or low discrepancy generators), then
     anththetic innovations  are added if desired (by default
     'anththetic=TRUE'), then the  innovations can be standardized
     within each loop (by default  'standardization=FALSE'), and
     finally the average payoff of  all samples in the loop is
     computed. The simulation can be traced  loop by loop setting the
     argument 'trace=TRUE'.

_V_a_l_u_e:

     _The user defined innovation generator_ 
      returns a numeric matrix of (random) innovations to build the
     Monte  Carlo Paths. 

     _The user defined path generator_ 
      returns a numeric matrix of the Monte Carlo paths for the
     calculation of the option's payoffs. To be more precise, as an
     example the function returns for a Wiener process the matrix 
     '(b-sigma*sigma/2)*delta.t + sigma*sqrt(delta.t)*innovations', 
     where the first term corresponds to the drift and the second to
     the  volatility. 

     _The user defined payoff calculator_, 
      returns the vector of the option's payoffs calculated from the
     generated paths. As an example this becomes for an arithmetic
     Asian call option with a Wiener Monte Carlo path 'payoff =
     exp(-r*Time)*max(SM-X, 0)'  where code{SM =
     mean(S*exp(cumsum(path)))} and 'path' denotes the MC price paths. 

     *MonteCarloOption:* 
        returns a vector with the option prices for each Monte Carlo
     loop.

_A_u_t_h_o_r(_s):

     Diethelm Wuertz for this R-Port.

_R_e_f_e_r_e_n_c_e_s:

     Birge J.R. (1994);   _Quasi-Monte Carlo Approaches to Option
     Pricing_,  Department of Industrial and Operations Engineering, 
     Technical Report 94-19, University of Michigan.

     Boyle P. (1977); _Options: A Monte Carlo approach_, Journal of
     Finance, 32, 323-338.

     Glasserman P. (2004);  _Monte Carlo Methods in Financial
     Engineering_, Springer-Verlag New York, Inc., 596 pp.

     Jaeckel P. (2002);  _Monte Carlo Methods in Finance_,  John Wiley
     and Sons Ltd, 222 pp.

_E_x_a_m_p_l_e_s:

     ## How to perform a Monte Carlo Simulation?
        
     ## First Step:
        xmpOptions("\nStart: Sobol Generator > ")
        # Write a function to generate the option's innovations. 
        # Use scrambled normal Sobol numbers:
        sobolInnovations = function(mcSteps, pathLength, init, ...) {
          # Create Normal Sobol Innovations:
          innovations = rnorm.sobol(mcSteps, pathLength, init, ...)
          # Return Value:
          innovations }
         
     ## Second Step: 
        xmpOptions("\nNext: Wiener Path > ")
        # Write a function to generate the option's price paths.  
        # Use a Wiener path:
        wienerPath = function(eps) { 
          # Note, the option parameters must be globally defined!
          # Generate the Paths:
          path = (b-sigma*sigma/2)*delta.t + sigma*sqrt(delta.t)*eps
          # Return Value:
          path }
           
     ## Third Step: 
        # Write a function for the option's payoff
        
        # Example 1: use the payoff for a plain Vanilla Call or Put:
        xmpOptions("\nNext: Plain Vanilla Payoff > ")
        plainVanillaPayoff = function(path) { 
          # Note, the option parameters must be globally defined!
          # Compute the Call/Put Payoff Value:
          ST = S*exp(sum(path))
          if (TypeFlag == "c") payoff = exp(-r*Time)*max(ST-X, 0)
          if (TypeFlag == "p") payoff = exp(-r*Time)*max(0, X-ST)
          # Return Value:
          payoff }
        
        # Example 2: use the payoff for an arithmetic Asian Call or Put:
        xmpOptions("\nNext: Arithmetic Asian Payoff > ")
        arithmeticAsianPayoff = function(path) { 
          # Note, the option parameters must be globally defined!
          # Compute the Call/Put Payoff Value:
          SM = mean(S*exp(cumsum(path)))
          if (TypeFlag == "c") payoff = exp(-r*Time)*max(SM-X, 0)
          if (TypeFlag == "p") payoff = exp(-r*Time)*max(0, X-SM)
          # Return Value:
          payoff }

     ## Final Step: 
        xmpOptions("\nNext: Set Option Parameters > ")
        # Set Global Parameters for the plain Vanilla / arithmetic Asian Options:
        TypeFlag <<- "c"; S <<- 100; X <<- 100
        Time <<- 1/12; sigma <<- 0.4; r <<- 0.10; b <<- 0.1
        
        # Do the Asian Simulation with scrambled random numbers:
        xmpOptions("\nNext: Monte Carlo Simulation > ")
        mc = MonteCarloOption(delta.t = 1/360, pathLength = 30, mcSteps = 5000, 
          mcLoops = 50, init = TRUE, innovations.gen = sobolInnovations, 
          path.gen = wienerPath, payoff.calc = arithmeticAsianPayoff, 
          antithetic = TRUE, standardization = FALSE, trace = TRUE, 
          scrambling = 2, seed = 4711)
        
        # Plot the MC Iteration Path:
        xmpOptions("\nNext: Output Results > ")
        par(mfrow = c(1, 1))
        mcPrice = cumsum(mc)/(1:length(mc))
        plot(mcPrice, type = "l", main = "Arithmetic Asian Option", 
          xlab = "Monte Carlo Loops", ylab = "Option Price")
        
        # Compare with Turnbull-Wakeman Approximation:
        TW = TurnbullWakemanAsianApproxOption(TypeFlag = "c", S = 100, SA = 100, 
          X = 100, Time = 1/12, time = 1/12, tau = 0 , r = 0.1, b = 0.1, 
          sigma = 0.4)$price
        print(TW)
        abline(h = TW, col = "red")
        grid()
      

