import pandas as pd
import pandasmore as pdm
from finsets.wrds import wrds_api
linking
Since WRDS is a subscription service, in the documentation below, I can not show any of the data that is being retrieved/generated (will show only column names).
Merging CRSP and COMPUSTAT
Official documentation for this merge is here
Relevant information from that site:
Because TICKERs and CUSIPs change over time, most datasets use permanent identifiers to indicate the same securities and companies. For example, CRSP employs PERMNO to track stocks, Compustat uses GVKEY to follow companies, and a combination of GVKEY and IID is used to track securities. As indicated in the preceding table, both PERMNO and GVKEY (+IID) remain the same, regardless of changes in TICKER, CUSIP, and company names.
The CRSP/Compustat Merged Database (CCM) is comprised of CRSP and Compustat data, together with the link and link-history references between these two databases. The key product of CCM is a permanent identifier linking table (PERMNO to GVKEY+IID), though CCM is often wrongly mistaken as the merged product of CRSP stock market data with Compustat accounting data. From an end user’s perspective, CCM only adds a link of PERMNO and PERMCO to the Compustat database, so that Compustat items can be searched by CRSP identifiers.
LinkType: A code describing the connection between the CRSP and Compustat data.
- LU: Link research complete. Standard connection between databases.
- LC: Non-researched link to issue by CUSIP.
- LD: Duplicate link to a security. Another GVKEY/IID is a better link to that CRSP record.
LinkPrim: Primary issue indicator for the link.
- P: Primary, identified by Compustat in monthly security data.
- C: Primary, assigned by CRSP to resolve ranges of overlapping or missing primary markers from Compustat in order to produce one primary security throughout the company history.
LINKDT: The first effective date of the link.
LINKENDDT: The last date when the link is valid. For a currently valid link, LINKENDDT is set to a NULL value (.E in SAS format).
gvkey_permno_m
gvkey_permno_m (nrows:int=None)
CRSP Monthly ids, with gvkeys
Type | Default | Details | |
---|---|---|---|
nrows | int | None | Number of rows to download. If None, full dataset will be downloaded |
Returns | DataFrame |
= gvkey_permno_m(nrows=1) df
df
permno | Mdate | gvkey | |
---|---|---|---|
0 | 10000 | 1986-01 | 013007 |
gvkey_permno_a
gvkey_permno_a (nrows:int=None)
qvkey to permno correspondence at the annual frequency. As done by CCM.
Type | Default | Details | |
---|---|---|---|
nrows | int | None | Number of rows to download. If None, full dataset will be downloaded |
Returns | DataFrame |
= gvkey_permno_a(nrows=1) df
df
permno | Adate | gvkey | |
---|---|---|---|
0 | 25881 | 1970 | 001000 |
gvkey_permno_q
gvkey_permno_q (nrows:int=None)
qvkey to permno correspondence at the quarterly frequency. As done by CCM.
Type | Default | Details | |
---|---|---|---|
nrows | int | None | Number of rows to download. If None, full dataset will be downloaded |
Returns | DataFrame |
= gvkey_permno_q(nrows=1) df
df
permno | Qdate | gvkey | |
---|---|---|---|
0 | 25881 | 1970Q4 | 001000 |
Merging IBES and CRSP
ibes_ticker_permno
ibes_ticker_permno (nrows:int=None)
= ibes_ticker_permno(nrows=1) ibes_permnos
ibes_permnos
ticker | permno | ncusip | sdate | edate | score | |
---|---|---|---|---|---|---|
0 | 0000 | 14471.0 | 87482X10 | 2014-02-20 | 2016-08-31 | 1.0 |
Merging TRACE Bond Data with CRSP
bond_cusip_permno
bond_cusip_permno (nrows:int=None)
= bond_cusip_permno(nrows=1) cusip_permnos
cusip_permnos
cusip | permno | permco | trace_startdt | trace_enddt | crsp_startdt | crsp_enddt | link_startdt | link_enddt | |
---|---|---|---|---|---|---|---|---|---|
0 | 000336AC1 | 60687 | 21372 | 2014-08-22 | 2014-08-22 | 2002-01-02 | 2022-12-30 | 2014-08-22 | 2014-08-22 |