quantlab.dataset.massive.ticker_map#
The Ticker map: each day’s Massive ticker to the permaticker that traded under it.
The Trade bar store’s symbol axis is the Massive ticker, the ticker a security traded under that day (ADR 0031). A ticker is not a security: one ticker can belong to different securities on different days. The Ticker map says, for each day and Massive ticker, which Sharadar permaticker traded under it, or none, with the evidence for the choice. It is the only way from the Trade bar store to Sharadar’s securities.
The rules, version 1 (RULES_VERSION). For a day D and a ticker t in
Massive’s day aggregates of D:
The candidates are every Sharadar holder of t, its span dates ignored (
PermatickerResolver.ticker_holders), from SEP’s and SFP’s TICKERS rows: stocks and funds.A candidate matches when its Sharadar unadjusted close of D (
closeunadj) is withinmax(1% of it, 0.0051)of Massive’s day close; the absolute floor admits a low-priced stock Sharadar rounds to two decimals.One candidate matches: it is chosen (
"price"). Several match: the one whose span covers D ("price+span"), and with none or several such, the ticker is unmapped.None matches: a candidate whose span covers D and whose close is off by a split ratio is chosen (
"split_corrected"). Sharadar’s “unadjusted” close is sometimes adjusted for a later split; the ratios tried are the cumulative products of the candidate’s ACTIONS splits dated after D, in either direction, within 1%.Otherwise the ticker is unmapped (
"unmapped") with a reason (UNMAPPED_REASONS).
The resolver’s two fallbacks for Sharadar’s own files (“a single holder maps whatever the dates”, “with none on the day, the one that ended last”) are not used: they gave trades of securities Sharadar lacks to companies delisted years before.
Storage. The map is a directory holding one Parquet file of rows per
mapped day, <path>/<YYYY>/<YYYY-MM-DD>.parquet, with the columns of
ROW_SCHEMA. append maps one more day; rebuild maps every day of
the raw tier again (after a change of rules or a Sharadar restatement) into
a sidecar and swaps it in. A row records the version of the rules that
built it.
Examples#
Needs Massive’s day aggregates and Sharadar’s TICKERS, ACTIONS, SEP and SFP in the raw tier:
ticker_map = TickerMap(TickerMapConfig(
path="/data/quantlab/market/massive/massive_ticker_map/massive_ticker_map",
massive_dir="/data/quantlab/downloads/massive",
sharadar_dir="/data/quantlab/downloads/sharadar",
))
ticker_map.append(date(2020, 3, 2))
rows = ticker_map.read("2020-03-02", "2020-03-02")
rows.filter(pl.col("ticker") == "VIAC")["evidence"].item() # 'unmapped'
Classes
The Ticker map of one directory: append a day, rebuild all, read rows. |
Functions
Map one ticker on one day by the rules of version 1 (see the module docstring). |