PROVIDER = 'Tarek A. Hassan, Stephan Hollander, Laurence van Lent, Ahmed Tahoun, 2019'
URL = 'https://www.dropbox.com/s/96xo9f1twlu3525/firmquarter_2022q1.csv?raw=1'
HOST_WEBSITE = 'https://www.firmlevelrisk.com/'
FREQ = 'Q'
MIN_YEAR = 2002
MAX_YEAR = 2022
ENTITY_ID_IN_RAW_DSET = 'gvkey'
ENTITY_ID_IN_CLEAN_DSET = 'permno'
TIME_VAR_IN_RAW_DSET = 'date'
TIME_VAR_IN_CLEAN_DSET = f'{FREQ}date'Hassan, et al. (2019)
This module downloads and processes data developed by:
- Tarek A. Hassan, Stephan Hollander, Laurence van Lent, Ahmed Tahoun, 2019, “Firm-Level Political Risk: Measurement and Effects,” Quarterly Journal of Economics, 134 (4), pp.2135-2202. https://doi.org/10.1093/qje/qjz021.
The dataset also contains data developed by the papers below:
Tarek A. Hassan, Stephan Hollander, Laurence van Lent, Ahmed Tahoun, “The Global Impact of Brexit Uncertainty,” 2020, NBER Working Paper 26609
Tarek A. Hassan, Stephan Hollander, Laurence van Lent, Markus Schwedeler, Ahmed Tahoun, “Firm-level Exposure to Epidemic Diseases: Covid-19, SARS, and H1N1,” 2020, mimeo London Business School. Avilable at SSRN: https://ssrn.com/abstract=3566530
See the authors’ dedicated website for more information on this dataset: https://www.firmlevelrisk.com/
list_all_vars
list_all_vars (url:str='https://www.dropbox.com/s/96xo9f1twlu3525/firmqua rter_2022q1.csv?raw=1', delimiter:str='\t')
alv = list_all_vars()
alv.head()| name | |
|---|---|
| 0 | gvkey |
| 1 | date |
| 2 | PRisk |
| 3 | NPRisk |
| 4 | Risk |
print(list(alv.name))['gvkey', 'date', 'PRisk', 'NPRisk', 'Risk', 'PSentiment', 'NPSentiment', 'Sentiment', 'PRiskT_economic', 'PRiskT_environment', 'PRiskT_trade', 'PRiskT_institutions', 'PRiskT_health', 'PRiskT_security', 'PRiskT_tax', 'PRiskT_technology', 'company_name', 'hqcountrycode', 'isin', 'cusip', 'ticker', 'date_earningscall', 'Covid_Exposure', 'Covid_Neg_Sentiment', 'Covid_Pos_Sentiment', 'Covid_Net_Sentiment', 'Covid_Risk', 'SARS_Exposure', 'H1N1_Exposure', 'Zika_Exposure', 'Ebola_Exposure', 'Brexit_Exposure', 'Brexit_Neg_Sentiment', 'Brexit_Pos_Sentiment', 'Brexit_Net_Sentiment', 'Brexit_Risk']
get_raw_data
get_raw_data (url:str='https://www.dropbox.com/s/96xo9f1twlu3525/firmquar ter_2022q1.csv?raw=1', nrows:int=None, delimiter:str='\t')
Download raw data from url
| Type | Default | Details | |
|---|---|---|---|
| url | str | https://www.dropbox.com/s/96xo9f1twlu3525/firmquarter_2022q1.csv?raw=1 | |
| nrows | int | None | How many rows to download. If None, all rows are downloaded |
| delimiter | str | ||
| Returns | pd.DataFrame |
raw = get_raw_data(nrows=3)raw| gvkey | date | PRisk | NPRisk | Risk | PSentiment | NPSentiment | Sentiment | PRiskT_economic | PRiskT_environment | ... | Covid_Risk | SARS_Exposure | H1N1_Exposure | Zika_Exposure | Ebola_Exposure | Brexit_Exposure | Brexit_Neg_Sentiment | Brexit_Pos_Sentiment | Brexit_Net_Sentiment | Brexit_Risk | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1004 | 2002q1 | 359.55072 | 2928.6014 | 168.98235 | 997.86415 | 5550.5807 | 469.39542 | 9001.563 | 6331.43 | ... | 0 | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN | NaN |
| 1 | 1004 | 2002q2 | 0.00000 | 0.0000 | 0.00000 | 1594.73210 | -5656.6074 | 544.82417 | 0.000 | 0.00 | ... | 0 | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN | NaN |
2 rows × 36 columns
process_raw_data
process_raw_data (df:pandas.core.frame.DataFrame=None, gvkey_permno_link:Union[bool,pandas.core.frame.DataFram e]=True)
Converts gvkey to string and applies pandasmore.setup_panel. Adds permno if gvkey_permno_link is not False.
| Type | Default | Details | |
|---|---|---|---|
| df | pd.DataFrame | None | Raw data |
| gvkey_permno_link | bool | pd.DataFrame | True | Whether to download permno or not. If DataFrame, must contain permno, gvkey, and Qdate |
| Returns | pd.DataFrame |
df = process_raw_data(raw, gvkey_permno_link=False)df| date | dtdate | PRisk | NPRisk | Risk | PSentiment | NPSentiment | Sentiment | PRiskT_economic | PRiskT_environment | ... | Covid_Risk | SARS_Exposure | H1N1_Exposure | Zika_Exposure | Ebola_Exposure | Brexit_Exposure | Brexit_Neg_Sentiment | Brexit_Pos_Sentiment | Brexit_Net_Sentiment | Brexit_Risk | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| gvkey | Qdate | |||||||||||||||||||||
| 001004 | 2002Q1 | 2002-03-31 | 2002-03-31 | 359.55072 | 2928.6014 | 168.98235 | 997.86415 | 5550.5807 | 469.39542 | 9001.563 | 6331.43 | ... | 0 | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN | NaN |
| 2002Q2 | 2002-06-30 | 2002-06-30 | 0.00000 | 0.0000 | 0.00000 | 1594.73210 | -5656.6074 | 544.82417 | 0.000 | 0.00 | ... | 0 | 0 | 0 | 0 | 0 | NaN | NaN | NaN | NaN | NaN |
2 rows × 36 columns