Skip to content

phynance/HestonlMonteCarlo-ImpliedVolSurfaceConstruction

Repository files navigation

HestonMonteCarlo

Although there is semi-closed form solution derived for plain vanilla option under Heston model and Monte-Carlo simulation is time-consuming, it is heuristic to simulate Heston model with Monte-Carlo method which can be extended to other types of derivatives or other variations of Heston model.

Clone this repo

$ git clone https://github.com/phynance/HestonMonteCarlo/

How to use?

First of all, the module "HestonPutCombined" is used to implement the Monte-Carlo simulation of Heston model and produce the Put option price, while the main program "main.py" is to calculate and construct the plots of option payoff diagram and implied volatility surface..

The Heston model decribes the asset price with the bivariate SDE:

, where

The variance is running under CIR process which may be negative if the Feller condition is not satisfied.

To deal with that, there are 2 schemes provided, either full truncation scheme or reflection scheme, which set the variance to zero or take the absolute value of it.

After generating a new value of variance, we update the asset price with either Euler scheme or Milstein scheme. Users can test the convergence rate of both schemes.

Users can set the values of the model parameters here.

# ######################   Parameters Values     ######################
ExercList = np.arange(1.5, 2.5, 0.1).tolist()
MaturityList = np.arange(0.5, 3+0.1, 0.1).tolist()

S_0=2
r=0.02

(S, V, Vcount0, OptionPriceMatrix, stdErrTable, Payoff) = \
EulerMilsteinPrice('Milstein', 'Trunca', numPaths=500, rho= -0.6, S_0=S_0, V_0=(0.1)**2, \
   Tmax=3,  kappa=0.5,theta=(0.25)**2 , sigma=0.1, r=r, q=0.0, MaturityList=MaturityList, \
       ExercList=ExercList)
# ######################################################################

Result

The program outputs three figures,

  1. simulated asset paths,

2.simulated variance Users can see the number of times variances reaching zero.

  1. the payoff diagram across moneyness and maturities.

  1. the implied vol surface is constructed in the function "impVolBsPut" by the Newton-Raphson method.

Define our function as f(x) for which we want to solve f(x)=0. In our case, it is equivalent to $$f(\sigma) = P_{BS} - P_{Heston}$$

Setting the initial guess of sigma to be 0.2.

Iterate as follows $\sigma_{n+1} = \sigma_{n} - \frac{P_{BS}(\sigma) - P_{Heston}(\sigma)} {\frac{\partial P_{BS}}{\partial\sigma}}$ , which is equivalent to the code

increment = (P-float(P_heston))/Pvega  
sigma = float(sigma) - increment

And it is well-known that the Vega of Black-Scholes put option has the closed-form $$Vega = S\sqrt{TN'(d_1)}$$

  1. The results of option price and implied volatility surface across moneyness and maturity are stored in
OptionPriceMatrix , ImpVolTable

About

simulation of Heston model by Monte-Carlo method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages