Hedging with Constrained Portfolios
Overview
Both hedging functions cast the optimization as a constrained linear least-squares problem.
(See the function lsqlin
for details.) In particular, lsqlin
attempts to minimize the constrained linear least squares problem
where C, A, and Aeq are matrices, and d, b, beq, lb, and ub are vectors. For Financial Instruments Toolbox™ software, x is a vector of asset holdings (contracts).
Depending on the constraint and the number of assets in the portfolio, a solution to a particular problem may or may not exist. Furthermore, if a solution is found, it may not be unique. For a unique solution to exist, the least squares problem must be sufficiently and appropriately constrained.
Fully Hedged Portfolio
This example shows how to use hedgeopt
to allocate an optimal hedge.
hedgeopt
allows you to allocate an optimal hedge by one of two goals:
Minimize the cost of hedging a portfolio given a set of target sensitivities.
Minimize portfolio sensitivities for a given set of maximum target costs.
Load the example portfolio and use crrsens
to compute the price and sensitivities.
load deriv.mat format bank [Delta, Gamma, Vega, Price] = crrsens(CRRTree, CRRInstSet);
Extract the current portfolio holdings.
Holdings = instget(CRRInstSet, 'FieldName', 'Quantity');
For convenience place the delta, gamma, and vega sensitivity measures into a matrix of sensitivities.
Sensitivities = [Delta Gamma Vega]
Sensitivities = 8×3
0.59 0.04 53.45
-0.31 0.03 67.00
0.69 0.03 67.00
-0.12 -0.01 -98.08
-0.40 -45926.32 88.18
-0.42 -112143.15 119.19
0.60 45926.32 49.21
0.82 112143.15 41.71
Each row of the Sensitivities
matrix is associated with a different instrument in the portfolio, and each column with a different sensitivity measure.
To summarize the portfolio information:
disp([Price Holdings Sensitivities])
8.29 10.00 0.59 0.04 53.45 2.50 5.00 -0.31 0.03 67.00 12.13 1.00 0.69 0.03 67.00 3.32 3.00 -0.12 -0.01 -98.08 7.60 7.00 -0.40 -45926.32 88.18 11.78 9.00 -0.42 -112143.15 119.19 4.18 4.00 0.60 45926.32 49.21 3.42 6.00 0.82 112143.15 41.71
Find the fully hedged portfolio using hedgeopt
.
TargetSens = [0 0 0]; FixedInd = [1 4 5 7 8]; [Sens,Cost,Quantity] = hedgeopt(Sensitivities, Price, ... Holdings, FixedInd, [], [], TargetSens)
Sens = 1×3
-0.00 0 -0.00
Cost = 306.38
Quantity = 1×8
10.00 -11.13 -16.83 3.00 7.00 4.77 4.00 6.00
This example finds a unique solution at a cost of $306.38. The matrix C
(formed internally by hedgeopt
and passed to lsqlin
) is the asset Price
vector expressed as a row vector.
C = Price' == [98.72 97.53 0.05 98.72 100.55 6.28 0.05 3.69]; Value0 = Holdings' * Price
Value0 = 313.93
The vector d
is the current portfolio value Value0
= 313.93
. The example maintains, as closely as possible, a constant portfolio value subject to the specified constraints.
Additional Constraints
In the absence of any additional constraints, the least squares objective involves a single equation with eight unknowns. This is an under-determined system of equations. Because such systems generally have an infinite number of solutions, you need to specify additional constraints to achieve a solution with practical significance.
The additional constraints can come from two sources:
User-specified equality constraints
Target sensitivity equality constraints imposed by
hedgeopt
The example in Fully Hedged Portfolio specifies five equality constraints associated with
holding assets 1, 4, 5, 7, and 8 fixed. This reduces the number of unknowns from eight to
three, which is still an under-determined system. However, when combined with the first
goal of hedgeopt
, the equality constraints
associated with the target sensitivities in TargetSens
produce an
additional system of three equations with three unknowns. This additional system
guarantees that the weighted average of the delta, gamma, and vega of assets 2, 3, and 6,
together with the remaining assets held fixed, satisfy the overall portfolio target
sensitivity needs in TargetSens
.
Combining the least-squares objective equation with the three portfolio sensitivity equations provides an overall system of four equations with three unknown asset holdings. This is no longer an under-determined system, and the solution is as shown.
If the assets held fixed are reduced, for example, FixedInd
= [1 4 5 7]
, hedgeopt
returns
a no cost, fully hedged portfolio (Sens = [0 0 0]
and Cost
= 0
).
If you further reduce FixedInd
(for example, [1
4 5]
, [1 4]
, or even []
), hedgeopt
always returns a no cost, fully
hedged portfolio. In these cases, insufficient constraints result
in an under-determined system. Although hedgeopt
identifies
no cost, fully hedged portfolios, there is nothing unique about them.
These portfolios have little practical significance.
Constraints must be sufficient and appropriately defined. Additional constraints having no effect on the optimization are called dependent constraints. As a simple example, assume that parameter Z is constrained such that . Furthermore, assume that you somehow add another constraint that effectively restricts . The constraint now has no effect on the optimization.
Minimize Portfolio Sensitivities
This example shows how to use hedgeopt
to minimize portfolio sensitivities for a given maximum target cost.
Load the example portfolio and use crrsens
to compute the price and sensitivities.
load deriv.mat format bank [Delta, Gamma, Vega, Price] = crrsens(CRRTree, CRRInstSet);
Extract the current portfolio holdings.
Holdings = instget(CRRInstSet, 'FieldName', 'Quantity');
For convenience place the delta, gamma, and vega sensitivity measures into a matrix of sensitivities.
Sensitivities = [Delta Gamma Vega]
Sensitivities = 8×3
0.59 0.04 53.45
-0.31 0.03 67.00
0.69 0.03 67.00
-0.12 -0.01 -98.08
-0.40 -45926.32 88.18
-0.42 -112143.15 119.19
0.60 45926.32 49.21
0.82 112143.15 41.71
Each row of the Sensitivities
matrix is associated with a different instrument in the portfolio, and each column with a different sensitivity measure.
To summarize the portfolio information:
disp([Price Holdings Sensitivities])
8.29 10.00 0.59 0.04 53.45 2.50 5.00 -0.31 0.03 67.00 12.13 1.00 0.69 0.03 67.00 3.32 3.00 -0.12 -0.01 -98.08 7.60 7.00 -0.40 -45926.32 88.18 11.78 9.00 -0.42 -112143.15 119.19 4.18 4.00 0.60 45926.32 49.21 3.42 6.00 0.82 112143.15 41.71
Specify a target cost of $20,000 and determine the new portfolio sensitivities, holdings, and cost of the rebalanced portfolio using hedgeopt
.
MaxCost = 20000; [Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price, ... Holdings, [1 4 5 7 8], [], MaxCost)
Sens = 1×3
-0.00 0 0.00
Cost = 306.38
Quantity = 1×8
10.00 -11.13 -16.83 3.00 7.00 4.77 4.00 6.00
When minimizing sensitivities, the maximum target cost is treated as an inequality constraint; in this case, MaxCost
is the most you are willing to spend to hedge a portfolio. The least-squares objective matrix C
is the matrix transpose of the input asset sensitivities.
C = Sensitivities'
C = 3×8
0.59 -0.31 0.69 -0.12 -0.40 -0.42 0.60 0.82
0.04 0.03 0.03 -0.01 -45926.32 -112143.15 45926.32 112143.15
53.45 67.00 67.00 -98.08 88.18 119.19 49.21 41.71
This is a 3
-by-8
matrix in this example, and d
is a 3
-by-1
column vector of zeros, [0 0 0]'
.
Without any additional constraints, the least-squares objective results in an under-determined system of three equations with eight unknowns. By holding assets 1, 4, 5, 7, and 8 fixed, you reduce the number of unknowns from eight to three. Now, with a system of three equations with three unknowns, hedgeopt
finds the solution shown.
Under-Determined System
This example shows how to use hedgeopt
to reduce the number of assets held fixed to then create an under-determined system with meaningless solutions.
Load the example portfolio and use crrsens
to compute the price and sensitivities.
load deriv.mat format bank [Delta, Gamma, Vega, Price] = crrsens(CRRTree, CRRInstSet);
Extract the current portfolio holdings.
Holdings = instget(CRRInstSet, 'FieldName', 'Quantity');
For convenience place the delta, gamma, and vega sensitivity measures into a matrix of sensitivities.
Sensitivities = [Delta Gamma Vega]
Sensitivities = 8×3
0.59 0.04 53.45
-0.31 0.03 67.00
0.69 0.03 67.00
-0.12 -0.01 -98.08
-0.40 -45926.32 88.18
-0.42 -112143.15 119.19
0.60 45926.32 49.21
0.82 112143.15 41.71
Each row of the Sensitivities
matrix is associated with a different instrument in the portfolio, and each column with a different sensitivity measure.
To summarize the portfolio information:
disp([Price Holdings Sensitivities])
8.29 10.00 0.59 0.04 53.45 2.50 5.00 -0.31 0.03 67.00 12.13 1.00 0.69 0.03 67.00 3.32 3.00 -0.12 -0.01 -98.08 7.60 7.00 -0.40 -45926.32 88.18 11.78 9.00 -0.42 -112143.15 119.19 4.18 4.00 0.60 45926.32 49.21 3.42 6.00 0.82 112143.15 41.71
Use hedgeopt
with only four assets constrained.
MaxCost = 20000; FixedInd = [1 4 5 7]; [Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price, ... Holdings, FixedInd, [], MaxCost)
Sens = 1×3
0.00 -0.00 0.00
Cost = 0
Quantity = 1×8
10.00 414.44 372.12 3.00 7.00 -334.43 4.00 -333.20
You have spent $20,000 (all the funds available for rebalancing) to achieve a fully hedged portfolio.
With an increase in available funds to $50,000, you still spend all available funds to get another fully hedged portfolio.
MaxCost = 50000; [Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price, ... Holdings, FixedInd, [], MaxCost)
Sens = 1×3
0.00 0.00 0.00
Cost = 0
Quantity = 1×8
10.00 301.47 268.87 3.00 7.00 -244.39 4.00 -243.16
All solutions to an under-determined system are meaningless. You buy and sell various assets to obtain zero sensitivities, spending all available funds every time. If you reduce the number of fixed assets any further, this problem is insufficiently constrained.
Note also that no solution exists whenever constraints are inconsistent. Inconsistent constraints create an infeasible solution space.
Portfolio Constraints with hedgeslf
This example shows how to use the hedging function hedgeslf
to minimize portfolio sensitivities such that the rebalanced portfolio maintains a constant value (the rebalanced portfolio is hedged against market moves and is closest to being self-financing). If a self-financing hedge is not found, hedgeslf
tries to rebalance a portfolio to minimize sensitivities.
From a least-squares systems approach, hedgeslf
first attempts to minimize cost in the same way that hedgeopt
does. If it cannot solve this problem (a no cost, self-financing hedge is not possible), hedgeslf
proceeds to minimize sensitivities like hedgeopt
. Thus, the discussion of constraints for hedgeopt
is directly applicable to hedgeslf
as well.
To illustrate this hedging facility using equity exotic options, consider the portfolio CRRInstSet
obtained from the MAT-file deriv.mat
. The portfolio consists of eight option instruments: two stock options, one barrier, one compound, two lookback, and two Asian. The hedging functions require inputs that include the current portfolio holdings (allocations) and a matrix of instrument sensitivities. To create these inputs, start by loading the example portfolio into memory.
load deriv.mat;
Compute the prices and sensitivities of the instruments in this portfolio.
[Delta, Gamma, Vega, Price] = crrsens(CRRTree, CRRInstSet);
Extract the current portfolio holdings (the quantity held or the number of contracts).
Holdings = instget(CRRInstSet, 'FieldName', 'Quantity');
For convenience place the delta, gamma, and vega sensitivity measures into a matrix of sensitivities.
Sensitivities = [Delta Gamma Vega];
Each row of the Sensitivities
matrix is associated with a different instrument in the portfolio and each column with a different sensitivity measure.
disp([Price Holdings Sensitivities])
1.0e+05 * 0.0001 0.0001 0.0000 0.0000 0.0005 0.0000 0.0001 -0.0000 0.0000 0.0007 0.0001 0.0000 0.0000 0.0000 0.0007 0.0000 0.0000 -0.0000 -0.0000 -0.0010 0.0001 0.0001 -0.0000 -0.4593 0.0009 0.0001 0.0001 -0.0000 -1.1214 0.0012 0.0000 0.0000 0.0000 0.4593 0.0005 0.0000 0.0001 0.0000 1.1214 0.0004
The first column contains the dollar unit price of each instrument, the second contains the holdings of each instrument, and the third, fourth, and fifth columns contain the delta, gamma, and vega dollar sensitivities, respectively.
Suppose that you want to obtain a delta, gamma, and vega neutral portfolio using hedgeslf
.
[Sens, Value1, Quantity]= hedgeslf(Sensitivities, Price, ... Holdings)
Sens = 3×1
10-9 ×
0.0000
-0.4657
0.0005
Value1 = 313.9265
Quantity = 8×1
10.0000
9.1168
1.3338
25.2794
10.8976
1.1658
-2.7992
6.7751
hedgeslf
returns the portfolio dollar sensitivities (Sens
), the value of the rebalanced portfolio (Value1
) and the new allocation for each instrument (Quantity
). If Value0
and Value1
represent the portfolio value before and after rebalancing, respectively, you can verify the cost by comparing the portfolio values.
Value0= Holdings' * Price
Value0 = 313.9265
In this example, the portfolio is fully hedged (simultaneous delta, gamma, and vega neutrality) and self-financing (the values of the portfolio before and after balancing (Value0
and Value1
) are the same.
Suppose now that you want to place some upper and lower bounds on the individual instruments in your portfolio. By using function portcons
, you can specify these constraints, along with various general linear inequality constraints.
As an example, assume that, in addition to holding instrument 1 fixed as before, you want to bound the position of all instruments to within +/- 20 contracts (for each instrument, you cannot short or long more than 20 contracts). Applying these constraints disallows the current position in the fourth instrument (long 26.13). All other instruments are currently within the upper/lower bounds.
You can generate these constraints by first specifying the lower and upper bounds vectors and then calling portcons
.
LowerBounds = [-20 -20 -20 -20 -20 -20 -20 -20];
UpperBounds = [20 20 20 20 20 20 20 20];
ConSet = portcons('AssetLims', LowerBounds, UpperBounds);
To impose these constraints, call hedgeslf
with ConSet
as the last input.
[Sens, Cost, Quantity1] = hedgeslf(Sensitivities, Price, ... Holdings, 1, ConSet)
Sens = 3×1
10-8 ×
0.0000
0.9080
0.0000
Cost = 313.9265
Quantity1 = 8×1
10.0000
12.2248
15.3827
19.9909
18.1621
-10.9603
-17.7956
3.7655
Observe that hedgeslf
enforces the upper bound on the fourth instrument, and the portfolio continues to be fully hedged and self-financing.
See Also
Topics
- Portfolio Creation Using Functions
- Adding Instruments to an Existing Portfolio Using Functions
- Instrument Constructors
- Creating Instruments or Properties
- Searching or Subsetting a Portfolio
- Pricing a Portfolio Using the Black-Derman-Toy Model
- Pricing and Hedging a Portfolio Using the Black-Karasinski Model
- Specifying Constraints with ConSet
- Portfolio Rebalancing
- Instrument Constructors
- Hedging