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.

Has there been any progress on this? The thread ended without resolution

We solved this problem in Turing because of its compatibility with DifferentialEquations.jl, i.e. https://turing.ml/dev/tutorials/10-bayesiandiffeq/ and https://diffeq.sciml.ai/stable/tutorials/jump_diffusion/ is sufficient information for how to do it. One of the next steps we’re working on is getting diffeqpy available as a TensorFlow operation which will allow the DifferentialEquations.jl stack to be used in PyMC4, and that will solve this issue.

3 Likes

Thanks for sharing Chris, these are interesting examples, However I don’t see how these examples apply to this specific problem. The issue we are having is with a two dimensional SDE with correlated innovations. If the original problem were restated with independent diffusions, a solution in PyMC3 would be straightforward. The challenge is when we generalize to a correlated process

@brandonwillard have been making some progress on fitting state space model, I think it might gives a bit of speed up in your problem as well as it allows stochastic node inside a scan (more see https://brandonwillard.github.io/dynamic-linear-models-in-theano.html). I gather that you end up coding your own MH sampler - maybe if you could share some top example we can take a look to see how it would work in PyMC3?

2 Likes

Hi @Marion2025. I am currently struggling with the same problem - estimation of a the Heston Model using MCMC and after reading all your posts here I get to the concusion it is not currently possible within PYMC3. You have written that you ended up writing your own sampler and I am thinking about doing the same, however - don’t know really where to start (I am pretty new to the whole Bayesian Inference thing). Could you possibly recommend any resources on how one can write such a sampler? Not to diverge form the topic of the discussion here, we can communicate one-to-one, if you wish. Thanks in advance!