WebCab Options and Futures Demo
v2.5
(J2SE Edition)

webcab.lib.finance.options.exotic
Class BlackScholes

java.lang.Object
  |
  +--webcab.lib.finance.options.exotic.BlackScholes
All Implemented Interfaces:
Serializable

public class BlackScholes
extends Object
implements Serializable

Within this class we enables the evaluation of standard exotic options (Asian, Lookback, Barrier, Parisian, Parasian) in accordance with the Black-Scholes model using Monte Carlo and Finite Differencing pricing techniques.

Option Contracts Considered

Here we consider a number of standard Exotic and Vanilla Options contracts which are evaluation in accordance with the Black-Scholes model using either Monte Carlo and/or Finite Differencing PDE pricing techniques.

In particular, we offer the following contract pricing models:

Remark: Though the pricing and evaluation of the Greeks for Vanilla and (cash-or-nothing) Binary options exhibit analytic solutions, we have decided to include evaluation methods using Monte Carlo and Finite Differencing pricing techniques so that our implementations can be tested in these cases against known analytic formulae. These analytic formulae have been implemented within the Options class.

Within the below sections we describe details concerning the provided methods and guidelines in there use.

Types of Parameters

For each of the option pricing evaluation methods you will need to give various parameters in order to define and then price the option contract being considered. Each of these parameters will provide one of the following two types of information:

  1. Financial Information - Parameters which provide financial information will contain information about either the contracts definition or the underlying market variables on which the contract depends.
  2. Pricing Technique Information - Parameters which vary the dynamics of the pricing approach used. In the case of Monte Carlo the corresponding parameters will allow you to set the following:
    1. Number of time steps - Now to simulate each Random Walk we divide the time interval into a finite number of sub-intervals. We then generate the Random Walk by using a `random step' on each of these intervals one at a time, from the initial point until the maturity. This parameter specifies the number of intervals (and hence number of steps) which are used in order to generate each one of these approximate Random Walks. Please see the PDF documentation for further details concern exactly how the procedure works.
    2. Number of Random Walks - The total number of Random Walks used in the Monte Carlo Simulation. As the number of Random walks increases the accuracy
    In the case of Finite Differencing Pricing Techniques the corresponding parameters will allow you to set the following:
    1. Algorithm Type - We allow you to select between the Explicit, Fully Implicit or Cranck-Nicholson finite differencing PDE algorithms. In most instances the Cranck-Nicholson should be the preferred algorithm. For further details concerning the nature of these algorithms please see the PDF documentation.
    2. Number of Time Steps - The number of time steps used in the generation of the finite differencing grid.
    3. Number of Path Dependent Variable steps (for path dependent options) - The number of path dependent variable steps used in the generation of the finite differencing grid.
    4. Maximum underlying price (variable) - The maximum value of the underlying price (or variable) represented within the finite differencing grid.
    5. Maximum value of the path dependent variable (for path dependent options) - The maximum value of the path dependent variable which is represented within the finite differencing grid.
    6. Tolerance - This parameter is only used in the case of American options and refers to the internal tolerance of the error which is used during the computation. The smaller the value (in principle) the greater the resulting accuracy (and a longer computation time). A typical value for this parameter is 0.00000001.

The financial parameters and the pricing algorithm parameters have the following significant difference:

The financial situation is given by the contract definition and the market variables whereas the pricing method parameters are user defined.

So, for a given contact and market conditions the financial parameters are either deduced from the definition of the contract under consideration or are read/evaluated from observed market variables. The model parameters such as the number of Random Walks in the case of Monte Carlo simulation or the maximum underlying asset value in the case of finite differencing, however must to set by the user. Therefore, in order to set these model parameters the user will need to use there judgment in order to select suitable choices. These choices will effect the efficiency (i.e. accuracy and time) of a pricing model applied to the evaluation of a given option contract.

Are general advice when using these methods within an application is to vary each one of the parameters in turn until you have the right balance of efficiency for your intended purposes.

See Also:
Serialized Form

Constructor Summary
BlackScholes()
          Creates a new instance.
 
Method Summary
 double asianMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, BlackScholesConstants strikeRate, BlackScholesConstants averagingType, double updatingInterval, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates the value of an Asian option at a given point in time in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double asianPDE(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, boolean isAmerican, BlackScholesConstants strikeRate, BlackScholesConstants averagingType, double updatingInterval, double riskFreeRate, double volatility, BlackScholesConstants algorithmType, int timeSteps, int stockPriceSteps, double maxStockPrice, int averageSteps, double maxAverage, double tolerance)
          Evaluates the value of an Asian option at a given point of time in accordance with the Black-Scholes model using a finite differencing PDE based pricing techniques.
 double barrierMC(BlackScholesConstants type, double currentTime, double maturity, double strike, double initialPrice, BlackScholesConstants inOut, BlackScholesConstants upDown, double barrierLevel, double rebate, double monitoringInterval, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates a (single) barrier option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double binaryMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, double payoff, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates a (cash-or-nothing) binary (or digital) option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double binaryPDE(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, double payoff, boolean isAmerican, double riskFreeRate, double volatility, BlackScholesConstants algorithmType, int timeSteps, int stockPriceSteps, double maxStockPrice, double tolerance)
          Evaluates a (cash-or-nothing) binary (or digital) option in accordance with the Black-Scholes model using finite differencing PDE pricing techniques.
 double lookbackMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, BlackScholesConstants strikeRate, BlackScholesConstants minMax, double updatingInterval, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates a lookback option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double lookbackPDE(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, boolean isAmerican, BlackScholesConstants strikeRate, BlackScholesConstants minMax, double updatingInterval, double riskFreeRate, double volatility, BlackScholesConstants algorithmType, int timeSteps, int stockPriceSteps, double maxStockPrice, int extremumSteps, double maxExtremum, double tolerance)
          Evaluates a lookback option in accordance with the Black-Scholes model using finite differencing PDE pricing techniques.
 double parasianMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, BlackScholesConstants upDown, BlackScholesConstants inOut, double barrierLevel, double rebate, double monitoringInterval, double timeToTrigger, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates a Parasian option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double parisianMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, BlackScholesConstants inOut, BlackScholesConstants upDown, double barrierLevel, double rebate, double monitoringInterval, double timeToTrigger, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates a Parisian option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double vanillaMC(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, double riskFreeRate, double volatility, int numberOfTimeSteps, int numberOfRandomWalks)
          Evaluates the value of a European Vanilla option at a given point in time in accordance with the Black-Scholes model using a Monte Carlo pricing technique.
 double vanillaPDE(BlackScholesConstants type, double currentTime, double maturity, double initialPrice, double strike, boolean isAmerican, double riskFreeRate, double volatility, BlackScholesConstants algorithmType, int timeSteps, int stockPriceSteps, double maxStockPrice, double tolerance)
          Evaluates the value of a European or American Vanilla option at a given point in time in accordance with the Black-Scholes model using Finite Differencing PDE pricing techniques.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlackScholes

public BlackScholes()
Creates a new instance.

Method Detail

vanillaMC

public double vanillaMC(BlackScholesConstants type,
                        double currentTime,
                        double maturity,
                        double initialPrice,
                        double strike,
                        double riskFreeRate,
                        double volatility,
                        int numberOfTimeSteps,
                        int numberOfRandomWalks)
                 throws EvaluationException,
                        BlackScholesDemoException
Evaluates the value of a European Vanilla option at a given point in time in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

Remark: Though the pricing and evaluation of the Greeks for Vanilla options exhibits analytic solutions, we have decided to include evaluation methods using a Monte-Carlo pricing technique so that are implementations can be throughly tested against known analytic formulae. These analytic formulae have been implemented within the Options class.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the option. This is the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime errors occurs.
BlackScholesDemoException

vanillaPDE

public double vanillaPDE(BlackScholesConstants type,
                         double currentTime,
                         double maturity,
                         double initialPrice,
                         double strike,
                         boolean isAmerican,
                         double riskFreeRate,
                         double volatility,
                         BlackScholesConstants algorithmType,
                         int timeSteps,
                         int stockPriceSteps,
                         double maxStockPrice,
                         double tolerance)
                  throws EvaluationException,
                         BlackScholesDemoException
Evaluates the value of a European or American Vanilla option at a given point in time in accordance with the Black-Scholes model using Finite Differencing PDE pricing techniques.

Remark: Since for European options there exists analytic formulae for such instances this method should only be used to test our implementation. These analytic formulae for Vanilla European option pricing have been implemented within the Options class.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the option. This is the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
isAmerican - a boolean value which specifies whether the holder can exercise the option earlier (i.e. is American) or not (i.e. not American). If the option is American then you should input TRUE, if the option is not American then you should input FALSE.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
timeSteps - the total number of time steps used along the time axis of the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the time steps please see the finite differencing section within the PDF documentation.
stockPriceSteps - the total number of asset price steps used along the asset price axis for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the stock price steps we refer the interested reader to the finite differencing section within the PDF documentation.
maxStockPrice - the maximum value of the stock price used within the finite difference grid. This asset price value will corresponding to the last item within the finite differencing grid along the stock price axis.
tolerance - the tolerance for the successive-over-relaxation (SOR) iterative algorithm. This parameter is used only when American options are priced using an implicit algorithm (i.e. FULLY_IMPLICIT or CRANCK_NICHOLSON). A reasonable value for this parameter is 0.00000001 (1e-8).
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

asianMC

public double asianMC(BlackScholesConstants type,
                      double currentTime,
                      double maturity,
                      double initialPrice,
                      double strike,
                      BlackScholesConstants strikeRate,
                      BlackScholesConstants averagingType,
                      double updatingInterval,
                      double riskFreeRate,
                      double volatility,
                      int numberOfTimeSteps,
                      int numberOfRandomWalks)
               throws EvaluationException,
                      BlackScholesDemoException
Evaluates the value of an Asian option at a given point in time in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

Using this method you are able to price all four types of Asian options, namely:

where the average used in each case may be of arithmetic or geometric type.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price is ONLY used for rate (price) Asian option. This is case the strike is the the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
updatingInterval - the period which corresponds to the frequency over which the average is evaluated. For example, if the average is evaluated every day then the parameter should be 1.0/daysInYear, where daysInYear is the number of days in the year.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

asianPDE

public double asianPDE(BlackScholesConstants type,
                       double currentTime,
                       double maturity,
                       double initialPrice,
                       double strike,
                       boolean isAmerican,
                       BlackScholesConstants strikeRate,
                       BlackScholesConstants averagingType,
                       double updatingInterval,
                       double riskFreeRate,
                       double volatility,
                       BlackScholesConstants algorithmType,
                       int timeSteps,
                       int stockPriceSteps,
                       double maxStockPrice,
                       int averageSteps,
                       double maxAverage,
                       double tolerance)
                throws EvaluationException,
                       BlackScholesDemoException
Evaluates the value of an Asian option at a given point of time in accordance with the Black-Scholes model using a finite differencing PDE based pricing techniques.

Using this method you are able to price all four type of Asian options, namely:

where the average used in each case may be of arithmetic or geometric type.

Below we first list the financial parameters following be the pricing algorithm parameters starting with the parameter timeSteps.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the option is ONLY used (and hence necessary) in the case of pricing rate Asian options. This is the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
isAmerican - specifies whether or not the options is of American type or not. If the option is American (i.e. allows the holder to exercise the option early) then the parameter should be set to TRUE, of the option is not American (i.e. does not allow the holder to exercise the option early) then the parameter should be set to FALSE.
updatingInterval - the period which corresponds to the frequency over which the average is evaluated. For example, if the average is evaluated every day then the parameter should be 1.0/daysInYear, where daysInYear is the number of days in the year.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
timeSteps - the total number of time steps used along the time axis of the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the time steps please see the finite differencing section within the PDF documentation.
stockPriceSteps - the total number of asset price steps used along the asset price axis for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the stock price steps we refer the interested reader to the finite differencing section within the PDF documentation.
maxStockPrice - the maximum stock price considered within the finite differencing PDE based model. This value will correspond to the point on the finite differencing mesh which has the highest value of the asset price. This point will naturally lie at one end of the finite differencing grid. For more details please see the finite differencing section of the PDF documentation.
averageSteps - the total number of path-dependent values (i.e. ``the average's'') steps used along the axis representing the (extra) path dependent variable for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the path dependent variable steps please see the finite differencing section within the PDF documentation.
maxAverage - the maximum values of the average parameter used within the finite differencing grid. This value will correspond to the value of the average corresponding to the last item of the finite differencing grid along the path dependent value (i.e. ``the average'') axis.
tolerance - the tolerance for the successive-over-relaxation (SOR) iterative algorithm. This parameter is used only when American options are priced using an implicit algorithm (i.e. FULLY_IMPLICIT or CRANCK_NICHOLSON). A reasonable value for this parameter is 0.00000001 (1e-8).
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

lookbackMC

public double lookbackMC(BlackScholesConstants type,
                         double currentTime,
                         double maturity,
                         double initialPrice,
                         double strike,
                         BlackScholesConstants strikeRate,
                         BlackScholesConstants minMax,
                         double updatingInterval,
                         double riskFreeRate,
                         double volatility,
                         int numberOfTimeSteps,
                         int numberOfRandomWalks)
                  throws EvaluationException,
                         BlackScholesDemoException
Evaluates a lookback option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

The method allows the evaluation of all four types of lookback options, namely:

where the extremum is either a minimum or a maximum.

Parameters:
type - if you are evaluating a call option then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - in the case of rate lookback options the strike (or exercise) price is the price at which the right to buy (in the case of a Call options) or the right to sell (in the case of a Put options) provide by the option can be acted upon. Please note that the strike is ONLY used for rate (price) lookback options, in the case of strike lookback options the final underlying asset price is used as the `strike'.
updatingInterval - the period which corresponds to the frequency over which the extremum is evaluated. For example, if the extremum is evaluated every day then this parameter should be 1.0/daysInYear, where daysInYear is the number of days in the year. Note that here the updating period must be higher than the time step used in the Monte Carlo procedure. The period of these time steps is totalTime/numberOfTimeSteps, where totalTime is the time over which the Monte Carlo process is run, or equivalently the difference between the currentTime and the maturity.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

lookbackPDE

public double lookbackPDE(BlackScholesConstants type,
                          double currentTime,
                          double maturity,
                          double initialPrice,
                          double strike,
                          boolean isAmerican,
                          BlackScholesConstants strikeRate,
                          BlackScholesConstants minMax,
                          double updatingInterval,
                          double riskFreeRate,
                          double volatility,
                          BlackScholesConstants algorithmType,
                          int timeSteps,
                          int stockPriceSteps,
                          double maxStockPrice,
                          int extremumSteps,
                          double maxExtremum,
                          double tolerance)
                   throws EvaluationException,
                          BlackScholesDemoException
Evaluates a lookback option in accordance with the Black-Scholes model using finite differencing PDE pricing techniques.

This method allows the evaluation all all four types of lookback options, namely:

where the extremum is either a minimum or a maximum.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - in the case of rate lookback options the strike (or exercise) price is the price at which the right to buy (in the case of a Call options) or the right to sell (in the case of a Put options) provide by the option can be acted upon. Please note that the strike is ONLY used for rate (price) lookback options, in the case of strike lookback options the final underlying asset price is used as the `strike'.
isAmerican - a boolean value which specifies whether the holder can exercise the option earlier (i.e. is American) or not (i.e. not American). If the option is American then you should input TRUE, if the option is not American then you should input FALSE.
updatingInterval - the period which corresponds to the frequency over which the extremum is evaluated. For example, if the extremum is evaluated every day then this parameter should be 1.0/daysInYear, where daysInYear is the number of days in the year. Note that here the updating period must be higher than the time step used in the Monte Carlo procedure. The period of these time steps is totalTime/numberOfTimeSteps, where totalTime is the time over which the Monte Carlo process is run, or equivalently the difference between the currentTime and the maturity.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
timeSteps - the total number of time steps used along the time axis of the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the time steps please see the finite differencing section within the PDF documentation.
stockPriceSteps - the total number of asset price steps used along the asset price axis for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the stock price steps we refer the interested reader to the finite differencing section within the PDF documentation.
extremumSteps - the total number of extremum (i.e. path-dependent) value steps used along the axis representing the (extra) extremum path dependent variable for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the path dependent variable steps please see the finite differencing section within the PDF documentation.
maxStockPrice - the maximum value of the asset price used within the finite difference grid. This value corresponds corresponding to the last item of the finite differencing grid along to asset price axis.
maxExtremum - the maximum value of the extremum of the asset price used within the finite differencing grid. This value will correspond to the value of the extremum corresponding to the last item of the finite differencing grid on the path dependent value (i.e. the extremum) axis.
tolerance - the tolerance for the successive-over-relaxation (SOR) iterative algorithm. This parameter is used only when American options are priced using an implicit algorithm (i.e. FULLY_IMPLICIT or CRANCK_NICHOLSON). A reasonable value for this parameter is 0.00000001 (1e-8).
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

binaryMC

public double binaryMC(BlackScholesConstants type,
                       double currentTime,
                       double maturity,
                       double initialPrice,
                       double strike,
                       double payoff,
                       double riskFreeRate,
                       double volatility,
                       int numberOfTimeSteps,
                       int numberOfRandomWalks)
                throws EvaluationException,
                       BlackScholesDemoException
Evaluates a (cash-or-nothing) binary (or digital) option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the binary option. This is the level of the market variable which determines whether or not the ``payoff'' will be paid. In particular, for the following types of binary options though the option can always be exercised it will only have a positive (rather than zero)``payoff'' in the following instances:
  • Binary Call Option - Payoff is paid at maturity if the underlying market variable is greater than the strike (or exercise) price.
  • Binary Put Option - Payoff is paid at maturity of the underlying market variable is less than the strike (or exercise) price.
payoff - the (positive) sum which will be paid at maturity if the underlying market variable at maturity is above the given strike in the case of binary call options, or below a given strike in the case of binary put options. Note that in both cases if the respective `binary condition' is not satisfied then t he option can still be exercised but the payoff will be zero.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

binaryPDE

public double binaryPDE(BlackScholesConstants type,
                        double currentTime,
                        double maturity,
                        double initialPrice,
                        double strike,
                        double payoff,
                        boolean isAmerican,
                        double riskFreeRate,
                        double volatility,
                        BlackScholesConstants algorithmType,
                        int timeSteps,
                        int stockPriceSteps,
                        double maxStockPrice,
                        double tolerance)
                 throws EvaluationException,
                        BlackScholesDemoException
Evaluates a (cash-or-nothing) binary (or digital) option in accordance with the Black-Scholes model using finite differencing PDE pricing techniques.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the binary option. This is the level of the market variable which determines whether or not the ``payoff'' will be paid. In particular, for the following types of binary options though the option can always be exercised it will only have a positive (rather than zero)``payoff'' in the following instances:
  • Binary Call Option - Payoff is paid at maturity if the underlying market variable is greater than the strike (or exercise) price.
  • Binary Put Option - Payoff is paid at maturity of the underlying market variable is less than the strike (or exercise) price.
payoff - the (positive) sum which will be paid at maturity if the underlying market variable at maturity is above the given strike in the case of binary call options, or below a given strike in the case of binary put options. Note that in both cases if the respective `binary condition' is not satisfied then the option can still be exercised but the payoff will be zero.
isAmerican - a boolean value which specifies whether the holder can exercise the option earlier (i.e. is American) or not (i.e. not American). If the option is American then you should input TRUE, if the option is not American then you should input FALSE.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
timeSteps - the total number of time steps used along the time axis of the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the time steps please see the finite differencing section within the PDF documentation.
stockPriceSteps - the total number of asset price steps used along the asset price axis for the finite differencing grid considered. Note that the higher the value given the finer the finite differencing mesh will become resulting in higher accuracy but also an increase in the computation time. For further details concerning the stock price steps we refer the interested reader to the finite differencing section within the PDF documentation.
maxStockPrice - the maximum value of the asset price used within the finite differencing grid. This value corresponds to the asset price corresponding to the last item of the finite differencing grid along the asset price axis.
tolerance - the tolerance for the successive-over-relaxation (SOR) iterative algorithm. This parameter is used only when American options are priced using an implicit algorithm (i.e. FULLY_IMPLICIT or CRANCK_NICHOLSON). A reasonable value for this parameter is 0.00000001 (1e-8).
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

barrierMC

public double barrierMC(BlackScholesConstants type,
                        double currentTime,
                        double maturity,
                        double strike,
                        double initialPrice,
                        BlackScholesConstants inOut,
                        BlackScholesConstants upDown,
                        double barrierLevel,
                        double rebate,
                        double monitoringInterval,
                        double riskFreeRate,
                        double volatility,
                        int numberOfTimeSteps,
                        int numberOfRandomWalks)
                 throws EvaluationException,
                        BlackScholesDemoException
Evaluates a (single) barrier option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price used within the evaluation of the payoff function of the barrier option.
barrierLevel - the price level of the underlying asset at which the barrier option is triggered.
rebate - the compensation paid at maturity to the holder of the barrier option if the option is not trigger and hence the (normal) payoff is not paid.
monitoringInterval - the periods in years between consecutive readings of the market variable which triggers the barrier option. Note that since no market variable can be continuously monitored it is usual that the contract will explicitly state at what intervals the market variable on which the contracts depends is read. The monitoring interval will imply a sequence of moments in time at which the market variables values are recorded and used to determine whether the trigger has been met.

Note that the length of the monitoring periods should be smaller than the time step periods used within the Monte Carlo procedure. If this is not the case then the time steps intervals will be taken to be equal to the monitoring period.

riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

parisianMC

public double parisianMC(BlackScholesConstants type,
                         double currentTime,
                         double maturity,
                         double initialPrice,
                         double strike,
                         BlackScholesConstants inOut,
                         BlackScholesConstants upDown,
                         double barrierLevel,
                         double rebate,
                         double monitoringInterval,
                         double timeToTrigger,
                         double riskFreeRate,
                         double volatility,
                         int numberOfTimeSteps,
                         int numberOfRandomWalks)
                  throws EvaluationException,
                         BlackScholesDemoException
Evaluates a Parisian option in accordance with the Black-Scholes model using a Monte Carlo pricing technique. Recall that Parisian options are just a (single) barrier options where the underlying needs to be above or below a given level for a given period of time in order to trigger the barrier.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the option. This is the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
barrierLevel - the price level of the underlying asset at which the Parisian option is triggered.
rebate - the compensation paid at maturity to the holder of the Parisian option if the option is not trigger and hence the (normal) payoff is not paid.
monitoringInterval - the periods in years between consecutive readings of the market variable which triggers the Parisian option. Note that since no market variable can be continuously monitored it is usual that the contract will explicitly state at what intervals the market variable on which the contracts depends is read. The monitoring interval will imply a sequence of moments in time at which the market variables values are recorded and used to determine whether the trigger has been met.

Note that the length of the monitoring periods should be smaller than the time step periods used within the Monte Carlo procedure. If this is not the case then the time steps intervals will be taken to be equal to the monitoring period.

timeToTrigger - this is the minimum continuous amount of time in years for which the barrier condition must to satisfied in order for the contract to be triggered.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime error occurs.
BlackScholesDemoException

parasianMC

public double parasianMC(BlackScholesConstants type,
                         double currentTime,
                         double maturity,
                         double initialPrice,
                         double strike,
                         BlackScholesConstants upDown,
                         BlackScholesConstants inOut,
                         double barrierLevel,
                         double rebate,
                         double monitoringInterval,
                         double timeToTrigger,
                         double riskFreeRate,
                         double volatility,
                         int numberOfTimeSteps,
                         int numberOfRandomWalks)
                  throws EvaluationException,
                         BlackScholesDemoException
Evaluates a Parasian option in accordance with the Black-Scholes model using a Monte Carlo pricing technique.

The Parasian option is a hybrid of a Parisian option which is itself a type of Barrier option. In short, the Parasian option is a cumulative Parisian option in the following sense. For the Parasian option to be triggered the sum of the periods for which the trigger is satisfied must to greater than a given interval given below as the timeToTrigger. Whereas the Parisian option requires that the option satisfies the trigger condition for some given continuous period of time.

Parameters:
type - if you are evaluating a call options then you should input CALL, if you are evaluating a put option then you should input PUT.
currentTime - the absolute time in years when the contract is evaluated. That is, if we wish to evaluate the contract on the 1st Jan 2010, then the currentTime should be set to 2010. If however we wish to evaluate the contract on the 1st July 2010, then the currentTime should be set to 2010.5.
maturity - the absolute time in years when the option contract expires. For example, if the contract expires on 1st Jan 2010, then the maturity should be set to 2010. If however the contract expires on the 1st July 2010, then the maturity should be set to 2010.5.
initialPrice - the price of the underlying asset at the currentTime. Please note that we evaluate the option for the currentTime, which may not be not present time until the maturity of the option contract.
strike - the strike (or exercise) price of the option. This is the price at which the right to buy (in the case of a Call option) or the right to sell (in the case of a Put option) provide by the option can be acted upon.
barrierLevel - the price level of the underlying asset at which the Parasian option is triggered.
rebate - the compensation paid at maturity to the holder of the Parasian option if the option is not triggered and hence the (normal) payoff is not paid.
monitoringInterval - the periods in years between consecutive readings of the market variable which triggers the Parisian option. Note that since no market variable can be continuously monitored it is usual that the contract will explicitly state at what intervals the market variable on which the contracts depends is read. The monitoring interval will imply a sequence of moments in time at which the market variables values are recorded and used to determine whether the trigger has been met.

Note that the length of the monitoring periods should be smaller than the time step periods used within the Monte Carlo procedure. If this is not the case then the time steps intervals will be taken to be equal to the monitoring period.

timeToTrigger - this is the minimum total amount of time which must be spent with the barrier condition satisfied in order for the contract to the triggered. Note that for the Parisian option this period of time must be one complete intervals, whereas here it only matter that the sum of the periods for which the triggered was satisfied is more than a given level.
riskFreeRate - the risk free interest rate at the point currentTime expressed in decimal format (i.e. 1 percent = 0.01).
volatility - an estimate of the volatility of the underlying asset (or market variable) which the option depends on at the time currentTime, expressed in decimal format (i.e. 1 percent = 0.01). See the Volatility class within the Options class for procedures which assist in the estimation of the volatility.
numberOfTimeSteps - the total number of time divisions used in the construction of a Monte Carlo simulation. Please note that as this parameter is increased the synthetic Random walks will converge to `real' continuous Random walks. Therefore, as the number of time steps increases the expectation of a higher level of accuracy will also increase. Also note that the computational time required will also increase in proportion to the number of time steps used.
numberOfRandomWalks - the total number of Random walks used within the Monte Carlo simulation. As the number of Random walks increases so the corresponding accuracy (in the sense given below) increase along with a proportional increase in the computation time. Note that since Monte Carlo is a probabilistic procedure the `accuracy' can only be interpreted in a probabilistic sense. That is, as the number of Random walks increases the corresponding accuracy will increase in the sense that for a given confidence level, the corresponding confidence intervals width will decrease like: two times, one over the root of N, where N is the number of Random walks. Please see the PDF documentation for a precise formulation of the confidence interval of the Monte Carlo procedure and further discussion.
Throws:
EvaluationException - thrown when any runtime errors occurs.
BlackScholesDemoException

WebCab Options and Futures Demo
v2.5
(J2SE Edition)