Python Charting Stocks/Forex for Technical Analysis Part 9 - Adding Volume data to matplotlib graph
Skills:
AI Pair Programming80%
Key Takeaways
Adds volume data to a matplotlib graph for stock price analysis using Python
Full Transcript
what is going on everybody welcome back to our graphing financial data tutorial where we left off we have this lovely looking chart coming up here it's not the most attractive visually but it's a good looking chart for now and so now what we want to do and now that we've figured out how to plot the price data we are we already have the volume data so we might as well start plotting the volume data that we have so how do we do that so what we're going to go ahead and do here is add another axis right we've got one sub pie here let's add another subplot so to do that what we want to do is we're going to come down I guess is here and we'll say ax 2 equals PLT dotsub fly and what we're going to do is change up the numbers like I was saying earlier the numbers are basically like a square right so if you have like a one by one right there's only the option for one chart right but we want to have multiple charts so what we're going to want to do is we're going to say this is a 2 by 1 so there's one chart well it's like I guess it's like you know 2 vertical x 1 horizontal I guess is the way to think about it this is going to be number one so you want to edit because like this originally says one by one by you know one by one and it's chart number one now it's two by one this is still chart number one this one's going to be a two by one oops two by one but it's chart number two name right so the next thing we want to do is we're going to say for a x2 this is actually you know a volume chart we could have a line right you could just draw like a line like we do with the open high low close right it's like a line graph but at most people do a bar graph right for volume data so let's go ahead and conform to that and we're going to do a bar chart and so to do that you just literally type in far right and in within the bar what are the things that we want to do well we still want to use date and then the other thing is volume and again we want that grid so we'll do a x2 grid and we're going to say true you do want a grid now what we want to do is we're going to have two labels so generally what you can do is like let us will leave date for there but now that we have two Y labels we kinda need to like specify like which one is which so here we'll come here and you'll say PLT dot Y label and this Y label will again be stock price but then down here we're going to do a quixote dot y label and this will be some remember this one so it'll already have inputted it and then we're going to just re input a Y label it's kind of a hacky way to do it but that's what we're gonna do and that's this is the volume data now what we want to do is we're happy with oh yeah we'll get to that in a second um let's see what we're going to want to do is I guess well let me try I think I think we can plot this now and I'll show you where we stand at the moment so you can see the necessary changes okay so when we plot this now you see what we have right we've got this volume data here and it's actually blue if you can't tell but like if we zoom in to the volume chart you can see it's very you know blue but as you can see there's a few problems one problem is this isn't showing date right so we obviously have to convert this to date this stuff is quite ugly and then also like let's say we want to zoom into like this area here on stock price volume didn't change like right so we'd have to like perfectly match it up ourselves right and like kind of the point of programming is to automate a lot of stuff and make life easy so how can we make life easy well turns out it's you know fairly simple to do so let's go ahead and do that so we're going to close out of here and what we first thing that we want to do is for this we're going to say share axis or share X share X and who do we want to share X with with axis one this way when we save that and run it again first of all it gives us the converted dates even though again like it's really hard to see it right now if we stretch it out you can see like the hold date let me put it back on the window um but what it's going to do it's special is if we zoom into right here now this automatically zooms in and like we're like oh what happened on this day where it was really high volume and we zoom in on the high volume point right the stock price stuff zooms in as well so it's all you know identical same thing like let's say you do this you're like oh I want to scoot over a little bit you can pull it and like now everything is like they have x axis is shared between these two bits of data so that's very very useful now the next thing that we want to do is for the label here instead of a x one one thing we can do with a is one to kind of cheat is do this and make it a 90 degree and then for label just copy that paste it and for label and a x2 and then change this to 45 now when we save that or run it it's kind of cleaned up this data it's still kind of showing but we can kind well we'll continue going through what we can do about that data but for now it looks at least a little better and we can actually see the state information and we still obviously have the same scroll ability where they're shared and zoom ability and all this good stuff so continuing I'll close out of that the next thing let's see if there's anything else I want to do in this specific video um you know I think that I think we will cut off the video here but the next thing up we really need to do is if you've ever liked look chart besides you know fix this stuff we'll get to that if you ever look at a chart and it's got like price and volume like there's no reason first of all we don't need these numbers at all on volume very rarely do you actually have like number stuff on that y-axis on a volume chart so we can get rid of that we can still leave you know the label of volume that's a good idea so we want to get rid of those but also you'll notice a lot of times that the actual volume chart is very small you know like it's like maybe a third of the size of this current volume chart and then the stock chart is like much larger because really volume is more for like a reference and it's like something you just quickly glanced at right so it's not something you need to look really have like a lot of detail so um so in the next video what we're going to do is make how to figure out how to make this chart a little bit smaller and so yeah so that's what we're getting into the next video and then also get rid of some of this data I just kind of cleaning up this chart a little bit but as you can see it's starting to evolve into a you know a respectable financial graph so stay tuned to the next video as always thank you for watching thanks for your support your subscriptions and until next time
Original Description
This is the ninth video in the series for stock price analysis and financial charting, improving on the basic chart we made in the previous video and adding volume data to our stock prices. 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
📰
📰
📰
📰
AI Tool-Calling: Translating Business Requirements to Database Schemas
Dev.to AI
NarraMeuGol: the AI that calls your street-football goal 🎙️⚽
Dev.to AI
Building Sniper Code: A Beautiful Browser UI for Claude Code (Without API Keys)
Medium · ChatGPT
Claude Code Sends 33k Tokens Before Your Prompt; OpenCode Sends 7k
Dev.to · TerminalBlog
🎓
Tutor Explanation
DeepCamp AI