So in this lecture, we will be looking at a notebook where we get to explore how to model the volatility
of stock returns.
We'll begin by downloading historical prices for spy, although obviously you can replace this with
whatever you like.
For example, Bitcoin or anything else.
The next step is to update stats models and install Arch at the same time.
The next step is to do our imports, the main import we're going to need is the arch model function,
everything else you've seen before.
Elsewhere in this chorus.
The next step is to load in our data using PDF that reads ESV.
The next step is to call the dot head to remind ourselves what this data looks like.
So we see the open, high, low, close and so forth.
The next step is to compute the log returns, which is the TIME series we're trying to model with Gargash.
The next step is to make a new data frame, which takes in everything except the first row, since that
does not contain any value for the return.
The next step is to plot the longer term so we know what it looks like.
So, as expected, we see a lot of volatility clustering every time the return has a large magnitude,
it's surrounded by other returns of large magnitude.
Notice how these kind of appear like shocks.
There's a really big value and then it tapers off over time, just like the garden model says it should.
OK, so the next step is to compute the square of the log returns.
The next step is to plot the square of the log returns.
So this makes it a bit easier to see that the volatility does, in fact cluster when the returns get
large, they are usually followed by more large returns.
OK, so in the next portion of this notebook, we're going to explore the akef and the.
Let's begin by simply plotting the AKF of the log returns.
We've seen this before, but it helps to remind ourselves what it looks like.
OK, so as expected, there are really no significant correlations, there are a couple of values that
go a little bit outside the significance threshold.
But as you recall, this also happens with actual ID noise as well.
Furthermore, as you recall, with a five percent significance threshold, we do expect to see false
positives five percent of the time by definition.
OK, so the next step is to plot the.
So, again, we see pretty much the same thing as the AKF.
Now, the next part is where things get interesting.
We're now going to plot the AKF of the squared returns.
OK, so as you can see, there are now many significant lags.
This tells us that there is a significant correlation in the Squared series.
The next step is to plot the pickoff of the squared returns.
So, again, we see that there are some very significant legs going far beyond the significance threshold.
So we've seen that the AKF and for the log returns look like a random walk, but the Akef and PKF four
squared returns have significant lags.
Now, by definition, we know that if we were to plot the account for a Gaussian white noise, we would
see the same thing.
But something we have not seen is the akef and the pickoff for the square of Gaussian white noise.
The question we want to answer is, can this be the thing that differentiates stock returns from actual
Gaussian white noise?
So in this next block of code, I've generated 500 points from the standard normal, which gives us
Gaussian white noise.
I've also squared these values.
So let's look at the HCF.
So, as you may have expected, Akef shows essentially no significant legs, we seem to have a couple
of values that peak through slightly, but nothing that goes far outside the blue area.
The next step is to plot the.
So, again, we see pretty much the same thing.
So what have we learned?
We've learned that the dependent's in the square to returns tells us that stock price returns are not
exactly like U.S. and white noise used to produce a random walk.
We've seen that because Gaussian white noise values are truly independent.
There will not be any autocorrelation no matter how you transform the series.