Estimate a Sharp Regression Discontinuity (RDD): the jump in dependent_ticker exactly where running_variable_ticker crosses cutoff.

Also known as: RDD, sharp RD.

For more information about the method, see causal_inference_model.get_regression_discontinuity.

Treats running_variable_ticker’s value as the running variable that (hypothetically) triggers some discrete change once it crosses cutoff – e.g. testing whether dependent_ticker’s return behaves discontinuously around a round-number/threshold level of another asset or indicator (a psychological price level, an index-inclusion market-cap threshold, a macro indicator’s policy-relevant threshold) fed in as running_variable_ticker. Fits separate local linear regressions of dependent_ticker’s return on the (cutoff-centered) running_variable_ticker value, one on each side of cutoff, and reports the gap between the two fitted lines exactly at the cutoff.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Regression Discontinuity (RDD) for you. Just ask in plain English.

Calculate the Regression Discontinuity (RDD) in Python

The Regression Discontinuity (RDD) is available in the Econometrics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_regression_discontinuity as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.econometrics.get_regression_discontinuity(
    "AAPL", "MSFT", cutoff=0.0, period="weekly"
)

Which returns:

  Value
Discontinuity 0.0003
Std. Error 0.0077
t-Statistic 0.0343
P-Value 0.9726
Cutoff 0.0000
Bandwidth 0.1257
N Left 71
N Right 85

Parameters

get_regression_discontinuity accepts the following parameters:

  • dependent_ticker (str): The outcome asset.
  • running_variable_ticker (str): The asset (or column) whose value determines which side of cutoff an observation falls on.
  • cutoff (float): The threshold value of running_variable_ticker at which the discontinuity is estimated.
  • period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
  • column (str, optional): The historical data column to use for both series. Defaults to “Return”.
  • bandwidth (float | None, optional): The maximum distance from cutoff an observation may be to be included in either local regression. Defaults to None, which uses half of the running variable’s observed range – see causal_inference_model.get_regression_discontinuity for why this is a deliberately naive default.
  • kernel (str, optional): One of “uniform” or “triangular”. Defaults to “uniform”.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.

The Econometrics module page introduces the module, and the sidebar lists all of its functions.

Share