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.

Chapter 4

Markov Chain Monte Carlo

In previous chapters we introduced Bayesian Statistics and considered how to infer a binomial

proportion using the concept of conjugate priors. We briefly mentioned that not all models can

make use of conjugate priors and thus calculation of the posterior distribution would need to be

approximated numerically.

In this chapter we introduce the main family of algorithms, known collectively as Markov

Chain Monte Carlo (MCMC), that allow us to approximate the posterior distribution as calculated

by Bayes’ Theorem. In particular, we consider the Metropolis Algorithm, which is easily

stated and relatively straightforward to understand. It serves as a useful starting point when

learning about MCMC before delving into more sophisticated algorithms such as Metropolis-

Hastings, Gibbs Samplers, Hamiltonian Monte Carlo and the No-U-Turn Sampler (NUTS).

Once we have described how MCMC works, we will carry it out using the open-source Pythonbased

PyMC3 library. The library takes care of the underlying implementation details allowing

us to concentrate specifically on modelling.

4.1 Bayesian Inference Goals

As quants our goal in studying Bayesian Statistics is to ultimately produce quantitative trading

strategies, using models derived from Bayesian methods. In order to reach that goal we need to

consider a reasonable amount of Bayesian Statistics theory. So far we have:

• Introduced the philosophy of Bayesian Statistics, making use of Bayes’ Theorem to update

our prior beliefs on probabilities of outcomes based on new data

• Used conjugate priors as a means of simplifying the computation of the posterior distribution

in the case of inference on a binomial proportion

In this chapter we are going to discuss MCMC as a means of computing the posterior distribution

when conjugate priors are not applicable.

Subsequent to a discussion on the Metropolis algorithm using PyMC3, we will consider more

sophisticated samplers and then apply them to more complex models. Ultimately we will arrive

at the point where our models are useful enough to provide insight into asset returns prediction.

At that stage we will be able to begin building a trading model from our Bayesian analysis.

35

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

Saved successfully!

Ooh no, something went wrong!