13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

61

plt.show()

Figure 6.1: Different realisations of the exponential distribution for various parameters λ.

Note that a much larger parameter value is chosen for σ than ν because there is a lot of

initial uncertainty associated with the scale of the volatility generating process. As more data

is provided to the model the Bayesian updating process will reduce the spread of the posterior

distribution reflecting an increased certainty in the scale factor of volatility.

This stochastic volatility model makes use of a random walk model for the latent volatility

variable. Random walk models are discussed in significant depth within the subsequent time

series chapter on White Noise and Random Walks. However the basic idea is that the latent

volatility at time point i, namely s i is a function only of the previous time point value s i−1 along

with some normally distributed error. In probabilistic terms this is written as:

s i ∼ N (s i−1 , σ −2 ) (6.3)

That is, the value of the latent vol at i, s i , has a normally distributed prior centred at the

previous value (s i−1 ) with variance σ −2 . This variance, as was seen above, is distributed as an

exponential distribution.

It remains only to assign a prior to the logarithmic returns of the asset price series being

modelled. The point of a stochastic volatility model is that these returns are related to the

underlying latent volatility variable. Hence any prior that is assigned to the log returns must

have a variance that involves s.

One approach (utilised in the PyMC3 tutorial) is to assume that the log returns, log(y i /y i−1 )

are distributed as a Student’s t-distribution, with mean zero and variance given as the exponential

of negative of the latent vol variable. Figure 6.2 shows how the PDF of a Student’s t-distribution

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

Saved successfully!

Ooh no, something went wrong!