### Heston stochastic volatility model- Library

Implementation for Heston stochastic volatility model. The model assumes that the volatility is stochastic and mean reverting.

##### Synoposis - Available functions

- heston_EuropeanCallPrice
- heston_EuropeanPutPrice
- heston_EuropeanCallPriceMC
- heston_EuropeanPutPriceMC
- heston_CalibrateLevMar
- heston_CalibrateDE

##### heston_EuropeanCallPrice

Description : Calculates the option price for European call using the Heston closed form solution.

**Input parameters**

Input variable | Example | Description |
---|---|---|

Spot | 100.00 | Underlying spot price |

Strike | 100.00 | Strike price |

TimeToMaturity | 1.5 | Time to maturity (in Years) |

InterestRate | 0.05 | Risk free interest rate - Dividend yield |

rho | -0.3 | Correlation between volatility and spot |

kappa | 3.0 | Mean reversion speed |

theta | 0.1 | Long run variance |

lambda | 0.0 | Market price of volatility risk. Use 0.0 for variable reduction. |

sigma | 0.20 | Volatility of variance |

v | 0.10 | Current variance |

##### heston_EuropeanPutPrice

Description : Calculates the option price for European put. This formula uses put call parity to arrive at the put price from the Heston closed form solution for European call.

**Input parameters**

Input variable | Example | Description |
---|---|---|

Spot | 100.00 | Underlying spot price |

Strike | 100.00 | Strike price |

TimeToMaturity | 1.5 | Time to maturity (in Years) |

InterestRate | 0.05 | Risk free interest rate - Dividend yield |

rho | -0.3 | Correlation between volatility and spot |

kappa | 3.0 | Mean reversion speed |

theta | 0.1 | Long run variance |

lambda | 0.0 | Market price of volatility risk. Use 0.0 for variable reduction. |

sigma | 0.20 | Volatility of variance |

v | 0.10 | Current variance |

##### heston_EuropeanCallPriceMC

Description : Calculates the option price for European call through Monte Carlo simulations. The volatility assumed to be stochastic as in Heston model. Pseudo random used for standard normal gaussian variables

**Input parameters**

Input variable | Example | Description |
---|---|---|

Spot | 100.00 | Underlying spot price |

Strike | 100.00 | Strike price |

TimeToMaturity | 1.5 | Time to maturity (in Years) |

InterestRate | 0.05 | Risk free interest rate - Dividend yield |

rho | -0.3 | Correlation between volatility and spot |

kappa | 3.0 | Mean reversion speed |

theta | 0.1 | Long run variance |

lambda | 0.0 | Market price of volatility risk. Use 0.0 for variable reduction. |

sigma | 0.20 | Volatility of variance |

v | 0.10 | Current variance |

nSimulations | 15000 | Number of simulations |

nTimeSteps | 300 | Number of time steps |

##### heston_EuropeanPutPriceMC

Description : Calculates the option price for European put through Monte Carlo simulations. The volatility assumed to be stochastic as in Heston model. Pseudo random used for standard normal gaussian variables

**Input parameters**

Input variable | Example | Description |
---|---|---|

Spot | 100.00 | Underlying spot price |

Strike | 100.00 | Strike price |

TimeToMaturity | 1.5 | Time to maturity (in Years) |

InterestRate | 0.05 | Risk free interest rate - Dividend yield |

rho | -0.3 | Correlation between volatility and spot |

kappa | 3.0 | Mean reversion speed |

theta | 0.1 | Long run variance |

lambda | 0.0 | Market price of volatility risk. Use 0.0 for variable reduction. |

sigma | 0.20 | Volatility of variance |

v | 0.10 | Current variance |

nSimulations | 15000 | Number of simulations |

nTimeSteps | 300 | Number of time steps |

##### heston_CalibrateLevMar

Description : Calibrates the model using Levenbergâ€“Marquardt non linear minimization technique. Requires an initial guess parameter array. This is a local minimizer and hence should be used only when a good guess is known. Ideally use the function within the VBA macro as the algorithm could take several minutes to complete

**Order of parameters - Initial volatility (v) , Long term volatility (theta) , Mean reversion speed (kappa) , Volatility of volatility (sigma) and Correlation between volatility and spot (rho) **

**Input parameters**

Input variable | Description |
---|---|

lowerBound | Lower bound for the parameters. Passed as array of decimals. |

upperbound | Upper bound for the parameters. Passed as array of decimals. |

initialGuess | Initial guess for the parameters. Passed as array of decimals. |

strikeArray | Observation table - strikes. Passed as array of decimals. |

maturityArray | Observation table - option maturities (in Years). Passed as array of decimals. |

callTypeArray | Observation table - option type (1 for call 0 for put). Passed as array of numbers. |

observedPriceArray | Observation table - observed option prices. Passed as array of decimals. |

currentSpot | Current spot price. |

interestRateArray | Discount rates = Risk free rate - dividend yield. Passed as array. |

weights | Weights for the observation data |

maxIterations | Maximum number of trials. |

##### heston_CalibrateDE

Description : Calibrates the model using Differential evolution non linear minimization technique. This is a global minimizer and hence does not need an initial guess. Ideally use the function within the VBA macro as the algorithm could take several minutes to complete

**Order of parameters - Initial volatility (v) , Long term volatility (theta) , Mean reversion speed (kappa) , Volatility of volatility (sigma) and Correlation between volatility and spot (rho) **

**Input parameters**

variable | Description |
---|---|

lowerBound | Lower bound for the parameters. Passed as array of decimals. |

upperbound | Upper bound for the parameters. Passed as array of decimals. |

strikeArray | Observation table - strikes. Passed as array of decimals. |

maturityArray | Observation table - option maturities (in Years). Passed as array of decimals. |

callTypeArray | Observation table - option type (1 for call 0 for put). Passed as array of numbers. |

observedPriceArray | Observation table - observed option prices. Passed as array of decimals. |

currentSpot | Current spot price. |

interestRateArray | Discount rates = Risk free rate - dividend yield. Passed as array. |

weights | Weights for the observation data |

maxIterations | Maximum number of trials. |