Book Image

Python for Finance

By : Yuxing Yan
Book Image

Python for Finance

By: Yuxing Yan

Overview of this book

Table of Contents (20 chapters)
Python for Finance
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The GARCH (Generalized ARCH) model


Generalized AutoRegressive Conditional Heteroskedasticity (GARCH) is an important extension of ARCH, by Bollerslev (1986). The GARCH (p,q) process is defined as follows:

Here, is the variance at time t, q is the order for the error terms, p is the order for the variance, is a constant, is the coefficient for the error term at t-i, is the coefficient for the variance at time t-i. Obviously, the simplest GARCH process is when both p and q are set to 1, that is, GARCH (1,1), which has following formula:

Simulating a GARCH process

Based on the previous program related to ARCH (1), we could simulate a GARCH (1,1) process as follows:

import scipy as sp
sp.random.seed(12345)
n=1000          # n is the number of observations
n1=100          # we need to drop the first several observations
n2=n+n1         # sum of two numbers
alpha=(0.1,0.3)     # GARCH (1,1) coefficients alpha0 and alpha1, see Equation (3)
beta=0.2
errors=sp.random.normal(0,1,n2)
t=sp.zeros(n2...