GenericPayOff





http://www.QuantTools.com
CapeTools Payoff function list

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

Key TAGs | Excel Index | API Index



Creates a custom Generic PayOff function with one variable (x) and up to 16 constant arguments (strike being one of them).

x represents the underlying price (stock, FX Rate etc...) and will be populated during the pricing.

Parameters a through n are the user defined constants.

The constant e is predefined as 2.718281828459045235360287, the constant pi is predefined as 3.141592653589793238462643. The string 'Key' resulting from a successful construction of this payoff object can be passed to the following functions : VanillaOption(), ContinuousAsianOption(), DiscreteAsianOption(), BarrierOption() and DivVanillaOption(). You must ensure that the payoff function satisfies black-scholes PDE equation.

Basically only provide functions with a linear payoff (ie - do not use sin(), exp() and such non-linear functions within your payoff formulas.).



This function creates an object and returns a string-key value to represent this created object.
The TAG value of the string-key returned (second part of the key) is : "GENPAY"



Note: Within Excel, the function is named - CT.PAY.GenericPayOff




High level graphic of GenericPayOff() function with parameters. Blue square node is the actual function with the parameters ordered.



Parameter Description


  1. Key parameter

    Key value to use as a handle for the created object
  2. Reload parameter

    When creating this object for the first time, set this parameter to a positive value. Within Excel, when re-computing a worksheet where you do not wish to recreate the object, set this parameter to zero (0).
  3. OptionType parameter

    Type of option (C)all or (P)ut.
  4. CallFormula parameter

    Formula to be used for pricing the Call option [ie - max(x-strike,b) ] (Do not include quotes around the formula).
  5. PutFormula parameter

    Formula to be used for pricing the Put option [ie - max(strike-x,b) ] (Do not include quotes around the formula).
  6. strike parameter

    Constant strike value for this parameter.
  7. Const_a parameter

    Constant numeric value for this parameter.
  8. Const_b parameter

    Constant numeric value for this parameter.
  9. Const_c parameter

    Constant numeric value for this parameter.
  10. Const_d parameter

    Constant numeric value for this parameter.
  11. Const_f parameter

    Constant numeric value for this parameter.
  12. Const_g parameter

    Constant numeric value for this parameter.
  13. Const_h parameter

    Constant numeric value for this parameter.
  14. Const_i parameter

    Constant numeric value for this parameter.
  15. Const_j parameter

    Constant numeric value for this parameter.
  16. Const_k parameter

    Constant numeric value for this parameter.
  17. Const_l parameter

    Constant numeric value for this parameter.
  18. Const_m parameter

    Constant numeric value for this parameter.
  19. Const_n parameter

    Constant numeric value for this parameter.


Extended information

Function Syntax

VB Syntax


String CTPayoff.GenericPayOff( _
String Key, _
Long Reload, _
String OptionType, _
String CallFormula, _
String PutFormula, _
Double strike, _
Double Const_a, _
Double Const_b, _
Double Const_c, _
Double Const_d, _
Double Const_f, _
Double Const_g, _
Double Const_h, _
Double Const_i, _
Double Const_j, _
Double Const_k, _
Double Const_l, _
Double Const_m, _
Double Const_n)


Excel Spreadsheet Syntax


=CT.PAY.GenericPayOff(
Excel String Cell Key,
Excel Numeric Cell Reload,
Excel String Cell OptionType,
Excel String Cell CallFormula,
Excel String Cell PutFormula,
Excel Numeric Cell strike,
Excel Numeric Cell Const_a,
Excel Numeric Cell Const_b,
Excel Numeric Cell Const_c,
Excel Numeric Cell Const_d,
Excel Numeric Cell Const_f,
Excel Numeric Cell Const_g,
Excel Numeric Cell Const_h,
Excel Numeric Cell Const_i,
Excel Numeric Cell Const_j,
Excel Numeric Cell Const_k,
Excel Numeric Cell Const_l,
Excel Numeric Cell Const_m,
Excel Numeric Cell Const_n)


C++ Syntax


static std::string GenericPayOff(
std::string Key,
long Reload,
std::string OptionType,
std::string CallFormula,
std::string PutFormula,
double strike,
double Const_a,
double Const_b,
double Const_c,
double Const_d,
double Const_f,
double Const_g,
double Const_h,
double Const_i,
double Const_j,
double Const_k,
double Const_l,
double Const_m,
double Const_n);


DotNET Syntax


System.String CTPayoffSA.GenericPayOff(
System.String Key,
System.Int32 Reload,
System.String OptionType,
System.String CallFormula,
System.String PutFormula,
System.Double strike,
System.Double Const_a,
System.Double Const_b,
System.Double Const_c,
System.Double Const_d,
System.Double Const_f,
System.Double Const_g,
System.Double Const_h,
System.Double Const_i,
System.Double Const_j,
System.Double Const_k,
System.Double Const_l,
System.Double Const_m,
System.Double Const_n);

Parameter data types

ArgNameArgTypeIsKey
KeyStringFALSE
ReloadLongFALSE
OptionTypeStringFALSE
CallFormulaStringFALSE
PutFormulaStringFALSE
strikeDoubleFALSE
Const_aDoubleFALSE
Const_bDoubleFALSE
Const_cDoubleFALSE
Const_dDoubleFALSE
Const_fDoubleFALSE
Const_gDoubleFALSE
Const_hDoubleFALSE
Const_iDoubleFALSE
Const_jDoubleFALSE
Const_kDoubleFALSE
Const_lDoubleFALSE
Const_mDoubleFALSE
Const_nDoubleFALSE


Example Inputs

The first column represents the name of the parameters. The second column specifies whether the parameters are optional or not. Finally the last column provides some sample input data.
Function call input string-keys are always in the format : "NAME.EXTTAG.TICKER" The "EXTTAG.TICKER" part is determined from the output of other, capetools, object creation functions.


ArgNameIsOptional (Excel only)Example
KeyFALSEMyGenericPayOff
ReloadFALSE1
OptionTypeTRUECall
CallFormulaFALSEmax(x-strike,a+b*c)
PutFormulaFALSEmax(strike-x,a+b*c)
strikeTRUE80
Const_aTRUE2
Const_bTRUE1
Const_cTRUE2
Const_dTRUE0.0
Const_fTRUE0.0
Const_gTRUE0.0
Const_hTRUE0.0
Const_iTRUE0.0
Const_jTRUE0.0
Const_kTRUE0.0
Const_lTRUE0.0
Const_mTRUE0.0
Const_nTRUE0.0


Example function usage


The C# example below contains all the sub-function calls leading up to this function call. As a result, the example can contain a lot of code.

The VB.NET, J#, C++.NET, Java, Excel VBA, Visual Basic 6 (via COM) and C++ examples below contain function code stubs for the calls leading up to this function call. However, the function call for this function is displayed.
You can easily reproduce the stub functions code from the C# example.


If you are accessing this functrion via the MiniXL libraries, this function is present within the CT.QL.Models20 MiniXL Excel Addin.

Within our Excel Example Addin Generator, we have used the following QuantTools sub-functions in order to prepare the arguments needed to call the GenericPayOff() function. If you are executing this function via the MiniXL libraries, the module addin name, (in brackets, to the right of the sub-functions listed below), indicates the MiniXL library in which the sub-function is held. You will need to load this library into your Excel session (along with any other libraries that the sub-function call within the addin requires (ie - CT.QT.Utils20 addin in almost all cases) in order for the example to compute successfully.


The following four examples demostrate calling this function within a Microsoft .NET environment

The following four examples demostrate calling this function within a non .NET environment

The following is a sample output from executing the GenericPayOff() function call


MyGenericPayOff_1.GENPAY.0

Copyright (c) 2003-2007 CapeTools - All Rights Reserved.