quantlab.acquisition.wrds.crsp#
Download of CRSP daily stock data from WRDS, keyed by PERMNO.
CRSP (the Center for Research in Security Prices) publishes the standard academic database of US stock prices and returns, including companies that were later delisted, which avoids survivorship bias (the error of studying only the companies that still exist today). WRDS (Wharton Research Data Services) serves CRSP to subscribers through a PostgreSQL server. CRSP identifies each security by its PERMNO, a permanent integer that never changes and is never reused for another security, unlike a ticker symbol.
WrdsCrspDailyAcquisition downloads crsp_a_stock.dsf_v2, the CRSP
Stock v2 daily table, through the shared WRDS connection defined in
quantlab.acquisition.wrds.taq. The work is split into pages. One page is
one calendar year for one batch of PERMNOs, fetched with a plain
COPY (SELECT ... WHERE permno = ANY(...) AND dlycaldt BETWEEN ...). The
rows are stored exactly as CRSP serves them, with no sorting, no
de-duplication and no derived or adjusted series. The raw data is keyed by
PERMNO rather than by ticker, because dsf_v2 cannot tell share classes
apart by ticker and a company’s ticker can change. The ticker is attached
later, when quantlab.dataset.crsp converts the raw data into a panel.
CrspQueries builds the SQL statements (pure functions that can be tested
without a server) and hands them to the session. year_pages defines the
page boundaries.
crsp_a_stock is CRSP’s annual-update product: WRDS replaces it once a
year with a new release, called a vintage, that ends on a fixed last day. A
window that runs past that day is refused unless
kwargs["clip_to_product_end"] is set. Each raw tier (the downloaded
parquet files) also records the vintage it was built from, so data from two
releases is never mixed.
Classes
SQL statements for the CRSP tables on WRDS, and the calls that run them. |
|
Download CRSP Stock v2 daily bars from |
Functions
Split |