📅 2024-01-18 — Session: Enhanced OLS Residuals Calculation and Visualization

🕒 16:05–17:10
🏷️ Labels: Python, OLS, Data Visualization, Rolling Residuals, Finance
📂 Project: Dev
⭐ Priority: MEDIUM

Session Goal

The session aimed to enhance the calculation and visualization of Ordinary Least Squares (OLS) residuals for financial data analysis.

Key Activities

  • Modified Function for Rolling Residuals Calculation: Updated the add_rolling_residuals function to perform OLS computations directly within the function, allowing for better debugging and control.
  • Line Plot Creation: Developed a line plot of adjusted close prices with residuals, due to the unavailability of mplfinance for candlestick charts.
  • Diagnostic Plot for OLS Model: Outlined the steps to create a diagnostic plot for an OLS model, including regression line, residuals, and model parameter annotations.
  • Integration with Candlestick Chart: Provided a script to integrate OLS diagnostic plots with candlestick charts, enhancing stock data visualization.
  • Efficient Calculation for Multiple Tickers: Implemented a script to apply the rolling residuals function across multiple tickers and save the results to a CSV file.

Achievements

  • Successfully modified and tested the add_rolling_residuals function.
  • Created visualizations that integrate OLS diagnostics with stock data, improving analytical insights.

Pending Tasks

  • Explore alternatives or updates for mplfinance to support candlestick charting directly.
  • Further optimize the rolling residuals calculation for large datasets.