Generic Pricing Category Group




Welcome | Documentation format | QuantTools Groups | QuantTools Categories | Licence

Key TAGs | Excel Index | API Index


http://www.QuantTools.com


  1. CapeTools Generic PDE Pricer


    General Description


    Functions to price generic Equity/FX/Commodity structures under a PDE framework. If your product's payoff does not refer to asset prices in the past (ie - Asian options) you can use this framework. This framework can also handle bermudan callable structures

    Here are some general rules to keep in mind regarding how the payoff grid will be processed :

    1. Rows are time points. As you read down the grid you are moving forward in time.
    2. Columns represent your payoff formulas. You can create as many columns as you like. Columns are there to help you split up your payoff, or for a payoff function within a cell to refer to other cells within the grid.
    3. For the PDE pricer, the pricing starts at the final timestep and prices from left to right.
    4. Formula expressions within a cell cannot refer to formula cells to the right of itself.
    5. Formula expressions within a cell cannot refer to formula cells above itself (past time points).


    If you bear the 5 points in mind, this should aid you in constructing payoff grids.

    Below is an example of a payoff table. This deal prices a callable structure (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff ColPayOff ColPayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    2#19/01/2006#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    3#19/07/2006#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    4#19/01/2007#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    5#19/07/2007#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    6#19/01/2008#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    7#19/07/2008#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    8#19/01/2009#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    9#19/07/2009#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    10#19/01/2010#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    11#19/07/2010#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    12#19/01/2011#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))



    The 'Repeat' column indicates that the instruction at the current step will be repeated for all the timesteps between this and the next.

    Even though there are only 12 timesteps above, you can instruct the function to insert additional steps between each step.



    Financial variables (case sensitive) :


    • cRow - refers to the current Row with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cRow, cRow-1, cRow+2 etc...) instead of a fixed value (ie - 1, 2 etc...). This is important especially if you enable American type handling from one timestep to another. Using static integer values will generate incorrect results.
    • cCol - refers to the current Column with the payoff table. Within all the financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cCol, cCol-1, cCol+2 etc...).
    • pct - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as a percent. (ie - 5pct => 0.05)
    • bp - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as basis points. (ie - 5bp => 0.0005)
    • _XXX - Constant variables can be defined by filling in the 'ConstParams' parameter of the GenericPDEPricer() function. All variables must be defined with a leading underscore character ( ie - _XXX = 0.5)


    Financial functions (case sensitive) :

    • Asset(row) - Returns the asset value at the integer row indicated. Starts at 1. You may refer to future values of the asset's price because the PDE methodology prices backwards in time (from the last expiry date). The expression 'Asset(cRow)' retrieves the asset price for the current timestep. The expression 'Asset(cRow+1)' retrieves the asset price for the next timestep (in the future).
    • Cell(row, col) - Retrieves a computed value within the PayOff Table. You can only refer to rows and columns below and to the left of the current cell location. You can also refer to the current cell location. This is because the PDE pricer prices backwards in time and thus past payoff values have not been computed as yet. The expression 'Cell(cRow, cCol-1)' retrieves the payoff value for the current timestep but at the previous column.
    • GridRowMin(Row, startCol, endCol) - Retrieves the minimum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowMax(Row, startCol, endCol) - Retrieves the maximum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowAvg(Row, startCol, endCol) - Retrieves the average value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowSum(Row, startCol, endCol) - Retrieves the sum across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • Interp1D(nIndex, XValue ) - If any 1D interpolation objects have been passed into GenericPDEPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' is the value where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • Interp2D(nIndex, XValue, YValue) - If any 2D interpolation objects have been passed into GenericPDEPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' and 'YValue' are the values where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • iff(condition, a, b) - Tests for the condition and returns the value of 'a' if true or 'b' if false.
    • PVCol(Column) - Requests the PV value of the indicated column up to the current step (cRow). This function must be used when pricing Bermudan / American type products.


    Predefined functions (case sensitive) :


    • sin(x) ( sine function )
    • cos(x) ( cosine function )
    • tan(x) ( tangens function )
    • asin(x) ( arcus sine function )
    • acos(x) ( arcus cosine function )
    • atan(x) ( arcus tangens function )
    • sinh(x) ( hyperbolic sine function )
    • cosh(x) ( hyperbolic cosine function )
    • tanh(x) ( hyperbolic tangens function )
    • asinh(x) ( hyperbolic arcus sine function )
    • acosh(x) ( hyperbolic arcus cosine function )
    • atanh(x) ( hyperbolic arcur tangens function )
    • log2(x) ( logarithm to the base 2 )
    • log10(x) ( logarithm to the base 10 )
    • log(x) ( logarithm to the base 10 )
    • ln(x) ( logarithm to the base e (2.71828...)
    • exp(x) ( e raised to the power of x )
    • sqrt(x) ( square root of a value )
    • sign(x) ( sign function ) -1=(if x<0), 1=(if x>0 )
    • rint(x) ( round to nearest integer )
    • abs(x) ( absolute value )
    • min(a,b,c,d,e,...) ( min of all arguments ie - min(-2,1,5,-6) )
    • max(a,b,c,d,e,...) ( max of all arguments ie - max(-2,1,5,-6) )
    • sum(a,b,c,d,e,...) ( sum of all arguments ie - sum(-2,1,5,-6) )
    • avg(a,b,c,d,e,...) ( mean value of all arguments ie - avg(-2,1,5,-6) )
    • ite(x,y,z) ( if ... then ... else ... : ie - ite(a<b, 5.0, -3.0) )


    Predefined operators :

    • + ( addition )
    • - ( subtraction )
    • * ( multiplication )
    • / ( division )
    • ^ ( raise x to the power of y )


    Predefined operators that can be used within the first parameter of the ite() or iff() function :

    • and ( logical and )
    • or ( logical or )
    • <= ( less or equal )
    • >= ( greater or equal )
    • != ( not equal )
    • == ( equal to )
    • > ( greater than )
    • < ( less than )

    • Brackets, '(' and ')', can also be used to simplify expressions.
    Some possible examples of what is possible now follow (Today = 19/07/2005):

    Vanilla Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(Asset(cRow) - 10, 0)



    Sum of two Vanilla Options (Call and Put). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSE100max(Asset(cRow) - Cell(cRow, cCol-1), 0) + PVCol(cCol)
    2#19/07/2007#FALSE90max(Cell(cRow, cCol-1) - Asset(cRow), 0)



    American Option (Repeat column and PVCol() function are used differently). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    1#19/07/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Delayed start American Option (starts at 19/10/2005, today is 19/07/2005). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/10/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    1#19/10/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Bermudan Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    2#19/01/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    4#19/01/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    5#19/07/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    6#19/01/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    7#19/07/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    8#19/01/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    9#19/07/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Starts as American then becomes Bermudan Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    2#19/01/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    4#19/01/2007#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    5#19/07/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    6#19/01/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    7#19/07/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    8#19/01/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    9#19/07/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Chooser Option. (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff Col
    1#19/07/2005#FALSEmax(PVCol(cCol-1), PVCol(cCol))
    2#19/07/2006#FALSEmax(Asset(cRow) - 10, 0)max(10 - Asset(cRow), 0)



    Compound Option (european on european). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(8.0 - PVCol(cCol), 0)
    2#19/01/2007#FALSEmax(Asset(cRow) - 10, 0)



    Compound Option (european on american, delayed by 2 days). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(8.0 - PVCol(cCol), 0)
    221/07/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2008#FALSEmax(Asset(cRow) - 10, 0)





  2. CapeTools Generic Tree Pricer


    General Description


    Functions to price generic Equity/FX/Commodity structures under a Binomial Tree framework. If your product's payoff does not refer to asset prices in the past (ie - Asian options) you can use this framework. This framework can also handle bermudan callable structures

    Here are some general rules to keep in mind regarding how the payoff grid will be processed :

    1. Rows are time points. As you read down the grid you are moving forward in time.
    2. Columns represent your payoff formulas. You can create as many columns as you like. Columns are there to help you split up your payoff, or for a payoff function within a cell to refer to other cells within the grid.
    3. For the Binomial Tree pricer, the pricing starts at the final timestep and prices from left to right.
    4. Formula expressions within a cell cannot refer to formula cells to the right of itself.
    5. Formula expressions within a cell cannot refer to formula cells above itself (past time points).


    If you bear the 5 points in mind, this should aid you in constructing payoff grids.

    Below is an example of a payoff table. This deal prices an callable structure (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff ColPayOff ColPayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    2#19/01/2006#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    3#19/07/2006#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    4#19/01/2007#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    5#19/07/2007#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    6#19/01/2008#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    7#19/07/2008#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    8#19/01/2009#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    9#19/07/2009#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    10#19/01/2010#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    11#19/07/2010#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))
    12#19/01/2011#FALSEAsset(cRow) + 10pctInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(Cell(cRow, cCol-1) - _var1, 0.0)max(Cell(cRow, cCol-1), PVCol(cCol))



    The 'Repeat' column indicates that the instruction at the current step will be repeated for all the timesteps between this and the next.

    Even though there are only 12 timesteps above, you can instruct the function to insert additional steps between each step.





    Financial variables (case sensitive) :

    • cRow - refers to the current Row with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cRow, cRow-1, cRow+2 etc...) instead of a fixed value (ie - 1, 2 etc...). This is important especially if you enable American type handling from one timestep to another. Using static integer values will generate incorrect results.
    • cCol - refers to the current Column with the payoff table. Within all the financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cCol, cCol-1, cCol+2 etc...).
    • pct - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as a percent. (ie - 5pct => 0.05)
    • bp - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as basis points. (ie - 5bp => 0.0005)
    • _XXX - Constant variables can be defined by filling in the 'ConstParams' parameter of the GenericTreePricer() function. All variables must be defined with a leading underscore character ( ie - _XXX = 0.5)


    Financial functions (case sensitive) :

    • Asset(row) - Returns the asset value at the integer row indicated. Starts at 1. You may refer to future values of the asset's price because the Tree methodology prices backwards in time (from the last expiry date). The expression 'Asset(cRow)' retrieves the asset price for the current timestep. The expression 'Asset(cRow+1)' retrieves the asset price for the next timestep (in the future).
    • Cell(row, col) - Retrieves a computed value within the PayOff Table. You can only refer to rows and columns below and to the left of the current cell location. You can also refer to the current cell location. This is because the Tree pricer prices backwards in time and thus past payoff values have not been computed as yet. The expression 'Cell(cRow, cCol-1)' retrieves the payoff value for the current timestep but at the previous column.
    • GridRowMin(Row, startCol, endCol) - Retrieves the minimum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowMax(Row, startCol, endCol) - Retrieves the maximum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowAvg(Row, startCol, endCol) - Retrieves the average value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowSum(Row, startCol, endCol) - Retrieves the sum across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • Interp1D(nIndex, XValue ) - If any 1D interpolation objects have been passed into GenericTreePricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' is the value where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • Interp2D(nIndex, XValue, YValue) - If any 2D interpolation objects have been passed into GenericTreePricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' and 'YValue' are the values where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • iff(condition, a, b) - Tests for the condition and returns the value of 'a' if true or 'b' if false.
    • PVCol(Column) - Requests the PV value of the indicated column up to the current step (cRow). This function must be used when pricing Bermudan / American type products.



    Predefined functions (case sensitive) :

    • sin(x) ( sine function )
    • cos(x) ( cosine function )
    • tan(x) ( tangens function )
    • asin(x) ( arcus sine function )
    • acos(x) ( arcus cosine function )
    • atan(x) ( arcus tangens function )
    • sinh(x) ( hyperbolic sine function )
    • cosh(x) ( hyperbolic cosine function )
    • tanh(x) ( hyperbolic tangens function )
    • asinh(x) ( hyperbolic arcus sine function )
    • acosh(x) ( hyperbolic arcus cosine function )
    • atanh(x) ( hyperbolic arcur tangens function )
    • log2(x) ( logarithm to the base 2 )
    • log10(x) ( logarithm to the base 10 )
    • log(x) ( logarithm to the base 10 )
    • ln(x) ( logarithm to the base e (2.71828...)
    • exp(x) ( e raised to the power of x )
    • sqrt(x) ( square root of a value )
    • sign(x) ( sign function ) -1=(if x<0), 1=(if x>0 )
    • rint(x) ( round to nearest integer )
    • abs(x) ( absolute value )
    • min(a,b,c,d,e,...) ( min of all arguments ie - min(-2,1,5,-6) )
    • max(a,b,c,d,e,...) ( max of all arguments ie - max(-2,1,5,-6) )
    • sum(a,b,c,d,e,...) ( sum of all arguments ie - sum(-2,1,5,-6) )
    • avg(a,b,c,d,e,...) ( mean value of all arguments ie - avg(-2,1,5,-6) )
    • ite(x,y,z) ( if ... then ... else ... : ie - ite(a<b, 5.0, -3.0) )


    Predefined operators :

    • + ( addition )
    • - ( subtraction )
    • * ( multiplication )
    • / ( division )
    • ^ ( raise x to the power of y )


    Predefined operators that can be used within the first parameter of the ite() or iff() function :

    • and ( logical and )
    • or ( logical or )
    • <= ( less or equal )
    • >= ( greater or equal )
    • != ( not equal )
    • == ( equal to )
    • > ( greater than )
    • < ( less than )

    • Brackets, '(' and ')', can also be used to simplify expressions.
    Some possible examples of what is possible now follow (Today = 19/07/2005):

    Vanilla Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(Asset(cRow) - 10, 0)



    Sum of two Vanilla Options (Call and Put). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSE100max(Asset(cRow) - Cell(cRow, cCol-1), 0) + PVCol(cCol)
    2#19/07/2007#FALSE90max(Cell(cRow, cCol-1) - Asset(cRow), 0)



    American Option (Repeat column and PVCol() function are used differently). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    1#19/07/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Delayed start American Option (starts at 19/10/2005, today is 19/07/2005). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/10/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    1#19/10/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Bermudan Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    2#19/01/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2006#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    4#19/01/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    5#19/07/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    6#19/01/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    7#19/07/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    8#19/01/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    9#19/07/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Starts as American then becomes Bermudan Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    2#19/01/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    4#19/01/2007#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    5#19/07/2007#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    6#19/01/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    7#19/07/2008#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    8#19/01/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))
    9#19/07/2009#FALSEmax(Asset(cRow) - 10, PVCol(cCol))



    Chooser Option. (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff Col
    1#19/07/2005#FALSEmax(PVCol(cCol-1), PVCol(cCol))
    2#19/07/2006#FALSEmax(Asset(cRow) - 10, 0)max(10 - Asset(cRow), 0)



    Compound Option (european on european). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(8.0 - PVCol(cCol), 0)
    2#19/01/2007#FALSEmax(Asset(cRow) - 10, 0)



    Compound Option (european on american, delayed by 2 days). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(8.0 - PVCol(cCol), 0)
    221/07/2006#TRUEmax(Asset(cRow) - 10, PVCol(cCol))
    3#19/07/2008#FALSEmax(Asset(cRow) - 10, 0)





  3. CapeTools Generic MonteCarlo Pricer


    General Description


    Functions to price generic Equity/FX/Commodity structures under a MonteCarlo framework. If your product's payoff does not refer to asset prices in the future (ie - Bermudan / American options) you can use this framework.

    Here are some general rules to keep in mind regarding how the payoff grid will be processed :

    1. Rows are time points. As you read down the grid you are moving forward in time.
    2. Columns represent your payoff formulas. You can create as many columns as you like. Columns are there to help you split up your payoff, or for a payoff function within a cell to refer to other cells within the grid.
    3. For the MonteCarlo pricer, the pricing starts at the first timestep and prices from left to right.
    4. Formula expressions within a cell cannot refer to formula cells to the right of itself.
    5. Formula expressions within a cell cannot refer to formula cells below itself (future time points).


    If you bear the 5 points in mind, this should aid you in constructing payoff grids.

    Below is an example of a payoff table. The Step column is not required.


    StepEventDateRepeat?PayOff ColPayOff ColPayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    2#19/01/2006#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    3#19/07/2006#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    4#19/01/2007#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    5#19/07/2007#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    6#19/01/2008#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    7#19/07/2008#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    8#19/01/2009#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    9#19/07/2009#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    10#19/01/2010#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    11#19/07/2010#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)
    12#19/01/2011#FALSEAsset(1, cRow) + _a + 5pctAsset(2, cRow) + Interp1D(1,cRow) - 100bpGridRowAvg(cRow, cCol-2, cCol-1)max(GridColMin(cCol-1, 1, cRow) - AssetMin(1, 1, cRow), 0.0) * DCF(1, cRow)



    The 'Repeat' column indicates that the instruction at the current step will be repeated for all the timesteps between this and the next.

    Even though there are only 12 timesteps above, you can instruct the function to insert additional steps between each step.





    Financial variables (case sensitive) :

    • cRow - refers to the current Row with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cRow, cRow-1, cRow+2 etc...) instead of a fixed value (ie - 1, 2 etc...). This is important especially if you enable American type handling from one timestep to another. Using static integer values will generate incorrect results.
    • cCol - refers to the current Column with the payoff table. Within all the financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cCol, cCol-1, cCol+2 etc...).
    • pct - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as a percent. (ie - 5pct => 0.05)
    • bp - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as basis points. (ie - 5bp => 0.0005)
    • _XXX - Constant variables can be defined by filling in the 'ConstParams' parameter of the GenericMCPricer() function. All variables must be defined with a leading underscore character ( ie - _XXX = 0.5)


    Financial functions (case sensitive) :

    • Asset(AssetNo, TimeStep)) - Retrieves the value of an asset value of an asset at the requested 'TimeStep'. If a CorrArrayProcesses process object was passed into the MonteCarlo pricer, the 'AssetNo is the index into this asset array. If a single Process object was passed in, the 'AssetNo' should equal one (1).
    • Cell(row, col) - Retrieves a computed value within the PayOff Table. You can only refer to rows and columns below and to the left of the current cell location. You can also refer to the current cell location. This is because the MonteCarlo pricer prices forwards in time and thus future payoff values have not been computed as yet. The expression 'Cell(cRow, cCol-1)' retrieves the payoff value for the current timestep but at the previous column.
    • DCF(AssetNo, TimeStep)) - Retrieves the discount value of an asset at the requested 'TimeStep'. . If a CorrArrayProcesses process object was passed into the MonteCarlo pricer, the 'AssetNo is the index into this asset array. If a single Process object was passed in, the 'AssetNo' should equal one (1). Unlike some of the other pricers, the MonteCarlo pricer does not discount values. This function is needed in order to compute the discount factor needed for discounting. The discount factor curve will be retrieved from the Process object indicated by the 'AssetNo' parameter.
    • DCF2(AssetNo, FromTimeStep, ToTimeStep)) - Retrieves the discount value between two timeSteps (ie - discount factor between step 'FromTimeStep' and 'ToTimeStep'). If a CorrArrayProcesses process object was passed into the MonteCarlo pricer, the 'AssetNo is the index into this asset array. If a single Process object was passed in, the 'AssetNo' should equal one (1). Unlike some of the other pricers, the MonteCarlo pricer does not discount values. This function is needed in order to compute the discount factor needed for discounting. The discount factor curve will be retrieved from the Process object indicated by the 'AssetNo' parameter.
    • AssetMin(AssetNo, startRow, endRow) - Retrieves the minimum asset value from a starting to an ending 'step' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • AssetMax(AssetNo, startRow, endRow) - Retrieves the maximum asset value from a starting to an ending 'step' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • AssetSum(AssetNo, startRow, endRow) - Retrieves the sum of the asset's value from a starting to an ending 'step' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • AssetAvg(AssetNo, startRow, endRow) - Retrieves the average of the asset's value from a starting to an ending 'step' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridRowMin(Row, startCol, endCol) - Retrieves the minimum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowMax(Row, startCol, endCol) - Retrieves the maximum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowAvg(Row, startCol, endCol) - Retrieves the average value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowSum(Row, startCol, endCol) - Retrieves the sum across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridColMin(Col, startRow, endRow) - Retrieves the minimum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColMax(Col, startRow, endRow) - Retrieves the maximum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColAvg(Col, startRow, endRow) - Retrieves the average value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColSum(Col, startRow, endRow) - Retrieves the sum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • Interp1D(nIndex, XValue ) - If any 1D interpolation objects have been passed into GenericMCPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' is the value where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • Interp2D(nIndex, XValue, YValue) - If any 2D interpolation objects have been passed into GenericMCPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' and 'YValue' are the values where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • iff(condition, a, b) - Tests for the condition and returns the value of 'a' if true or 'b' if false.



    Predefined functions (case sensitive) :

    • sin(x) ( sine function )
    • cos(x) ( cosine function )
    • tan(x) ( tangens function )
    • asin(x) ( arcus sine function )
    • acos(x) ( arcus cosine function )
    • atan(x) ( arcus tangens function )
    • sinh(x) ( hyperbolic sine function )
    • cosh(x) ( hyperbolic cosine function )
    • tanh(x) ( hyperbolic tangens function )
    • asinh(x) ( hyperbolic arcus sine function )
    • acosh(x) ( hyperbolic arcus cosine function )
    • atanh(x) ( hyperbolic arcur tangens function )
    • log2(x) ( logarithm to the base 2 )
    • log10(x) ( logarithm to the base 10 )
    • log(x) ( logarithm to the base 10 )
    • ln(x) ( logarithm to the base e (2.71828...)
    • exp(x) ( e raised to the power of x )
    • sqrt(x) ( square root of a value )
    • sign(x) ( sign function ) -1=(if x<0), 1=(if x>0 )
    • rint(x) ( round to nearest integer )
    • abs(x) ( absolute value )
    • min(a,b,c,d,e,...) ( min of all arguments ie - min(-2,1,5,-6) )
    • max(a,b,c,d,e,...) ( max of all arguments ie - max(-2,1,5,-6) )
    • sum(a,b,c,d,e,...) ( sum of all arguments ie - sum(-2,1,5,-6) )
    • avg(a,b,c,d,e,...) ( mean value of all arguments ie - avg(-2,1,5,-6) )
    • ite(x,y,z) ( if ... then ... else ... : ie - ite(a<b, 5.0, -3.0) )


    Predefined operators :

    • + ( addition )
    • - ( subtraction )
    • * ( multiplication )
    • / ( division )
    • ^ ( raise x to the power of y )


    Predefined operators that can be used within the first parameter of the ite() or iff() function :

    • and ( logical and )
    • or ( logical or )
    • <= ( less or equal )
    • >= ( greater or equal )
    • != ( not equal )
    • == ( equal to )
    • > ( greater than )
    • < ( less than )

    • Brackets, '(' and ')', can also be used to simplify expressions.
    Some possible examples of what is possible now follow (Today = 19/07/2005):

    Vanilla Option. (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2006#FALSEmax(Asset(1, cRow) - 10, 0) * DCF(1, cRow)



    Two Vanilla Options (Call and Put). (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff ColPayOff Col
    1#19/07/2006#FALSE100max(Asset(1, cRow) - Cell(cRow, cCol-1), 0) * DCF(1, cRow)
    2#19/07/2007#FALSE90max(Cell(cRow, cCol-1) - Asset(1, cRow), 0) * DCF(1, cRow)GridColSum(cCol-1, 1, cRow)



    Asian Lookback Option. (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(1, cRow)
    2#19/01/2006#FALSEAsset(1, cRow)
    3#19/07/2006#FALSEAsset(1, cRow)
    4#19/01/2007#FALSEAsset(1, cRow)
    5#19/07/2007#FALSEAsset(1, cRow)max(GridColAvg(cCol-1, 1, cRow) - GridColMax(cCol-1, 1, cRow), 0) * DCF(1, cRow)



    Asian Option with fixed strike. (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(1, cRow)
    2#19/01/2006#FALSEAsset(1, cRow)
    3#19/07/2006#FALSEAsset(1, cRow)
    4#19/01/2007#FALSEAsset(1, cRow)
    5#19/07/2007#FALSEAsset(1, cRow)max(GridColAvg(cCol-1, 1, cRow) - 10, 0) * DCF(1, cRow)



    Asian Option with fixed strike (daily averaging). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUE
    2#19/01/2006#TRUE
    3#19/07/2006#TRUE
    4#19/01/2007#TRUE
    5#19/07/2007#FALSEmax(AssetAvg(1, 1, cRow) - 10, 0) * DCF(1, cRow)



    Asian Option with floating strike. (The Step column is not required).


    StepEventDateRepeat?PayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(1, cRow)
    2#19/01/2006#FALSEAsset(1, cRow)
    3#19/07/2006#FALSEAsset(1, cRow)
    4#19/01/2007#FALSEAsset(1, cRow)
    5#19/07/2007#FALSEAsset(1, cRow)max(GridColAvg(cCol-1, 1, cRow) - Cell(cRow, cCol), 0) * DCF(1, cRow)



    Asian Option with floating strike (daily averaging). (The Step column is not required).


    StepEventDateRepeat?PayOff Col
    1#19/07/2005#TRUE
    2#19/01/2006#TRUE
    3#19/07/2006#TRUE
    4#19/01/2007#TRUE
    5#19/07/2007#FALSEmax(AssetAvg(1, 1, cRow) - Cell(cRow, cCol), 0) * DCF(1, cRow)




    Quanto Asian Basket Option with floating strike. (The Step column is not required).

    This example was picked up from one of the QuantLib's mailing list (with some modifications).


    Let us consider a quanto asian basket average rate option, which has as underlying 2 equities quoted in currencies AAA and BBB (the values are not "real word" data).

    Underlying #1: current price = 75 AAA, dividend yield = 3.1%, volatility = 20%
    Underlying #2: current price = 100 BBB, dividend yield = 2%, volatility = 15%

    AAA risk free rate: 5.1%
    BBB risk free rate: 3.5%
    Exchange rate AAA/BBB: 1.5
    Volatility of exchange rate AAA/BBB: 15%
    Correlation between Underlying #2 and the exchange rate = 0.4

    The option is paid in currency AAA and has the payoff of a quanto asian
    Basket (note: in the payoff there is no exchange rate):

    Basket1 = underlying1[samplingDate1] + underlying2[samplingDate1]
    Basket2 = underlying1[samplingDate2] + underlying2[samplingDate2]
    .
    .
    .
    BasketN = underlying1[samplingDateN] + underlying2[samplingDateN]

    Average = (basket1 + basket2 + ... + basketN) / N
    Strike: 175
    Sampling dates: 19/07/2005, 19/01/2006, 19/07/2006, 19/01/2007, 19/07/2007
    Expiry date: 19/07/2007
    Payoff at expiry = max(0; Average - Strike)

    One can use the following payoff table :


    StepEventDateRepeat?PayOff ColPayOff ColPayOff ColPayOff Col
    1#19/07/2005#FALSEAsset(1, cRow)Asset(2, cRow)Cell(cRow, cCol-2)+Cell(cRow, cCol-1)
    2#19/01/2006#FALSEAsset(1, cRow)Asset(2, cRow)Cell(cRow, cCol-2)+Cell(cRow, cCol-1)
    3#19/07/2006#FALSEAsset(1, cRow)Asset(2, cRow)Cell(cRow, cCol-2)+Cell(cRow, cCol-1)
    4#19/01/2007#FALSEAsset(1, cRow)Asset(2, cRow)Cell(cRow, cCol-2)+Cell(cRow, cCol-1)
    5#19/07/2007#FALSEAsset(1, cRow)Asset(2, cRow)Cell(cRow, cCol-2)+Cell(cRow, cCol-1)max(GridColAvg(cCol-1, 1, cRow) - 175, 0) * DCF(1, cRow)




    In terms of the assets themselves, we would construct a CorrArrayProcesses() object and fill it with just 2 process objects created via the GBSProcess() function.
    The correlation matrix used in the simulation is consequently just 2x2 and has only the correlations between the assets.

    For the first process, GBSProcess(), we would consider the following arguments.

    • Asset price = 75
    • Volatility = 0.2
    • Rate = 0.051
    • dividend yield = 0.031



    However for the second process, GBSProcess(), we would consider the following arguments.

    • Asset price = 100
    • Volatility = 0.15
    • Rate = 0.035 - (correlation * volAsset2 * volExRate)
    • dividend yield = 0.02



    Thus the Rate value for the second process will equal : 0.035 - (0.4 * 0.15 * 0.15).


    The reason why the second process's rate value is modified is because the currency of this asset is not equal to the payment currency. If you do not want to use a FX rate in the expression then a Quanto adjustment must be made to the 'rate' parameter. You also see that we use the DCF(1, cRow) function within the payoff table. The first parameter indicates which asset's discounting curve are we using. In this case, Asset #1's discounting curve.


    When pricing Quanto products, there is no need to construct another process object to simulate the exchange rate.


  4. CapeTools Generic IR LMM MonteCarlo Pricer


    General Description


    Functions to price generic interest rate structures under a LMM MonteCarlo framework. If your product's payoff does not refer to asset prices in the future (ie - Bermudan / American options) you can use this framework.

    Here are some general rules to keep in mind regarding how the payoff grid will be processed :

    1. Rows are time points. As you read down the grid you are moving forward in time.
    2. Columns represent your payoff formulas. You can create as many columns as you like. Columns are there to help you split up your payoff, or for a payoff function within a cell to refer to other cells within the grid.
    3. For the MonteCarlo pricer, the pricing starts at the first timestep and prices from left to right.
    4. Formula expressions within a cell cannot refer to formula cells to the right of itself.
    5. Formula expressions within a cell cannot refer to formula cells below itself (future time points).
    6. No payoff formulas must be present within the very first timestep and you can never refer to the very first time step (we call this step, time step 0).


    If you bear the 6 points in mind, this should aid you in constructing payoff grids.

    Below is an example of a payoff table. The Step column is not required.


    StepEventDatePayOff ColPayOff ColPayOff ColPayOff Col
    0#21/07/2006#
    1#23/10/2006#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    2#22/01/2007#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    3#23/04/2007#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    4#23/07/2007#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    5#22/10/2007#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    6#21/01/2008#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    7#21/04/2008#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    8#21/07/2008#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    9#21/10/2008#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    10#21/01/2009#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    11#21/04/2009#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    12#21/07/2009#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    13#21/10/2009#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    14#21/01/2010#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    15#21/04/2010#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    16#21/07/2010#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    17#21/10/2010#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    18#21/01/2011#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    19#21/04/2011#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)
    20#21/07/2011#Libor(cRow) + _aInterp1D(1,cRow)GridRowSum(cRow, cCol-2, cCol-1)max(GridColMin(cCol-1, 1, cRow) - LiborMin(1, cRow), 0.0) * DCF(cRow) * Cvg(cRow)




    Note the following definitions :

    • DCF(date) = Discount factor.at the given 'date'
    .
    • Coverage(start, end) = Year fraction between 'start' and 'end' dates.
    • CashRate(start, end) = ((DCF(start)/DCF(end)) - 1) / Coverage(start, end)
    • Libor(start, end) = CashRate(start, end) + FwdSpread(end)
    • If a yieldcurve stripper was used without utilizing cross-currency swaps against the dollar and the Index object does not specify any Basis Swap curves then the FwdSpread(end) function will be equal to zero (0).
    • If a yieldcurve stripper was used utilizing cross-currency swaps against the dollar, then the CashRate() function uses only the discounting curve and the rate will not equal the LIBOR rate. The forward spread is the difference between the CashRate() and the Libor() rate.
    • If a yieldcurve stripper was used without utilizing cross-currency swaps against the dollar but the Index object does specify a Basis Swap curve then the CashRate() function will return the LIBOR rate. However the Index object specifies a spread to be added to the LIBOR rate and this spread is encapsulated within the FwdSpread() function.



    Financial variables (case sensitive) :

    • cRow - refers to the current Row with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cRow, cRow-1, cRow+2 etc...) instead of a fixed value (ie - 1, 2 etc...). This is important especially if you enable American type handling from one timestep to another. Using static integer values will generate incorrect results.
    • cCol - refers to the current Column with the payoff table. Within all the financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cCol, cCol-1, cCol+2 etc...).
    • pct - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as a percent. (ie - 5pct => 0.05)
    • bp - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as basis points. (ie - 5bp => 0.0005)
    • _XXX - Constant variables can be defined by filling in the 'ConstParams' parameter of the GenericLMM_MCPricer() function. All variables must be defined with a leading underscore character ( ie - _XXX = 0.5)


    Financial functions (case sensitive) :

    • Libor(row) - Returns the libor value between the previous time step and this time step. Thus the LIBOR rate will be FIXED at the previous timestep and PAID at the current timestep.
    • CashRate(row) - Returns the CashRate value between the previous time step and this time step. Thus the CashRate rate will be FIXED at the previous timestep and PAID at the current timestep.
    • Cvg(row) - Returns the year fraction between the previous time step and this time step.
    • FwdSpread(row) - Returns the Forward Spread at the given time step.
    • Cell(row, col) - Retrieves a computed value within the PayOff Table. You can only refer to rows and columns below and to the left of the current cell location. You can also refer to the current cell location. This is because the MC pricer prices forwards in time and thus future payoff values have not been computed as yet. The expression 'Cell(cRow, cCol-1)' retrieves the payoff value for the current timestep but at the previous column.
    • DCF(TimeStep) - Retrieves the discount value of an asset at the requested 'TimeStep'. Unlike some of the other pricers, the MonteCarlo pricer does not discount values. This function is needed in order to compute the discount factor needed for discounting. The discount factor curve will be retrieved from the Process object indicated by the 'AssetNo' parameter.
    • DCF2(FromTimeStep, ToTimeStep) - Retrieves the discount value between two timeSteps (ie - discount factor between step 'FromTimeStep' and 'ToTimeStep'). Unlike some of the other pricers, the MonteCarlo pricer does not discount values. This function is needed in order to compute the discount factor needed for discounting. The discount factor curve will be retrieved from the Process object indicated by the 'AssetNo' parameter.
    • LiborMin(startRow, endRow) - Retrieves the minimum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborMax(startRow, endRow) - Retrieves the maximum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborAvg(startRow, endRow) - Retrieves the average of the LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborSum(startRow, endRow) - Retrieves the sum of the LIBOR values across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateMin(startRow, endRow) - Retrieves the minimum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateMax(startRow, endRow) - Retrieves the maximum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateAvg(startRow, endRow) - Retrieves the average of the LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateSum(startRow, endRow) - Retrieves the sum of the LIBOR values across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridRowMin(Row, startCol, endCol) - Retrieves the minimum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowMax(Row, startCol, endCol) - Retrieves the maximum value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowAvg(Row, startCol, endCol) - Retrieves the average value across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridRowSum(Row, startCol, endCol) - Retrieves the sum across the columns of the PayOff table (given a 'TimeStep' or row value). For the 'startCol' and 'endCol' parameters you can only refer to columns to the left or equal to the current cell location.
    • GridColMin(Col, startRow, endRow) - Retrieves the minimum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColMax(Col, startRow, endRow) - Retrieves the maximum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColAvg(Col, startRow, endRow) - Retrieves the average value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • GridColSum(Col, startRow, endRow) - Retrieves the sum value across the rows of the PayOff table (given a column value). For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • Interp1D(nIndex, XValue ) - If any 1D interpolation objects have been passed into GenericLMM_MCPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' is the value where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • Interp2D(nIndex, XValue, YValue) - If any 2D interpolation objects have been passed into GenericLMM_MCPricer() function (a maximum of 2 objects can be defined), then you can execute this function within your payoff grid. The 'nIndex' parameter refers to the intepolation object (1-based). 'XValue' and 'YValue' are the values where the interpolation is to be performed. The interpolation object will not extrapolate values.
    • iff(condition, a, b) - Tests for the condition and returns the value of 'a' if true or 'b' if false.


    Predefined functions (case sensitive) :

    • sin(x) ( sine function )
    • cos(x) ( cosine function )
    • tan(x) ( tangens function )
    • asin(x) ( arcus sine function )
    • acos(x) ( arcus cosine function )
    • atan(x) ( arcus tangens function )
    • sinh(x) ( hyperbolic sine function )
    • cosh(x) ( hyperbolic cosine function )
    • tanh(x) ( hyperbolic tangens function )
    • asinh(x) ( hyperbolic arcus sine function )
    • acosh(x) ( hyperbolic arcus cosine function )
    • atanh(x) ( hyperbolic arcur tangens function )
    • log2(x) ( logarithm to the base 2 )
    • log10(x) ( logarithm to the base 10 )
    • log(x) ( logarithm to the base 10 )
    • ln(x) ( logarithm to the base e (2.71828...)
    • exp(x) ( e raised to the power of x )
    • sqrt(x) ( square root of a value )
    • sign(x) ( sign function ) -1=(if x<0), 1=(if x>0 )
    • rint(x) ( round to nearest integer )
    • abs(x) ( absolute value )
    • min(a,b,c,d,e,...) ( min of all arguments ie - min(-2,1,5,-6) )
    • max(a,b,c,d,e,...) ( max of all arguments ie - max(-2,1,5,-6) )
    • sum(a,b,c,d,e,...) ( sum of all arguments ie - sum(-2,1,5,-6) )
    • avg(a,b,c,d,e,...) ( mean value of all arguments ie - avg(-2,1,5,-6) )
    • ite(x,y,z) ( if ... then ... else ... : ie - ite(a<b, 5.0, -3.0) )


    Predefined operators :

    • + ( addition )
    • - ( subtraction )
    • * ( multiplication )
    • / ( division )
    • ^ ( raise x to the power of y )


    Predefined operators that can be used within the first parameter of the ite() or iff() function :

    • and ( logical and )
    • or ( logical or )
    • <= ( less or equal )
    • >= ( greater or equal )
    • != ( not equal )
    • == ( equal to )
    • > ( greater than )
    • < ( less than )

    • Brackets, '(' and ')', can also be used to simplify expressions.

  5. CapeTools Generic IR Tree Pricer


    General Description


    Functions to price generic interest rate structures under an interest rate tree framework. If your product's payoff does not refer to LIBOR RATES in the past (ie - Asian options) you can use this framework.

    Here are some general rules to keep in mind regarding how the payoff grid will be processed :

    1. Rows are time points. As you read down the grid you are moving forward in time.
    2. Columns represent your payoff formulas. You can create as many columns as you like. Columns are there to help you split up your payoff, or for a payoff function within a cell to refer to other cells within the grid.
    3. For the Tree pricer, the pricing starts at the last timestep and prices from left to right.
    4. Formula expressions within a cell cannot refer to formula cells to the right of itself.
    5. Formula expressions within a cell cannot refer to formula cells above itself (past time points).
    6. Given any step within your payoff table, the current step is defined as the fixing date and the next step is the payment date.
    7. No payoff formulas may be present within the very last timestep (used as a holder for the last rate payment date).


    If you bear the 7 points in mind, this should aid you in constructing payoff grids.

    Below is an example of a payoff table. This deal prices a cap (sum of caplets). The Step column is not required.


    StepEventDatePayOff ColPayOff ColPayOff ColPayOff Col
    1#21/07/2006#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    2#23/10/2006#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    3#22/01/2007#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    4#23/04/2007#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    5#23/07/2007#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    6#22/10/2007#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    7#21/01/2008#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    8#21/04/2008#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    9#21/07/2008#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    10#21/10/2008#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    11#21/01/2009#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    12#21/04/2009#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    13#21/07/2009#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    14#21/10/2009#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    15#21/01/2010#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    16#21/04/2010#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    17#21/07/2010#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    18#21/10/2010#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    19#21/01/2011#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1) + PVCol(cCol)
    20#21/04/2011#Libor(cRow)ZCB(cRow)Caplet(_X, 0.0) * Cvg(cRow) * _NotionalCell(cRow, cCol-1)
    21#21/07/2011#




    Note the following financial definitions :

    • DCF(date) = Discount factor.at the given 'date'
    .
    • Coverage(start, end) = Year fraction between 'start' and 'end' dates.
    • CashRate(start, end) = ((DCF(start)/DCF(end)) - 1) / Coverage(start, end)
    • Libor(start, end) = CashRate(start, end) + FwdSpread(end)
    • If a yieldcurve stripper was used without utilizing cross-currency swaps against the dollar and the Index object does not specify any Basis Swap curves then the FwdSpread(end) function will be equal to zero (0).
    • If a yieldcurve stripper was used utilizing cross-currency swaps against the dollar, then the CashRate() function uses only the discounting curve and the rate will not equal the LIBOR rate. The forward spread is the difference between the CashRate() and the Libor() rate.
    • If a yieldcurve stripper was used without utilizing cross-currency swaps against the dollar but the Index object does specify a Basis Swap curve then the CashRate() function will return the LIBOR rate. However the Index object specifies a spread to be added to the LIBOR rate and this spread is encapsulated within the FwdSpread() function.



    Financial variables (case sensitive) :

    • cRow - refers to the current Row with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cRow, cRow-1, cRow+2 etc...) instead of a fixed value (ie - 1, 2 etc...). This is important especially if you enable American type handling from one timestep to another. Using static integer values will generate incorrect results.
    • cCol - refers to the current Column with the payoff table. Within all the Financial functions listed below, we recommend that you always use this variable (with perhaps offset values, ie - cCol, cCol-1, cCol+2 etc...).
    • pct - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as a percent. (ie - 5pct => 0.05)
    • bp - When an integer value is placed in front of this expression (no spaces), the function will interp the whole expression as basis points. (ie - 5bp => 0.0005)
    • _XXX - Constant variables can be defined by filling in the 'ConstParams' parameter of the GenericIRTreePricer() function. All variables must be defined with a leading underscore character ( ie - _XXX = 0.5)


    Financial functions (case sensitive) :

    • Libor(row) - Returns the libor value between the current time step and the next time step. Thus the LIBOR rate will be FIXED at this timestep and PAID at the next timestep.
    • CashRate(row) - Returns the CashRate value between the current time step and the next time step. Thus the CashRate rate will be FIXED at this timestep and PAID at the next timestep.
    • ZCB(row) - Returns the zero coupon bond (discount factor) value up to the current (rate fixing) timestep.


    Because the the current step is defined as the fixing date and the next step is the payment date, you cannot price a caplet via the following expression [max(Libor(cRow) - strike, dTest)]. Expressions like these only work if the current step is the payment step. However we have provided the correct functions for you to price caplets/floorlets.

    • Caplet(strike, dTest) - Returns the caplet value [max(Libor(cRow) - strike, dTest)] between the current time step and the next time step.
    • Floorlet(strike, dTest) - Returns the floorlet value [max(strike - Libor(cRow), dTest)] between the current time step and the next time step.
    • Cvg(row) - Returns the year fraction between the previous time step and this time step.
    • FwdSpread(row) - Returns the Forward Spread at the given time step.
    • Cell(row, col) - Retrieves a computed value within the PayOff Table. You can only refer to rows and columns below and to the left of the current cell location. You can also refer to the current cell location. This is because the Tree pricer prices backwards in time and thus past payoff values have not been computed as yet. The expression 'Cell(cRow, cCol-1)' retrieves the payoff value for the current timestep but at the previous column.
    • LiborMin(startRow, endRow) - Retrieves the minimum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborMax(startRow, endRow) - Retrieves the maximum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborAvg(startRow, endRow) - Retrieves the average of the LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • LiborSum(startRow, endRow) - Retrieves the sum of the LIBOR values across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateMin(startRow, endRow) - Retrieves the minimum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateMax(startRow, endRow) - Retrieves the maximum LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateAvg(startRow, endRow) - Retrieves the average of the LIBOR value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • CashRateSum(startRow, endRow) - Retrieves the sum of the LIBOR values across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • ZCBMin(startRow, endRow) - Retrieves the minimum zero coupon bond value across a starting and ending 'TimeStep' range. For the 'startRow' and 'endRow' parameters you can only refer to rows above or equal to the current cell location (past dates).
    • ZCBMax(startRow, endRow) - Retrieves the maximum zero co