MFixedStrikeLookback





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

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

Key TAGs | Excel Index | API Index



Call option, the strike is fixed in advance and at expiry the option pays out the max of the difference between the highest observed price Smax and the strike X and 0. A put at expiry pays out the max of the difference between the fixed strike X and the min observed price Smin and 0. 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.MFixedStrikeLookback




High level graphic of MFixedStrikeLookback() 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
  8. Smin parameter

    Minimum underlying price observed thus far
  9. Smax parameter

    Maximum underlying price observed thus far
  10. X parameter

    Strike price
  11. Time parameter

    Time to expiration of the 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), 'dSmin' (for the 'Smin' parameter), 'dSmax' (for the 'Smax' parameter), 'dX' (for the 'X' parameter), 'dTime' (for the 'Time' 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.MFixedStrikeLookback( _
Long ValueDate, _
DayCountEnum dayCounter, _
Variant Units, _
Variant Position, _
String Level, _
Variant CallPut, _
Variant Underlying, _
Variant Smin, _
Variant Smax, _
Variant X, _
Variant Time, _
Variant Rate, _
Variant B, _
Variant Vol, _
String Greek)


Excel Spreadsheet Syntax


=CT.MFixedStrikeLookback(
Excel Numeric Cell ValueDate,
Excel String Cell dayCounter,
XLRange Units,
XLRange Position,
Excel String Cell Level,
XLRange CallPut,
XLRange Underlying,
XLRange Smin,
XLRange Smax,
XLRange X,
XLRange Time,
XLRange Rate,
XLRange B,
XLRange Vol,
Excel String Cell Greek)


C++ Syntax


static CTRangeDataCPP MFixedStrikeLookback(
long ValueDate,
DayCountEnum dayCounter,
CTRangeDataCPP Units,
CTRangeDataCPP Position,
std::string Level,
CTRangeDataCPP CallPut,
CTRangeDataCPP Underlying,
CTRangeDataCPP Smin,
CTRangeDataCPP Smax,
CTRangeDataCPP X,
CTRangeDataCPP Time,
CTRangeDataCPP Rate,
CTRangeDataCPP B,
CTRangeDataCPP Vol,
std::string Greek);


DotNET Syntax


CTRangeData CTExoticAnalysisSA.MFixedStrikeLookback(
System.Int32 ValueDate,
CTIEnums.DayCountEnum dayCounter,
CTRangeData Units,
CTRangeData Position,
System.String Level,
CTRangeData CallPut,
CTRangeData Underlying,
CTRangeData Smin,
CTRangeData Smax,
CTRangeData X,
CTRangeData Time,
CTRangeData Rate,
CTRangeData B,
CTRangeData Vol,
System.String Greek);

Parameter data types

ArgNameArgTypeIsKey
ValueDateLongFALSE
dayCounterDayCountEnumFALSE
UnitsRangeFALSE
PositionRangeFALSE
LevelStringFALSE
CallPutRangeFALSE
UnderlyingRangeFALSE
SminRangeFALSE
SmaxRangeFALSE
XRangeFALSE
TimeRangeFALSE
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
UnitsFALSEMFixedStrikeLookback_Units_Range (creates a range object)
PositionFALSEMFixedStrikeLookback_Position_Range (creates a range object)
LevelFALSEALL
CallPutFALSEMFixedStrikeLookback_CallPut_Range (creates a range object)
UnderlyingFALSEMFixedStrikeLookback_Underlying_Range (creates a range object)
SminFALSEMFixedStrikeLookback_Smin_Range (creates a range object)
SmaxFALSEMFixedStrikeLookback_Smax_Range (creates a range object)
XFALSEMFixedStrikeLookback_X_Range (creates a range object)
TimeFALSEMFixedStrikeLookback_Time_Range (creates a range object)
RateFALSEMFixedStrikeLookback_Rate_Range (creates a range object)
BFALSEMFixedStrikeLookback_B_Range (creates a range object)
VolFALSEMFixedStrikeLookback_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 MFixedStrikeLookback_Units;


int[] arrBMFixedStrikeLookback_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 arrMFixedStrikeLookback_Units =
new  CTQL.IntVector(arrBMFixedStrikeLookback_Units);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_Units = new  CTQL.CTRangeData(arrMFixedStrikeLookback_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 MFixedStrikeLookback_Position;


string[] arrBMFixedStrikeLookback_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 arrMFixedStrikeLookback_Position =
new  CTQL.StringVector(arrBMFixedStrikeLookback_Position);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_Position = new  CTQL.CTRangeData(arrMFixedStrikeLookback_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 MFixedStrikeLookback_CallPut;


string[] arrBMFixedStrikeLookback_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 arrMFixedStrikeLookback_CallPut =
new  CTQL.StringVector(arrBMFixedStrikeLookback_CallPut);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_CallPut = new  CTQL.CTRangeData(arrMFixedStrikeLookback_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 MFixedStrikeLookback_Underlying;


int[] arrBMFixedStrikeLookback_Underlying = {
106,
92,
100,
91,
94,
105,
100,
105,
105,
101,
110,
106,
107,
99,
109,
95,
109,
94,
109,
100  //  Array Data

};

CTQL.IntVector arrMFixedStrikeLookback_Underlying =
new  CTQL.IntVector(arrBMFixedStrikeLookback_Underlying);

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


Example range for parameter : Smin

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


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

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



CTQL.CTRangeData MFixedStrikeLookback_Smin;


int[] arrBMFixedStrikeLookback_Smin = {
91,
91,
96,
101,
95,
100,
94,
96,
106,
106,
104,
106,
105,
93,
97,
92,
97,
92,
97,
100  //  Array Data

};

CTQL.IntVector arrMFixedStrikeLookback_Smin =
new  CTQL.IntVector(arrBMFixedStrikeLookback_Smin);

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


Example range for parameter : Smax

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


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

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



CTQL.CTRangeData MFixedStrikeLookback_Smax;


int[] arrBMFixedStrikeLookback_Smax = {
102,
98,
97,
98,
92,
97,
98,
109,
99,
96,
106,
93,
110,
104,
101,
91,
92,
93,
99,
100  //  Array Data

};

CTQL.IntVector arrMFixedStrikeLookback_Smax =
new  CTQL.IntVector(arrBMFixedStrikeLookback_Smax);

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


Example range for parameter : X

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


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

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



CTQL.CTRangeData MFixedStrikeLookback_X;


int[] arrBMFixedStrikeLookback_X = {
114,
103,
96,
113,
97,
114,
110,
106,
100,
98,
98,
114,
106,
103,
99,
110,
110,
100,
107,
105  //  Array Data

};

CTQL.IntVector arrMFixedStrikeLookback_X =
new  CTQL.IntVector(arrBMFixedStrikeLookback_X);

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


Example range for parameter : Time

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


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

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



CTQL.CTRangeData MFixedStrikeLookback_Time;


int[] arrBMFixedStrikeLookback_Time = {
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 arrMFixedStrikeLookback_Time =
new  CTQL.IntVector(arrBMFixedStrikeLookback_Time);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_Time = new  CTQL.CTRangeData(arrMFixedStrikeLookback_Time, 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 MFixedStrikeLookback_Rate;


double[] arrBMFixedStrikeLookback_Rate = {
0.0951,
0.1005,
0.1073,
0.0915,
0.104,
0.0946,
0.1074,
0.1094,
0.1011,
0.0965,
0.1073,
0.0982,
0.0941,
0.1042,
0.1091,
0.1029,
0.0946,
0.1042,
0.1096,
0.1  //  Array Data

};

CTQL.DoubleVector arrMFixedStrikeLookback_Rate =
new  CTQL.DoubleVector(arrBMFixedStrikeLookback_Rate);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_Rate = new  CTQL.CTRangeData(arrMFixedStrikeLookback_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 MFixedStrikeLookback_B = new CTQL.CTRangeData();

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

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

// Parse the string into the Range object.
MFixedStrikeLookback_B.RangeFromStr( MFixedStrikeLookback_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 MFixedStrikeLookback_Vol;


double[] arrBMFixedStrikeLookback_Vol = {
0.1946,
0.2092,
0.181,
0.1866,
0.1842,
0.2161,
0.2039,
0.1971,
0.2047,
0.2082,
0.1961,
0.2044,
0.2012,
0.2133,
0.2074,
0.1815,
0.2073,
0.1928,
0.2052,
0.2  //  Array Data

};

CTQL.DoubleVector arrMFixedStrikeLookback_Vol =
new  CTQL.DoubleVector(arrBMFixedStrikeLookback_Vol);

// Second parameter determines whether the array is a column array (false) or a row array (true)
MFixedStrikeLookback_Vol = new  CTQL.CTRangeData(arrMFixedStrikeLookback_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 MFixedStrikeLookback() 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 MFixedStrikeLookback() function call


Example
NoOfUnitsPositionCallPutUnderlyingSminSmaxXTimeRateBVolPREMIUM
1LONGCall951099696387340.108500.218913.7733
1LONGCall909494107387340.108100.19232.39224
1LONGCall105109105113387340.107100.21669.57488
1LONGCall1049899101387340.105600.187417.0932
1LONGCall1099610396387340.097300.191127.7401
1LONGCall1109799109387340.099500.209117.1067
1LONGCall107107101103387340.104900.215220.2762
1LONGCall101103105104387340.10100.214412.6096
1LONGCall93106103111387340.109800.21183.07033
1LONGCall9598106105387340.090800.21216.79152
1LONGCall99100103103387340.109200.18119.66919
1LONGCall10910391102387340.098700.202122.9463
1LONGCall9110094104387340.109500.20244.32071
1LONGCall10410198100387340.098500.189318.105
1LONGCall10910296115387340.091500.212710.9104
1LONGCall9392109101387340.100900.188110.2993
1LONGCall979295111387340.101100.21254.85701
1LONGCall100979697387340.094100.184316.1078
1LONGCall107105109105387340.098700.201617.1772
1LONGCall100100100105387340.100.29.86775



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