Documentation Center 
Selffinancing hedge
[PortSens, PortValue, PortHolds]
= hedgeslf(Sensitivities,
Price, CurrentHolds, FixedInd,
ConSet)
Sensitivities  Number of instruments (NINST) by number of sensitivities (NSENS) matrix of dollar sensitivities of each instrument. Each row represents a different instrument. Each column represents a different sensitivity. 
NINSTby1 vector of instrument unit prices.  
CurrentHolds  NINSTby1 vector of contracts allocated in each instrument. 
FixedInd  (Optional) Empty or number of fixed instruments (NFIXED)by1 vector of indices of instruments to hold fixed. The default is FixedInd = 1; the holdings in the first instrument are held fixed. If NFIXED instruments will not be changed, enter all their locations in the portfolio in a vector. If no instruments are to be held fixed, enter FixedInd = []. 
ConSet  (Optional) Number of constraints (NCONS)byNINST matrix
of additional conditions on the portfolio reallocations. An eligible NINSTby1 vector
of contract holdings, PortHolds, satisfies all
the inequalities 
[PortSens, PortValue, PortHolds]
= hedgeslf(Sensitivities,
Price, CurrentHolds, FixedInd,
ConSet) allocates a selffinancing hedge among a collection
of instruments. hedgeslf finds the reallocation in a portfolio of
financial instruments that hedges the portfolio against market moves
and that is closest to being selffinancing (maintaining constant
portfolio value). By default the first instrument entered is hedged
with the other instruments.
PortSens is a 1byNSENS vector of portfolio dollar sensitivities. When a perfect hedge exists, PortSens is zeros. Otherwise, the best possible hedge is chosen.
PortValue is the total portfolio value (scalar). When a perfectly selffinancing hedge exists, PortValue is equal to dot(Price, CurrentWts) of the initial portfolio.
PortHolds is an NINSTby1 vector of contracts allocated to each instrument. This is the reallocated portfolio.
Notes

Example 1. Perfect sensitivity cannot be reached.
Sens = [0.44 0.32; 1.0 0.0]; Price = [1.2; 1.0]; W0 = [1; 1]; [PortSens, PortValue, PortHolds]= hedgeslf(Sens, Price, W0)
PortSens = 0.0000 0.3200 PortValue = 0.7600 PortHolds = 1.0000 0.4400
Example 2. Constraints are in conflict.
Sens = [0.44 0.32; 1.0 0.0]; Price = [1.2; 1.0]; W0 = [1; 1]; ConSet = pcalims([2 2]) % O.K. if nothing fixed. [PortSens, PortValue, PortHolds]= hedgeslf(Sens, Price, W0,... [], ConSet)
PortSens = 2.8800 0.6400 PortValue = 4.4000 PortHolds = 2 2
% W0(1) is not greater than 2. [PortSens, PortValue, PortHolds] = hedgeslf(Sens, Price, W0,... 1, ConSet)
??? Error using ==> hedgeslf Overly restrictive allocation constraints implied by ConSet and by fixing the weight of instruments(s): 1
Example 3. Constraints are impossible to meet.
Sens = [0.44 0.32; 1.0 0.0]; Price = [1.2; 1.0]; W0 = [1; 1]; ConSet = pcalims([2 2],[1 1]); [PortSens, PortValue, PortHolds] = hedgeslf(Sens, Price, W0,... [],ConSet)
??? Error using ==> hedgeslf Overly restrictive allocation constraints specified in ConSet