Python Charting Stocks/Forex for Technical Analysis Part 9 - Adding Volume data to matplotlib graph

sentdex · Intermediate ·💻 AI-Assisted Coding ·12y ago

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 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related Reads

📰
AI Tool-Calling: Translating Business Requirements to Database Schemas
Learn how AI tool-calling translates business requirements to database schemas, streamlining development and operations
Dev.to AI
📰
NarraMeuGol: the AI that calls your street-football goal 🎙️⚽
Create a radio-style commentary for amateur football matches using AI with NarraMeuGol
Dev.to AI
📰
Building Sniper Code: A Beautiful Browser UI for Claude Code (Without API Keys)
Learn to build a beautiful browser UI for Claude Code without API keys and enhance your coding experience
Medium · ChatGPT
📰
Claude Code Sends 33k Tokens Before Your Prompt; OpenCode Sends 7k
Learn how Claude Code and OpenCode compare in terms of token shipping for system prompts and tools, and why it matters for efficient coding
Dev.to · TerminalBlog
Up next
99% of People Still Don't Understand Vibe Coding
Vskills Certification
Watch →