Construct a Synthetic Control for treated_ticker from a weighted combination of donor_tickers (Abadie, Diamond & Hainmueller, 2010), and estimate the effect of an event/intervention as the post-treatment_period gap between treated_ticker’s actual and synthetic counterfactual return path.

Also known as: SCM, synthetic control method.

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

Synthetic Control in Python

get_synthetic_control is part of the Econometrics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_synthetic_control as shown below.

from financetoolkit import Toolkit

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

toolkit.econometrics.get_synthetic_control(
    "AAPL",
    treatment_period="2021-07-01",
    donor_tickers=["MSFT", "Benchmark"],
    period="weekly",
)

Which returns:

  Value
Average Treatment Effect 0.0012
Pre-Treatment RMSPE 0.0286
Post-Treatment RMSPE 0.024
RMSPE Ratio 0.8417
P-Value 0.3333
N Donors 2
N Pre-Periods 78
N Post-Periods 79

Parameters

get_synthetic_control accepts the following parameters:

  • treated_ticker (str): The asset believed to be affected by an event/ intervention starting at treatment_period.
  • treatment_period (str): The first post-treatment period – periods at or after this value (within period’s index) are treated as post-treatment, everything before as pre-treatment (used to fit the synthetic control’s weights).
  • donor_tickers (str | list[str] | None, optional): The ticker(s) forming the donor pool the synthetic control is built from. Defaults to None, meaning every other Toolkit ticker (subject to include_benchmark).
  • period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
  • column (str, optional): The historical data column to use. Defaults to “Return”.
  • include_benchmark (bool, optional): Whether to include “Benchmark” in the default donor pool (has no effect when donor_tickers is given explicitly). Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.
Share