Both `hedgeopt`

and `hedgeslf`

accept an optional input argument, `ConSet`

,
that allows you to specify a set of linear inequality constraints
for instruments in your portfolio. The examples in this section are
brief. For additional information regarding portfolio constraint specifications,
refer to Analyzing Portfolios.

For the first example of setting constraints, return to the
fully hedged portfolio example that used `hedgeopt`

to
determine the minimum cost of obtaining simultaneous delta, gamma,
and vega neutrality (target sensitivities all `0`

).
Recall that when `hedgeopt`

computes
the cost of rebalancing a portfolio, the input target sensitivities
you specify are treated as equality constraints during the optimization
process. The situation is reproduced next for convenience.

TargetSens = [0 0 0]; [Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,... Holdings, FixedInd, [], [], TargetSens);

The outputs provide a fully hedged portfolio

Sens = -0.00 -0.00 -0.00

at an expense of over $23,000.

Cost = 23055.90

The positions required to achieve this fully hedged portfolio are

Quantity' = 100.00 -182.36 -19.55 80.00 8.00 -32.97 40.00 10.00

Suppose now that you want to place some upper and lower bounds
on the individual instruments in your portfolio. You can specify these
constraints, along with a variety of general linear inequality constraints,
with Financial Toolbox™ function `portcons`

.

As an example, assume that, in addition to holding instruments 1, 4, 5, 7, and 8 fixed as before, you want to bound the position of all instruments to within +/- 180 contracts (for each instrument, you cannot short or long more than 180 contracts). Applying these constraints disallows the current position in the second instrument (short 182.36). 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 = [-180 -180 -180 -180 -180 -180 -180 -180];
UpperBounds = [ 180 180 180 180 180 180 180 180];
ConSet = portcons('AssetLims', LowerBounds, UpperBounds);
```

To impose these constraints, call `hedgeopt`

with `ConSet`

as
the last input.

[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,... Holdings, FixedInd, [], [], TargetSens, ConSet);

Examine the outputs and see that they are all set to `NaN`

,
indicating that the problem, given the constraints, is not solvable.
Intuitively, the results mean that you cannot obtain simultaneous
delta, gamma, and vega neutrality with these constraints at any price.

To see how close you can get to portfolio neutrality with these
constraints, call `hedgeslf`

.

[Sens, Value1, Quantity] = hedgeslf(Sensitivities, Price,... Holdings, FixedInd, ConSet);

Sens = -352.43 21.99 -498.77 Value1 = 855.10 Quantity = 100.00 -180.00 -37.22 80.00 8.00 -31.86 40.00 10.00

`hedgeslf`

enforces the
lower bound for the second instrument, but the sensitivity is far
from neutral. The cost to obtain this portfolio is

Value0 - Value1

ans = 22819.52

As a final example of user-specified constraints, rebalance
the portfolio using the second hedging goal of `hedgeopt`

. Assume that you are willing
to spend as much as $20,000 to rebalance your portfolio, and you want
to know what minimum portfolio sensitivities you can get for your money.
In this form, recall that the target cost ($20,000) is treated as
an inequality constraint during the optimization process.

For reference, start up `hedgeopt`

without
any user-specified linear inequality constraints.

[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,... Holdings, FixedInd, [], 20000);

Sens = -4345.36 295.81 -6586.64 Cost = 20000.00 Quantity' = 100.00 -151.86 -253.47 80.00 8.00 -18.18 40.00 10.00

This result corresponds to the $20,000 point along the Portfolio Sensitivities Profile shown in the figure Rebalancing Cost.

Assume that, in addition to holding instruments 1, 4, 5, 7, and 8 fixed as before, you want to bound the position of all instruments to within +/- 150 contracts (for each instrument, you cannot short more than 150 contracts and you cannot long more than 150 contracts). These bounds disallow the current position in the second and third instruments (-151.86 and -253.47). All other instruments are currently within the upper/lower bounds.

As before, you can generate these constraints by first specifying
the lower and upper bounds vectors and then calling `portcons`

.

```
LowerBounds = [-150 -150 -150 -150 -150 -150 -150 -150];
UpperBounds = [ 150 150 150 150 150 150 150 150];
ConSet = portcons('AssetLims', LowerBounds, UpperBounds);
```

To impose these constraints, again call `hedgeopt`

with `ConSet`

as
the last input.

[Sens, Cost, Quantity] = hedgeopt(Sensitivities, Price,... Holdings,FixedInd, [], 20000, [], ConSet);

Sens = -8818.47 434.43 -4010.79 Cost = 19876.89 Quantity' = 100.00 -150.00 -150.00 80.00 8.00 -28.32 40.00 10.00

With these constraints, `hedgeopt`

enforces
the lower bound for the second and third instruments. The cost incurred
is $19,876.89.

Was this topic helpful?