WEBVTT

00:01.180 --> 00:06.390
In this video we are going to create a price weighted stock index containing our six stocks.

00:06.520 --> 00:14.020
So the stocks Amazon Boeing Disney IBM and Microsoft are the so-called constituents of our customized

00:14.050 --> 00:14.980
index.

00:15.190 --> 00:20.560
And actually the weights of the constituents and the index are determined by the stock prices.

00:21.100 --> 00:23.170
So first of all let's have a look at our stocks.

00:23.170 --> 00:24.810
We are still important.

00:24.850 --> 00:25.720
The stocks.

00:25.740 --> 00:26.400
Yes we're.

00:27.250 --> 00:32.270
So these are the first five four hours here and we also still import it.

00:32.320 --> 00:42.130
The normalized prices starting from 100 at the thirty first of December 2000 and 13 and actually creating

00:42.130 --> 00:47.800
a price weighted index is nothing else than having for all constituents an equal amount of stocks in

00:47.800 --> 00:48.950
the index.

00:48.970 --> 00:54.340
So the easiest example is to have exactly one stock per constituent in the index.

00:54.580 --> 01:01.180
And consequently the total price of our index would be at each point in time simply the sum of the constituent

01:01.180 --> 01:02.410
prices.

01:02.410 --> 01:04.480
So let's have a look at an example here.

01:05.050 --> 01:11.170
So this is our first time stamp and here are the stock prices for our six stocks.

01:11.170 --> 01:18.080
And if you put that one stock per constituent into one portfolio on index then the value of the portfolio

01:18.080 --> 01:23.040
of the index is simply the sum of the stock prices here.

01:23.090 --> 01:27.900
And action on a first step you want to calculate the sum for all rows here.

01:27.970 --> 01:35.970
So far the timestamps and we can do the same with the sum method and passing one to the access parameter.

01:36.070 --> 01:40.690
So we are calculating the sum for all rows or along the columns.

01:40.690 --> 01:49.720
So let's say this here and for example here for the very first time stamp the sum of all constituent

01:49.720 --> 01:52.400
prices is eight hundred seventy seven.

01:52.430 --> 01:58.750
Then at the next day I hadn't read 74 and so on and we are actually almost finished.

01:58.750 --> 02:01.690
So this is our price weighted index.

02:01.870 --> 02:04.700
And typically we would normalize the index.

02:04.720 --> 02:10.010
So we want to have at the very first time stamp the value of 100.

02:10.210 --> 02:16.140
So we can simply select here the very first price at index Position ZERO.

02:16.150 --> 02:23.170
So here we have the eight hundred seventy seven and now actually for our time stamps you can normalize

02:23.170 --> 02:29.920
them the price of our index by dividing all values by the initial value and we can do this by having

02:29.920 --> 02:36.630
here the sum for all rows and then we divide the sum for all rows by the very first element.

02:36.640 --> 02:41.850
So let's have a look here.

02:41.860 --> 02:45.770
So now our index is normalized to a value of 1.

02:45.880 --> 02:54.340
And as it's more common to have a base value of 100 we actually multiply all values here with 100 and

02:54.340 --> 02:57.430
we can do this with the Mayan method.

02:57.430 --> 03:03.260
So let's sort this here and this is now actually our price weighted index.

03:03.280 --> 03:07.710
So at the very first time stamp we have a base value of 100.

03:08.230 --> 03:14.290
And then our index price changes depending on the performance of the constituent stocks.

03:14.830 --> 03:18.260
So let's have a look at the very last time stamp.

03:18.280 --> 03:26.740
So here at the end of two 18 we are already at a value of two hundred forty six and that's actually

03:26.740 --> 03:28.050
a quite good multiplier.

03:28.100 --> 03:28.360
Yes.

03:28.380 --> 03:32.270
So we have a multiplier of two point four six.

03:32.600 --> 03:35.590
And this only within five years.

03:35.590 --> 03:37.570
So this is pretty good.

03:37.670 --> 03:43.740
Now actually we can add our price weighted index to our norm data frame here on the right hand side.

03:43.840 --> 03:49.070
So we create an additional column called price weighted index.

03:49.360 --> 03:52.730
And we use exactly the code that we derived here.

03:52.780 --> 03:56.380
So let's run this year and let's have a look.

03:56.380 --> 04:02.030
So here we have our six constituents and our price weighted index.

04:02.070 --> 04:08.140
Now we can also plot all six stocks in our price weighted index by using the plot method here on our

04:08.140 --> 04:09.650
norm data frames for that.

04:09.660 --> 04:15.340
So this and the price weighted index graph is actually here.

04:15.340 --> 04:19.400
The dark blue graph so it's pretty hard to see here.

04:19.570 --> 04:26.620
And as we can see here from the above from the uh non normalized stock prices by far the highest stock

04:26.620 --> 04:29.560
price we have here for the Amazon stock.

04:30.130 --> 04:37.450
So the Amazon stock has actually acquired a higher weight in our new index and maybe we can also see

04:37.450 --> 04:40.070
this from a graph here.

04:40.090 --> 04:42.190
So now we are only plotting.

04:42.220 --> 04:46.180
The Amazon stock and our price weighted index.

04:47.080 --> 04:51.580
And we can see here that they pretty much uh move together here.

04:51.820 --> 04:55.720
So to say there is a lot of Amazon yeah our price weighted index.

04:56.020 --> 05:00.730
And in contrast to that we could also plot the price weighted index.

05:00.760 --> 05:04.330
And for example a lower weight stock.

05:04.330 --> 05:10.060
So for example here the Coca-Cola stock that has only a little weight and our price weighted index.

05:10.060 --> 05:18.810
So let's throw this here so we are plotting Coca-Cola and our price weighted index and we can see that

05:18.810 --> 05:24.820
the correlation or the relationship between those two is uh fairly low actually.

05:25.110 --> 05:30.920
And this is simply because there's only very little Coca-Cola in our index here.

05:31.380 --> 05:38.730
So our index is actually dominated by the Amazon stock and we can also calculate the weights of the

05:38.760 --> 05:40.860
constituents over time.

05:40.860 --> 05:43.770
So let's again have a look at our stocks data frame.

05:43.770 --> 05:51.120
The first five rows and we can see here at the very first timestamp that the Amazon price is much higher

05:51.120 --> 05:53.080
than the Coca-Cola price.

05:53.160 --> 05:59.860
So we would expect a much higher rate for the Amazon stock than for the Coca-Cola stock and our customized

05:59.860 --> 06:01.590
to price index.

06:01.590 --> 06:07.530
And we can actually calculate the weights of the constituents on each timestamp by actually dividing

06:07.530 --> 06:07.700
here.

06:07.710 --> 06:11.030
Each value by the sum of each row.

06:11.130 --> 06:19.590
So we take uh the sum here for each row and then we divide all values in a row by the respective sum.

06:19.590 --> 06:25.610
So we use see the tough method and we pass the rows to the axis perimeter.

06:25.620 --> 06:30.690
So let's have a look and we can see at the very first timestamp.

06:30.750 --> 06:38.490
So the weight of the Amazon stock is 45 percent and the weight of the Coca-Cola stock is only four point

06:38.490 --> 06:39.860
seven percent.

06:40.110 --> 06:43.580
And we can also have a look at the very end here.

06:43.590 --> 06:50.040
So here we are at the end of 2018 and we can see here that the weight of the Amazon stock in our index

06:50.490 --> 06:53.280
even increased to 68 percent.

06:54.360 --> 07:01.110
And the weight of the Coca-Cola stock actually decreased to only two point two percent.

07:01.200 --> 07:06.870
So this is kind of a weight data frame and we can also save this and the variable weights the price

07:06.870 --> 07:14.730
weighted index and then we can also visualize the evolution of our weights over time by using the plot

07:14.730 --> 07:15.250
method.

07:15.270 --> 07:21.080
So let's have a look and we can see in blue the Amazon weight.

07:21.540 --> 07:32.820
So starting at a weight of 45 percent in 2014 we end up at a rate of almost 70 percent in the year 2000

07:32.850 --> 07:34.540
and 18.

07:34.590 --> 07:39.130
And actually the weight of all other stocks is uh yeah fairly low here.

07:39.210 --> 07:46.270
So our price weighted index is heavily influenced by the Amazon stock and uh the Amazon stock performance.

07:46.560 --> 07:51.930
And this is actually one of the pitfalls of a price weighted index because stocks with the highest prices

07:51.930 --> 07:58.560
have the highest rates and therefore the index has kind of a concentrated position in these stocks and

07:58.560 --> 08:05.310
is actually poorly diversified and also a high stock price does not mean that the company is large in

08:05.310 --> 08:07.800
a market capitalization sense.

08:07.800 --> 08:15.630
So for example if there were only 100 stocks of the Amazon stock then Amazon would be a pretty small

08:15.630 --> 08:23.010
company but with a huge position in our index and actually on the other hand side calculating and constructing

08:23.010 --> 08:25.090
a price weighted indexes.

08:25.140 --> 08:26.040
Pretty simple.

08:26.370 --> 08:31.700
So we actually only need a two or three lines of code and very little data.

08:31.730 --> 08:37.050
So we only need it actually the price data over time for our stocks.

08:37.050 --> 08:44.140
So as a summary there are pros and cons for a price weighted index and in the next video we will create.

08:44.160 --> 08:46.080
The equally weighted index.

08:46.080 --> 08:47.700
So hope to see you there by.
