NAME

Finance::Options - Options pricing and related calculations


SYNOPSIS

In general, for the examples, and in the code, I have made use of the same variable names used in Haug (1998) to ease comparison.

  # usage
  use Finance::Options;

  # calculate a fair price using the Black-Scholes model
  $price = BlackScholes($call_put_flag, $S, $X, $T, $r, $v);

  # determine implied volatility using the bisection algorithm
  $volatility = ImpliedVolatilityB('BlackScholes', $price, $call_put_flag, $S, $X, $T, $r);


DESCRIPTION

Finance::Options is a set of routines for performing options pricing and related calculations.

All of the routines here are drawn from Haug, E.G. (1998) The Complete Guide to Option Pricing Formulas. McGraw Hill. This is a very readable and practical guide to implementing a lot of option models, as well as related material.


Vanilla Options


European Options

BlackScholes

Routine to implement the Black and Scholes (1973) option pricing formula.

  $price = BlackScholes($call_put_flag, $S, $X, $T, $r, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, and $v is the volatility in percent per annum.

GBlackScholes

Routine to implement the generalized Black-Scholes option pricing formula.

  $price = GBlackScholes($call_put_flag, $S, $X, $T, $r, $b, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.

GDelta

Calculate Delta for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

GGamma

Gamma for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

GTheta

Theta for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

Vega

Vega for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

GRho

Rho for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

GCarry

Carry for the generalized Black-Scholes formula. Inputs as for GBlackScholes.

French

French (1984) adjusted Black-Scholes model for trading day volatility. $call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $t1 is trading days to maturity/trading days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.

JumpDiffusion

Merton (1976) jump diffusion model. $call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, $lambda is the expected number of jumps per year, $gamma is percentage of total volatility explained by the jumps, and $v is the volatility in percent per annum.

Merton73

Merton (1973) Options on stock indices model. $call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $q is dividend yield, and $v is the volatility in percent per annum.

Black76

Black (1977) Options on futures or forwards.

  $price = Black76($call_put_flag, $F, $X, $T, $r, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $F is the price on the futures contract, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, and $v is the volatility in percent per annum.

MiltersonSchwarz

Miltersen and Schwartz (1997) model for options on commodity futures.

  $price = MiltersonSchwarz($call_put_flag, $Pt, $FT, $X, $t1, $T2,
                            $vS, $vE, $vf,
                            $rhoSe, $rhoSf, $rhoef, $Kappae, $Kappaf);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $Pt is a zero-coupon bond that expires on maturity, $FT is a futures price with time to expiration <$T2>, $X is the strike price, $t1 is time to maturity of the option, $vS, $vE, and $vf are volatilities of spot commodity price, future convenience yield, and forward interest rate respectively, $rhoSe, $rhoSf, and $rhoef are correlations between spot commodity price and forward interest rate, between spot commodity price and convenience yield, and between forward interest rate and convenience yield respectively, and $Kappae and $Kappaf are the speeds of mean reversion of the forward interest rate and covenience yield respectively.


American Options

RollGeskeWhaley

American calls on stocks with known dividends.

  $price = RollGeskeWhaley($S, $X, $t1, $T2, $r, $d, $v);

$S is the underlying price, $X is the strike price, $t1 is the time to dividend payout, $T2 is the time to option expiration, $r is the risk-free interest rate, $d is the cash dividend, and $v is the volatility in percent per annum.

BAWAmericanApprox

Barone-Adesi and Whaley (1987) American approximation.

  $price = BAWAmericanApprox($call_put_flag, $S, $X, $T, $r, $b, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.

BSAmericanApprox

Bjerksund and Stensland (1993) American option approximation. From Haug (1998).

  $price = BSAmericanApprox($call_put_flag, $S, $X, $T, $r, $b, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to expiration/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.


Exotic Options

Executive

Jennergren and Naslund (1993) model for executive stock options.

  $price = Executive($call_put_flag, $S, $X, $T, $r, $b, $lambda, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, $lambda is the jump rate per year (negative exponential model), and $v is the volatility in percent per annum.

ForwardStartOption

Rubinstein (1990) formula for forward start option.

  $price = ForwardStartOption($call_put_flag, $S, $X, $t1, $T, $r, $b, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $t1 is forward start time, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.

TimeSwitchOption

Pechtl (1995) discrete time-switch option.

  $price = TimeSwitchOption($call_put_flag, $S, $X, $a, $T, $m, $dt, $r, $b, $v);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $a is payoff per $dt time interval, $T is calendar days to maturity/calendar days per year, $m is number of time units where option has fulfilled its condition, $r is the risk-free interest rate, $b is the cost-of-carry term, and $v is the volatility in percent per annum.


Chooser Options

SimpleChooser

Rubinstein (1991) formula for a chooser option.

  $price = SimpleChooser($S, $X, $t1, $T2, $m, $dt, $r, $b, $v);

$S is the underlying price, $X is the strike price, $t1 is the time to choice, $T2 is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost of carry term, and $v is the volatility in percent per annum.


Options on Two Different Assets

TwoAssetCorrelation

Zhang (1995) formula for payoff for a call of max(S2-X2) if S1>X1, 0 otherwise (put max(X2-S2) if S1<X1, 0 otherwise).

  $price = TwoAssetCorrelation($call_put_flag, $S1, $S2, $X1, $X2, $T,
                                               $b1, $b2, $r, $v1, $v2, $rho);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S1 and $S2 are the underlying prices, $X1 and $X2 are the strike prices, $T is calendar days to maturity/calendar days per year, $b1 and $b2 are the cost of carry terms, $r is the risk-free interest rate, $v1 and $v2 are the volatilities in percent per annum, and $rho is the correlation between the two stocks.

EuropeanExchangeOption

European option to exchange an asset for another asset. Formula of Margrabe (1978).

  $price = EuropeanExchangeOption($S1, $S2, $Q1, $Q2, $T,
                                  $r, $b1, $b2, $v1, $v2, $rho);

$S1 and $S2 are the underlying prices, $Q1 and $Q2 are quantities of assets $S1 and $S2 respectively, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b1 and $b2 are the cost of carry terms, $v1 and $v2 are the volatilities in percent per annum, and $rho is the correlation between the assets.

AmericanExchangeOption

Bjerksund and Stensland (1993) model for American version. Arguments as in EuropeanExchangeOption.

ExchangeExchangeOption

Carr (1988) model for exchange option on exchange option.

  $price = ExchangeExchangeOption($type_flag, $S1, $S2, $q, $t1, $T2,
                                 $r, $b1, $b2, $v1, $v2, $rho) = @_;

See Haug (1998) for a description of the variables.

OptionsOnTheMaxMin

Options on the maximum or minimum of two risky assets

  $price = OptionsOnTheMaxMin($type_flag, $S1, $S2, $X, $T,
                              $r, $b1, $b2, $v1, $v2, $rho);

See Haug (1998) for a description of the variables.

SpreadApproximation

  $price = SpreadApproximation($call_put_flag, $f1, $f2, $X, $T, $r, $v1, $v2, $rho);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $f1 and $f2 are futures contract prices, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $v1 and $v2 are the volatilities, and $rho is the correlation between the two futures contracts.


Numerical Methods


Binomial Options Pricing

CRRBinomial

Cox-Ross-Rubinstein (1979) binomial tree model.

  $price = CRRBinomial($ame_eur_flag, $call_put_flag, $S, $X, $T, $r, $b, $n, $v);

$ame_eur_flag is either 'a' or 'e' for American or European options respectively, $call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, $b is the cost of carry term, $n is the number of time steps, and $v is the volatility in percent per annum.


Trinomial Trees

TrinomialTree

The trinomial tree (Boyle, 1986).

  $price = TrinomialTree($ame_eur_flag, $call_put_flag, $S, $X, $T, $r, $b, $n, $v);

Inputs as in CRRBinomial.


Volatility and Correlation

ImpliedVolatilityB

Uses the bisection algorithm to numerically determing the volatility of an option given its fair market value.

  $volatility = ImpliedVolatilityB($algorithm, $cm, @args);
  $volatility = ImpliedVolatilityB('BlackScholes', $cm, $call_put_flag, $S, $X, $T, $r);

$algorithm is one of (BlackScholes, GBlackScholes), $cm is the fair market value of the option, and @args is the list of arguments to the option pricing algorithm excepting the final volatility value $v -- order is important!

ImpliedVolatilityNR

Uses the Newton-Raphson algorithm to numerically determing the volatility of an option priced using the generalized Black-Scholes model, given its fair market value.

  $volatility = ImpliedVolatilityNR($call_put_flag, $S, $X, $T, $r, $cm);

$call_put_flag is either 'c' or 'p' for a call or put respectively, $S is the underlying price, $X is the strike price, $T is calendar days to maturity/calendar days per year, $r is the risk-free interest rate, and $cm is the fair market value of the option,


Utility Routines

From E. G. Haug (1998) The Complete Guide to Option Pricing Formulas. McGraw-Hill.

CND

Approximate the cumulative normal distribution. That is, the value of the integral of the standard normal density from minus infinity to $x.

  $p = &CND($x);
ND

The standard normal density evaluated at $x.

  $p = &ND($x);
CBND

Standardized cumulative bivariate normal distribution with covariance $rho evaluated at $a, $b. That is, the double integral evaluated from minus infinity to each argument respectively.

  $p = CBND($a, $b, $rho);
max

Maximum of an array.

  $max = max(@array);
sgn

Sign of a number. Zero returns zero.

  $sign = sgn($num);
factorial

Factorial function -- naive implementation.

  print factorial(4);    # prints 24


AUTHOR

Jerome V. Braun <jerome.braun@kmri.com>


VERSION

Version 0.02

Document generated from $Id: Options.pm,v 1.14 1999/07/17 20:16:22 Jerome Braun Exp $


COPYRIGHT

Copyright (c) 1999 Jerome V. Braun. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself (see http://www.perl.com/perl/misc/Artistic.html).