-
All in Python
-
The SAS version is here EquityCharacteristicsSAS
-
Extension to China A Share Market
-
Extension to Factors and Portfolios in China Market
For financial researches, we need equity characteristics. This repository is a toolkit to calculate asset characteristics in individual equity level and portfolio level.
- Read the listed papers
- WRDS account with subscription to CRSP, Compustat and IBES.
- Python
- 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
- 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
- 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)
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
- 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
This topic is summaried by Green Hand Zhang and Hou Xue Zhang.
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:
- Characteristics-sorted Portfolio, see the listed papers and also Deep Learning in Characteristics-Sorted Factor Models
- DGTW Benchmark, see DGTW 1997 JF
- Industry portfolio
Many papers contribute a lot to this repository. I am very sorry for only listing the following papers.
-
Measuring Mutual Fund Performance with Characteristic‐Based Benchmarks by DANIEL, GRINBLATT, TITMAN, WERMERS 1997 JF
-
Dissecting Anomalies with a Five-Factor Model by Fama and French 2015 RFS
- Define the characteristics of a portfolio as the value-weight averages (market-cap weights) of the variables for the firms in the portfolio
- French's Data Library
-
The Characteristics that Provide Independent Information about Average U.S. Monthly Stock Returns by Green Hand Zhang 2017 RFS
-
Replicating Anormalies by Hou Xue Zhang 2018 RFS
- Calculate equity characteristics with SAS code, mainly refering to SAS code by Green Hand Zhang.
- Portfolio characteristics, mainly refering to WRDS Financial Ratios Suite and Variable Definition
- DGTW code refers to this python code or this SAS code
All comments are welcome.