Skip to content

Repository files navigation

SimpleStockRegression

A C++ command-line tool for performing linear regression analysis on stock time series data to calculate beta coefficients between a target ticker and an index ticker.

Overview

This project analyzes the relationship between two securities by computing a linear regression on their daily percentage changes. It reads historical bar data from Sierra Chart data files and calculates the slope (beta) and intercept of the regression line, which can be used to understand how a target security moves relative to an index.

Features

  • Time Series Data Loading: Parses Sierra Chart .dly_BarData.txt CSV files containing OHLC (Open, High, Low, Close) data
  • Percent Change Calculation: Computes daily percentage changes for each security
  • Linear Regression: Performs least-squares linear regression using modern C++23 ranges
  • Beta Coefficient: Calculates the beta (slope) showing the target's sensitivity to index movements
  • Configurable Analysis Period: Analyze any number of recent bars

Requirements

  • C++23 compatible compiler (Visual Studio 2022 or later)
  • Sierra Chart data files in the format: {TICKER}-NQTV.dly_BarData.txt
  • Data files must be located in: C:\SierraChart\Data\

Building the Project

  1. Open SimpleStockRegression.sln in Visual Studio
  2. Build the solution (Ctrl+Shift+B)
  3. The executable will be generated in the output directory

Usage

Command Line Syntax

reg.exe <TargetTicker> <IndexTicker> <NumBars>

Parameters

  • TargetTicker: The ticker symbol of the security to analyze (e.g., AAPL, MSFT)
  • IndexTicker: The ticker symbol of the index or benchmark (e.g., SPX, NDX)
  • NumBars: Number of most recent daily bars to include in the regression analysis

Examples

reg.exe META SPY 252

[META-SPY] y=1.64x+0.006

reg.exe QQQ SPY 31

[QQQ-SPY] y=1.33x+0.002

About

Stock regression using C++ ranges

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages