## Hedging Class CallHedgeStatisticsGraphs

```java.lang.Object
Hedging.CallHedgeStatisticsGraphs
```

public class CallHedgeStatisticsGraphs
extends java.lang.Object

European calls on a constant volatility asset are hedged and the mean and standard deviation of the hedge profit and loss computed as a function of the strike price K and or the volatility hedge_sigma employed in computing the hedge weights. The hedge is rebalanced at each time step.

These functions are sampled (computed) at evenly spaced points K respectively hedge_sigma in their respective domains. The values are reported as a percentage of the Black Scholes call price.

This class provides methods to compute these functions as arrays and to graph them with graphs either displayed in a window or saved as a jpeg file.

Various hedge deltas can be specified:

• analytic deltas (if analytic option price defined)
• analytic minimum variance deltas
• analytic quotient deltas

Both Analytic minimum variance deltas and analytic quotient deltas are computed under the market probability.

Transaction costs have a fixed and a proportional component. The fixed component also has to be normalized to cost per share. If you transact in lots of 1000 shares and such a trade costs 10 dollars, fixed transaction costs are 10/1000=0.01. The proportional transaction costs come from bid-ask spread etc., 0.1 is a conservative number. Transaction costs are assumed to remain constant in today's dollars.

 Constructor Summary ```CallHedgeStatisticsGraphs(ConstantVolatilityAsset asset, int nPaths, int nBranch, int nPoints, javax.swing.JProgressBar jPrgBar, int reportFrequency)```

 Method Summary ` double[][]` ```functionOfStrike(double K_min, double K_max, double fixed_trc, double prop_trc)```           Call hedge mean and standard deviation as functions of the call strike. ` void` ```graphFunctionOfHedgeVolatility(double K, double vol_min, double vol_max, double fixed_trc, double prop_trc)```           For a fixed strike K the call is hedged with analytic deltas computed using a volatility vol which may be different from the true volatility sigma of the underlying. ` void` ```graphFunctionOfStrikeAllDeltas(double K_min, double K_max, boolean minimum_variance_deltas, boolean quotient_deltas, double fixed_trc, double prop_trc)```           Computes the mean and standard deviation of the hedge profit/loss of hedging a call over nPath paths using various hedge deltas. `static void` `main(java.lang.String[] args)`           Test program testing graphFunctionOfStrikeAllDeltas on analytic deltas.

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

### CallHedgeStatisticsGraphs

```public CallHedgeStatisticsGraphs(ConstantVolatilityAsset asset,
int nPaths,
int nBranch,
int nPoints,
javax.swing.JProgressBar jPrgBar,
int reportFrequency)```
Parameters:
`asset` - underlying asset.
`nPaths` - number of asset price paths simulated.
`nBranch` - number of path branches for each conditional expectation.
`nPoints` - number of evenly spaced points in function domain.
`jPrgBar` - target of progress report.
`reportFrequency` - number of paths between progress report updates.
 Method Detail

### functionOfStrike

```public double[][] functionOfStrike(double K_min,
double K_max,
double fixed_trc,
double prop_trc)```

Call hedge mean and standard deviation as functions of the call strike.

Let f(K)=(mean, standardDeviation) of the delta hedge for the call with strike price K using analytic deltas. The function f is sampled at nPoints points

K_i=K_min+i*(K_max-K_min)/n, i=0,1,...,n=nPoints-1,

evenly spaced between K_min and K_max inclusively. Mean and standard deviation are omputed over a sample of nPaths paths of the underlying simulated under the market probability.

The hedge is rebalanced at each time step. The volatility used in computing the hedge deltas is the true volatility of the underlying and transaction costs are allowed.

Returns an array double[][] with return_value[0][i]=mean(K[i]) and return_value[1][i]=standardDeviation(K[i]).

Parameters:
`K_min` - minimum strike.
`K_max` - maximum strike.
`fixed_trc` - fixed transaction costs (normalized to one share).
`prop_trc` - proportional transaction costs.

### graphFunctionOfHedgeVolatility

```public void graphFunctionOfHedgeVolatility(double K,
double vol_min,
double vol_max,
double fixed_trc,
double prop_trc)
throws java.io.FileNotFoundException,
java.io.IOException```

For a fixed strike K the call is hedged with analytic deltas computed using a volatility vol which may be different from the true volatility sigma of the underlying. The hedge is rebalanced at each time step and transaction costs are allowed.

The mean and standard deviation of the call hedge are computed as a function of this volatility for nPoints points vol

vol_i=vol_min+i*(vol_max-vol_min), i=0,...,nPoints-1.

used in computing the analytic deltas. Mean and standard deviation are computed over a sample of nPaths paths of the underlying simulated under the market probability.

The resulting functions are graphed, the graphs displayed and saved as jpeg files.

Parameters:
`K` - call strike.
`vol_min` - minimum hedge volatility.
`vol_max` - maximum hedge volatility.
`fixed_trc` - fixed transaction costs (normalized to one share).
`prop_trc` - proportional transaction costs.
Throws:
`java.io.FileNotFoundException`
`java.io.IOException`

### graphFunctionOfStrikeAllDeltas

```public void graphFunctionOfStrikeAllDeltas(double K_min,
double K_max,
boolean minimum_variance_deltas,
boolean quotient_deltas,
double fixed_trc,
double prop_trc)
throws java.io.FileNotFoundException,
java.io.IOException```

Computes the mean and standard deviation of the hedge profit/loss of hedging a call over nPath paths using various hedge deltas. The hedge is rebalanced at each time step and transaction costs are allowed.

The boolean flags minimum_variance_deltas, monte_carlo_deltas, control for which hedge deltas the computation is carried out (analytic deltas are always used). As a default the deltas arecomputed from the risk neutral probability. The boolean flag market_probability_also controls wether the computation is carried out for deltas computed under the market probability also.

The mean and standard deviation are computed as functions of the strike price K for nPoints evenly spaced points K between K_min,K_max and paths of the underlying are simulated under the market probability. The parameter nBranch gives the number of path branches spent on each conditional expectation.

Such conditional expectations are computed at each rebalancing of the hedge for each delta except analytic deltas. Consequently he computation is massive and can easily take hours. Turn on only flags you are really interested in. Analytic deltas alone are quite fast.

The results are then charted in two separate charts means/standard deviations which are both displayed and saved as jpeg files.

WARNING: each branch simulation destroys an existing price path of the underlying from the time of branching forward. Such simulations occur whenever a conditional expectation is computed, that is, in the computation of nonanalytic hedge deltas. Consequently we cannot simply compute a full path of the underlying and then move the hedge along this path. Instead we evolve the path simultaneous with the hedge in single time steps.

Parameters:
`K_min` - minimum strike
`K_max` - maximum strike
`minimum_variance_deltas` - include or not
`quotient_deltas` - include or not
`fixed_trc` - fixed transaction costs (normalized to one share).
`prop_trc` - proportional transaction costs.
Throws:
`java.io.FileNotFoundException`
`java.io.IOException`

### main

```public static void main(java.lang.String[] args)
throws java.io.FileNotFoundException,
java.io.IOException```
Test program testing graphFunctionOfStrikeAllDeltas on analytic deltas.

Throws:
`java.io.FileNotFoundException`
`java.io.IOException`