Skip to content

BETA

Summary

Beta: the slope of a least-squares linear regression of one series' percentage returns (y, from inReal1) against another's (x, from inReal0) over a rolling window. Measures how much a security moves relative to a market index. Beta = 1 moves with the index; < 1 less volatile, > 1 more volatile.

Formula

Per-bar returns: \(x_i=(p^0_i-p^0_{i-1})/p^0_{i-1}\) from inReal0, \(y_i=(p^1_i-p^1_{i-1})/p^1_{i-1}\) from inReal1. With \(n\)=period over the window: \(\beta = \dfrac{n\,S_{xy}-S_x S_y}{n\,S_{xx}-S_x^2}\), where \(S_{xx}=\sum x^2,\ S_{xy}=\sum xy,\ S_x=\sum x,\ S_y=\sum y\).

Inputs

  • inReal0 — Series whose returns are the regression x (market/index)
  • inReal1 — Series whose returns are the regression y (security)

Outputs

  • outReal — Beta: regression slope of inReal1-returns on inReal0-returns

Parameters

  • optInTimePeriod — Rolling window length (number of returns) for the regression sums

Implementation

TA-Lib Definition: beta.c · beta.yaml

Native File
C ta_BETA.c
Rust beta.rs
Java Core.java

TA-Lib is also available for Python, R and more using a wrapper.

Aliases

Beta coefficient

See Also

CORREL · LINEARREG_SLOPE · VAR · STDDEV