quantlab.dataset.crsp.tickers#
Read the ticker sidecar to show a CRSP PERMNO as a readable ticker.
CRSP (the Center for Research in Security Prices) is a US stock database. A
PERMNO is its permanent integer id for one security. The CRSP price panel
uses the PERMNO as its symbol axis: the right id for code, but not what
a person wants to read in a log line, a settlements.json entry or a
coverage report. The readable names live in a JSON sidecar next to the
Zarr store, {zarr}.crsp_tickers.json, as date intervals per PERMNO. One
name per PERMNO would not do: FB and META are the same PERMNO 13407, so a
single name would be wrong for half its history. The CRSP conversion writes
the sidecar, and CrspTickerLookup answers “which ticker did this PERMNO
have on this day” from it.
The lookup has three entry points, each with a deliberate way of handling a
sidecar that is missing, unparseable or wrongly shaped. It implements the
dataset layer’s TickerLookup interface (names and label), which is
how a backtest labels symbols without naming this class; a CRSP dataset
returns one from ticker_lookup().
as_of(permno, day)is strict. It raises a clear error (naming the class, the path and the rebuild that fixes it) in all three cases, so “the file could not be read” is never mistaken for “that PERMNO had no name that day”.product_endis strict about the file and its top level, but not about the interval table. A sidecar with broken intervals can still say which CRSP data version it was built from, and one that records no version returnsNone.names(permnos, day)andlabel(permnos, day)are the display entry points and never raise. With an unusable sidecar they fall back to the PERMNO digits, and log one warning per lookup object, so a broken sidecar can be told apart from a store that never had one. The sidecar records no company, so every name’scompanyisNone.
The sidecar suffix constant is imported inside beside_store, where the
parent package is fully initialized.
Classes
Look up the ticker a PERMNO had on a given day, from one |