1
00:00:11,140 --> 00:00:16,600
So in this lecture, we will be looking at a notebook where we get to explore how to model the volatility

2
00:00:16,810 --> 00:00:17,990
of stock returns.

3
00:00:18,610 --> 00:00:24,340
We'll begin by downloading historical prices for spy, although obviously you can replace this with

4
00:00:24,340 --> 00:00:25,340
whatever you like.

5
00:00:25,360 --> 00:00:27,670
For example, Bitcoin or anything else.

6
00:00:34,310 --> 00:00:38,300
The next step is to update stats models and install Arch at the same time.

7
00:00:45,710 --> 00:00:51,120
The next step is to do our imports, the main import we're going to need is the arch model function,

8
00:00:51,620 --> 00:00:53,310
everything else you've seen before.

9
00:00:53,360 --> 00:00:54,590
Elsewhere in this chorus.

10
00:01:00,870 --> 00:01:04,590
The next step is to load in our data using PDF that reads ESV.

11
00:01:09,070 --> 00:01:13,530
The next step is to call the dot head to remind ourselves what this data looks like.

12
00:01:18,560 --> 00:01:21,640
So we see the open, high, low, close and so forth.

13
00:01:24,900 --> 00:01:29,910
The next step is to compute the log returns, which is the TIME series we're trying to model with Gargash.

14
00:01:34,910 --> 00:01:40,100
The next step is to make a new data frame, which takes in everything except the first row, since that

15
00:01:40,100 --> 00:01:42,470
does not contain any value for the return.

16
00:01:48,030 --> 00:01:51,540
The next step is to plot the longer term so we know what it looks like.

17
00:01:56,530 --> 00:02:02,920
So, as expected, we see a lot of volatility clustering every time the return has a large magnitude,

18
00:02:03,140 --> 00:02:06,040
it's surrounded by other returns of large magnitude.

19
00:02:06,730 --> 00:02:08,860
Notice how these kind of appear like shocks.

20
00:02:09,250 --> 00:02:14,410
There's a really big value and then it tapers off over time, just like the garden model says it should.

21
00:02:17,750 --> 00:02:21,440
OK, so the next step is to compute the square of the log returns.

22
00:02:25,340 --> 00:02:28,580
The next step is to plot the square of the log returns.

23
00:02:33,490 --> 00:02:39,430
So this makes it a bit easier to see that the volatility does, in fact cluster when the returns get

24
00:02:39,430 --> 00:02:42,720
large, they are usually followed by more large returns.

25
00:02:46,380 --> 00:02:50,730
OK, so in the next portion of this notebook, we're going to explore the akef and the.

26
00:02:53,970 --> 00:02:57,730
Let's begin by simply plotting the AKF of the log returns.

27
00:02:58,320 --> 00:03:02,040
We've seen this before, but it helps to remind ourselves what it looks like.

28
00:03:06,300 --> 00:03:11,910
OK, so as expected, there are really no significant correlations, there are a couple of values that

29
00:03:11,910 --> 00:03:14,570
go a little bit outside the significance threshold.

30
00:03:14,790 --> 00:03:18,570
But as you recall, this also happens with actual ID noise as well.

31
00:03:19,470 --> 00:03:24,930
Furthermore, as you recall, with a five percent significance threshold, we do expect to see false

32
00:03:24,930 --> 00:03:28,050
positives five percent of the time by definition.

33
00:03:31,710 --> 00:03:33,360
OK, so the next step is to plot the.

34
00:03:39,260 --> 00:03:42,350
So, again, we see pretty much the same thing as the AKF.

35
00:03:45,860 --> 00:03:48,230
Now, the next part is where things get interesting.

36
00:03:48,770 --> 00:03:52,160
We're now going to plot the AKF of the squared returns.

37
00:03:56,680 --> 00:04:00,220
OK, so as you can see, there are now many significant lags.

38
00:04:00,640 --> 00:04:05,290
This tells us that there is a significant correlation in the Squared series.

39
00:04:09,350 --> 00:04:13,060
The next step is to plot the pickoff of the squared returns.

40
00:04:18,500 --> 00:04:23,990
So, again, we see that there are some very significant legs going far beyond the significance threshold.

41
00:04:28,070 --> 00:04:35,150
So we've seen that the AKF and for the log returns look like a random walk, but the Akef and PKF four

42
00:04:35,150 --> 00:04:37,890
squared returns have significant lags.

43
00:04:38,510 --> 00:04:45,110
Now, by definition, we know that if we were to plot the account for a Gaussian white noise, we would

44
00:04:45,110 --> 00:04:46,040
see the same thing.

45
00:04:46,730 --> 00:04:52,460
But something we have not seen is the akef and the pickoff for the square of Gaussian white noise.

46
00:04:53,060 --> 00:04:58,910
The question we want to answer is, can this be the thing that differentiates stock returns from actual

47
00:04:58,910 --> 00:05:00,150
Gaussian white noise?

48
00:05:00,710 --> 00:05:05,990
So in this next block of code, I've generated 500 points from the standard normal, which gives us

49
00:05:05,990 --> 00:05:07,220
Gaussian white noise.

50
00:05:07,610 --> 00:05:09,370
I've also squared these values.

51
00:05:09,860 --> 00:05:11,340
So let's look at the HCF.

52
00:05:17,440 --> 00:05:23,600
So, as you may have expected, Akef shows essentially no significant legs, we seem to have a couple

53
00:05:23,600 --> 00:05:27,720
of values that peak through slightly, but nothing that goes far outside the blue area.

54
00:05:31,550 --> 00:05:32,690
The next step is to plot the.

55
00:05:38,140 --> 00:05:40,270
So, again, we see pretty much the same thing.

56
00:05:41,260 --> 00:05:42,500
So what have we learned?

57
00:05:43,180 --> 00:05:49,030
We've learned that the dependent's in the square to returns tells us that stock price returns are not

58
00:05:49,030 --> 00:05:52,820
exactly like U.S. and white noise used to produce a random walk.

59
00:05:53,530 --> 00:05:57,260
We've seen that because Gaussian white noise values are truly independent.

60
00:05:57,610 --> 00:06:01,720
There will not be any autocorrelation no matter how you transform the series.
