WEBVTT

0
00:00.090 --> 00:00.720
Hey guys,

1
00:00.720 --> 00:05.720
it's Angela here and welcome to Day 36 of 100 Days of Code. Today

2
00:06.150 --> 00:08.370
we've got a fun project for you.

3
00:08.550 --> 00:12.720
We're going to be building a stock news monitoring project.

4
00:13.410 --> 00:16.650
So I don't know how many of you guys trade stocks out there,

5
00:16.800 --> 00:19.110
but I've recently started learning about it.

6
00:19.350 --> 00:22.590
And one of the pictures that always come to my mind when I think of people

7
00:22.590 --> 00:25.440
trading stocks is something like this,

8
00:25.890 --> 00:28.230
where if you will sit in front of a million screens,

9
00:28.260 --> 00:31.020
looking at all of the data and all of the news.

10
00:31.800 --> 00:33.990
Now I did a bit of research into this

11
00:34.050 --> 00:39.050
and it seems like a lot of the people who trade stocks professionally have

12
00:39.110 --> 00:43.700
access to what's that a Bloomberg terminal, which looks something like this.

13
00:43.790 --> 00:45.890
And it provides you with a number of things,

14
00:46.370 --> 00:49.640
the current stock prices of whichever companies you're looking at,

15
00:50.150 --> 00:55.130
and also the breaking news that's relevant to those companies. So 

16
00:55.130 --> 00:57.440
depending on whether if they had some good news

17
00:57.440 --> 01:00.680
say they earned a lot of money in the last quarter, or

18
01:00.690 --> 01:04.520
they built a really great product or they developed a new vaccine.

19
01:04.760 --> 01:09.760
Then obviously you can imagine the price of their company's stock go up or down

20
01:11.540 --> 01:16.540
depending on the type of news that comes out. And finally these platforms

21
01:17.450 --> 01:22.450
also give you the ability to alert you when relevant pieces of news happen that are

22
01:23.930 --> 01:26.030
related to stocks that you're following.

23
01:27.170 --> 01:32.170
So I found out for my friend that to subscribe to one of these Bloomberg

24
01:33.290 --> 01:34.123
terminals,

25
01:34.220 --> 01:39.220
it costs something like $24,000 a year.

26
01:39.920 --> 01:43.160
So that was the end of that research. Um,

27
01:43.190 --> 01:46.820
but I thought about it and I thought about the kind of things that would be

28
01:46.820 --> 01:49.400
really useful to somebody who trades stocks.

29
01:49.580 --> 01:54.260
And I thought about how we could turn this into a Python project.

30
01:54.830 --> 01:56.360
So here's what's going to happen.

31
01:56.600 --> 02:01.600
We're going to DIY our own a Bloomberg terminal or at least the parts of the

32
02:01.640 --> 02:05.240
functionality that are quite useful. First,

33
02:05.300 --> 02:09.500
let's take a look at what stock market data looks like. So here,

34
02:09.500 --> 02:14.500
I've got a website up called tradingview.com and I'm looking at the large cap

35
02:15.950 --> 02:16.783
companies.

36
02:17.120 --> 02:20.840
So these are well known companies that you've probably heard of like Apple or

37
02:20.840 --> 02:22.370
Microsoft or Amazon.

38
02:22.910 --> 02:26.330
And let's say that we had an interest in a particular stock.

39
02:26.360 --> 02:28.610
Let's say that we bought shares in Tesla,

40
02:29.120 --> 02:31.340
and we want to know how it's doing. Well,

41
02:31.340 --> 02:34.130
we could take a closer look at it and we could take a look at

42
02:34.400 --> 02:35.840
the full featured chart.

43
02:36.560 --> 02:41.560
And this shows us the price of the Tesla stock over the past few days.

44
02:45.410 --> 02:49.670
Now I'm going to change the time zone here to the actual time zone of the

45
02:49.670 --> 02:54.170
exchange. And if I change the view to one day view,

46
02:54.470 --> 02:58.730
then you can see the points at which the market is open and when it's closed.

47
02:59.110 --> 03:03.010
So these blue sections highlight when the market is closed.

48
03:03.730 --> 03:07.540
Currently it's the 22nd of July. So because this day's

49
03:07.540 --> 03:11.550
data is not yet complete, we're going to look at the previous day's data.

50
03:11.580 --> 03:12.750
So this is yesterday.

51
03:13.320 --> 03:18.120
And you can see that NASDAQ opens at 9:30 AM New York time

52
03:18.180 --> 03:21.840
and it closes down at 4:00 PM on the same day.

53
03:22.410 --> 03:24.960
And often when you're getting data on stocks,

54
03:25.260 --> 03:30.060
you can get the price of a particular stock at the point when the market opens

55
03:30.300 --> 03:33.120
and when the market closes. For example,

56
03:33.120 --> 03:38.120
we could compare the price of the Tesla stock at market close yesterday.

57
03:38.610 --> 03:43.610
So that was about $1,567 and at market close the previous day

58
03:45.560 --> 03:48.510
so that's four o'clock on the 20th of July,

59
03:48.900 --> 03:53.900
and that was at around $1,641.

60
03:54.120 --> 03:59.120
So there was a big difference between the end of the 20th of July and the end of

61
03:59.490 --> 04:03.630
the 21st of July. As a stock trader would be quite 

62
04:03.630 --> 04:08.310
interested in these big fluctuations because it might mean that we would want to

63
04:08.340 --> 04:12.150
buy more, or we might want to sell our stocks in Tesla.

64
04:13.020 --> 04:14.910
When you look at a lot of these services

65
04:14.940 --> 04:18.690
be it Bloomberg terminals or something much simpler like this,

66
04:19.020 --> 04:21.930
they often give you a whole bunch of other data as well.

67
04:23.100 --> 04:28.100
One of the most useful things is actually to look at the news that's related to

68
04:28.350 --> 04:32.340
the company that you're investigating. So for example,

69
04:32.340 --> 04:34.740
these are the current headlines for Tesla,

70
04:35.250 --> 04:39.990
and it comes from various news sources like Reuters or my Wall Street or

71
04:39.990 --> 04:44.850
Bloomberg. And it gives us some information to start analyzing.

72
04:44.850 --> 04:48.480
For example, well why was there this big drop, what's the reason,

73
04:48.990 --> 04:52.710
and there's various news sources that might tell us why. For example,

74
04:52.710 --> 04:56.130
maybe they're experiencing problems with servicing staff,

75
04:56.220 --> 05:00.330
or maybe as this news piece suggests, the stock is probably going to rise again.

76
05:00.930 --> 05:02.850
So these are really interesting things

77
05:02.880 --> 05:05.820
if we were to trade this particular stock.

78
05:06.750 --> 05:10.350
If we were to create a Python program that's going to help us trade stocks,

79
05:11.010 --> 05:14.010
then this is how it might work. First,

80
05:14.160 --> 05:18.480
we're going to pull in the stock prices of the stocks that we're interested in.

81
05:18.900 --> 05:21.810
So we would be using an API to get this data.

82
05:22.560 --> 05:26.460
And let's say that we were monitoring the Tesla stock cause we bought some

83
05:26.460 --> 05:29.400
shares and we want to know how it's doing. Well,

84
05:29.430 --> 05:34.430
it might pull in the data for the price of Tesla stock that was at market close.

85
05:35.220 --> 05:37.950
Let's say that today was March the 11th.

86
05:38.250 --> 05:43.170
So we're pulling in yesterday's closing price and let's just say, for example,

87
05:43.320 --> 05:44.700
it is $1,000.

88
05:45.270 --> 05:49.320
Now the next thing our program is going to do is it's going to pull in the

89
05:49.350 --> 05:52.020
closing price on the previous day.

90
05:52.530 --> 05:56.760
And we're going to compare these two values. So over the course of one day,

91
05:56.790 --> 05:59.300
what was the difference. And in this case,

92
05:59.360 --> 06:03.890
there's a difference of a hundred dollars and the direction is up.

93
06:03.950 --> 06:08.720
So it increased in value, right? Going from March 9th to March 10th.

94
06:08.960 --> 06:12.260
So that's good news for us if we bought in. Now,

95
06:12.320 --> 06:16.910
we can also calculate what is the percentage that this rise represents.

96
06:16.940 --> 06:21.770
So if we look at this difference of a hundred dollars and calculate it as a

97
06:21.770 --> 06:24.890
percentage of yesterday's closing price,

98
06:25.160 --> 06:30.160
then we can see that the price on March 9th was 10% lower than on March 10th.

99
06:31.340 --> 06:33.650
So let's say that in our Python program,

100
06:34.010 --> 06:37.550
we set the program to run and fetch us some news

101
06:37.790 --> 06:42.530
whenever we get a slightly extraordinary rise or an extraordinary fall.

102
06:42.920 --> 06:46.850
So you can define that as anything you want, but let's say it's 10%.

103
06:47.600 --> 06:52.400
If there was a difference of 10% or more between yesterday's closing price and

104
06:52.400 --> 06:55.040
the previous day, then we want to know about it.

105
06:55.910 --> 07:00.470
So we're going to get our API to fetch us some relevant news.

106
07:01.070 --> 07:05.240
That way we can figure out what is the reason for this rise or what is the

107
07:05.240 --> 07:06.350
reason for this fall.

108
07:06.860 --> 07:11.030
And it might just turn out well because Tesla launched a new product,

109
07:11.360 --> 07:14.240
or because they've acquired a new factory.

110
07:14.480 --> 07:17.240
Some sort of indicator that says, well,

111
07:17.240 --> 07:20.630
this company is going to do a lot better. Now,

112
07:20.630 --> 07:25.630
once the stock prices have triggered this alert and we fetched the news data,

113
07:26.660 --> 07:29.660
then we're going to send ourselves an SMS.

114
07:29.930 --> 07:34.190
So we're going to send ourselves a message telling us what was the big

115
07:34.220 --> 07:39.220
fluctuation that happened and what is the relevant news so that we can decide

116
07:39.440 --> 07:41.780
there and then whether if you want to sell our stock,

117
07:41.810 --> 07:42.950
or if we want to buy more.

118
07:43.730 --> 07:48.440
We're aiming for messages from Twilio that look a bit like this.

119
07:48.950 --> 07:49.610
That way

120
07:49.610 --> 07:52.940
when you wake up in the morning and you're wondering what's happening with my

121
07:52.940 --> 07:57.020
Tesla stock and it just so happens that over the last two days,

122
07:57.110 --> 07:59.510
it experienced huge fluctuations,

123
07:59.870 --> 08:04.870
then you would get sent the relevant pieces of news to help you decide and help

124
08:05.270 --> 08:10.190
you figure out what you should do with your trades. That's the goal.

125
08:10.430 --> 08:15.350
And the best part of this project is the fact that it's going to be mostly up to

126
08:15.350 --> 08:17.060
you as to how you create it

127
08:18.190 --> 08:20.350
<v 1>In the course resources I've got links</v>

128
08:20.650 --> 08:24.100
<v 0>to starting projects with the comment and hints,</v>

129
08:24.580 --> 08:29.020
and depending on which level of difficulty you want to choose, normal,

130
08:29.020 --> 08:33.520
hard or extra hard, you can pick the starting project that's right for you.

131
08:34.090 --> 08:35.710
Once you pick the starting project,

132
08:35.740 --> 08:37.780
then you are going to work through each of the comments

133
08:38.110 --> 08:42.280
and you're going to try and complete the functionality of this program.

134
08:42.940 --> 08:47.200
Now I want you to spend at least a half an hour to 45 minutes working on this

135
08:47.200 --> 08:51.580
project, just because it has quite a few APIs that you need to tap into.

136
08:51.940 --> 08:53.440
And most importantly,

137
08:53.710 --> 08:58.440
I want you to read through the API documentation yourself so that you can

138
08:58.440 --> 09:02.820
understand how to work with it and how to figure out things on your own.

139
09:03.210 --> 09:06.300
Because after all, there are millions of APIs out there

140
09:06.420 --> 09:09.270
and if you're going to need it for a special project of your own,

141
09:09.570 --> 09:12.870
you're going to need to go through this process that all developers go through

142
09:13.050 --> 09:18.050
which is digging through documentation and understanding how to work with an

143
09:18.240 --> 09:19.073
external piece of  software

144
09:19.550 --> 09:21.350
<v 2>or code.</v>

145
09:21.380 --> 09:25.700
<v 0>That's the challenge I've set for you. Head over to the course resources now and</v>

146
09:25.700 --> 09:29.630
get the starting code so that you can get started working on the project.

147
09:29.750 --> 09:30.380
Good luck.