Version
Academic Background
For financial researches, we need equity characteristics. This repository is a toolkit to calculate asset characteristics in individual equity level and portfolio level.
Prerequisite
- Read the listed papers
- WRDS account with subscription to CRSP, Compustat and IBES.
- Python
Files
Main Files
- accounting_60_hxz.py – most annual, quarterly and monthly frequency characteristics
- functions.py – impute and rank functions
- merge_chars.py – merge all the characteristics from different pickle file into one pickle file
- impute_rank_output_bchmk.py – impute the missing values and standardize raw data
- iclink.py – preparation for IBES
- pkl_to_csv.py – converge the pickle file to csv
Single Characteristic Files
- beta.py – 3 months rolling CAPM beta
- rvar_capm.py, rvar_ff3.py – residual variance of CAPM and fama french 3 factors model, rolling window is 3 months
- rvar_mean.py – variance of return, rolling window is 3 months
- abr.py – cumulative abnormal returns around earnings announcement dates
- myre.py – revisions in analysts’ earnings forecasts
- sue.py – unexpected quarterly earnings
- ill.py – illiquidity, rolling window is 3 months
- maxret_d.py – maximum daily returns, rolling window is 3 months
- std_dolvol.py – std of dollar trading volume, rolling window is 3 months
- std_turn.py – std of share turnover, rolling window is 3 months
- bid_ask_spread.py – bid-ask spread, rolling window is 3 months
- zerotrade.py – number of zero-trading days, rolling window is 3 months
How to use
- run accounting_60_hxz.py
- run all the single characteristic files (you can run them in parallel)
- run merge_chars.py
- run impute_rank_output_bckmk.py (you may want to comment the part of sp1500 in this file if you just need the all stocks version)
Outputs
Data
The date range is 1972 to 2019. The stock universe is top 3 exchanges (NYSE/AMEX/NASDAQ) in US.
The currant time of data is $ret_t = chars_{t-1}$
- chars_raw_no_impute.feather (all data with original missing value)
- chars_raw_imputed.feather (impute missing value with industry median/mean value)
- chars_rank_no_imputed.feather (standardize chars_raw_no_impute.pkl)
- chars_rank_imputed.feather (standardize chars_raw_imputed.pkl)
- stock indicator: gvkey, permno
- time: datadate, date, year (‘datadate’ is the available time for data and ‘date’ is the date of return)
- industry: sic, ffi49
- exchange info: exchcd, shrcd
- return: ret (we also provide original return and return without dividend, you can keep them by modifing impute_rank_output_bchmk.py)
- market equity: me/rank_me
Method
Equity Characteristics
This topic is summaried by Green Hand Zhang and Hou Xue Zhang.
Portfolio Characteristics
Portfolio charactaristics is the equal-weighted / value-weighted averge of the characteristics for all equities in the portfolio.
The portfolios includes and not limited to:
Reference
Papers
Many papers contribute a lot to this repository. I am very sorry for only listing the following papers.
Codes
All comments are welcome.