Python Charting Stocks/Forex for Technical Analysis Part 8 - Improving our Stock Chart
Skills:
AI Pair Programming80%
Key Takeaways
Improves a stock chart by adding grid lines, title, and labels using matplotlib in Python
Full Transcript
what is up everybody welcome back to another uh graphing financial information tutorial where we left off let's bring that chart up we were plotting this chart now obviously the date is a little you know it's kind of going under this like this is overlapping the day but this is clearly the correct price here that is the correct date even though we can't see it if we just the size of this window it kind of stretches up um but we'll we'll be coding it in to fix that in a moment and you know we don't have a title we don't have any labels over here so it's not really a proper chart and also I'd like to have grid lines so that's what we're going to go ahead and do in this video so close out of that and the first thing I'd like to do is like let's set up the grids so here uh right underneath the last ax1 plot let's do ax1 do grid and parentheses just type in true that will add a grid to uh what we're doing now the next thing I'd like to do is we want to add a title and the correct labels so we'll just do that down here and let's say pt. x Lael and we're going to say the X label is date and then PLT doy Lael for this we're going to um it's stock price so now that we have the labels let's bring up the graph again and the grid so now it makes it a little bit easier to read right when you have the Grid on there it's really easy to line up the date with you know the price at the time um and then Al like as you hover it if you'll notice down here in the corner you see the information but if like your mouse is over here it's still reading you information but anyway um and just like let's go through a couple quick things again this is all covered in my map plot lib tutorial series but um let's go over a couple things to how to use this for one if you want to zoom in like to different parts of the graph um you can use this like zoom in button and like let and you make a square like you click and drag a square and then you let go and now we've zoomed in and as you can see the date has actually changed with us but we can't really see that so let's go over how to fix that if you click on this configure subplots button it brings up this window here and you can kind of manipulate how much spacing there is on the side like you could have zero and it would just go all the way to the edge but we want to have our labels seen so like you know that looks pretty good like 07 then on the bottom obviously we need more so we're going to drag that up a little bit and now you can see date shows and then the right we could move it over slightly and these two are more in top you could bring up top we don't have a title yet but we will have one soon but since we don't have a title we could drag it all the way up um or have it a little bit of space there and then head space and width space or wide space I don't know what really maybe it's horizontal I don't know anyway this is like space between the like the tops of the chart so if you have more than one plot you would want to change this maybe um but since we only have one plot there's that it's not going to do anything same thing with the width space that's not going to do anything but eventually um it will do something so you can kind of like remember these numbers but we're going to go through and hardcode it so every time this chart comes up with you don't have to like set that stuff right cuz that's kind of lame so that's the next thing that we're going to do but first let's go through a couple more things with the chart so as you can see like when we zoom in uh the dates will change you know dynamically and all this and let's say like you do this and you're like oh my gosh this is way too close like how do I get back to where I was you can use these um arrows to get back and then you're like oh no I wanted that one just prior you know you can go back forward and so on the other thing you can do is you can click on this like I don't even know what it is but it's so you can like kind of Click hold it and you can drag the chart around so that's how you do that and then if you just get so lost and all you want to do is just get right back to where you started you can to hit this home button and it takes you back home that's just how to kind of navigate these charts if you're unfamiliar with them um but generally what you want to do is kind of code it in to display exactly what you want but if it doesn't you can still kind of go through and play with it so anyway that's that so uh what we're going to do now is let's do the subplot stuff so the way that you do that is to edit it you do PLT or PLT do subplots uncore adjust and in here you put all those parameters um that we saw so there was like left bottom right top w space and h space so let's go ahead and Define them all and you can use that tool to figure out exactly what you want um or you can just kind of guess and for us um I'm pretty decent at it so PR sure like with left we want like a 10 bottom we'll do um9 right uh like 93 top equals like 095 I think so once we throw in a title um we'll want to have that and w space we're not even really going to touch those yet so I guess I guess we could code in but we we don't need them yet um 20 and then h space equal 007 something like that you can adjust them like I said on your own if you want so now let's add a title and to do that we're going to use what's called a super tile or subtitle um and for our title we want it to be whatever the stock name is plus a space and then a stock price so if we're doing like test it'll say Tesla space stock price so it kind of looks good so let's save that and let's run it and sure enough on popup this looks pretty darn good right the date is formatted nice and neatly got stock price over here the title is like perfect that was a good guess um yeah so this chart is looking a lot better right on load and what's nice about it is what you can do later on is instead of like loading up the chart in this little like figure diagram you just automatically shoot it out to a image like a PNG or you can do like a tiff or whatever you want um you can you can have it come out as so it's just it's kind of helpful to have it like already formatted just in case you don't want to actually generate the chart yourself uh and you just maybe want to generate images real quick so um I think that's going to conclude everything I wanted to cover in this video um in the next video we'll be uh continuing along here and I think what we going what we're going to do uh in the next one is like this is pretty I mean it's decent enough we will get into doing like Candlestick and you can like change you can change everything like you can change the font you can change the colors you can change the background here you can change just everything like all the line colors and the background color face color here and the background here and all everything can be changed so um there is a lot of customization that can be done but and we'll get into that because everybody like with their financial charts they got to be like badass looking right you make more money if your chart looks badass so um we definitely have to do that eventually but first let's go ahead and get the essentials down so in the next video what we're going to do is start plotting up uh volume data so what we want to do you know you've got stock price up here and then maybe down here you've got volume right of that data so that'll be the next thing that we do so uh if that sounds interesting to you uh carry on to the next video as always thank you for watching thank you for your support and your subscriptions and until next time
Original Description
This is the eighth video in the series for stock price analysis and financial charting, improving on the basic chart we made in the previous video. The purpose of the videos in this series is to teach you how to program your own charting and analysis of stocks or Forex.
This is beneficial for you if you plan to do any sort of algorithmic, high-frequency, or any sort of automated trading.
Sentdex.com
Facebook.com/sentdex
Twitter.com/sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: AI Pair Programming
View skill →Related Reads
📰
📰
📰
📰
The Collapse of ‘Who Understands, Who Maintains’ — A Software Landscape in the AI Age
Medium · Programming
Building an OpenAI + Azure SQL App from Scratch
Medium · Python
Breaking the Abstraction Tax: Mastering Custom C++ Operations for High-Performance Edge AI on Android
Dev.to · Programming Central
Five Habits I'm Unlearning After Claude Code 101
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI