Summary
Keywords
Full Transcript
@MattMacarty ## 🐍 Python Download Historical Stock Data & Save to CSV (eod Library & Pandas) | Part 3 Welcome to Part 3 of the **Python Stock Analysis Course**! In this video, we move from curating a list of stock symbols (Part 2) to the crucial step of **downloading and saving historical price data** for analysis. You will learn how to replace cumbersome API calls with a cleaner, class-based approach using the dedicated **`eod` Python library** (for EODHistoricalData). We then write a robust function to process the downloaded data and save it locally as clean **CSV files** with a Datetime index. ### 🎯 Key Learning Outcomes: 1. **Simplify API Calls:** Install and use the **`eod` Python library** to handle API endpoint communication more efficiently than direct URL calls. 2. **Date Range Setup:** Define default start and end dates to retrieve a consistent time period of historical data (e.g., 13 months). 3. **Data Processing:** Convert the raw downloaded data into a **Pandas DataFrame**, set a **DatetimeIndex** for time-series analysis, and drop unnecessary columns. 4. **Local Storage:** Create a function that loops through a list of tickers, downloads data for each, and saves it to a designated local folder (`data_files`) as individual **CSV files**. ### ⏱️ Video Chapters (Jump Ahead!): 0:00 - Introduction & Course Review (Tickers acquired, now need data) 0:43 - **Installing and Importing the `eod` API Client Library** 1:48 - Setting up Default Start & End Dates (e.g., 13 months of data) 2:56 - Defining the `get_data` Function (Arguments: Tickers, API Key, Path) 4:30 - Instantiating the API Client and Looping Through Tickers 5:18 - Making the API Call for **End-of-Day (EOD) Prices** 5:42 - **Setting the DatetimeIndex in Pandas** 6:14 - Saving the Cleaned Data to a **Local CSV File** 7:00 - Printing Download Status and Skipped Tickers 7:45 - Testing the Function with Energy Sector Stocks 10:48 - Preview of Part 4: Processing the Downloaded Data (Returns, Plotting) ### 🔗 Course Series & Resources: * **Part 1 (Tickers List):** [https://youtu.be/bKUZrBAzqJs](https://youtu.be/bKUZrBAzqJs) * **Part 2 (Filtering):** [https://youtu.be/KKVZHKDEKFA](https://youtu.be/KKVZHKDEKFA) * **Get the Code:** https://github.com/mjmacarty/python-stock-analysis ***Disclaimer: This video is for educational purposes only. The information provided should not be construed as investment advice. *** \#PythonForFinance \#HistoricalData \#APICall \#Pandas \#PythonTutorial \#CSVExport \#eodLibrary \#StockDataDownload \#Part3
