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

## webcab.lib.finance.options.exotic
Class ScenarioGrid

    java.lang.Object
      |
      +--webcab.lib.finance.options.exotic.ScenarioGrid

All Implemented Interfaces:
  Serializable

public class ScenarioGrid
extends Object
implements Serializable

Within this class we implement methods by which the Scenario Grid of an option can be evaluated. A Scenario Grid's purpose is to show how the options value varies under changes of the underlying market variables.

That is, this class constructs the scenario grid for a generic price function f of n variables. That is, the scenario grid contains the evaluation of the price function calculated at a given point and discrete shifts of two of the n coordinates from this point.

For example, we could consider the scenario grid of an Asian option evaluated in accordance with the Black-Scholes model using Monte-Carlo Simulation where we vary the underlying price and volatility. In this case we would pass the ``price function'' on the Monte-Carlo process in order to populate the scenario grid with re-evaluations of the options value with various shifts of the underlying price and volatility.

See Also:
  Serialized Form

Constructor Summary
`ScenarioGrid()`

Method Summary
`double[][]` `evaluateGrid(Function instanceOfFunction, int noShiftsOfFirst, int noShiftsOfSecond, int middleIndexOfFirst, int middleIndexOfSecond, int firstSelectedIndex, int secondSelectedIndex, double percentageShiftOfFirst, double percentageShiftOfSecond, double[] initialPoint)` This method returns a double array which corresponds to the entries within the scenario grid.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ScenarioGrid

    public ScenarioGrid()

Method Detail

### evaluateGrid

    public double[][] evaluateGrid(Function instanceOfFunction,
                                   int noShiftsOfFirst,
                                   int noShiftsOfSecond,
                                   int middleIndexOfFirst,
                                   int middleIndexOfSecond,
                                   int firstSelectedIndex,
                                   int secondSelectedIndex,
                                   double percentageShiftOfFirst,
                                   double percentageShiftOfSecond,
                                   double[] initialPoint)
                            throws ScenarioGridDemoException

  This method returns a double array which corresponds to the entries within the scenario grid. Recall, that the scenario grid includes re-evaluations of the pricing function with one or two of the values of the underlying variables shifted.

  For example, say we wish to consider the scenario grid of the values of a given Asian option which we evaluate in accordance with the Black-Scholes model. To perform the sensitivity analysis in accordance with the scenario grid we will need to perform the following:

  1. Passing the pricing function: From our choice of pricing approach the pricing function will be determined since the contract which you wish to analyze has already been selected. This pricing function needs to be passed to the Scenario Grid class.
  2. Selecting the parameters to shift: The scenario grid will shift two of the underlying market variables on which the pricing function depends. Therefore, you will need to select which two underlying variables you wish to shift.
  3. Size and number of shifts: Once you have selected which particular parameters you wish to shift you will next need to decide the number of shifts considered and the size of each shift. A popular choice could be shifting each of the variables up and down by 1 and 2 percent. This would result in each parameter taking one of five values and the total number of re-evaluations of the pricing function being twenty-five. Therefore, the computational demands in this case of evaluating the scenario grid is precisely twenty-five times the demands on evaluating the pricing function once.

  Remark: The selection of the particular parameters to shift and the size and number of these shifts should be made with the particular business problem in mind. For example, your application may suggest certain appropriate combinations of parameters and shift size for which the pricing functions scenario grid will display valuable qualitative information. On the other hand you may wish to investigate a particular phenomenon which has been hypothesized, in which case your choices will be reflected by the given problem at hand. Even if you do not have any a-priori idea as to what particular shifts to consider, by repeatedly applying the scenario grid approach you will be able to build up an intuition as to what shifts are most appropriate for which market conditions and for which particular issues you are addressing.

  Description of the Parameters and other practical issues

  The dimensions of the scenario grid is `noShiftsOfFirst` by `noShiftsOfSecond`, where the `noShiftsOfFirst` is the number of shifts of the first selected variable and `noShiftsOfSecond` is the number of shifts of the second selected variable. The variables of the given function which are shifted are selected by the integer parameters `firstSelectedIndex`, `secondSelectedIndex` which correspond to the index of the parameters of the pricing function. Please note that the indexing of these parameters starts from 0.

  Note that the `noShiftsOfFirst` represents the `height' of the scenario grid and `noShiftsOfSecond` represents the `width' of the scenario grid, with respect to the returned 2 dimensional double array (or grid). When constructing the scenario grid it is necessary to assign a `middle cell' which corresponds to the `initialPoint`, for which the function under consideration takes some default parameter values. At the `initialPoint` the function is evaluated before the parameters are shifted from these given default values after which the function is re-evaluated is order to populate to rest of the scenario grid.

  The returned scenario grid has the property that for a given `row' only the second selected variable is varied, where as for a given `column' of the scenario grid only the first selected variable is varied. Since we are using percentages to describe to size of the shifts of a selected variables these shifts are proportional to the absolute values of the two selected parameters at the `initialPoint`. That is, the size of each of the shifts in the first selected variable is `firstSelectedShift := percentageShiftOfFirst * abs(initialPoint[firstSelectedIndex])`, and correspondingly the size of each of the shifts in the second selected variable is `secondSelectedShift := percentageShiftOfSecond * abs(initialPoint[secondSelectedIndex])`, where `abs` is the absolute value. Therefore, if the function under consideration is denoted by `f`, and `x0` denotes the initial `middle' point, denoted by `initialPoint`, then the ``(i,j)`th' cell of the scenario grid is given by:

  f(x0[0], x0[1], ... ,x0[firstSelectedIndex] + (i - middleIndexOfFirst) firstSelectedShift, ... ,x0[secondSelectedIndex] + (j - middleIndexOfSecond) * secondSelectedShift, ..., x0[n]).

  Parameters:
    `noShiftsOfFirst` - The number of shifts (or perturbations) of the first variable selected which are considered within the scenario grid. This parameter also corresponds to the `height' of the scenario grid given by the returned 2 dimensional double array.
    `noShiftsOfSecond` - The number of shifts (or perturbations) of the second variable selected which are considered within the scenario grid. This parameter also corresponds to the `width' of the scenario grid given by the returned 2 dimensional double array.
    `middleIndexOfFirst` - The first coordinate of the grid cell which will contain the evaluation at the `initialPoint`. Note that the indexing begins with 0.
    `middleIndexOfSecond` - The second coordinate of the grid cell which will contain the evaluation at the `initialPoint`. Note that the indexing begins with 0.
    `firstSelectedIndex` - The index (beginning with 0) of the first variable selected of the given function which will be shifted.
    `secondSelectedIndex` - The index (beginning with 0) of the second variable selected of the given function which will be shifted.
    `percentageShiftOfFirst` - the amount as a percentage (i.e. 1 = 1 percent) of the initial given value of the first selected parameter (that is, the value of the first selected parameter at the point `initialPoint`) which is shifted between each `column' of the scenario grid. The size of each of these shifts in absolute terms is given by `percentageShiftOfFirst * abs(initialPoint[firstSelectedIndex]) / 100`.
    `percentageShiftOfSecond` - the amount as a percentage (i.e. 1 = 1 percent) of the initial given value of the second selected parameter (that is, the value of the second selected parameter at the point `initialPoint`) which is shifted between each `row' of the scenario grid. The size of each of these shifts in absolute terms is given by `percentageShiftOfSecond * abs(initialPoint[secondSelectedIndex]) / 100`.
    `initialPoint` - an array which given the coordinate values of the initial given point around which the function is shifted and then re-evaluated.
  Returns:
    a 2 dimensional double array representing the scenario grid of dimensions `noShiftsOfFirst` by `noShiftsOfSecond`.
    `ScenarioGridDemoException`

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