Main Content

hedgeopt

Allocate optimal hedge for target costs or sensitivities

Description

[PortSens,PortCost,PortHolds] = hedgeopt(Sensitivities,Price,CurrentHolds) allocates an optimal hedge by one of two criteria:

  • Minimize portfolio sensitivities (exposure) for a given set of target costs.

  • Minimize the cost of hedging a portfolio given a set of target sensitivities.

Hedging involves the fundamental tradeoff between portfolio insurance and the cost of insurance coverage. This function lets investors modify portfolio allocations among instruments to achieve either of the criteria. The chosen criterion is inferred from the input argument list. The problem is cast as a constrained linear least-squares problem.

example

[PortSens,PortCost,PortHolds] = hedgeopt(___,FixedInd,NumCosts,TargetCost,TargetSensConSet) adds additional optional arguments.

example

Examples

collapse all

To illustrate the hedging facility, consider the portfolio HJMInstSet obtained from the example file deriv.mat. The portfolio consists of eight instruments: two bonds, one bond option, one fixed-rate note, one floating-rate note, one cap, one floor, and one swap.

In this examples, portfolio target sensitivities are treated as equality constraints during the optimization process. You can use hedgeopt to specify what sensitivities you want, and hedgeopt computes what it will cost to get those sensitivities.

load deriv.mat;

Compute the price and sensitivities

warning('off')
[Delta, Gamma, Vega, Price] = hjmsens(HJMTree, HJMInstSet)
Delta = 8×1

 -272.6462
 -347.4315
   -8.0781
 -272.6462
   -1.0445
  294.9700
  -47.1629
 -282.0465

Gamma = 8×1
103 ×

    1.0299
    1.6227
    0.6434
    1.0299
    0.0033
    6.8526
    8.4600
    1.0597

Vega = 8×1

    0.0000
   -0.0397
   34.0746
    0.0000
         0
   93.6946
   93.6946
    0.0000

Price = 8×1

   98.7159
   97.5280
    0.0486
   98.7159
  100.5529
    6.2831
    0.0486
    3.6923

Extract the current portfolio holdings.

warning('on')
Holdings = instget(HJMInstSet, 'FieldName', 'Quantity')
Holdings = 8×1

   100
    50
   -50
    80
     8
    30
    40
    10

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.

Summarize the portfolio information.

disp([Price  Holdings  Sensitivities])
   1.0e+03 *

    0.0987    0.1000   -0.2726    1.0299    0.0000
    0.0975    0.0500   -0.3474    1.6227   -0.0000
    0.0000   -0.0500   -0.0081    0.6434    0.0341
    0.0987    0.0800   -0.2726    1.0299    0.0000
    0.1006    0.0080   -0.0010    0.0033         0
    0.0063    0.0300    0.2950    6.8526    0.0937
    0.0000    0.0400   -0.0472    8.4600    0.0937
    0.0037    0.0100   -0.2820    1.0597    0.0000

The first column above is the dollar unit price of each instrument, the second is the holdings of each instrument (the quantity held or the number of contracts), and the third, fourth, and fifth columns are the dollar delta, gamma, and vega sensitivities, respectively.

The current portfolio sensitivities are a weighted average of the instruments in the portfolio.

TargetSens  = Holdings' * Sensitivities
TargetSens = 1×3
105 ×

   -0.6191    7.8895    0.0485

Maintaining Existing Allocations

To illustrate using hedgeopt, suppose that you want to maintain your existing portfolio. hedgeopt minimizes the cost of hedging a portfolio given a set of target sensitivities. If you want to maintain your existing portfolio composition and exposure, you should be able to do so without spending any money. To verify this, set the target sensitivities to the current sensitivities.

FixedInd = [1 2 3 4 5 6 7 8];
[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,Holdings, FixedInd, [], [], TargetSens)
Sens = 1×3
105 ×

   -0.6191    7.8895    0.0485

Cost = 0
Quantity = 1×8

   100    50   -50    80     8    30    40    10

Portfolio composition and sensitivities are unchanged, and the cost associated with doing nothing is zero. The cost is defined as the change in portfolio value. This number cannot be less than zero because the rebalancing cost is defined as a nonnegative number.

If Value0 and Value1 represent the portfolio value before and after rebalancing, respectively, the zero cost can also be verified by comparing the portfolio values.

Value0 = Holdings' * Price
Value0 = 2.3675e+04
Value1 = Quantity * Price
Value1 = 2.3675e+04

Partially Hedged Portfolio

Building on this example, suppose you want to know the cost to achieve an overall portfolio dollar sensitivity of [-23000 -3300 3000], while allowing trading only in instruments 2, 3, and 6 (holding the positions of instruments 1, 4, 5, 7, and 8 fixed). To find the cost, first set the target portfolio dollar sensitivity.

TargetSens = [-23000 -3300 3000];

Specify the instruments to be fixed.

FixedInd = [1 4 5 7 8];

Use hedgeopt:

[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,Holdings, FixedInd, [], [], TargetSens)
Sens = 1×3
104 ×

   -2.3000   -0.3300    0.3000

Cost = 1.9174e+04
Quantity = 1×8

  100.0000 -141.0267  137.2638   80.0000    8.0000  -57.9606   40.0000   10.0000

Recompute Value1, the portfolio value after rebalancing.

Value1 = Quantity * Price
Value1 = 4.5006e+03

As expected, the cost, $19174.02, is the difference between Value0 and Value1, $23674.62 — $4500.60. Only the positions in instruments 2, 3, and 6 are changed.

Fully Hedged Portfolio

The example has illustrated a partial hedge, but perhaps the most interesting case involves the cost associated with a fully hedged portfolio (simultaneous delta, gamma, and vega neutrality). In this case, set the target sensitivity to a row vector of 0s and call hedgeopt again.

TargetSens = [0 0 0];
[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price, Holdings, FixedInd, [], [], TargetSens)
Sens = 1×3
10-10 ×

    0.1091    0.5821    0.0045

Cost = 2.3056e+04
Quantity = 1×8

  100.0000 -182.3615  -19.5501   80.0000    8.0000  -32.9674   40.0000   10.0000

Examining the outputs reveals that you have obtained a fully hedged portfolio but at an expense of over $20,000 and Quantity defines the positions required to achieve a fully hedged portfolio.

The resulting new portfolio value is

Value1 = Quantity * Price
Value1 = 618.7168

Input Arguments

collapse all

Sensitivities of each instrument, specified as a number of instruments (NINST) by number of sensitivities (NSENS) matrix of dollar sensitivities. Each row represents a different instrument. Each column represents a different sensitivity.

Data Types: double

Instrument prices, specified as an NINST-by-1 vector.

Data Types: double

Contracts allocated to each instrument, specified as an NINST-by-1 vector.

Data Types: double

(Optional) Number of fixed instruments, specified as an NFIXED-by-1 vector of indices of instruments to hold fixed. For example, to hold the first and third instruments of a 10 instrument portfolio unchanged, set FixedInd = [1 3]. Default = [], no instruments held fixed.

Data Types: double

(Optional) Number of points generated along the cost frontier when a vector of target costs (TargetCost) is not defined, specified as an integer. The default is 10 equally spaced points between the point of minimum cost and the point of minimum exposure. When specifying TargetCost, enter NumCosts as an empty matrix [].

Data Types: double

(Optional) Target cost values along the cost frontier, specified as a vector. If TargetCost is empty, or not entered, hedgeopt evaluates NumCosts equally spaced target costs between the minimum cost and minimum exposure. When specified, the elements of TargetCost should be positive numbers that represent the maximum amount of money the owner is willing to spend to rebalance the portfolio.

Data Types: double

(Optional) Target sensitivity values of the portfolio, specified as a 1-by-NSENS vector containing the target sensitivity values of the portfolio. When specifying TargetSens, enter NumCosts and TargetCost as empty matrices [].

Data Types: double

(Optional) Additional conditions on the portfolio reallocations, specified as a number of constraints (NCONS) by number of instruments (NINST) matrix of additional conditions on the portfolio reallocations. An eligible NINST-by-1 vector of contract holdings, PortWts, satisfies all the inequalities A*PortWts <= b, where A = ConSet(:,1:end-1) and b = ConSet(:,end).

Note

The user-specified constraints included in ConSet may be created with the functions pcalims or portcons. However, the portcons default PortHolds positivity constraints are typically inappropriate for hedging problems since short-selling is usually required.

NPOINTS, the number of rows in PortSens and PortHolds and the length of PortCost , is inferred from the inputs. When the target sensitivities, TargetSens, is entered, NPOINTS = 1; otherwise NPOINTS = NumCosts, or is equal to the length of the TargetCost vector.

Not all problems are solvable (for example, the solution space may be infeasible or unbounded, or the solution may fail to converge). When a valid solution is not found, the corresponding rows of PortSens, PortHolds, and the elements of PortCost are padded with NaNs as placeholders.

Data Types: double

Output Arguments

collapse all

Portfolio dollar sensitivities, returned as a number of points (NPOINTS-by-NSENS) matrix. When a perfect hedge exists, PortSens is zeros. Otherwise, the best hedge possible is chosen.

Note

Not all problems are solvable (for example, the solution space may be infeasible, unbounded, or insufficiently constrained), or the solution may fail to converge. When a valid solution is not found, the corresponding rows of PortSens and PortHolds and elements of PortCost are padded with NaN's as placeholders. In addition, the solution may not be unique.

Total portfolio costs, returned as a 1-by-NPOINTS vector.

Contracts allocated to each instrument, returned as an NPOINTS-by-NINST matrix. These are the reallocated portfolios.

Version History

Introduced before R2006a