13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

60

stochastic differential equations (SDE). Using the same notation from that book the model is

given below:

dS t = µS t dt + √ ν t S t dW S t (6.1)

dν t = κ(θ − ν t )dt + ξ √ ν t dW ν t (6.2)

This model says that the change in the volatility ν is a mean-reverting process, with its own

variance given by ξ. Thus the volatility has a mean of κθ but can take on more extreme values

occasionally.

The asset paths themselves, given by S t , follow a Geometric Random Walk model with the

variance given by the square root of the volatility process.

In this section a simpler stochastic volatility model will be provided that does not assume

mean reversion of volatility. Instead the volatility ν will follow a Gaussian Random Walk with

the returns distributed as a Student’s t-distribution, with variance derived from ν.

6.2 Bayesian Stochastic Volatility

In order to implement the Bayesian approach to stochastic volatility it is necessary to select priors

for the model parameters. These parameters include σ, which represents the scale of the volatility

and ν, which represents the degrees of freedom of the Student’s t-distribution. Priors must also

be selected for the latent volatility process and subsequently the asset returns distribution.

At this stage the uncertainty on the parameter values is large and so the selected priors

must reflect that. In addition σ and ν must be real-valued positive numbers, so we need to

use a probability distribution that has positive support. As an initial choice the exponential

distribution will be chosen for σ and ν. The Python code to visualise a set of PDFs for the

exponential distribution is given below and plotted in Figure 6.1:

# exponential_plot.py

import numpy as np

import matplotlib.pyplot as plt

import seaborn as sns

if __name__ == "__main__":

sns.set_palette("deep", desat=.6)

sns.set_context(rc={"figure.figsize": (8, 4)})

x = np.linspace(0.0, 5.0, 100)

lambdas = [0.5, 1.0, 2.0]

for lam in lambdas:

y = lam*np.exp(-lam*x)

ax = plt.plot(x, y, label="$\\lambda=%s$" % lam)

plt.xlabel("x")

plt.ylabel("P(x)")

plt.legend(title="Parameters")

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!