Stochastic Volatility with Jump Diffusion?

Has anyone attempted to implement additional stochastic volatility models? I’m currently trying to implement the Heston square-root volatility model with jumps in returns. The model is described in page 61 of the paper below
https://www0.gsb.columbia.edu/faculty/mjohannes/PDFpapers/JP_2006.pdf where the author describes estimation with Metropolis

This (and similar models) are widely used in finance and it would be great to be able to use NUTS for estimation

1 Like

I totally TL;DR but is it related to Regime-switching model?

I’ll have to review your example but thanks for sharing! The paper I referenced actually includes an example of a regime switching model

The model(s) I’m trying to implement are of the following form. Stock price follows an SDE, and the volatility process also follows an SDE, where the brownian motions of each SDE are correlated. For stochastic volatility jump diffusion, the SDE also contains a jump diffusion.

I’ve made some progress implementing a log-stochastic volatility model. The model is described on page 54 in the paper I referenced in my initial comment. I’m using the AR time-series distribution to model the log volatility process

My next step is to incorporate correlation between the stochastic return process and the stochastic log-volatility process (page 56). I’m not sure how to do this in PyMC3. I’m wondering if I can replace the AR process with a MVGuassianRandomWalk

Code for log-stochastic volatility below:
#Log Stochastic Volatility

import numpy as np
import matplotlib.pyplot as plt
import pymc3 as pm

returns = np.genfromtxt(pm.get_data(“SP500.csv”))

with pm.Model() as sp500_model:

alpha=pm.Normal('alpha',0,sd=100)
beta=pm.Normal('beta',0,sd=10)
sigmaV=pm.InverseGamma('sigmaV',2.5,0.1)

logV = pm.AR('logV', [alpha,beta], sd=sigmaV**.5,constant=True,shape=len(returns))

volatility_process = pm.Deterministic('volatility_process', pm.math.exp(.5*logV))

r = pm.Normal('r', mu=0,sd=volatility_process, observed=returns)

with sp500_model:
trace = pm.sample(2000,chains=1,cores=1)

pm.traceplot(trace, [alpha,beta,sigmaV]);

Hello,

have you made any progress with including the Jump part in the process?

I could never get the stochastic vol estimation to work for Heston, never even got to trying jumps. I couldn’t figure out how to implement the multivariate Heston SDE where the Brownian motions are correlated and the volatility process is latent. The PyMC3 interface just isn’t flexible enough to handle this type of problem, which is too bad since they are prominent in quant finance

Ah, I’m sorry to hear that. Did you switch to another interface or did you abandon the project altogether? Does e.g. STAN provide more flexibility? I would also be very interested in a model with jumps.

In which specific ways would you say the modelling interface wasn’t flexible enough to handle this standard quant finance model? If you would share some of your specific notes, it would be incredibly helpful for Pymc3’s further development, as I also believe quant finance would benefit from being able to use NUTS.

If you read my previous post you will understand the problem I was trying to solve, but I’ll generalize to speak to what features would make PyMC3 more flexible to handle a wide variety of quant finance problems

Most models in quant finance are SDEs. The problem I was trying to handle was a multivariate , correlated SDE
where one process is latent. It would be great if the time series methods were expanded to include a general, multivariate SDE, basically an extension of the single SDE class that exists. This would be great for stochastic volatility models like Heston or interest rate model like multi factor CIR or HW

I just wrote my own Metropolis sampler for this model, but it was very slow

differential equation support is not great in PyMC3 - but things are going to improved in the coming months starting with @dpananos’s GSoC work on ODEs.

junpenglao, is this something an SMC sampler would help with as well, once the ODE solvers are also in place?

Working in the same field, you find me passing four consecutive days in the same project , i am still in progress but without any solution. If you want we can work together at the same problem.

I’m happy to collaborate. Fitting stochastic vol is pretty easy in PyMC3 if the return and volatility process are independent, as in the example provided in the PyMC3 documentation. When they are correlated (as in Heston or logSV) is where I couldn’t get it working. In general, fitting a multivariate SDE where one or more state variables are latent is the task. Let me know if you want to work together

1 Like

I would be down to try to figure out an effective way to do this Pymc. At this point I think a SMC sampler is what is needed, so we could work with and re-purpose the non-time-series SMC sampler just recently put in place, but I am open to other suggestions. Dm me if you want to start at some point.