RSKSpreadApproximation





http://www.QuantTools.com
CapeTools Bump Risk function list

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

Key TAGs | Excel Index | API Index



European call spread option on two futures contracts is max(F1-F2-X,0), European put spread option on two futures contracts is max(X-F1+F2,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 bumps an input parameter given a bump map and displays the difference from the base value.

You can request to see the difference of any of the option greeks.

The name of the parameter that you wish to bump is simply entered into the 'BumpParam' string parameter.

The bump map can be a single value, a vector or a matrix input.



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




High level graphic of RSKSpreadApproximation() 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. BumpRange parameter

    A range of bump values, of which the chosen input will be bumped by. For Equity, FX type deals, you can provide a single value, vector or matrix, for interest rate type products, the bump range must be of the same shape as the market curve.
  4. BumpParam parameter

    The parameter in which will be bumped, you can only choose parameters in which the ranges normally take double (decimal) values.
  5. CallPut parameter

    Option Types (C)all or (P)ut
  6. F1 parameter

    Futures price of the first underlying
  7. F2 parameter

    Futures price of the second underlying
  8. Strike parameter

    Option strike price.
  9. Time parameter

    Time to expiration of the option.
  10. 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.
  11. Vol1 parameter

    Volatility of the underlying dF1.
  12. Vol2 parameter

    Volatility of the underlying dF2.
  13. Rho parameter

    Correlation between the two assets.
  14. Greek parameter

    For the option premium specify 'PREMIUM'. For all first derivatives, you can specify one of the following : 'dF1' (for the 'F1' parameter), 'dF2' (for the 'F2' parameter), 'dStrike' (for the 'Strike' parameter), 'dTime' (for the 'Time' parameter), 'dRate' (for the 'Rate' parameter), 'dVol1' (for the 'Vol1' parameter), 'dVol2' (for the 'Vol2' parameter), 'dRho' (for the 'Rho' parameter), For second order derivatives, you can specify combinations of the first order derivatives (i.e. - 'dF1dF1', 'dVol1dVol1', 'dF1dVol1'. )


Extended information

Function Syntax

VB Syntax


Variant CTBumpRisk.RSKSpreadApproximation( _
Long ValueDate, _
DayCountEnum dayCounter, _
Variant BumpRange, _
String BumpParam, _
Variant CallPut, _
Variant F1, _
Variant F2, _
Variant Strike, _
Variant Time, _
Variant Rate, _
Variant Vol1, _
Variant Vol2, _
Variant Rho, _
String Greek)


Excel Spreadsheet Syntax


=CT.RSKSpreadApproximation(
Excel Numeric Cell ValueDate,
Excel String Cell dayCounter,
XLRange BumpRange,
Excel String Cell BumpParam,
XLRange CallPut,
XLRange F1,
XLRange F2,
XLRange Strike,
XLRange Time,
XLRange Rate,
XLRange Vol1,
XLRange Vol2,
XLRange Rho,
Excel String Cell Greek)


C++ Syntax


static CTRangeDataCPP RSKSpreadApproximation(
long ValueDate,
DayCountEnum dayCounter,
CTRangeDataCPP BumpRange,
std::string BumpParam,
CTRangeDataCPP CallPut,
CTRangeDataCPP F1,
CTRangeDataCPP F2,
CTRangeDataCPP Strike,
CTRangeDataCPP Time,
CTRangeDataCPP Rate,
CTRangeDataCPP Vol1,
CTRangeDataCPP Vol2,
CTRangeDataCPP Rho,
std::string Greek);


DotNET Syntax


CTRangeData CTBumpRiskSA.RSKSpreadApproximation(
System.Int32 ValueDate,
CTIEnums.DayCountEnum dayCounter,
CTRangeData BumpRange,
System.String BumpParam,
CTRangeData CallPut,
CTRangeData F1,
CTRangeData F2,
CTRangeData Strike,
CTRangeData Time,
CTRangeData Rate,
CTRangeData Vol1,
CTRangeData Vol2,
CTRangeData Rho,
System.String Greek);

Parameter data types

ArgNameArgTypeIsKey
ValueDateLongFALSE
dayCounterDayCountEnumFALSE
BumpRangeRangeFALSE
BumpParamStringFALSE
CallPutRangeFALSE
F1RangeFALSE
F2RangeFALSE
StrikeRangeFALSE
TimeRangeFALSE
RateRangeFALSE
Vol1RangeFALSE
Vol2RangeFALSE
RhoRangeFALSE
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
BumpRangeFALSERSKSpreadApproximation_BumpRange_Range (creates a range object)
BumpParamFALSEVol1
CallPutFALSERSKSpreadApproximation_CallPut_Range (creates a range object)
F1FALSERSKSpreadApproximation_F1_Range (creates a range object)
F2FALSERSKSpreadApproximation_F2_Range (creates a range object)
StrikeFALSERSKSpreadApproximation_Strike_Range (creates a range object)
TimeFALSERSKSpreadApproximation_Time_Range (creates a range object)
RateFALSERSKSpreadApproximation_Rate_Range (creates a range object)
Vol1FALSERSKSpreadApproximation_Vol1_Range (creates a range object)
Vol2FALSERSKSpreadApproximation_Vol2_Range (creates a range object)
RhoFALSERSKSpreadApproximation_Rho_Range (creates a range object)
GreekFALSEPREMIUM


Example range for parameter : BumpRange

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_BumpRange;


double[] arrBRSKSpreadApproximation_BumpRange = {
0.0186,
0.0185,
0.0217,
0.0215,
0.0205,
0.0206,
0.0217,
0.0203,
0.0212,
0.02,
0.0203,
0.0189,
0.019,
0.0189,
0.0193,
0.0194,
0.0216,
0.0198,
0.0195,
0.02  //  Array Data

};

CTQL.DoubleVector arrRSKSpreadApproximation_BumpRange =
new  CTQL.DoubleVector(arrBRSKSpreadApproximation_BumpRange);

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


string[] arrBRSKSpreadApproximation_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 arrRSKSpreadApproximation_CallPut =
new  CTQL.StringVector(arrBRSKSpreadApproximation_CallPut);

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


Example range for parameter : F1

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_F1;


int[] arrBRSKSpreadApproximation_F1 = {
26,
28,
26,
28,
31,
29,
26,
28,
26,
30,
29,
26,
30,
29,
26,
27,
31,
28,
26,
28  //  Array Data

};

CTQL.IntVector arrRSKSpreadApproximation_F1 =
new  CTQL.IntVector(arrBRSKSpreadApproximation_F1);

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


Example range for parameter : F2

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_F2;


int[] arrBRSKSpreadApproximation_F2 = {
19,
19,
22,
19,
20,
19,
20,
19,
18,
21,
22,
21,
21,
21,
21,
22,
18,
19,
20,
20  //  Array Data

};

CTQL.IntVector arrRSKSpreadApproximation_F2 =
new  CTQL.IntVector(arrBRSKSpreadApproximation_F2);

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


Example range for parameter : Strike

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_Strike;


int[] arrBRSKSpreadApproximation_Strike = {
7,
8,
7,
7,
6,
7,
7,
7,
7,
8,
7,
7,
7,
8,
7,
7,
7,
7,
7,
7  //  Array Data

};

CTQL.IntVector arrRSKSpreadApproximation_Strike =
new  CTQL.IntVector(arrBRSKSpreadApproximation_Strike);

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


int[] arrBRSKSpreadApproximation_Time = {
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy"),
CTQL.Date.serialNumber("18/10/2005", "dd/mm/yyyy")  //  Array Data

};

CTQL.IntVector arrRSKSpreadApproximation_Time =
new  CTQL.IntVector(arrBRSKSpreadApproximation_Time);

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


double[] arrBRSKSpreadApproximation_Rate = {
0.0496,
0.0533,
0.0528,
0.0465,
0.0459,
0.0458,
0.0534,
0.0535,
0.0515,
0.052,
0.0489,
0.0472,
0.052,
0.0476,
0.0527,
0.0456,
0.0493,
0.0504,
0.0525,
0.05  //  Array Data

};

CTQL.DoubleVector arrRSKSpreadApproximation_Rate =
new  CTQL.DoubleVector(arrBRSKSpreadApproximation_Rate);

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


Example range for parameter : Vol1

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_Vol1;


double[] arrBRSKSpreadApproximation_Vol1 = {
0.2622,
0.2725,
0.2797,
0.27,
0.2887,
0.3042,
0.2713,
0.2816,
0.3095,
0.2635,
0.2848,
0.292,
0.3142,
0.2722,
0.2625,
0.3041,
0.2832,
0.306,
0.2954,
0.29  //  Array Data

};

CTQL.DoubleVector arrRSKSpreadApproximation_Vol1 =
new  CTQL.DoubleVector(arrBRSKSpreadApproximation_Vol1);

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


Example range for parameter : Vol2

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_Vol2;


double[] arrBRSKSpreadApproximation_Vol2 = {
0.3912,
0.334,
0.3615,
0.3474,
0.3421,
0.388,
0.3532,
0.3607,
0.3548,
0.3536,
0.3912,
0.3881,
0.3694,
0.3251,
0.3768,
0.3889,
0.3687,
0.3406,
0.3803,
0.36  //  Array Data

};

CTQL.DoubleVector arrRSKSpreadApproximation_Vol2 =
new  CTQL.DoubleVector(arrBRSKSpreadApproximation_Vol2);

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


Example range for parameter : Rho

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


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

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



CTQL.CTRangeData RSKSpreadApproximation_Rho;


double[] arrBRSKSpreadApproximation_Rho = {
0.4477,
0.4146,
0.4612,
0.4529,
0.414,
0.4023,
0.439,
0.3813,
0.392,
0.4431,
0.4128,
0.4442,
0.4394,
0.4533,
0.4501,
0.4022,
0.4608,
0.3884,
0.4162,
0.42  //  Array Data

};

CTQL.DoubleVector arrRSKSpreadApproximation_Rho =
new  CTQL.DoubleVector(arrBRSKSpreadApproximation_Rho);

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


Example
0.0660101
0.0615955
0.0369909
0.0440269
0.0394858
0.0679495
0.0811329
0.060187
0.0637737
0.0631371
0.0483577
0.075142
0.0577269
0.0568867
0.0638066
0.0675331
0.0658669
0.0286679
0.0687246
0.0643101



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