EasyEventStudies
This package makes it easy to run event studies on financial assets. In contrast to other packages, it is easy to use, correct and allows for three different models of normal returns estimation. All calculations are based on the standard reference in the literature: The Econometrics of Financial Markets; John Y. Campbell, Andrew W. Lo and Craig MacKinlay (1998)
Quick Start Guide
Install the package using pip:
pip install pip install EasyEventStudies==1.0
The run_event_study function runs a complete event study analysis for a financial asset and an event date. The package takes financial data from Yahoo Finance, so search for the ticker symbol of the asset you are interested on their website here.
As an example, we will run an event study on Boeing Co. (ticker: BA) on 8th of March, 2019. At this time, the Boing 737 Max was involved in two crashes and the FAA was about to ground the fleet.
results = run_event_study(
ticker='BA',
event_date='2019-03-08',
estimation_window=[-250, 0],
event_window=[0, 20],
model_type="market_model"
)
plot_CAR_over_time(results)
The event study shows that the failure of the Boing 737 Max was associated with a drop in the stock price of about 17 Percent in the first 20 days after the event.
More Detailed Documentation
- The main function is
run_event_study. It returns a pandas DataFrame with the results of the event study. Remember to specify the model you want to use to estimate normal returns.
def run_event_study(
ticker: str,
event_date: str,
estimation_window: Tuple[int, int],
event_window: Tuple[int, int],
historical_days: int = 10,
model_type: str = "market_model"
):
- ticker: The ticker symbol from Yahoo Finance as a string (e.g., 'BA' for Boeing)
- event_date: The date of the event in 'YYYY-MM-DD' format (e.g., '2019-03-08')
- estimation_window: A tuple of two integers defining the time period used to estimate normal returns. The first number is the start of the window, the second is the end. For example, [-250, -1] uses the previous year's data.
- event_window: A tuple of two integers defining the period for calculating cumulative abnormal returns. The first number is the start, the second is the end. For example, [0, 10] analyzes the 10 days following the event.
- historical_days: Number of days before the event window to include in the output. This allows for plotting pre-event stock returns. Defaults to 10.
- model_type: The model to use for estimating normal returns. Options are:
- "market_model": Estimates returns as a function of market returns
- "constant_model": Assumes constant normal returns
- "three_factor_model": Uses the Fama-French three-factor model
The models to estimate normal returns are standard in the literature and defined as:
1. Market Model ("market_model")
The market model assumes a linear relationship between the stock's returns and the market's returns:
$R_{it} = \alpha_i + \beta_i R_{mt} + \epsilon_{it}$
Where:
- $R_{it}$: Return of stock $i$ at time $t$
- $R_{mt}$: Return of the market index at time $t$
- $\alpha_i$: Intercept term for stock $i$
- $\beta_i$: Slope coefficient (beta) for stock $i$
- $\epsilon_{it}$: Error term
2. Constant Mean Return Model ("constant_model")
This model assumes that the expected return is constant over time:
$R_{it} = \mu_i + \epsilon_{it}$
Where:
- $\mu_i$: Average return of stock $i$ over the estimation window
- $\epsilon_{it}$: Error term
3. Fama-French Three-Factor Model ("three_factor_model")
The three-factor model includes additional factors for size and value:
$R_{it} = \alpha_i + \beta_i R_{mt} + s_i \text{SMB}_t + h_i \text{HML}t + \epsilon{it}$
Where:
- $R_{it}$: Return of stock $i$ at time $t$
- $R_{mt}$: Return of the market portfolio at time $t$
- $\text{SMB}_t$: Small Minus Big factor at time $t$ (size effect)
- $\text{HML}_t$: High Minus Low factor at time $t$ (value effect)
- $\alpha_i$: Intercept term for stock $i$
- $\beta_i$, $s_i$, $h_i$: Factor loadings for stock $i$
- $\epsilon_{it}$: Error term
- The
plot_CAR_over_timefunction plots the cumulative abnormal returns over time. It takes the results of therun_event_studyfunction as an input and plots the cumulative abnormal returns over time.
def plot_CAR_over_time(event_study_results,
days_before_event: int = 10,
days_after_event: int = 10
):
- event_study_results: The results of the
run_event_studyfunction. - days_before_event: Number of days before the event window to include in the plot. Defaults to 10.
- days_after_event: Number of days after the event window to include in the plot. Defaults to 10.
Citation
If you use this package in your work, please cite it as:
Roever, Nicolas (2024). EasyEventStudies: A Python Package for Event Studies. https://github.com/NicolasRoever/EasyEventStudies
Notes for Developer
Publishing the package:
- Delete the dist folder
- Update the version number in pyproject.toml
- Run
python -m build - Run
python -m twine upload dist/*
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyeventstudies-1.6.tar.gz.
File metadata
- Download URL: easyeventstudies-1.6.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f32712b677d1843f721a2fa00aefadde69b4436a668417b16bf40723f126899
|
|
| MD5 |
e0961cd2b68d176ee211103307f7bc32
|
|
| BLAKE2b-256 |
032867f177563684901d020db679da8912a588ff0ad7b90a648afbb8115f8101
|
File details
Details for the file EasyEventStudies-1.6-py3-none-any.whl.
File metadata
- Download URL: EasyEventStudies-1.6-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c9925bec4d529c671617527f9523ebc9893df98e72a568f667061b0b54a7767
|
|
| MD5 |
3917d76146f8c0738c0d1c43ed175c01
|
|
| BLAKE2b-256 |
c790ea77a3dc13f18111f1d3febd5e2e54a9199fd5c85018fc8497fd12535f1a
|