MExtendibleWriter





http://www.QuantTools.com
CapeTools Exotic Analysis function list

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

Key TAGs | Excel Index | API Index



Options that can be exercised at their initial maturity date t1, but are extended to T2 if the option is out of the money at t1.

This function utilizes an analytical (closed-form) algorithm.

Note that the risk (greek) numbers produced are the mathematically defined equivalent of a derivative (instantaneous change).

You can convert the risk number to your own definition of risk by multiplying by the shift you require.

For example, for a typical definition of VANNA, (change in underlying and volatility), where one defines the change in the underlying as a single unit of change (1.0) and the change in volatility as a one percent change (0.01), simply multiply the VANNA result calculated by (1.0*0.01).

For VEGA, change in volatility of one percent (0.01), simply multiply the VEGA result by 0.01. Within option contracts THETA is negative, however the mathematically defined equivalent of THETA (instantaneous FORWARD change in time) is positive.

Internally we have negated this value for you.

To express THETA as THETA per day, simply multiply the THETA result by 1/365 or 1/252 (depending on whether you require calendar days or business days).

This function prices a portfolio of equity, commodities, futures or FX option deals from raw inputs.

All memory is discarded once the computation is finished.

You can request for all first and second order risk statistics simply by filling in the greek field with the name of the parameter.

The name of the parameter must be proceeded with the character 'd'. Thus if 'Stock', 'Time' and 'Vol' are the names of three parameters which represent underlying price, Option Maturity and option volatility respectively, you can request DELTA as 'dStock', GAMMA as 'dStockdStock' (dStock twice), VEGA as 'dVol', THETA as 'dTime', VOLGA as 'dVoldVol' (dVol twice) and VANNA (cross-derivative) as 'dStockdVol' or 'dVoldStock'. You can also, if you wish request 'dTimedVol' (second derivative with respect to Time and Vol).

If you wish to view all the second order derivatives within a matrix, please refer to the CapeTools Derivative Matrix category of functions.

This logic can be applied to any parameter which is of a double-valued type (decimal value).

The risk statistics are the partial derivatives with respect to the option price, thus you can scale the results by multiplying by a factor.

For example, to compute the VEGA for a one percent change in volatility (0.01), simply multiply the VEGA result by 0.01. To compute THETA for a one day change (1/365), multiply the THETA result by 1/365. To compute the DELTA for a one-unit change (1), multiply the delta by 1 which is, of course the same result as the original delta.

For second order risks, simply multiply by the product of the changes.



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




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



Parameter Description


  1. ValueDate parameter

    Valuation Date (typically equal to Today's date)
  2. dayCounter parameter

    For any input parameter within this function that represents a dividend rate, risk free rate, foreign rate or holding cost rate, these rates will be defined as annually compounded using the DayCounter defined within this parameter. Thus if 'actual365' is used for this 'dayCounter' parameter, then all input parameters that represent a dividend, risk free, foreign or holding cost rates will be defined as annually compounded Actual365 rates.
  3. Units parameter

    Number of option contracts you wish to trade in (positive value).
  4. Position parameter

    Whether you are long or short the option.
  5. Level parameter

    Whether you would like to view the PV for the entire structure/portfolio 'TOTAL'. Whether you would like to view the PV for each option 'CASHFLOW'. Or whether you would like to view the PV and extended information, 'ALL'. Thus valid values are - 'TOTAL', 'CASHFLOW' or 'ALL'.
  6. CallPut parameter

    Option Types (C)all or (P)ut
  7. Underlying parameter

    Underlying price, curve
  8. Strike1 parameter

    Strike price of the option.
  9. Strike2 parameter

    Extended Strike price.
  10. Timet1 parameter

    Expiration date of the first option.
  11. TimeT parameter

    Expiration date of the extended option.
  12. Rate parameter

    For the underlying (equity, futures, FX or commodity), this should be an annualised rate (risk free rate or foreign rate). If this is an option on a FX underlying, then if the underlying is quoted as domestic/foreign then this rate will be the domestic rate. If, however, the FX underlying is quoted as foreign/domestic then this will be the foreign rate.
  13. B parameter

    For the underlying (equity, futures, FX or commodity), this should be an annualised rate (dividend rate, risk free rate, foreign rate or holding cost rate respectively). If this is an option on a FX underlying, then if the underlying is quoted as domestic/foreign then this rate will be the foreign rate. If, however, the FX underlying is quoted as foreign/domestic then this will be the domestic rate.
  14. Vol parameter

    Volatility of the underlying.
  15. Greek parameter

    For the option premium specify 'PREMIUM'. For all first derivatives, you can specify one of the following : 'dUnderlying' (for the 'Underlying' parameter), 'dStrike1' (for the 'Strike1' parameter), 'dStrike2' (for the 'Strike2' parameter), 'dTimet1' (for the 'Timet1' parameter), 'dTimeT' (for the 'TimeT' parameter), 'dRate' (for the 'Rate' parameter), 'dB' (for the 'B' parameter), 'dVol' (for the 'Vol' parameter), For second order derivatives, you can specify combinations of the first order derivatives (i.e. - 'dUnderlyingdUnderlying', 'dVoldVol', 'dUnderlyingdVol'. )


Extended information

Function Syntax

VB Syntax


Variant CTExoticAnalysis.MExtendibleWriter( _
Long ValueDate, _
DayCountEnum dayCounter, _
Variant Units, _
Variant Position, _
String Level, _
Variant CallPut, _
Variant Underlying, _
Variant Strike1, _
Variant Strike2, _
Variant Timet1, _
Variant TimeT, _
Variant Rate, _
Variant B, _
Variant Vol, _
String Greek)


Excel Spreadsheet Syntax


=CT.MExtendibleWriter(
Excel Numeric Cell ValueDate,
Excel String Cell dayCounter,
XLRange Units,
XLRange Position,
Excel String Cell Level,
XLRange CallPut,
XLRange Underlying,
XLRange Strike1,
XLRange Strike2,
XLRange Timet1,
XLRange TimeT,
XLRange Rate,
XLRange B,
XLRange Vol,
Excel String Cell Greek)


C++ Syntax


static CTRangeDataCPP MExtendibleWriter(
long ValueDate,
DayCountEnum dayCounter,
CTRangeDataCPP Units,
CTRangeDataCPP Position,
std::string Level,
CTRangeDataCPP CallPut,
CTRangeDataCPP Underlying,
CTRangeDataCPP Strike1,
CTRangeDataCPP Strike2,
CTRangeDataCPP Timet1,
CTRangeDataCPP TimeT,
CTRangeDataCPP Rate,
CTRangeDataCPP B,
CTRangeDataCPP Vol,
std::string Greek);


DotNET Syntax


CTRangeData CTExoticAnalysisSA.MExtendibleWriter(
System.Int32 ValueDate,
CTIEnums.DayCountEnum dayCounter,
CTRangeData Units,
CTRangeData Position,
System.String Level,
CTRangeData CallPut,
CTRangeData Underlying,
CTRangeData Strike1,
CTRangeData Strike2,
CTRangeData Timet1,
CTRangeData TimeT,
CTRangeData Rate,
CTRangeData B,
CTRangeData Vol,
System.String Greek);

Parameter data types

ArgNameArgTypeIsKey
ValueDateLongFALSE
dayCounterDayCountEnumFALSE
UnitsRangeFALSE
PositionRangeFALSE
LevelStringFALSE
CallPutRangeFALSE
UnderlyingRangeFALSE
Strike1RangeFALSE
Strike2RangeFALSE
Timet1RangeFALSE
TimeTRangeFALSE
RateRangeFALSE
BRangeFALSE
VolRangeFALSE
GreekStringFALSE


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
ValueDateFALSE19/Jul/2005 (serial date type)
dayCounterFALSEACT365
UnitsFALSEMExtendibleWriter_Units_Range (creates a range object)
PositionFALSEMExtendibleWriter_Position_Range (creates a range object)
LevelFALSEALL
CallPutFALSEMExtendibleWriter_CallPut_Range (creates a range object)
UnderlyingFALSEMExtendibleWriter_Underlying_Range (creates a range object)
Strike1FALSEMExtendibleWriter_Strike1_Range (creates a range object)
Strike2FALSEMExtendibleWriter_Strike2_Range (creates a range object)
Timet1FALSEMExtendibleWriter_Timet1_Range (creates a range object)
TimeTFALSEMExtendibleWriter_TimeT_Range (creates a range object)
RateFALSEMExtendibleWriter_Rate_Range (creates a range object)
BFALSEMExtendibleWriter_B_Range (creates a range object)
VolFALSEMExtendibleWriter_Vol_Range (creates a range object)
GreekFALSEPREMIUM


Example range for parameter : Units

Within Excel, a range such as this can be passed directly into the Units parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Units



CTQL.CTRangeData MExtendibleWriter_Units;


int[] arrBMExtendibleWriter_Units = {
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_Units =
new  CTQL.IntVector(arrBMExtendibleWriter_Units);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Units = new  CTQL.CTRangeData(arrMExtendibleWriter_Units, false);


Example range for parameter : Position

Within Excel, a range such as this can be passed directly into the Position parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Position



CTQL.CTRangeData MExtendibleWriter_Position;


string[] arrBMExtendibleWriter_Position = {
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG",
"LONG"  //  Array Data

};

CTQL.StringVector arrMExtendibleWriter_Position =
new  CTQL.StringVector(arrBMExtendibleWriter_Position);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Position = new  CTQL.CTRangeData(arrMExtendibleWriter_Position, false);


Example range for parameter : CallPut

Within Excel, a range such as this can be passed directly into the CallPut parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : CallPut



CTQL.CTRangeData MExtendibleWriter_CallPut;


string[] arrBMExtendibleWriter_CallPut = {
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call",
"Call"  //  Array Data

};

CTQL.StringVector arrMExtendibleWriter_CallPut =
new  CTQL.StringVector(arrBMExtendibleWriter_CallPut);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_CallPut = new  CTQL.CTRangeData(arrMExtendibleWriter_CallPut, false);


Example range for parameter : Underlying

Within Excel, a range such as this can be passed directly into the Underlying parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Underlying



CTQL.CTRangeData MExtendibleWriter_Underlying;


int[] arrBMExtendibleWriter_Underlying = {
88,
76,
83,
73,
72,
79,
80,
77,
79,
80,
86,
75,
74,
76,
75,
77,
81,
86,
81,
80  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_Underlying =
new  CTQL.IntVector(arrBMExtendibleWriter_Underlying);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Underlying = new  CTQL.CTRangeData(arrMExtendibleWriter_Underlying, false);


Example range for parameter : Strike1

Within Excel, a range such as this can be passed directly into the Strike1 parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Strike1



CTQL.CTRangeData MExtendibleWriter_Strike1;


int[] arrBMExtendibleWriter_Strike1 = {
86,
97,
90,
83,
95,
93,
82,
97,
94,
90,
82,
92,
88,
83,
97,
94,
95,
84,
97,
90  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_Strike1 =
new  CTQL.IntVector(arrBMExtendibleWriter_Strike1);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Strike1 = new  CTQL.CTRangeData(arrMExtendibleWriter_Strike1, false);


Example range for parameter : Strike2

Within Excel, a range such as this can be passed directly into the Strike2 parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Strike2



CTQL.CTRangeData MExtendibleWriter_Strike2;


int[] arrBMExtendibleWriter_Strike2 = {
82,
80,
83,
84,
78,
84,
76,
81,
90,
77,
85,
82,
90,
75,
87,
82,
81,
87,
81,
82  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_Strike2 =
new  CTQL.IntVector(arrBMExtendibleWriter_Strike2);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Strike2 = new  CTQL.CTRangeData(arrMExtendibleWriter_Strike2, false);


Example range for parameter : Timet1

Within Excel, a range such as this can be passed directly into the Timet1 parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Timet1



CTQL.CTRangeData MExtendibleWriter_Timet1;


int[] arrBMExtendibleWriter_Timet1 = {
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("17/1/2006", "dd/mm/yyyy")  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_Timet1 =
new  CTQL.IntVector(arrBMExtendibleWriter_Timet1);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Timet1 = new  CTQL.CTRangeData(arrMExtendibleWriter_Timet1, false);


Example range for parameter : TimeT

Within Excel, a range such as this can be passed directly into the TimeT parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : TimeT



CTQL.CTRangeData MExtendibleWriter_TimeT;


int[] arrBMExtendibleWriter_TimeT = {
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy"),
CTQL.Date.serialNumber("19/4/2006", "dd/mm/yyyy")  //  Array Data

};

CTQL.IntVector arrMExtendibleWriter_TimeT =
new  CTQL.IntVector(arrBMExtendibleWriter_TimeT);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_TimeT = new  CTQL.CTRangeData(arrMExtendibleWriter_TimeT, false);


Example range for parameter : Rate

Within Excel, a range such as this can be passed directly into the Rate parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Rate



CTQL.CTRangeData MExtendibleWriter_Rate;


double[] arrBMExtendibleWriter_Rate = {
0.0996,
0.1035,
0.0996,
0.0969,
0.102,
0.0945,
0.0975,
0.0956,
0.0942,
0.0985,
0.1086,
0.0976,
0.1066,
0.0908,
0.1086,
0.0927,
0.1016,
0.0903,
0.1014,
0.1  //  Array Data

};

CTQL.DoubleVector arrMExtendibleWriter_Rate =
new  CTQL.DoubleVector(arrBMExtendibleWriter_Rate);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Rate = new  CTQL.CTRangeData(arrMExtendibleWriter_Rate, false);


Example range for parameter : B

Within Excel, a range such as this can be passed directly into the B parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : B



CTQL.CTRangeData MExtendibleWriter_B = new CTQL.CTRangeData();

System.Text.StringBuilder MExtendibleWriter_B_builder =
new System.Text.StringBuilder(100);

MExtendibleWriter_B_builder.Append("{");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0 ;");
MExtendibleWriter_B_builder.Append("0.00");
MExtendibleWriter_B_builder.Append("}");

// Parse the string into the Range object.
MExtendibleWriter_B.RangeFromStr( MExtendibleWriter_B_builder.ToString() );


Example range for parameter : Vol

Within Excel, a range such as this can be passed directly into the Vol parameter.


Data is stored within the second column (Vector of data)..

Example C# API usage for setting the range data for parameter : Vol



CTQL.CTRangeData MExtendibleWriter_Vol;


double[] arrBMExtendibleWriter_Vol = {
0.3138,
0.2877,
0.2946,
0.3048,
0.3132,
0.3169,
0.3203,
0.3229,
0.2879,
0.3208,
0.2992,
0.3093,
0.2743,
0.2995,
0.325,
0.3014,
0.2842,
0.3258,
0.2727,
0.3  //  Array Data

};

CTQL.DoubleVector arrMExtendibleWriter_Vol =
new  CTQL.DoubleVector(arrBMExtendibleWriter_Vol);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MExtendibleWriter_Vol = new  CTQL.CTRangeData(arrMExtendibleWriter_Vol, false);



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.Pricing20 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 MExtendibleWriter() 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 MExtendibleWriter() function call


Example
NoOfUnitsPositionCallPutUnderlyingStrike1Strike2Timet1TimeTRateBVolPREMIUM
1LONGCall84848138734388260.101600.303810.4944
1LONGCall86868138734388260.09500.294110.6039
1LONGCall80917538734388260.10500.28988.5457
1LONGCall86948538734388260.107800.32469.07387
1LONGCall74867438734388260.109900.27086.27108
1LONGCall81948738734388260.105600.29155.75355
1LONGCall83907738734388260.090700.31819.50906
1LONGCall83897838734388260.102600.31329.50117
1LONGCall85968938734388260.094100.27926.23736
1LONGCall84827538734388260.091600.298711.6851
1LONGCall82987738734388260.101600.27418.86518
1LONGCall83878538734388260.108100.28748.17952
1LONGCall83968238734388260.108500.30467.91953
1LONGCall85878838734388260.101300.27298.44147
1LONGCall83868338734388260.099200.27498.23336
1LONGCall87968038734388260.100500.28989.68352
1LONGCall83867638734388260.100200.298510.0527
1LONGCall82967538734388260.104500.30369.7986
1LONGCall84958638734388260.100100.28086.70264
1LONGCall80908238734388260.100.36.82584



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