Python Financial Analysis: Returns, Correlation Matrix, & Performance Plots | Part 5 ๐Ÿ“ˆ

Matt Macarty ยท Beginner ยท๐Ÿ“Š Data Analytics & Business Intelligence ยท4y ago

About this lesson

@MattMacarty ## ๐Ÿ Python Financial Analysis: Calculate Returns, Correlation Matrix, & Plot Performance with Pandas | Part 5 Welcome to Part 5 of the **Python Stock Analysis Course**! Now that we have aggregated all our historical closing prices (from Part 4), we can begin performing core financial analysis. This video teaches you how to build three fundamental functions using **Pandas** and **NumPy** to transform raw price data into actionable metrics. ### ๐ŸŽฏ Key Learning Outcomes: 1. **Calculate Returns:** Master the use of **Pandas** and **NumPy** to quickly calculate **instantaneous rate of returns** for all securities in your dataset. 2. **Correlation Matrix:** Create a function to generate a **Correlation Matrix** using the calculated returns, allowing you to instantly visualize the co-movement of all stocks. 3. **Performance Plotting:** Build a flexible function using **Matplotlib** to plot either the absolute prices or the **relative performance** (normalized against the starting price) of multiple securities on a single chart. ### โฑ๏ธ Video Chapters (Jump Ahead!): 0:00 - Introduction & Review (Starting with Aggregated Closing Prices) 0:33 - Importing **NumPy** for Calculations 0:48 - **Function 1: Calculating Instantaneous Rate of Returns** 1:40 - Testing the Returns Function and Reviewing the Output 2:24 - **Function 2: Creating a Correlation Matrix with Pandas** 3:30 - Reviewing the Correlation Matrix Output (High correlation in Energy stocks) 3:48 - **Function 3: Plotting Security Performance with Matplotlib** 4:26 - Setting up Conditional Logic for CSV vs. Excel Input 4:54 - **Absolute vs. Relative Performance Plotting Logic** 5:05 - Using **Matplotlib** to Generate the Plot (Grid, Lines, & Adjustments) 6:13 - Testing the Plot Function with Absolute Prices (Hard to compare) 6:19 - Testing the Plot Function with **Relative Performance** (Easy to compare) 7:10 - Preview of Part 6: Calculating Daily Changes and Saving Data ### ๐Ÿ”— Course Series & Re

Original Description

@MattMacarty ## ๐Ÿ Python Financial Analysis: Calculate Returns, Correlation Matrix, & Plot Performance with Pandas | Part 5 Welcome to Part 5 of the **Python Stock Analysis Course**! Now that we have aggregated all our historical closing prices (from Part 4), we can begin performing core financial analysis. This video teaches you how to build three fundamental functions using **Pandas** and **NumPy** to transform raw price data into actionable metrics. ### ๐ŸŽฏ Key Learning Outcomes: 1. **Calculate Returns:** Master the use of **Pandas** and **NumPy** to quickly calculate **instantaneous rate of returns** for all securities in your dataset. 2. **Correlation Matrix:** Create a function to generate a **Correlation Matrix** using the calculated returns, allowing you to instantly visualize the co-movement of all stocks. 3. **Performance Plotting:** Build a flexible function using **Matplotlib** to plot either the absolute prices or the **relative performance** (normalized against the starting price) of multiple securities on a single chart. ### โฑ๏ธ Video Chapters (Jump Ahead!): 0:00 - Introduction & Review (Starting with Aggregated Closing Prices) 0:33 - Importing **NumPy** for Calculations 0:48 - **Function 1: Calculating Instantaneous Rate of Returns** 1:40 - Testing the Returns Function and Reviewing the Output 2:24 - **Function 2: Creating a Correlation Matrix with Pandas** 3:30 - Reviewing the Correlation Matrix Output (High correlation in Energy stocks) 3:48 - **Function 3: Plotting Security Performance with Matplotlib** 4:26 - Setting up Conditional Logic for CSV vs. Excel Input 4:54 - **Absolute vs. Relative Performance Plotting Logic** 5:05 - Using **Matplotlib** to Generate the Plot (Grid, Lines, & Adjustments) 6:13 - Testing the Plot Function with Absolute Prices (Hard to compare) 6:19 - Testing the Plot Function with **Relative Performance** (Easy to compare) 7:10 - Preview of Part 6: Calculating Daily Changes and Saving Data ### ๐Ÿ”— Course Series & Re
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Related AI Lessons

โšก
Surviving the Data Science Behavioral Interview
Learn to ace data science behavioral interviews with confidence using three key tips
Towards Data Science
โšก
Before I needed it, no one told me that "legacy tape management" was an entire industry.
Learn about legacy tape management and its importance in data migration, especially when dealing with large-scale tape collections
Reddit r/artificial
โšก
Top 5 DBMS Concepts (2026) | Perfectnotes
Learn the top 5 DBMS concepts to manage data efficiently in applications
Medium ยท Data Science
โšก
The Nervous System of the Telco: Unlocking the Real-Time Power of the Network Element Interfacesโ€ฆ
Unlock the power of network element interfaces to enable real-time insights in telco operations
Medium ยท Data Science

Chapters (13)

Introduction & Review (Starting with Aggregated Closing Prices)
0:33 Importing **NumPy** for Calculations
0:48 **Function 1: Calculating Instantaneous Rate of Returns**
1:40 Testing the Returns Function and Reviewing the Output
2:24 **Function 2: Creating a Correlation Matrix with Pandas**
3:30 Reviewing the Correlation Matrix Output (High correlation in Energy stocks)
3:48 **Function 3: Plotting Security Performance with Matplotlib**
4:26 Setting up Conditional Logic for CSV vs. Excel Input
4:54 **Absolute vs. Relative Performance Plotting Logic**
5:05 Using **Matplotlib** to Generate the Plot (Grid, Lines, & Adjustments)
6:13 Testing the Plot Function with Absolute Prices (Hard to compare)
6:19 Testing the Plot Function with **Relative Performance** (Easy to compare)
7:10 Preview of Part 6: Calculating Daily Changes and Saving Data
Up next
Spreadsheet Guy Meets the CFO: "Define How Much"
Digital Transformation with Eric Kimberling
Watch โ†’