back to index

Building a PlotLy $GME Chart in Python


Chapters

0:0
1:0 Simple Moving Average
3:56 Time Series Intraday Api
5:36 The Candlestick Format
24:48 Indicators
28:37 Moving Average
36:29 Add Candlesticks
43:11 Unbalanced Volume
56:44 Update the Layout
58:39 Confirming Trade
60:11 Shaking Oscillator

Whisper Transcript | Transcript Only Page

00:00:00.000 | Hi, and welcome to the video.
00:00:01.400 | We're going to do something a little bit different today,
00:00:03.820 | and we're going to build a Python project from scratch.
00:00:07.280 | And what I want to do is build a Plotly chart
00:00:10.800 | and feed stock information into this chart from the Alpha
00:00:14.000 | Vantage API, which is very similar to the Yahoo Finance
00:00:19.320 | API, as far as I am aware.
00:00:21.200 | I haven't used either of them that much, to be honest.
00:00:25.400 | But they seem to have pretty good documentation,
00:00:28.000 | and it's a little bit different, and I just
00:00:29.800 | want to explore using this API rather than
00:00:31.880 | Yahoo Finance, which is like the de facto standard, almost.
00:00:36.440 | So after we give some stock information to this chart,
00:00:39.840 | we want to actually chart it and plot a few interesting
00:00:43.360 | indicators.
00:00:45.160 | So you can see on the screen, I've
00:00:47.960 | gone for a few different indicators here.
00:00:51.880 | I haven't really seen any of these
00:00:54.040 | because I'm not a finance person,
00:00:55.480 | so I don't claim to know what all of this means exactly.
00:01:01.000 | Obviously, the simple moving average
00:01:02.600 | is a moving average of the stock price over time,
00:01:06.440 | so that one is quite simple.
00:01:08.780 | And I just want to include that in there
00:01:10.440 | so that we can see that we're actually doing things right
00:01:12.820 | and we're plotting these indicators correctly.
00:01:16.920 | And then we have this thing called the onBalanceVolume,
00:01:19.600 | which measures positive and negative volume flow.
00:01:24.480 | So the reason I'm including all this volume
00:01:27.680 | and balancing momentum-based indicators is at the moment
00:01:33.800 | in the stock market, we have the big Wall Street
00:01:36.400 | versus Wall Street bets.
00:01:39.200 | And I want to use this opportunity
00:01:42.880 | to just build a cool project that at least gives
00:01:47.600 | a little bit of information on what is actually
00:01:49.680 | happening in terms of the actual stock market.
00:01:52.920 | Now, a lot of these are traditional indicators.
00:01:56.580 | They've been around for a few years,
00:01:58.080 | so I don't know if they're actually
00:01:59.500 | going to be useful or not because, obviously,
00:02:03.040 | the market conditions at the moment are not normal.
00:02:07.840 | But it'll be interesting to see.
00:02:09.240 | And then we have this balance of power,
00:02:10.860 | which is the market strength of buyers versus sellers.
00:02:13.840 | So again, pretty relevant.
00:02:16.480 | Rate of change, maybe we'll include this.
00:02:19.600 | I'm not sure, this one called Arun, which looks
00:02:25.520 | quite interesting, actually.
00:02:26.800 | So if we go on here, you can see that it essentially
00:02:35.400 | gives us this.
00:02:38.480 | So we get a downtrend and uptrend indicator line.
00:02:43.800 | And whenever these cross over, that's
00:02:45.440 | typically when you see an uptrend or downtrend.
00:02:47.640 | And I think that'll be quite interesting to see as well.
00:02:50.020 | And so this is based on the time between highs and lows
00:02:55.480 | in a specific time period.
00:02:58.480 | So what you're doing here is measuring the lowest point,
00:03:01.680 | and that gives you the points, the edges,
00:03:05.840 | or the peeps and troughs of this indicator here.
00:03:10.480 | So I think that'll be pretty interesting.
00:03:13.800 | And then we have this Chaikin oscillator.
00:03:19.720 | And I thought this would also be quite interesting,
00:03:21.840 | because this is tracking the strength of price movements
00:03:26.640 | and the underlying buying and selling pressure
00:03:29.520 | to estimate demand.
00:03:31.480 | So that should also be pretty interesting.
00:03:36.240 | So let's go ahead, and we're going to start coding this up.
00:03:40.440 | So the first thing we need to do is figure out
00:03:44.040 | how to use the Alpha Vantage API.
00:03:46.160 | So basically, all the data that we want, we can get from here.
00:03:53.880 | So the main part of that is going to be this time series
00:03:57.560 | intraday API.
00:04:00.840 | So we'll just go ahead and figure this out.
00:04:03.400 | OK, so if we just take this, let's figure out
00:04:28.560 | the format that data is actually going to come in with.
00:04:31.880 | OK, so we have our interval, which
00:05:00.280 | we included here, symbol.
00:05:08.200 | We're going to change that to GME.
00:05:09.720 | And then we have this time series,
00:05:18.720 | which is in the dictionary.
00:05:19.840 | And inside here, we have our open high, low, close,
00:05:24.400 | and volume as well, which is interesting.
00:05:27.920 | So OK, let's pull that together.
00:05:33.080 | So first, I do want to have the candlestick format.
00:05:39.200 | So I came up with this.
00:05:45.120 | So candlestick is this, whereas if we were just
00:05:49.920 | tracking the average, it would look like this.
00:05:54.080 | So first, we're just going to do this with Blightly.
00:05:58.400 | And then we'll figure out how to build the candlestick.
00:06:03.480 | So we're going to go ahead and try and build that.
00:06:08.400 | So for now, we're just going to use this data.
00:06:12.640 | And we'll get into a data frame.
00:06:16.800 | So import pandas and just clean it up a little bit.
00:06:25.360 | [MUSIC PLAYING]
00:06:28.840 | [MUSIC PLAYING]
00:06:32.320 | [MUSIC PLAYING]
00:06:35.800 | [MUSIC PLAYING]
00:06:38.800 | [MUSIC PLAYING]
00:07:06.280 | OK, so I'm going to initialize the data frame first.
00:07:09.280 | And then we'll just loop through each of these entries.
00:07:12.440 | We'll have the date and time in one column,
00:07:15.800 | the open, high, low, close, and volume in other columns.
00:07:18.920 | And we'll just append each one of these
00:07:25.000 | as we work through.
00:07:26.360 | So here, we're just going to print out
00:07:53.160 | each of the date time keys.
00:07:56.320 | Because here, we need to actually access this in order
00:07:58.560 | to get into our actual values here.
00:08:02.480 | So just print this out.
00:08:03.480 | And then we need to also add this.
00:08:09.560 | There we go.
00:08:14.240 | So these five minute intervals, and this
00:08:15.960 | is what we're going to work with.
00:08:18.640 | Let's just make things a little bit easier to read.
00:08:21.040 | , and now we're going to do here, we're going to do here, we're going to do here, we're going to do here.
00:08:29.040 | Let's just make things a little bit easier to read.
00:08:31.040 | And now, we're going to do here is append a dictionary, which
00:08:52.560 | is going to contain each one of these columns.
00:08:56.040 | And now, we're going to do here is append a dictionary, which
00:08:59.360 | is going to contain each one of these columns.
00:09:02.840 | And now, we're going to do here is append a dictionary, which
00:09:07.160 | is going to contain each one of these columns.
00:09:09.560 | And now, we're going to do here is append a dictionary, which
00:09:15.960 | is going to contain each one of these columns.
00:09:18.440 | And now, we're going to do here is append a dictionary, which
00:09:21.640 | is going to contain each one of these columns.
00:09:24.000 | And now, we're going to do here is append a dictionary, which
00:09:27.560 | is going to contain each one of these columns.
00:09:30.040 | And now, we're going to do here is append a dictionary, which
00:09:34.240 | is going to contain each one of these columns.
00:09:36.840 | And now, we're going to do here is append a dictionary, which
00:09:41.040 | is going to contain each one of these columns.
00:09:43.640 | And now, we're going to do here is append a dictionary, which
00:09:47.240 | is going to contain each one of these columns.
00:09:49.840 | And now, we're going to do here is append a dictionary, which
00:09:53.640 | is going to contain each one of these columns.
00:09:56.240 | And now, we're going to do here is append a dictionary, which
00:09:59.840 | is going to contain each one of these columns.
00:10:02.440 | And now, we're going to do here is append a dictionary, which
00:10:06.040 | is going to contain each one of these columns.
00:10:08.440 | And now, we're going to do here is append a dictionary, which
00:10:12.040 | is going to contain each one of these columns.
00:10:14.440 | And now, we're going to do here is append a dictionary, which
00:10:18.040 | is going to contain each one of these columns.
00:10:20.440 | And now, we're going to do here is append a dictionary, which
00:10:24.040 | is going to contain each one of these columns.
00:10:26.440 | And now, we're going to do here is append a dictionary, which
00:10:29.640 | is going to contain each one of these columns.
00:10:32.040 | And now, we're going to do here is append a dictionary, which
00:10:35.240 | is going to contain each one of these columns.
00:10:37.640 | And now, we're going to do here is append a dictionary, which
00:10:40.840 | is going to contain each one of these columns.
00:10:43.240 | And now, we're going to do here is append a dictionary, which
00:10:46.240 | is going to contain each one of these columns.
00:10:48.440 | And now, we're going to do here is append a dictionary, which
00:10:51.640 | is going to contain each one of these columns.
00:10:53.840 | And now, we're going to do here is append a dictionary, which
00:10:56.840 | is going to contain each one of these columns.
00:10:59.640 | And now, we're going to do here is append a dictionary, which
00:11:02.640 | is going to contain each one of these columns.
00:11:05.040 | And now, we're going to do here is append a dictionary, which
00:11:08.240 | is going to contain each one of these columns.
00:11:10.640 | And now, we're going to do here is append a dictionary, which
00:11:13.840 | is going to contain each one of these columns.
00:11:16.240 | And now, we're going to do here is append a dictionary, which
00:11:19.240 | is going to contain each one of these columns.
00:11:21.440 | And now, we're going to do here is append a dictionary, which
00:11:24.440 | is going to contain each one of these columns.
00:11:27.040 | And now, we're going to do here is append a dictionary, which
00:11:30.040 | is going to contain each one of these columns.
00:11:32.240 | And now, we're going to do here is append a dictionary, which
00:11:35.240 | is going to contain each one of these columns.
00:11:37.640 | And now, we're going to do here is append a dictionary, which
00:11:40.640 | is going to contain each one of these columns.
00:11:43.040 | And now, we're going to do here is append a dictionary, which
00:11:46.040 | is going to contain each one of these columns.
00:11:48.440 | And now, we're going to do here is append a dictionary, which
00:11:51.440 | is going to contain each one of these columns.
00:11:54.440 | And now, we're going to do here is append a dictionary, which
00:11:57.440 | is going to contain each one of these columns.
00:12:00.040 | And now, we're going to do here is append a dictionary, which
00:12:03.040 | is going to contain each one of these columns.
00:12:05.640 | And now, we're going to do here is append a dictionary, which
00:12:08.640 | is going to contain each one of these columns.
00:12:11.040 | And now, we're going to do here is append a dictionary, which
00:12:14.040 | is going to contain each one of these columns.
00:12:16.440 | And now, we're going to do here is append a dictionary, which
00:12:19.440 | is going to contain each one of these columns.
00:12:22.440 | And now, we're going to do here is append a dictionary, which
00:12:25.440 | is going to contain each one of these columns.
00:12:28.440 | And now, we're going to do here is append a dictionary, which
00:12:31.440 | is going to contain each one of these columns.
00:12:34.440 | And now, we're going to do here is append a dictionary, which
00:12:37.440 | is going to contain each one of these columns.
00:12:40.440 | And now, we're going to do here is append a dictionary, which
00:12:43.440 | is going to contain each one of these columns.
00:12:46.440 | And now, we're going to do here is append a dictionary, which
00:12:49.440 | is going to contain each one of these columns.
00:12:52.440 | And now, we're going to do here is append a dictionary, which
00:12:55.440 | is going to contain each one of these columns.
00:12:58.440 | And now, we're going to do here is append a dictionary, which
00:13:01.440 | is going to contain each one of these columns.
00:13:04.440 | And now, we're going to do here is append a dictionary, which
00:13:07.440 | is going to contain each one of these columns.
00:13:10.440 | And now, we're going to do here is append a dictionary, which
00:13:13.440 | is going to contain each one of these columns.
00:13:16.440 | And now, we're going to do here is append a dictionary, which
00:13:19.440 | is going to contain each one of these columns.
00:13:22.440 | And now, we're going to do here is append a dictionary, which
00:13:25.440 | is going to contain each one of these columns.
00:13:28.440 | And now, we're going to do here is append a dictionary, which
00:13:31.440 | is going to contain each one of these columns.
00:13:34.440 | And now, we're going to do here is append a dictionary, which
00:13:37.440 | is going to contain each one of these columns.
00:13:40.440 | And now, we're going to do here is append a dictionary, which
00:13:43.440 | is going to contain each one of these columns.
00:13:46.440 | And now, we're going to do here is append a dictionary, which
00:13:49.440 | is going to contain each one of these columns.
00:13:52.440 | And now, we're going to do here is append a dictionary, which
00:13:55.440 | is going to contain each one of these columns.
00:13:58.440 | And now, we're going to do here is append a dictionary, which
00:14:01.440 | is going to contain each one of these columns.
00:14:04.440 | And now, we're going to do here is append a dictionary, which
00:14:07.440 | is going to contain each one of these columns.
00:14:10.440 | And now, we're going to do here is append a dictionary, which
00:14:13.440 | is going to contain each one of these columns.
00:14:16.440 | And now, we're going to do here is append a dictionary, which
00:14:19.440 | is going to contain each one of these columns.
00:14:22.440 | And now, we're going to do here is append a dictionary, which
00:14:25.440 | is going to contain each one of these columns.
00:14:28.440 | And now, we're going to do here is append a dictionary, which
00:14:31.440 | is going to contain each one of these columns.
00:14:34.440 | And now, we're going to do here is append a dictionary, which
00:14:37.440 | is going to contain each one of these columns.
00:14:40.440 | And now, we're going to do here is append a dictionary, which
00:14:43.440 | is going to contain each one of these columns.
00:14:46.440 | And now, we're going to do here is append a dictionary, which
00:14:49.440 | is going to contain each one of these columns.
00:14:52.440 | And now, we're going to do here is append a dictionary, which
00:14:55.440 | is going to contain each one of these columns.
00:14:58.440 | And now, we're going to do here is append a dictionary, which
00:15:01.440 | is going to contain each one of these columns.
00:15:04.440 | And now, we're going to do here is append a dictionary, which
00:15:07.440 | is going to contain each one of these columns.
00:15:10.440 | And now, we're going to do here is append a dictionary, which
00:15:13.440 | is going to contain each one of these columns.
00:15:16.440 | And now, we're going to do here is append a dictionary, which
00:15:19.440 | is going to contain each one of these columns.
00:15:22.440 | And now, we're going to do here is append a dictionary, which
00:15:25.440 | is going to contain each one of these columns.
00:15:28.440 | And now, we're going to do here is append a dictionary, which
00:15:31.440 | is going to contain each one of these columns.
00:15:34.440 | And now, we're going to do here is append a dictionary, which
00:15:37.440 | is going to contain each one of these columns.
00:15:40.440 | And now, we're going to do here is append a dictionary, which
00:15:43.440 | is going to contain each one of these columns.
00:15:46.440 | And now, we're going to do here is append a dictionary, which
00:15:49.440 | is going to contain each one of these columns.
00:15:52.440 | And now, we're going to do here is append a dictionary, which
00:15:55.440 | is going to contain each one of these columns.
00:15:58.440 | And now, we're going to do here is append a dictionary, which
00:16:01.440 | is going to contain each one of these columns.
00:16:04.440 | And now, we're going to do here is append a dictionary, which
00:16:07.440 | is going to contain each one of these columns.
00:16:10.440 | And now, we're going to do here is append a dictionary, which
00:16:13.440 | is going to contain each one of these columns.
00:16:16.440 | And now, we're going to do here is append a dictionary, which
00:16:19.440 | is going to contain each one of these columns.
00:16:22.440 | And now, we're going to do here is append a dictionary, which
00:16:25.440 | is going to contain each one of these columns.
00:16:28.440 | And now, we're going to do here is append a dictionary, which
00:16:31.440 | is going to contain each one of these columns.
00:16:34.440 | And now, we're going to do here is append a dictionary, which
00:16:37.440 | is going to contain each one of these columns.
00:16:40.440 | And now, we're going to do here is append a dictionary, which
00:16:43.440 | is going to contain each one of these columns.
00:16:46.440 | And now, we're going to do here is append a dictionary, which
00:16:49.440 | is going to contain each one of these columns.
00:16:52.440 | And now, we're going to do here is append a dictionary, which
00:16:55.440 | is going to contain each one of these columns.
00:16:58.440 | And now, we're going to do here is append a dictionary, which
00:17:01.440 | is going to contain each one of these columns.
00:17:04.440 | And now, we're going to do here is append a dictionary, which
00:17:07.440 | is going to contain each one of these columns.
00:17:10.440 | And now, we're going to do here is append a dictionary, which
00:17:13.440 | is going to contain each one of these columns.
00:17:16.440 | Let's do that.
00:17:43.440 | Let's go with the open for now.
00:17:59.440 | So you can see that it's not showing anything.
00:18:01.440 | And this is an issue with one of the Plotly extensions.
00:18:15.440 | So we just need to install those.
00:18:18.440 | It's not difficult, though, from what I remember.
00:18:21.440 | Yeah, this is Plotly extension.
00:18:41.440 | Yeah.
00:18:44.440 | So it's the JupyterLab extension.
00:18:47.440 | So that's checking what we have.
00:18:57.440 | So I need these two, JupyterLab extension--
00:19:01.440 | JupyterLab Plotly and Plotly widget.
00:19:04.440 | So let's go and install those two.
00:19:14.440 | I realize maybe this is too small for you to see.
00:19:17.440 | So these two are going to do.
00:19:19.440 | Although these are the uninstallable,
00:19:21.440 | we're going to install them.
00:19:22.440 | All right.
00:19:55.440 | So then we need to install the other one as well.
00:20:10.440 | Then we might need to restart Jupyter,
00:20:13.440 | but let's see if it works.
00:20:18.440 | I'm also going to need a JupyterLab build as well,
00:20:21.440 | just in case I need it.
00:20:23.440 | I don't think I will, but let's try.
00:20:44.440 | So let's go back to our lab.
00:20:47.440 | And let's just refresh and try.
00:20:49.440 | Let's see if it works.
00:20:50.440 | If not, we'll just restart.
00:20:56.440 | Yeah, OK.
00:20:57.440 | So let's just restart it quickly.
00:21:26.440 | And let's try all this again.
00:21:29.440 | Here we go.
00:21:30.440 | So it's working now.
00:21:31.440 | So yeah, that's pretty cool.
00:21:36.440 | Although, what is this?
00:21:37.440 | We have-- yeah, that's weird.
00:21:45.440 | Do we need to-- let me check what these are.
00:21:52.440 | I assume these must be strings.
00:21:54.440 | They're not actual numbers.
00:22:09.440 | Yeah, so we need to convert these into numbers as well.
00:22:18.440 | OK, so we can do that with the two numeric function.
00:22:26.440 | And then just pass the columns that we want in there.
00:22:30.440 | I'm not sure if we can do all of them at once
00:22:33.440 | or if we have to do one at a time.
00:22:35.440 | Let's try all.
00:22:49.440 | OK, yeah, so just one at a time.
00:22:51.440 | Let's just take this list.
00:23:10.440 | I'm also not sure if it does it in place or not as well.
00:23:14.440 | Let's just have a quick look.
00:23:36.440 | OK, so I think it does not do it in place.
00:23:40.440 | Let's see.
00:23:47.440 | OK, so-- OK, so no, it doesn't.
00:24:11.440 | All right, there we go.
00:24:12.440 | So now it's a float.
00:24:15.440 | This should work now.
00:24:16.440 | There we go.
00:24:20.440 | So that looks pretty cool.
00:24:21.440 | And we have this sort of interactive--
00:24:27.440 | interactivity with the chart, which-- this
00:24:30.440 | is why I wanted to use Plotly over, like, Matplotlib.
00:24:34.440 | I think this is definitely something
00:24:36.440 | we want to have in the chart.
00:24:38.440 | So we have that now.
00:24:43.440 | Before we do the candlesticks, let's just
00:24:45.440 | try putting on a few of the indicators
00:24:48.440 | and see how that looks and see if they're
00:24:51.440 | straightforward or not.
00:24:52.440 | So it is simple moving average.
00:24:58.440 | So let's add that in.
00:25:00.440 | Add that in.
00:25:22.440 | OK, so let's just clean this API requesting up a little bit.
00:25:50.440 | OK, so that is our API.
00:25:54.440 | And then we just want to change these.
00:25:59.440 | We'll just use it like this instead.
00:26:06.440 | OK, so we have SMA.
00:26:24.440 | We want GME weekly interval.
00:26:29.440 | No, we want-- so five minutes.
00:26:31.440 | Oh, no, we don't.
00:26:32.440 | We want-- so it's a moving average.
00:26:34.440 | So yeah, let's go weekly.
00:26:36.440 | And see how that looks.
00:26:37.440 | Time period, this is like 10 days.
00:26:45.440 | What do we have here?
00:26:46.440 | We don't have a time period.
00:26:49.440 | So we do want to adjust that a little bit.
00:26:53.440 | So maybe we can--
00:26:55.440 | let me zoom in a little bit here.
00:26:57.440 | Probably can't see anything.
00:27:02.440 | So the function interval, so yeah, we have a few.
00:27:07.440 | Let's go like a 60 minute, because then we can actually
00:27:10.440 | see that on the time period that we're already looking at.
00:27:13.440 | Number of data points.
00:27:17.440 | But OK, let's change this to a 60 minute moving average.
00:27:31.440 | So no, we don't want to change that one.
00:27:33.440 | We change this one.
00:27:35.440 | And add in the API key as well.
00:27:44.440 | OK, let's just see what we get.
00:27:50.440 | OK, cool.
00:27:55.440 | So we have this--
00:27:56.440 | OK, we have this technical analysis.
00:27:59.440 | Interval, OK.
00:28:03.440 | So we want to pulling data out of here.
00:28:08.440 | OK, cool.
00:28:09.440 | So I wonder if you can add multiple functions.
00:28:15.440 | I don't know.
00:28:16.440 | But let's stick with this.
00:28:19.440 | And we're basically going to do the same thing again,
00:28:22.440 | where we take these.
00:28:26.440 | But this time, we are getting our moving average.
00:28:39.440 | So technical analysis.
00:28:41.440 | Let's put this in.
00:28:48.440 | And all we want here is the date time and then this SMA value.
00:28:58.440 | So technical analysis, I think that's fine.
00:29:07.440 | So now we just change this to SMA.
00:29:13.440 | I think that should be OK.
00:29:19.440 | Let's see.
00:29:22.440 | OK, let's put that in here so I don't do that again.
00:29:30.440 | And I just overwrote all of that.
00:29:34.440 | I mean, I need to change this.
00:29:41.440 | [TYPING SOUNDS]
00:30:09.440 | OK, that looks cool.
00:30:12.440 | So we will also need to do this again, where
00:30:16.440 | we convert it to numeric.
00:30:19.440 | [TYPING SOUNDS]
00:30:22.440 | Let's just add SMA head here.
00:30:43.440 | [TYPING SOUNDS]
00:30:46.440 | Then let's plot this.
00:30:56.440 | And let's just see what we get.
00:30:59.440 | [TYPING SOUNDS]
00:31:09.440 | So we get a lot more data here.
00:31:13.440 | So we need to restrict that to only within what we have here.
00:31:20.440 | But at the same time, I think it would be cool
00:31:25.440 | if we got a little more data than what we have.
00:31:27.440 | But let's just keep it dynamic for now.
00:31:32.440 | So we just take the minimum date time that we have within DF.
00:31:37.440 | And then we'll just apply that to all of our technical indicators
00:31:40.440 | so that we're only pulling it from then onwards.
00:31:44.440 | And we could probably get it from the API.
00:31:47.440 | But let's just filter the data frame.
00:32:02.440 | Yeah, because here, I'm not sure they do actually give you
00:32:05.440 | a date time limit that you can just extract from that point.
00:32:13.440 | So yeah, I think we need to do it from the data frame anyway.
00:32:22.440 | So after we do all of this, let's also get the min date time.
00:32:35.440 | That would just be DF date time dot min.
00:32:45.440 | We also need to re-extract all of that because I overwrote it earlier.
00:33:12.440 | Okay, and then let's check our date time.
00:33:16.440 | It should be something reasonable.
00:33:19.440 | So yeah, I think that makes sense.
00:33:22.440 | It's like 12 hours before.
00:33:24.440 | No, about eight hours before this point.
00:33:29.440 | So that's fine.
00:33:31.440 | So eight hours of data in there.
00:33:34.440 | So when we do this, all we need to do is just filter out anything
00:33:41.440 | that is below that date time.
00:33:45.440 | So all we do is SMA equals SMA,
00:33:56.440 | where the date time is greater than or equal to minDT.
00:34:08.440 | So let's just check.
00:34:10.440 | So we have the length of SMA here.
00:34:13.440 | So we've got 560 rows.
00:34:15.440 | And then if we do this, we filter it down to nine,
00:34:20.440 | which is more reasonable.
00:34:22.440 | So we have, I think we had around eight hours in there.
00:34:26.440 | So nine hours maybe.
00:34:29.440 | And we're taking it in 60 minute intervals.
00:34:33.440 | So that makes sense.
00:34:36.440 | And then if we do that, cool.
00:34:42.440 | So we get our SMA indicator here.
00:34:46.440 | So let's plot those both together and see how it looks.
00:35:00.440 | Okay, so apparently you need to also add fig,
00:35:09.440 | add scatter.
00:35:12.440 | And then you add mode lines onto the end to add another line.
00:35:22.440 | So maybe I didn't see this.
00:35:47.440 | Okay, so line is supposed to be lines, I think.
00:36:06.440 | Okay, cool.
00:36:08.440 | So that looks good.
00:36:11.440 | We have our SMA and our actual plot.
00:36:21.440 | So that seems pretty straightforward.
00:36:25.440 | But now we actually want to maybe add candlesticks into this
00:36:30.440 | because that would be pretty cool in my opinion.
00:36:35.440 | No idea how we can do that in Plotly.
00:36:37.440 | So let's try and figure it out.
00:37:06.440 | It actually looks really simple.
00:37:08.440 | So you need to use the graph objects instead of express.
00:37:26.440 | Let's try and add that then.
00:37:31.440 | So if it's really that easy, then this -- oh, it's super easy.
00:37:38.440 | Oh, wow.
00:38:02.440 | Okay, so that's our candlestick.
00:38:05.440 | That's really cool.
00:38:12.440 | I don't really know if you want this bit, but I suppose it's kind of cool.
00:38:18.440 | Let's just go with it for now.
00:38:21.440 | So we have that and then we also want to add scatter again to add the SMA.
00:38:32.440 | Okay, that's pretty cool.
00:38:46.440 | So now we just want to add in a few of those other indicators.
00:38:51.440 | So what do we have?
00:38:54.440 | We have this OnBalanceVolume, BalanceOfPower, RateOfChange, Arun, and Trikin.
00:39:02.440 | So let's do this OnBalanceVolume one first.
00:39:05.440 | I'm going to add in a couple of functions to actually do things as well.
00:39:11.440 | So like here, every time that we want to convert these to numeric,
00:39:17.440 | I think we want to convert anything that's just not called date/time.
00:39:24.440 | So we can just add that as a function.
00:39:50.440 | Let's do toNumeric and then just add our DataFrame.
00:39:58.440 | Then we just go for col in df.columns.
00:40:06.440 | We only want to do this if col is not equal to date/time.
00:40:16.440 | So every other column we do want to convert to numeric.
00:40:22.440 | And just return that.
00:40:26.440 | Okay, so instead of needing to write it out every time,
00:40:29.440 | we can just write toNumeric when we have our data.
00:40:48.440 | Okay.
00:41:13.440 | So here we're getting the time series data.
00:41:23.440 | We also want to convert to numeric here.
00:41:34.440 | We can leave it as df.
00:41:43.440 | Okay, and let's just test that, see how it is.
00:41:48.440 | Okay, looks good.
00:41:55.440 | So we can remove that.
00:41:57.440 | And then we are getting our SMA data.
00:42:14.440 | So let's just move that into OneBox as well.
00:42:23.440 | And this, we just want SMA and SMA.
00:42:44.440 | Okay.
00:42:47.440 | Let's move this up to the top as well.
00:42:57.440 | I want to add in a few more here.
00:43:01.440 | So we have -- which one is it?
00:43:04.440 | It's the onBalance, I think.
00:43:11.440 | Yeah, the onBalance volume, let's do that one.
00:43:24.440 | And we're probably going to do something similar here again, right?
00:43:27.440 | So let's go to our documentation and let's get the onBalance.
00:43:41.440 | So we have this.
00:43:52.440 | So paste that there.
00:43:58.440 | Do something pretty similar again.
00:44:05.440 | So we have the API key, which is going to be our key.
00:44:13.440 | The interval.
00:44:17.440 | I should probably check what that actually means for this.
00:44:38.440 | So this one is probably the one that I was most interested in seeing.
00:44:45.440 | It's like a -- it measures the positive and negative flow with the intention of
00:44:52.440 | identifying where you've got a load of sort of big investors putting a lot of
00:45:01.440 | money into it.
00:45:08.440 | Or sorry, when you've got a lot of smaller investors putting a lot of money
00:45:12.440 | into it, so basically the volume is higher.
00:45:15.440 | Because obviously the retail investors are putting a lot more bets on, but
00:45:22.440 | they're smaller buys or sells.
00:45:27.440 | So that I imagine would be how this works.
00:45:40.440 | Although, you know, I've just read this very briefly before, so it could be
00:45:44.440 | completely wrong.
00:45:46.440 | But it sounds pretty interesting from reading this.
00:45:50.440 | So let's just try and implement it.
00:45:52.440 | I'm going to go with shorter time period than what it's suggesting here.
00:46:01.440 | Because I don't know if we will see anything with that.
00:46:04.440 | Or the shorter interval, sorry.
00:46:09.440 | And then GME.
00:46:13.440 | Okay, so let's put this in.
00:46:25.440 | No need to see what we actually get here.
00:46:40.440 | Okay, so we have this technical analysis.
00:46:43.440 | And it's basically the same as before when we had the SMA.
00:46:49.440 | So we could probably write a function that does that for us.
00:46:55.440 | But let's just do it like this for now.
00:47:04.440 | So we just change this to ABV.
00:47:07.440 | That's a pretty easy change.
00:47:29.440 | Okay.
00:47:32.440 | So let's try that.
00:47:41.440 | I think this one should be pretty interesting to see.
00:47:47.440 | And I don't know, to be honest, we're going to need to put these on another chart.
00:47:53.440 | Because obviously that isn't going to work.
00:47:57.440 | I imagine there isn't an easy way of doing it.
00:48:02.440 | But let's just check quickly.
00:48:07.440 | Yeah.
00:48:09.440 | Okay.
00:48:18.440 | So we should probably have a look at how people normally do this.
00:48:47.440 | Okay, and let's try and stick with the graph objects.
00:49:14.440 | So I don't know if this is going to give us -- yeah, this just gives us express.
00:49:33.440 | Okay.
00:49:36.440 | So we're actually just going to use a scatter.
00:49:40.440 | Okay, cool.
00:49:43.440 | So we want something like this.
00:49:51.440 | We go scatter.
00:49:54.440 | And then we add X and Y.
00:50:23.440 | Okay, so we just swapped out ABV.
00:50:35.440 | Okay, cool.
00:50:37.440 | So we have this.
00:50:40.440 | Interesting.
00:50:48.440 | So this is our unbalanced value.
00:50:55.440 | Is that right?
00:50:56.440 | Unbalanced volume, sorry.
00:50:59.440 | So I wonder if this would make more sense because it's volume to have it as a bar chart at the bottom.
00:51:22.440 | Yeah, that would be interesting, I think.
00:51:50.440 | Okay.
00:52:15.440 | So we have subplots here.
00:52:18.440 | We have space very similar to -- okay, perfect.
00:52:24.440 | So that looks kind of good.
00:52:28.440 | But we want steps, so I think it's the same as far as I know.
00:52:32.440 | Yeah.
00:52:34.440 | The only thing that I'm not doing here is matching on the X-axis.
00:52:39.440 | But again, that shouldn't really be an issue for us because we do actually have -- we have already matched on the X-axis.
00:52:47.440 | So let's give that a go.
00:53:00.440 | So we want subplots, make.
00:53:05.440 | And we append trace this time instead.
00:53:19.440 | So this time we're going to append trace.
00:53:32.440 | I don't know if we can add scatter.
00:53:37.440 | Okay, no, so we need to -- yeah, I don't know if we should have really been doing that anyway because it needs to be more like this.
00:53:54.440 | And then I suppose we can add mode here.
00:53:58.440 | Or maybe not, let's not for now.
00:54:04.440 | Let's just append trace.
00:54:08.440 | And we do that for SMA as well.
00:54:22.440 | Let's see how that goes.
00:54:27.440 | I just want two rows.
00:54:31.440 | And we've already imported this.
00:54:34.440 | So let's -- okay, so we have data, Y.
00:54:41.440 | Okay.
00:54:45.440 | And we also need to specify the row and the column as well.
00:55:06.440 | Okay, so this is going to be row -- which one?
00:55:10.440 | Yeah, this one's going to be row two.
00:55:13.440 | This one here will be row one, col1.
00:55:20.440 | And we just need to remove the data part that we added in here.
00:55:27.440 | So I suppose -- yeah.
00:55:36.440 | So append trace.
00:55:40.440 | And we just remove that.
00:55:57.440 | Okay.
00:56:00.440 | So yeah, it's pretty messy.
00:56:02.440 | Okay, so it's because we have this.
00:56:05.440 | So I kind of want to just get rid of that for now.
00:56:25.440 | So I don't know what it is, like an excited slider maybe.
00:56:37.440 | Okay, so this is kind of what we need, I think.
00:56:42.440 | Yeah.
00:56:44.440 | So we just need to update the layout.
00:56:55.440 | And just made this false.
00:57:03.440 | And I think -- let's put this up to here.
00:57:10.440 | Type date, okay, this should work.
00:57:14.440 | Let's see.
00:57:34.440 | Okay, cool.
00:57:35.440 | So we have -- so now we have this.
00:57:42.440 | What is it most useful?
00:57:45.440 | How do you normally -- let's have a look at how this unbalance volume is normally plotted.
00:58:00.440 | Okay.
00:58:13.440 | So this is the unbalance volume here.
00:58:15.440 | So it's just like another line chart underneath the other line chart.
00:58:25.440 | So it's basically what we have already.
00:58:32.440 | This is interesting.
00:58:38.440 | So here's like a confirming trade when they're both in the same direction.
00:58:51.440 | Okay, so this is what we want to look at here.
00:58:56.440 | When the price and OBV are making higher peaks and higher troughs, upward trend is likely to continue.
00:59:04.440 | So when they're both going up, when they're making lower and lower, there's a downward trend.
00:59:12.440 | If the OBV is rising, accumulation may be taking place.
00:59:20.440 | So if we have a look at this.
00:59:23.440 | So you can see they're both going down.
00:59:25.440 | So that's like, okay, the downward trend is likely to continue.
00:59:30.440 | And here they're both going up.
00:59:33.440 | So upward trend is likely to continue.
00:59:35.440 | And then they're just leveling out here.
00:59:37.440 | So it's not really anything of interest.
00:59:39.440 | But I suppose here it's kind of balanced.
00:59:42.440 | And we see the momentum sort of pushing up again just before it rises.
00:59:50.440 | So maybe that is what we're sort of looking for.
00:59:54.440 | Either way, it's pretty interesting to actually look at.
01:00:08.440 | And then I also want to probably have a look at this shaking osculator as well.
01:00:14.440 | So it looks pretty interesting, I think.
01:00:20.440 | So if we go back into the API documentation.
01:00:35.440 | So I think it's this one.
01:00:40.440 | Yeah.
01:00:42.440 | So it's the Chaikin AD line.
01:00:51.440 | Okay, so this is measuring big investors, I think.
01:00:55.440 | So when you're looking for where the big investors are putting their money,
01:01:03.440 | this is supposed to be an indicator of it, as far as I understand.
01:01:09.440 | So it examines the strength of price moves and the underlying buying and selling pressure
01:01:14.440 | to try and measure the demand.
01:01:19.440 | Then divergence between the price and the oscillator is indicated as most frequent single
01:01:24.440 | and flags a short-term reverse on price.
01:01:26.440 | So that'd be interesting to see if we can maybe find that happening around here or around here.
01:01:40.440 | So let's figure that one out as well.
01:02:09.440 | Okay.
01:02:37.440 | So this time, we're just replacing the function with AD interval, this one's doing daily.
01:02:45.440 | So maybe this is the sort of thing we want to be looking at more frequently.
01:02:56.440 | So you have the key, GME.
01:03:03.440 | And I think that's pretty much what we want.
01:03:06.440 | So let's put this down to, let's go 60 minutes again.
01:03:12.440 | And then we can maybe change that.
01:03:22.440 | Okay, so let's see what we get.
01:03:24.440 | So this is Chaikin AD.
01:03:28.440 | Okay, cool.
01:03:35.440 | So let's pull that through.
01:03:39.440 | So I'm going to use this code again.
01:03:43.440 | So replace this.
01:03:49.440 | I'm just going to call it AD or just call it Chad, Chaikin AD.
01:04:06.440 | Okay.
01:04:09.440 | And what was it?
01:04:10.440 | Just Chaikin AD, right?
01:04:12.440 | Yeah.
01:04:17.440 | So that's what we want.
01:04:26.440 | Let's replace this with Chaikin AD again.
01:04:30.440 | And add Chad down here as well.
01:04:42.440 | Okay.
01:04:52.440 | So I think, so this bit we need, what do we want this bit to be?
01:05:00.440 | So just Chaikin AD.
01:05:08.440 | Okay.
01:05:10.440 | We've got two numeric, so that all looks pretty good to me.
01:05:13.440 | Let's add that in.
01:05:16.440 | So obviously that's going to need another row.
01:05:22.440 | So let's just add that in.
01:05:28.440 | Add Chad.
01:05:44.440 | And we'll put this at the bottom.
01:05:46.440 | We need to add another row here.
01:05:53.440 | Let's see how that looks.
01:05:55.440 | So, okay, cool.
01:06:01.440 | Doesn't look bad.
01:06:02.440 | It's interesting.
01:06:03.440 | So the point was that when they diverge,
01:06:09.440 | it's an indication of a sort of a movement change.
01:06:19.440 | And that indicates a reversal in price.
01:06:23.440 | So I don't know, I suppose here is like the only bit where it kind of doesn't
01:06:27.440 | follow the price because the price is pretty level.
01:06:30.440 | In fact, it's even going down here, right?
01:06:33.440 | And here it starts to go up.
01:06:39.440 | So maybe that's indicating the reversal in price change.
01:06:44.440 | But it's also kind of difficult too because we're only looking at our time
01:06:48.440 | here, so we should probably increase the, you know, how much we're reviewing.
01:06:54.440 | So let's just go to like 10 minutes and see how that looks.
01:07:02.440 | Okay, I bet we can't do that.
01:07:09.440 | Yeah, it's not returning anything.
01:07:15.440 | It's probably the interval.
01:07:16.440 | Oh, you see.
01:07:17.440 | Okay, so we need 15 minutes.
01:07:22.440 | Let's just go five, see what it's like.
01:07:35.440 | Okay, so that's more interesting.
01:07:41.440 | So now we just see like this big movement up here.
01:07:48.440 | But then I bet if we look at long term, it's probably pretty stable.
01:07:53.440 | So let's try and increase how much data we're actually looking at.
01:08:04.440 | So the interval.
01:08:33.440 | Okay, so what's our MNDT?
01:08:47.440 | Okay, so this is returning.
01:08:54.440 | Okay, so this is actually returning Friday.
01:08:56.440 | So I was wrong earlier when I said this is a Saturday's data.
01:09:00.440 | It's kind of stupid.
01:09:09.440 | But does this actually return us anything more than what we have here?
01:09:24.440 | Okay, cool.
01:09:25.440 | So we're showing this full rather than compact.
01:09:30.440 | So output size is going to be full.
01:09:48.440 | So that should give us a lot more data.
01:09:49.440 | So before we were heading at 11 on the 29th.
01:09:55.440 | Let's see what we have now.
01:09:57.440 | Okay, that's way further back.
01:09:59.440 | So that's cool.
01:10:02.440 | We probably, I don't know if we'll be able to even see that much though.
01:10:07.440 | So maybe it's worth maybe not doing a five minute interval as we're going.
01:10:14.440 | Like daily.
01:10:19.440 | Let's see what that looks like.
01:10:26.440 | Of course that changes this as well.
01:10:46.440 | So let's change it here.
01:10:53.440 | Hopefully that should work.
01:10:56.440 | Okay, now.
01:10:59.440 | So let's check what we are returning.
01:11:19.440 | Okay, so how because we are doing the intraday.
01:11:24.440 | We can go 60 minutes.
01:11:30.440 | So let's change that to 60 minutes.
01:11:49.440 | Okay.
01:11:51.440 | Oh, no goes even further back.
01:11:54.440 | I wasn't expecting that.
01:11:56.440 | That's pretty good.
01:11:58.440 | That's a lot of data.
01:12:03.440 | So now I'm thinking, what do we want here?
01:12:06.440 | Maybe daily?
01:12:10.440 | Do we want daily?
01:12:16.440 | Let's go weekly for now.
01:12:23.440 | Or maybe we can go daily.
01:12:47.440 | So let's have a look at these, how they are now.
01:12:51.440 | So here's obviously the volume.
01:12:55.440 | It's pushing up loads and everyone's buying into it.
01:12:58.440 | But you can see there's this massive increase here.
01:13:02.440 | This is back in at the start of January.
01:13:11.440 | So start of January.
01:13:13.440 | And yet it was going up but not loads.
01:13:15.440 | You can just see it kind of pushing up, pushing up.
01:13:22.440 | And then here you have same again.
01:13:25.440 | It starts to go a little bit crazy.
01:13:27.440 | So here went over, went greater than zero.
01:13:32.440 | And this is January 22nd.
01:13:35.440 | So here.
01:13:41.440 | This is before it all went crazy.
01:13:43.440 | So I think it kind of went down here and then back up.
01:13:51.440 | Let's see.
01:13:55.440 | It's pretty interesting.
01:14:00.440 | So, I mean, I think that's it for this video for now.
01:14:05.440 | It's probably, I mean, obviously there's a lot we could do like tidying up.
01:14:08.440 | But just in getting a few indicators together and the actual stock data in Candlestick.
01:14:15.440 | So it's pretty easy.
01:14:18.440 | I mean, I've never done most of this before with Plotly and it's super easy to figure out.
01:14:23.440 | So that's pretty good.
01:14:25.440 | So I suppose that's it.
01:14:27.440 | So thank you for watching the video.
01:14:30.440 | I'll leave all this code on GitHub as well.
01:14:33.440 | I'll add a link in the description if it helps.
01:14:37.440 | I mean, it's not too much anyway.
01:14:39.440 | But it might help you pull things together a bit quicker.
01:14:44.440 | So, anyway, thank you for watching.
01:14:47.440 | And I will see you again next time.