ZipLime commited on
Commit
ed5ee12
·
verified ·
1 Parent(s): b475d66

Update the security master

Browse files
PIPELINE.md CHANGED
@@ -61,7 +61,7 @@ company that stopped filing in 2014 permanently current under its 2014 ticker,
61
  and when another company later took that ticker over, both were current at
62
  once — 1 218 tickers, 6% of the live universe, each pointing at two companies.
63
 
64
- Now `is_current` also requires the filer to still be filing, and 53 remain.
65
  Those are genuine: dual filers and reorganisations mid-transfer.
66
  `is_latest_for_filer` keeps the old meaning, because "what did this company last
67
  call itself" is a real question about dormant companies, and keying issuer
@@ -80,15 +80,18 @@ Two things were learned by measuring rather than assuming.
80
 
81
  **The count is the wrong measure.** By raw CUSIP count the bridge looked 37%
82
  complete, which reads like a failure. Against actual 13F holdings the same
83
- bridge covers 82.8% of holding rows and 87.9% of position value. Two thirds of
84
- the CUSIPs ever traded are one-off warrants, foreign lines and delisted shells
85
- that no strategy touches. The build now gates on match rate weighted by
86
- settlement traffic, excluding funds.
87
-
88
- **Exchange-traded funds can never resolve, and that is correct.** `IVV`, `IWM`,
89
- `SPY` settle like shares and file nothing a CIK could attach to. Counting them
90
- as misses is what made the bridge look broken. They carry `looks_like_fund` and
91
- sit outside the gated denominator.
 
 
 
92
 
93
  **The first six characters are the issuer.** A CUSIP's prefix identifies the
94
  company, the suffix the instrument, so a class B share or a preferred of a
@@ -97,6 +100,39 @@ so is a fact about how CUSIPs are assigned, not a guess — but the instrument
97
  itself was never matched, only its issuer, so it carries its own method and a
98
  middle confidence. It lifted coverage from 37% to 69% of pairs.
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  ## Verification
101
 
102
  [`quality.py`](recipe/quality.py) gates publication. The check that earns its
@@ -122,7 +158,7 @@ things that move.
122
  * **No history before Form 4.** Ticker evidence effectively starts in 2006.
123
  EDGAR does not carry what a company traded as in 1998, so neither does this.
124
  * **No exchange history worth the name.** Filers rarely name the venue and SEC's
125
- current map covers only live listings, so 8 210 spans is all the evidence
126
  there is.
127
  * **No ISIN, no LEI, no FIGI.** 13F carries a FIGI column and N-PORT carries
128
  ISIN; neither is ingested yet. The schema has room for them.
 
61
  and when another company later took that ticker over, both were current at
62
  once — 1 218 tickers, 6% of the live universe, each pointing at two companies.
63
 
64
+ Now `is_current` also requires the filer to still be filing, and 54 remain.
65
  Those are genuine: dual filers and reorganisations mid-transfer.
66
  `is_latest_for_filer` keeps the old meaning, because "what did this company last
67
  call itself" is a real question about dormant companies, and keying issuer
 
80
 
81
  **The count is the wrong measure.** By raw CUSIP count the bridge looked 37%
82
  complete, which reads like a failure. Against actual 13F holdings the same
83
+ bridge covers 83.1% of holding rows and 87.5% of position value. Two thirds
84
+ of the CUSIPs ever traded are one-off warrants, foreign lines and delisted
85
+ shells that no strategy touches. The build now gates on match rate weighted
86
+ by settlement traffic, excluding funds.
87
+
88
+ **Most funds cannot resolve, and that is correct.** `IVV`, `IWM` and `VOO`
89
+ settle like shares, but they are lines inside a registrant trust's filings and
90
+ file nothing under a ticker of their own. Counting them as misses is what made
91
+ the bridge look broken; they carry `looks_like_fund` and sit outside the gated
92
+ denominator. *Never* was too strong, though, and both documents said it: a fund
93
+ that is its own trust does file, and `SPY`, `GLD`, `DIA` and `MDY` resolve to
94
+ the trust that issues them. 749 fund rows carry a CIK.
95
 
96
  **The first six characters are the issuer.** A CUSIP's prefix identifies the
97
  company, the suffix the instrument, so a class B share or a preferred of a
 
100
  itself was never matched, only its issuer, so it carries its own method and a
101
  middle confidence. It lifted coverage from 37% to 69% of pairs.
102
 
103
+ **Some of that lift was wrong, and the coverage gate rewarded it.** The prefix
104
+ rule borrowed a filer from *any* match, and a fund family is one prefix: when
105
+ iShares' `ICF` collided with ICF International's ticker, all 74 iShares funds
106
+ under `464287` became ICF International — IVV, IWM and EFA among them — and 14
107
+ Vanguard funds became a Van Kampen muni trust the same way. Checked against
108
+ the filer's own names, 8.6% of the 7 653 inherited fund rows were right. The
109
+ weighted-match gate counts any CIK, right or wrong, so it read the damage as
110
+ progress. Now only a date-confirmed, non-fund match may lend its issuer, a
111
+ prefix that points at two filers lends nothing, and funds never inherit;
112
+ inherited rows that agree on a name went from 84% to 96%.
113
+
114
+ **A fund is not the company that shares its ticker.** SPDR's `MDY` matched
115
+ Midway Gold by ticker and date, PIMCO's `CORP` a Michigan bank. Names are still
116
+ never used to attach a CUSIP; they are used to refuse one — a fund whose name
117
+ shares no distinctive word with anything the filer was ever called gets
118
+ `name_conflict` and no CIK, and the next candidate is considered. MDY now
119
+ resolves to the SPDR MidCap 400 trust. `CORP` still does not: "PIMCO
120
+ INVESTMENT GRADE CORP BD" carries no word the fund pattern knows.
121
+
122
+ **One symbol, three spellings.** Settlement records write `BRKB`, filings
123
+ `BRK.B` or `BRK-B`. The join used the literal string, so multi-class companies
124
+ matched only where a filer happened to type the record's spelling. Tickers
125
+ are now joined with the class separator removed; the published `ticker` is
126
+ still the one the record stated.
127
+
128
+ **The same inputs have to give the same bridge.** When two filers have each
129
+ stated a symbol exactly once, they tie on every key the candidates are ranked
130
+ by, and the winner was whichever row the join emitted first: feeding the
131
+ published pairs back through the builder moved 36 rows to a different filer.
132
+ The CIK now breaks the last tie — arbitrary, but the same every run, which is
133
+ what lets anyone rebuild `cusip_map` from the published tables and get the
134
+ file that was published.
135
+
136
  ## Verification
137
 
138
  [`quality.py`](recipe/quality.py) gates publication. The check that earns its
 
158
  * **No history before Form 4.** Ticker evidence effectively starts in 2006.
159
  EDGAR does not carry what a company traded as in 1998, so neither does this.
160
  * **No exchange history worth the name.** Filers rarely name the venue and SEC's
161
+ current map covers only live listings, so 8 228 spans is all the evidence
162
  there is.
163
  * **No ISIN, no LEI, no FIGI.** 13F carries a FIGI column and N-PORT carries
164
  ISIN; neither is ingested yet. The schema has room for them.
README.md CHANGED
@@ -45,8 +45,8 @@ configs:
45
  Which company a ticker belonged to, on a date. Which filer a CUSIP points at.
46
  What a company used to be called.
47
 
48
- **23 529 filers · 143 932 identifier spans · 10 056 033 dated observations ·
49
- 74 392 CUSIPs · 1960 to 2026**
50
 
51
  This is the glue for the rest of the family. Every other ZipLime dataset keys
52
  on the SEC's CIK, which never changes — and every price series, broker feed and
@@ -61,9 +61,9 @@ See [PIPELINE.md](PIPELINE.md) for the method and its limits.
61
 
62
  | | |
63
  |---|---|
64
- | Filers that changed ticker | **6 392** of 23 529 |
65
- | Filers that changed name | **11 435** |
66
- | Tickers held by more than one company over time | **2 215** of 26 844 |
67
 
68
  A ticker is not an identity. `PLUM` can be one company until 2014 and another
69
  from 2019, and a strategy that resolves it by today's map reads the second
@@ -102,7 +102,7 @@ Two flags answer two different questions:
102
  filing in 2011.
103
  * `is_current` — that, **and** the company still files. Use it to ask *who owns
104
  this ticker now*. Defining current without the second condition left 1 218
105
- tickers current for two companies at once; with it, 53 remain, and those are
106
  genuine dual filers.
107
 
108
  ## The CUSIP bridge
@@ -114,20 +114,37 @@ filer over a span, and the two compose.
114
 
115
  | Match | Rows | Meaning |
116
  |---|---|---|
117
- | `ticker_and_dates` | 22 921 | the ticker matched and the dates overlap — **high** |
118
- | `cusip6_inherited` | 23 519 | another security of the same issuer resolved — **medium** |
119
- | `ticker_only` | 4 747 | the ticker matched, the dates do not overlap — **low** |
120
- | `unmatched` | 23 205 | no filer found — **none** |
121
-
122
- **68.8% of CUSIP-ticker pairs resolve to a filer; 78.8% weighted by how often
123
- the CUSIP appears in settlement records.** Measured against real 13F holdings,
124
- the matched set covers **82.8% of holding rows and 87.9% of position value.**
 
 
 
 
 
 
 
 
125
 
126
  Counting raw CUSIPs understates it badly, and the reason is worth knowing:
127
- 10 536 of these are exchange-traded funds. An ETF settles like a share and
128
- files nothing a CIK could attach to — `IVV`, `IWM`, `SPY` will never resolve to
129
- an operating company, because they are not one. They carry
130
- `looks_like_fund = true` and are excluded from the coverage the build gates on.
 
 
 
 
 
 
 
 
 
131
 
132
  ```python
133
  bridge = pl.read_parquet("data/cusip_map/*.parquet")
@@ -142,11 +159,11 @@ holdings = holdings.join(
142
 
143
  | Config | Rows | What one row is |
144
  |---|---|---|
145
- | `issuers` | 23 529 | one filer: current name, ticker, industry, and how long it has filed |
146
- | `identifiers` | 143 932 | one identifier and the span of filings that stated it |
147
- | `cusip_map` | 74 392 | one CUSIP, the ticker it settles under, the filer behind it |
148
- | `observations` | 10 056 033 | one dated statement — the evidence the spans are built from |
149
- | `pit` | 143 932 | one point-in-time identifier event, plus a Delta table for ziplime |
150
 
151
  `observations` is published so that anyone who disagrees with how the spans
152
  were derived can derive their own. It is the only honest way to ship a
@@ -156,10 +173,10 @@ judgement.
156
 
157
  | Source | Observations | What it gives |
158
  |---|---|---|
159
- | Form 4 filings, via [ZipLime/insider-trading](https://huggingface.co/datasets/ZipLime/insider-trading) | 8 123 634 | the ticker a company printed on a filing, on that day — the only free source of ticker **history** |
160
  | XBRL filings, via [ZipLime/company-fundamentals](https://huggingface.co/datasets/ZipLime/company-fundamentals) | 1 901 363 | names, former names with change dates, industry, incorporation, fiscal year end |
161
- | SEC `company_tickers_exchange.json` | 31 036 | today's listings, including companies that never filed a Form 4 |
162
- | SEC fails-to-deliver records, 409 archives | 23.4M records | CUSIP to ticker, twice a month since 2004 |
163
 
164
  `company_tickers.json` alone is what most projects use, and it is a snapshot:
165
  it states today and carries no past, so a company that changed symbol appears
@@ -170,14 +187,14 @@ filings that each stated a symbol on a known date.
170
 
171
  * **81% of filers have a ticker; 93% of *active* filers do.** The rest are
172
  funds, trusts and private filers that never printed one.
173
- * **Exchange is sparse** — 8 210 spans. Filers rarely name the venue, and SEC's
174
  current map only covers live listings.
175
  * **Coverage starts in 1960** only because a filing header stated a name change
176
  from then. Ticker evidence effectively begins in 2006 with Form 4, and
177
  identifiers before that are not in EDGAR to be found.
178
  * **A span is evidence, not a registry.** See above.
179
- * **Fund CUSIPs do not resolve, by construction.** See above.
180
- * **53 tickers are current for two filers.** Dual filers and reorganisations
181
  mid-transfer; the raw observations let you decide.
182
 
183
  ## Provenance and updates
 
45
  Which company a ticker belonged to, on a date. Which filer a CUSIP points at.
46
  What a company used to be called.
47
 
48
+ **23 553 filers · 144 054 identifier spans · 10 061 784 dated observations ·
49
+ 74 814 CUSIP–ticker pairs · 1960 to 2026**
50
 
51
  This is the glue for the rest of the family. Every other ZipLime dataset keys
52
  on the SEC's CIK, which never changes — and every price series, broker feed and
 
61
 
62
  | | |
63
  |---|---|
64
+ | Filers that changed ticker | **6 410** of 23 553 |
65
+ | Filers that changed name | **11 439** |
66
+ | Tickers held by more than one company over time | **2 224** of 26 895 |
67
 
68
  A ticker is not an identity. `PLUM` can be one company until 2014 and another
69
  from 2019, and a strategy that resolves it by today's map reads the second
 
102
  filing in 2011.
103
  * `is_current` — that, **and** the company still files. Use it to ask *who owns
104
  this ticker now*. Defining current without the second condition left 1 218
105
+ tickers current for two companies at once; with it, 54 remain, and those are
106
  genuine dual filers.
107
 
108
  ## The CUSIP bridge
 
114
 
115
  | Match | Rows | Meaning |
116
  |---|---|---|
117
+ | `ticker_and_dates` | 23 074 | the ticker matched and the dates overlap — **high** |
118
+ | `cusip6_inherited` | 13 105 | another security of the same issuer resolved — **medium** |
119
+ | `ticker_only` | 4 145 | the ticker matched, the dates do not overlap — **low** |
120
+ | `name_conflict` | 683 | a fund, and the filer holding its ticker was never called anything like it — **none** |
121
+ | `unmatched` | 33 807 | no filer found — **none** |
122
+
123
+ **53.9% of CUSIP-ticker pairs resolve to a filer; 74.8% weighted by how often
124
+ the CUSIP appears in settlement records, counting only the pairs that are not
125
+ funds — which is what the build gates on.** Measured against real 13F holdings,
126
+ the matched set covers **83.1% of holding rows and 87.5% of position
127
+ value** (82.2% and 86.7% keeping only `high` and `medium`).
128
+
129
+ Every one of those was higher a release ago — 68.8%, 78.7%, 93.9% and 95.0% —
130
+ because the issuer-prefix rule was lending fund families a stranger's CIK and a
131
+ coverage metric counts a wrong filer as a hit. Dropping the wrong matches reads
132
+ as lost coverage. [PIPELINE.md](PIPELINE.md) has what happened.
133
 
134
  Counting raw CUSIPs understates it badly, and the reason is worth knowing:
135
+ 10 679 of these rows are funds. A fund settles like a share, and most file
136
+ nothing under a ticker of their own — `IVV`, `IWM` and `VOO` are lines inside a
137
+ registrant trust's filings, not filers. They carry `looks_like_fund = true` and
138
+ are excluded from the coverage the build gates on. Some funds *are* their own
139
+ trust and do file: `SPY`, `GLD`, `DIA` and `MDY` each resolve to the trust that
140
+ issues them, and 749 fund rows carry a CIK on that basis. A fund that matched a
141
+ company only by sharing its ticker is refused instead: `MDY` pointed at Midway
142
+ Gold until the name check was added.
143
+
144
+ A further 8 527 rows carry a settlement symbol that nobody trades under —
145
+ clearing placeholders (`XCEMZZZZ`), preferred lines (`BACPRS`), CUSIP fragments.
146
+ They are real evidence about the instrument and are marked
147
+ `standard_symbol = false` rather than dropped.
148
 
149
  ```python
150
  bridge = pl.read_parquet("data/cusip_map/*.parquet")
 
159
 
160
  | Config | Rows | What one row is |
161
  |---|---|---|
162
+ | `issuers` | 23 553 | one filer: current name, ticker, industry, and how long it has filed |
163
+ | `identifiers` | 144 054 | one identifier and the span of filings that stated it |
164
+ | `cusip_map` | 74 814 | one CUSIP, the ticker it settles under, the filer behind it |
165
+ | `observations` | 10 061 784 | one dated statement — the evidence the spans are built from |
166
+ | `pit` | 144 054 | one point-in-time identifier event, plus a Delta table for ziplime |
167
 
168
  `observations` is published so that anyone who disagrees with how the spans
169
  were derived can derive their own. It is the only honest way to ship a
 
173
 
174
  | Source | Observations | What it gives |
175
  |---|---|---|
176
+ | Form 4 filings, via [ZipLime/insider-trading](https://huggingface.co/datasets/ZipLime/insider-trading) | 8 129 289 | the ticker a company printed on a filing, on that day — the only free source of ticker **history** |
177
  | XBRL filings, via [ZipLime/company-fundamentals](https://huggingface.co/datasets/ZipLime/company-fundamentals) | 1 901 363 | names, former names with change dates, industry, incorporation, fiscal year end |
178
+ | SEC `company_tickers_exchange.json` | 31 132 | today's listings, including companies that never filed a Form 4 |
179
+ | SEC fails-to-deliver records, 411 archives | 23.5M records | CUSIP to ticker, twice a month since 2004 |
180
 
181
  `company_tickers.json` alone is what most projects use, and it is a snapshot:
182
  it states today and carries no past, so a company that changed symbol appears
 
187
 
188
  * **81% of filers have a ticker; 93% of *active* filers do.** The rest are
189
  funds, trusts and private filers that never printed one.
190
+ * **Exchange is sparse** — 8 228 spans. Filers rarely name the venue, and SEC's
191
  current map only covers live listings.
192
  * **Coverage starts in 1960** only because a filing header stated a name change
193
  from then. Ticker evidence effectively begins in 2006 with Form 4, and
194
  identifiers before that are not in EDGAR to be found.
195
  * **A span is evidence, not a registry.** See above.
196
+ * **Most fund CUSIPs do not resolve, by construction.** See above.
197
+ * **54 tickers are current for two filers.** Dual filers and reorganisations
198
  mid-transfer; the raw observations let you decide.
199
 
200
  ## Provenance and updates
data/cusip_map/part-00000.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7fe2bc6558ea0b7f64166f3fa8076d27de966e68c2568eb7d12292c17bcbcc35
3
- size 1837556
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd8ebbc682ffeb905eb416a4d6093b349ca51c8f53c0058095127e7e33f75f4f
3
+ size 1850407
data/identifiers/part-00000.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:aa4f6ab540e4de2ae8bd8aa041b3cf3e8a5a5b4e86cc36e57ac51ce6874911f9
3
- size 1770597
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48e7f1a03d54a79d1e1a774991371bea147ba876b83a7cfbcfc471905af87a13
3
+ size 1771167
data/issuers/part-00000.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a3767783e6e4e72bc41a6b2e73083e523a06633da8a7337558488133da2c85e8
3
- size 690488
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96d9e2dfa18a30c07334a0de8bd47e94132b4d916292a59a8d1378f90dd9d7b1
3
+ size 690592
data/observations/part-00000.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e732e57a433d255b41f2bbb533e0a6fa81b9414b70956dad53b45af1c9bb3d6f
3
  size 29425864
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9306be91d3a4b46cf263bbba4754979a1ead3211ccf30cefb6096bb4f45170ae
3
  size 29425864
data/observations/part-00001.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b931492089f73a3cb297af4bbe1fa06edcc8be36690736a31490f855826f451e
3
- size 29758364
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:743c18ff609e0318bb11ee363402643b16a218cdc5c16b56bd768b6f6b0bd4e4
3
+ size 29754913
data/observations/part-00002.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b4df1b9b681330eb66423071389a38347491a38d6d7b215717897385410556a5
3
- size 482268
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15bfda17d6006a1b18eb94672cf259d3af5239dda400fd81c3f3589f3d48baf9
3
+ size 495479
data/pit/part-00000.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:86dd5e2364d0fdaf5d44a78d5e69b25f37e9bdee9dea80970a95322b2ba02db1
3
- size 3619219
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc58f679482815557e75b0f742202585e4046bbc702734b45cd1f34198eb0be8
3
+ size 3620006
data/pit/security_master.delta/_delta_log/00000000000000000000.json CHANGED
@@ -1,4 +1,4 @@
1
- {"commitInfo":{"timestamp":1790581452693,"operation":"WRITE","operationParameters":{"mode":"Overwrite"},"engineInfo":"delta-rs:py-1.6.6","clientVersion":"delta-rs.py-1.6.6","operationMetrics":{"num_added_files":1,"num_removed_files":0,"num_partitions":0,"num_added_rows":144029,"execution_time_ms":107,"num_retries":0}}}
2
  {"protocol":{"minReaderVersion":1,"minWriterVersion":2}}
3
- {"metaData":{"id":"460c6a06-33c5-4047-817e-510cb8a85aa6","name":null,"description":null,"format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"pit_event_id\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"entity_id\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"event_date\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}},{\"name\":\"knowledge_date\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}},{\"name\":\"knowledge_estimated\",\"type\":\"boolean\",\"nullable\":true,\"metadata\":{}},{\"name\":\"kind\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"value\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"valid_to\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}},{\"name\":\"observations\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}},{\"name\":\"sources\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"is_current\",\"type\":\"boolean\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ingested_at\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":[],"createdTime":1790581452586,"configuration":{}}}
4
- {"add":{"path":"part-00000-30ff4273-3822-47c0-a53e-31ffde051c5d-c000.snappy.parquet","partitionValues":{},"size":5121007,"modificationTime":1790581452693,"dataChange":true,"stats":"{\"numRecords\":144029,\"minValues\":{\"event_date\":\"1960-02-01\",\"kind\":\"exchange\",\"sources\":\"company_tickers\",\"valid_to\":\"1960-02-01\",\"knowledge_estimated\":true,\"value\":\"'MKTG, INC.'\",\"entity_id\":\"0000000017\",\"knowledge_date\":\"1960-02-01T23:59:59Z\",\"observations\":1,\"pit_event_id\":\"0000000017|name|DEFINED ASSET FUNDS MUNICIPAL INVT TR FD MON PYM\",\"is_current\":false,\"ingested_at\":\"2026-09-28T07:44:11.567Z\"},\"maxValues\":{\"value\":\"zulily, inc.\",\"entity_id\":\"0002155226\",\"is_current\":true,\"sources\":\"xbrl\",\"ingested_at\":\"2026-09-28T07:44:11.567Z\",\"valid_to\":\"2026-09-28\",\"knowledge_date\":\"2026-09-28T23:59:59Z\",\"event_date\":\"2026-09-28\",\"observations\":12865,\"pit_event_id\":\"0002155226|ticker|UNIC|2026-09-28\",\"kind\":\"ticker\",\"knowledge_estimated\":true},\"nullCount\":{\"knowledge_date\":0,\"knowledge_estimated\":0,\"valid_to\":0,\"kind\":0,\"sources\":0,\"entity_id\":0,\"is_current\":0,\"value\":0,\"ingested_at\":0,\"event_date\":0,\"pit_event_id\":0,\"observations\":0}}","tags":null,"baseRowId":null,"defaultRowCommitVersion":null,"clusteringProvider":null}}
 
1
+ {"commitInfo":{"timestamp":1790898362759,"operation":"WRITE","operationParameters":{"mode":"Overwrite"},"engineInfo":"delta-rs:py-1.6.6","clientVersion":"delta-rs.py-1.6.6","operationMetrics":{"num_added_files":1,"num_removed_files":0,"num_partitions":0,"num_added_rows":144054,"execution_time_ms":99,"num_retries":0}}}
2
  {"protocol":{"minReaderVersion":1,"minWriterVersion":2}}
3
+ {"metaData":{"id":"2b0c4c1c-2193-49a6-b7ac-63cd204232fb","name":null,"description":null,"format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"pit_event_id\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"entity_id\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"event_date\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}},{\"name\":\"knowledge_date\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}},{\"name\":\"knowledge_estimated\",\"type\":\"boolean\",\"nullable\":true,\"metadata\":{}},{\"name\":\"kind\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"value\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"valid_to\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}},{\"name\":\"observations\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}},{\"name\":\"sources\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"is_current\",\"type\":\"boolean\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ingested_at\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":[],"createdTime":1790898362662,"configuration":{}}}
4
+ {"add":{"path":"part-00000-cea57932-5dc2-4803-9d90-2ac29a05c73d-c000.snappy.parquet","partitionValues":{},"size":5118766,"modificationTime":1790898362759,"dataChange":true,"stats":"{\"numRecords\":144054,\"minValues\":{\"event_date\":\"1960-02-01\",\"value\":\"'MKTG, INC.'\",\"pit_event_id\":\"0000000017|name|DEFINED ASSET FUNDS MUNICIPAL INVT TR FD MON PYM\",\"entity_id\":\"0000000017\",\"knowledge_estimated\":true,\"knowledge_date\":\"1960-02-01T23:59:59Z\",\"sources\":\"company_tickers\",\"ingested_at\":\"2026-10-01T23:46:02.152Z\",\"observations\":1,\"kind\":\"exchange\",\"valid_to\":\"1960-02-01\",\"is_current\":false},\"maxValues\":{\"event_date\":\"2026-10-02\",\"valid_to\":\"2026-10-02\",\"ingested_at\":\"2026-10-01T23:46:02.152Z\",\"knowledge_estimated\":true,\"value\":\"zulily, inc.\",\"sources\":\"xbrl\",\"knowledge_date\":\"2026-10-02T23:59:59Z\",\"observations\":12865,\"kind\":\"ticker\",\"is_current\":true,\"entity_id\":\"0002156068\",\"pit_event_id\":\"0002156068|ticker|INBT|2026-10-02\"},\"nullCount\":{\"value\":0,\"event_date\":0,\"observations\":0,\"is_current\":0,\"knowledge_date\":0,\"valid_to\":0,\"kind\":0,\"knowledge_estimated\":0,\"ingested_at\":0,\"sources\":0,\"entity_id\":0,\"pit_event_id\":0}}","tags":null,"baseRowId":null,"defaultRowCommitVersion":null,"clusteringProvider":null}}
data/pit/security_master.delta/{part-00000-30ff4273-3822-47c0-a53e-31ffde051c5d-c000.snappy.parquet → part-00000-cea57932-5dc2-4803-9d90-2ac29a05c73d-c000.snappy.parquet} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d854f17ef87ca07c31a574d0986ae20f9b198229d43deb595babfe71e73bd650
3
- size 5121007
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27a03dcfe5fa5bd520a2ea40b8eed9ff5d6fed4eebabf09b038dc9c3c83f82a5
3
+ size 5118766
manifest.json CHANGED
@@ -4,11 +4,11 @@
4
  "table_uri": "data/pit/security_master.delta"
5
  },
6
  "config_rows": {
7
- "cusip_map": 74634,
8
- "identifiers": 144029,
9
- "issuers": 23545,
10
- "observations": 10059627,
11
- "pit": 144029
12
  },
13
  "config_schemas": {
14
  "cusip_map": {
@@ -23,6 +23,7 @@
23
  "match_confidence": "String",
24
  "match_method": "String",
25
  "observations": "Int32",
 
26
  "ticker": "String"
27
  },
28
  "identifiers": {
@@ -103,7 +104,7 @@
103
  }
104
  },
105
  "coverage": {
106
- "max_observation": "2026-09-28",
107
  "min_observation": "1960-02-01"
108
  },
109
  "data_type": "PIT_DATA",
@@ -113,7 +114,7 @@
113
  "event_date": "valid_from",
114
  "event_date_type": "date",
115
  "frequency_seconds": null,
116
- "generated_at": "2026-09-28T07:44:13.078072+00:00",
117
  "identifier_kinds": [
118
  "ticker",
119
  "name",
@@ -138,7 +139,7 @@
138
  },
139
  "pretty_name": "ZipLime US Security Master (PIT)",
140
  "quality_ok": true,
141
- "rows": 144029,
142
  "source": {
143
  "build_version": "1.0.0",
144
  "coverage_note": "Ticker evidence effectively begins in 2006 with Form 4; earlier dates come from name-change fields in filing headers.",
@@ -147,7 +148,7 @@
147
  "origin": "SEC EDGAR Form 4 and XBRL filings (via ZipLime/insider-trading and ZipLime/company-fundamentals), company_tickers_exchange.json, and SEC fails-to-deliver records",
148
  "package_version": "1.0.0",
149
  "recipe": "recipe/",
150
- "recipe_hash": "sha256:b8590bad2e9e0bd3379fd17073833442bb7fe532ac44c5715098a903f3208994",
151
  "schedule": "40 7 * * 1"
152
  },
153
  "trading_calendar_name": null,
 
4
  "table_uri": "data/pit/security_master.delta"
5
  },
6
  "config_rows": {
7
+ "cusip_map": 74814,
8
+ "identifiers": 144054,
9
+ "issuers": 23553,
10
+ "observations": 10061784,
11
+ "pit": 144054
12
  },
13
  "config_schemas": {
14
  "cusip_map": {
 
23
  "match_confidence": "String",
24
  "match_method": "String",
25
  "observations": "Int32",
26
+ "standard_symbol": "Boolean",
27
  "ticker": "String"
28
  },
29
  "identifiers": {
 
104
  }
105
  },
106
  "coverage": {
107
+ "max_observation": "2026-10-02",
108
  "min_observation": "1960-02-01"
109
  },
110
  "data_type": "PIT_DATA",
 
114
  "event_date": "valid_from",
115
  "event_date_type": "date",
116
  "frequency_seconds": null,
117
+ "generated_at": "2026-10-01T23:46:02.964020+00:00",
118
  "identifier_kinds": [
119
  "ticker",
120
  "name",
 
139
  },
140
  "pretty_name": "ZipLime US Security Master (PIT)",
141
  "quality_ok": true,
142
+ "rows": 144054,
143
  "source": {
144
  "build_version": "1.0.0",
145
  "coverage_note": "Ticker evidence effectively begins in 2006 with Form 4; earlier dates come from name-change fields in filing headers.",
 
148
  "origin": "SEC EDGAR Form 4 and XBRL filings (via ZipLime/insider-trading and ZipLime/company-fundamentals), company_tickers_exchange.json, and SEC fails-to-deliver records",
149
  "package_version": "1.0.0",
150
  "recipe": "recipe/",
151
+ "recipe_hash": "sha256:d8e7e1cfa1f07d5f208516b8ad0f50a297b2383fab02585334c915874464c173",
152
  "schedule": "40 7 * * 1"
153
  },
154
  "trading_calendar_name": null,
recipe/intervals.py CHANGED
@@ -47,6 +47,43 @@ FUND_NAME = re.compile(
47
  re.I,
48
  )
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  def build_identifiers(observations: pl.DataFrame) -> pl.DataFrame:
52
  """One row per (filer, kind, value) with the span it was stated over."""
@@ -160,6 +197,16 @@ def build_issuers(identifiers: pl.DataFrame, observations: pl.DataFrame) -> pl.D
160
  return align(frame, ISSUER_SCHEMA).sort("cik")
161
 
162
 
 
 
 
 
 
 
 
 
 
 
163
  def build_cusip_map(ftd: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFrame:
164
  """CUSIP to CIK, by way of the ticker both of them name.
165
 
@@ -171,19 +218,47 @@ def build_cusip_map(ftd: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFram
171
  """
172
  if ftd.is_empty():
173
  return empty_frame(CUSIP_MAP_SCHEMA)
 
174
 
175
- pairs = ftd.group_by(["cusip", "ticker"]).agg(
176
- pl.col("issuer_name").mode().first().alias("issuer_name"),
177
- pl.col("observed_on").min().alias("first_seen"),
178
- pl.col("observed_on").max().alias("last_seen"),
179
- pl.len().cast(pl.Int32).alias("observations"),
 
 
 
 
 
 
 
 
180
  )
181
  spans = (
182
  identifiers.filter(pl.col("kind") == "ticker")
183
- .select("cik", pl.col("value").alias("ticker"), "valid_from", "valid_to", "observations")
 
184
  .rename({"observations": "ticker_observations"})
185
  )
186
- joined = pairs.join(spans, on="ticker", how="left")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
  slack = timedelta(days=CUSIP_MATCH_SLACK_DAYS)
189
  overlaps = (pl.col("first_seen") <= pl.col("valid_to") + slack) & (
@@ -192,21 +267,34 @@ def build_cusip_map(ftd: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFram
192
  joined = joined.with_columns(
193
  pl.when(pl.col("cik").is_null())
194
  .then(pl.lit("unmatched"))
 
 
195
  .when(overlaps)
196
  .then(pl.lit("ticker_and_dates"))
197
  .otherwise(pl.lit("ticker_only"))
198
  .alias("match_method")
 
 
 
199
  )
200
  # One ticker can belong to several filers over time -- that is the whole
201
  # point of this dataset -- so the date-overlapping candidate wins, and the
202
- # best-evidenced one breaks a remaining tie.
 
 
 
 
 
203
  ranked = joined.sort(
204
  ["cusip", "ticker",
205
  pl.col("match_method").replace_strict(
206
- {"ticker_and_dates": 0, "ticker_only": 1, "unmatched": 2}, default=3
 
207
  ),
208
- pl.col("ticker_observations").fill_null(0)],
209
- descending=[False, False, False, True],
 
 
210
  ).group_by(["cusip", "ticker"], maintain_order=True).first()
211
 
212
  ranked = ranked.with_columns(pl.col("cusip").str.slice(0, 6).alias("cusip6"))
@@ -217,21 +305,31 @@ def build_cusip_map(ftd: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFram
217
  # so is a fact about how CUSIPs are assigned rather than a guess. It carries
218
  # its own method and a middle confidence, because the *instrument* was never
219
  # matched -- only its issuer.
 
 
 
 
 
 
 
220
  issuer_level = (
221
- ranked.filter(pl.col("cik").is_not_null())
222
  .group_by("cusip6")
223
- .agg(pl.col("cik").mode().first().alias("issuer_cik"))
 
 
 
 
 
 
224
  )
225
  ranked = ranked.join(issuer_level, on="cusip6", how="left").with_columns(
226
- pl.when(pl.col("cik").is_null() & pl.col("issuer_cik").is_not_null())
227
- .then(pl.lit("cusip6_inherited"))
228
- .otherwise(pl.col("match_method"))
229
  .alias("match_method"),
230
- pl.coalesce([pl.col("cik"), pl.col("issuer_cik")]).alias("cik"),
231
  )
232
 
233
  ranked = ranked.with_columns(
234
- pl.col("issuer_name").fill_null("").str.contains(FUND_NAME.pattern).alias("looks_like_fund"),
235
  pl.when(pl.col("match_method") == "ticker_and_dates")
236
  .then(pl.lit("high"))
237
  .when(pl.col("match_method") == "cusip6_inherited")
 
47
  re.I,
48
  )
49
 
50
+ # What filers and clearing records put between a root and its share class.
51
+ # BRK.B, BRK-B, BRK/B and BRKB are one symbol: settlement records write it
52
+ # without a separator and filings with one, so joining on the literal string
53
+ # left every multi-class company -- Berkshire, Brown-Forman, Lennar, Heico,
54
+ # Moog -- matched by luck or not at all.
55
+ CLASS_SEPARATOR = r"[.\-/ ]"
56
+
57
+ # A settlement symbol in the shape a listing has. The rest is real evidence about
58
+ # the instrument but not a symbol anyone trades under: clearing placeholders
59
+ # (XCEMZZZZ, ORCXXXX), preferred lines (BACPRS) and CUSIP fragments (78478V).
60
+ STANDARD_SYMBOL = r"^[A-Z]{1,5}$"
61
+
62
+ # Words too common in issuer names to say that two names are one company.
63
+ NAME_STOPWORDS = frozenset({
64
+ "INC", "CORP", "CO", "LTD", "THE", "OF", "TR", "TRUST", "FUND", "FUNDS", "ETF",
65
+ "SHS", "CL", "COM", "NEW", "PLC", "GROUP", "HLDGS", "HOLDINGS", "LLC", "LP",
66
+ "SA", "NV", "AG", "CORPORATION", "COMPANY", "INTL", "AMER", "AMERICAN", "FIRST",
67
+ "NATL", "NATIONAL", "BANCORP", "FINL", "FINANCIAL", "CAP", "CAPITAL", "SER",
68
+ "SERIES", "AND", "DEL", "ADR", "SPONSORED", "ORD", "CLASS", "INDEX", "SHARES",
69
+ "INCOME", "STK", "UNIT", "UNITS",
70
+ })
71
+
72
+
73
+ def ticker_key(column: str) -> pl.Expr:
74
+ """A ticker with the share-class separator removed, for joining across sources."""
75
+ return pl.col(column).str.to_uppercase().str.replace_all(CLASS_SEPARATOR, "")
76
+
77
+
78
+ def name_tokens(column: str) -> pl.Expr:
79
+ """The distinctive words of a name, as a list."""
80
+ return (
81
+ pl.col(column).fill_null("").str.to_uppercase().str.extract_all(r"[A-Z0-9]+")
82
+ .list.eval(pl.element().filter(
83
+ (pl.element().str.len_chars() > 1) & ~pl.element().is_in(list(NAME_STOPWORDS))
84
+ ))
85
+ )
86
+
87
 
88
  def build_identifiers(observations: pl.DataFrame) -> pl.DataFrame:
89
  """One row per (filer, kind, value) with the span it was stated over."""
 
197
  return align(frame, ISSUER_SCHEMA).sort("cik")
198
 
199
 
200
+ def ftd_pairs(ftd: pl.DataFrame) -> pl.DataFrame:
201
+ """Settlement records folded to one row per (CUSIP, ticker) and its dates."""
202
+ return ftd.group_by(["cusip", "ticker"]).agg(
203
+ pl.col("issuer_name").mode().first().alias("issuer_name"),
204
+ pl.col("observed_on").min().alias("first_seen"),
205
+ pl.col("observed_on").max().alias("last_seen"),
206
+ pl.len().cast(pl.Int32).alias("observations"),
207
+ )
208
+
209
+
210
  def build_cusip_map(ftd: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFrame:
211
  """CUSIP to CIK, by way of the ticker both of them name.
212
 
 
218
  """
219
  if ftd.is_empty():
220
  return empty_frame(CUSIP_MAP_SCHEMA)
221
+ return build_cusip_map_from_pairs(ftd_pairs(ftd), identifiers)
222
 
223
+
224
+ def build_cusip_map_from_pairs(pairs: pl.DataFrame, identifiers: pl.DataFrame) -> pl.DataFrame:
225
+ """The bridge from already-folded pairs, so it can be rebuilt from a published map."""
226
+ if pairs.is_empty():
227
+ return empty_frame(CUSIP_MAP_SCHEMA)
228
+
229
+ pairs = pairs.select(
230
+ "cusip", "ticker", "issuer_name", "first_seen", "last_seen", "observations"
231
+ ).with_columns(
232
+ ticker_key("ticker").alias("ticker_key"),
233
+ pl.col("issuer_name").fill_null("").str.contains(FUND_NAME.pattern)
234
+ .alias("looks_like_fund"),
235
+ pl.col("ticker").str.contains(STANDARD_SYMBOL).alias("standard_symbol"),
236
  )
237
  spans = (
238
  identifiers.filter(pl.col("kind") == "ticker")
239
+ .select("cik", ticker_key("value").alias("ticker_key"), "valid_from", "valid_to",
240
+ "observations")
241
  .rename({"observations": "ticker_observations"})
242
  )
243
+ joined = pairs.join(spans, on="ticker_key", how="left")
244
+
245
+ # A fund that shares a ticker with a company is not that company. SPDR's MDY
246
+ # matched Midway Gold, PIMCO's CORP a Michigan bank, Vanguard's VPL an Invesco
247
+ # muni trust. Names are not used to *attach* a CUSIP -- a wrong name match
248
+ # looks exactly like a right one -- only to refuse a fund whose name shares no
249
+ # word with anything the filer was ever called.
250
+ filer_tokens = (
251
+ identifiers.filter(pl.col("kind").is_in(["name", "former_name"]))
252
+ .group_by("cik")
253
+ .agg(pl.col("value").str.join(" "))
254
+ .select("cik", name_tokens("value").list.unique().alias("filer_tokens"))
255
+ )
256
+ joined = joined.join(filer_tokens, on="cik", how="left").with_columns(
257
+ pl.col("filer_tokens").list.len().fill_null(0).gt(0).alias("filer_named"),
258
+ name_tokens("issuer_name").list.set_intersection(pl.col("filer_tokens"))
259
+ .list.len().fill_null(0).gt(0).alias("name_agrees"),
260
+ )
261
+ conflict = pl.col("looks_like_fund") & pl.col("filer_named") & ~pl.col("name_agrees")
262
 
263
  slack = timedelta(days=CUSIP_MATCH_SLACK_DAYS)
264
  overlaps = (pl.col("first_seen") <= pl.col("valid_to") + slack) & (
 
267
  joined = joined.with_columns(
268
  pl.when(pl.col("cik").is_null())
269
  .then(pl.lit("unmatched"))
270
+ .when(conflict)
271
+ .then(pl.lit("name_conflict"))
272
  .when(overlaps)
273
  .then(pl.lit("ticker_and_dates"))
274
  .otherwise(pl.lit("ticker_only"))
275
  .alias("match_method")
276
+ ).with_columns(
277
+ pl.when(pl.col("match_method") == "name_conflict").then(None)
278
+ .otherwise(pl.col("cik")).alias("cik")
279
  )
280
  # One ticker can belong to several filers over time -- that is the whole
281
  # point of this dataset -- so the date-overlapping candidate wins, and the
282
+ # best-evidenced one breaks a remaining tie. Two filers that each stated the
283
+ # symbol once are still tied after that, and without a last key the winner
284
+ # was whichever row the join happened to emit first: the same inputs gave
285
+ # 36 rows a different filer depending on the order the pairs arrived in.
286
+ # The CIK is an arbitrary tie-break but a stable one, which is what a
287
+ # published build has to be.
288
  ranked = joined.sort(
289
  ["cusip", "ticker",
290
  pl.col("match_method").replace_strict(
291
+ {"ticker_and_dates": 0, "ticker_only": 1, "name_conflict": 2, "unmatched": 3},
292
+ default=4,
293
  ),
294
+ pl.col("ticker_observations").fill_null(0),
295
+ pl.col("cik")],
296
+ descending=[False, False, False, True, False],
297
+ nulls_last=True,
298
  ).group_by(["cusip", "ticker"], maintain_order=True).first()
299
 
300
  ranked = ranked.with_columns(pl.col("cusip").str.slice(0, 6).alias("cusip6"))
 
305
  # so is a fact about how CUSIPs are assigned rather than a guess. It carries
306
  # its own method and a middle confidence, because the *instrument* was never
307
  # matched -- only its issuer.
308
+ #
309
+ # Only a confident, unambiguous match may lend its issuer. Inheriting from any
310
+ # match let one fund's accidental ticker collision -- iShares' ICF with ICF
311
+ # International, Vanguard's VOT with a Van Kampen trust -- name the issuer of
312
+ # every fund under the same prefix: 74 iShares and 14 Vanguard ETFs, IVV,
313
+ # IWM, EFA, VOO and VTI among them. A fund family's prefix is a registrant
314
+ # trust that files nothing under a ticker, so funds never inherit at all.
315
  issuer_level = (
316
+ ranked.filter((pl.col("match_method") == "ticker_and_dates") & ~pl.col("looks_like_fund"))
317
  .group_by("cusip6")
318
+ .agg(pl.col("cik").n_unique().alias("issuers"), pl.col("cik").first().alias("issuer_cik"))
319
+ .filter(pl.col("issuers") == 1)
320
+ .select("cusip6", "issuer_cik")
321
+ )
322
+ inherits = (
323
+ pl.col("cik").is_null() & pl.col("issuer_cik").is_not_null() & ~pl.col("looks_like_fund")
324
+ & (pl.col("match_method") != "name_conflict")
325
  )
326
  ranked = ranked.join(issuer_level, on="cusip6", how="left").with_columns(
327
+ pl.when(inherits).then(pl.lit("cusip6_inherited")).otherwise(pl.col("match_method"))
 
 
328
  .alias("match_method"),
329
+ pl.when(inherits).then(pl.col("issuer_cik")).otherwise(pl.col("cik")).alias("cik"),
330
  )
331
 
332
  ranked = ranked.with_columns(
 
333
  pl.when(pl.col("match_method") == "ticker_and_dates")
334
  .then(pl.lit("high"))
335
  .when(pl.col("match_method") == "cusip6_inherited")
recipe/quality.py CHANGED
@@ -161,6 +161,23 @@ def validate(data_dir: Path) -> QualityReport:
161
  )
162
  if cusip_map.select("cusip", "ticker").unique().height != cusip_map.height:
163
  report.error("cusip_map: duplicate (cusip, ticker) rows")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  if not pit.is_empty():
166
  if pit.height != identifiers.height:
 
161
  )
162
  if cusip_map.select("cusip", "ticker").unique().height != cusip_map.height:
163
  report.error("cusip_map: duplicate (cusip, ticker) rows")
164
+ # A fund family shares one CUSIP prefix, so a fund inheriting its filer
165
+ # from that prefix means one accidental ticker collision has named every
166
+ # fund under it. This is how IVV, IWM and EFA came to be ICF International.
167
+ inherited_funds = cusip_map.filter(
168
+ pl.col("looks_like_fund").fill_null(False)
169
+ & (pl.col("match_method") == "cusip6_inherited")
170
+ ).height
171
+ report.metric("cusip_fund_rows_inherited", inherited_funds)
172
+ if inherited_funds:
173
+ report.error(
174
+ f"cusip_map: {inherited_funds} fund rows took a filer from their CUSIP "
175
+ f"prefix — a fund family's prefix names no operating company"
176
+ )
177
+ report.metric(
178
+ "cusip_name_conflicts",
179
+ cusip_map.filter(pl.col("match_method") == "name_conflict").height,
180
+ )
181
 
182
  if not pit.is_empty():
183
  if pit.height != identifiers.height:
recipe/schema.py CHANGED
@@ -86,6 +86,9 @@ CUSIP_MAP_SCHEMA: dict[str, pl.DataType] = {
86
  # nothing a CIK could be attached to. Not a failed match: a different kind
87
  # of instrument.
88
  "looks_like_fund": pl.Boolean,
 
 
 
89
  "inserted_at": UTC_DATETIME,
90
  }
91
 
 
86
  # nothing a CIK could be attached to. Not a failed match: a different kind
87
  # of instrument.
88
  "looks_like_fund": pl.Boolean,
89
+ # False for a clearing placeholder (XCEMZZZZ), a preferred line (BACPRS) or
90
+ # a CUSIP fragment: evidence about the instrument, not a symbol to trade.
91
+ "standard_symbol": pl.Boolean,
92
  "inserted_at": UTC_DATETIME,
93
  }
94
 
tests/test_intervals.py CHANGED
@@ -6,7 +6,14 @@ from datetime import date
6
 
7
  import polars as pl
8
 
9
- from recipe.intervals import build_cusip_map, build_identifiers, build_issuers, build_pit
 
 
 
 
 
 
 
10
 
11
 
12
  def test_a_ticker_change_becomes_two_spans(observations):
@@ -87,3 +94,102 @@ def test_pit_dates_every_span_and_never_leaks(observations):
87
  # Knowledge is the end of the day observed, so it never precedes the event.
88
  assert (pit["knowledge_date"].dt.date() >= pit["event_date"]).all()
89
  assert pit["knowledge_estimated"].all()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  import polars as pl
8
 
9
+ from recipe.intervals import (
10
+ build_cusip_map,
11
+ build_cusip_map_from_pairs,
12
+ build_identifiers,
13
+ build_issuers,
14
+ build_pit,
15
+ ftd_pairs,
16
+ )
17
 
18
 
19
  def test_a_ticker_change_becomes_two_spans(observations):
 
94
  # Knowledge is the end of the day observed, so it never precedes the event.
95
  assert (pit["knowledge_date"].dt.date() >= pit["event_date"]).all()
96
  assert pit["knowledge_estimated"].all()
97
+
98
+
99
+ def _bridge(observations, ftd_rows):
100
+ return build_cusip_map(pl.DataFrame(ftd_rows, strict=False), build_identifiers(observations))
101
+
102
+
103
+ def _ftd(cusip, ticker, name, day):
104
+ return {"cusip": cusip, "ticker": ticker, "issuer_name": name, "observed_on": day,
105
+ "source_ref": "f"}
106
+
107
+
108
+ def test_a_share_class_matches_across_separators():
109
+ """Settlement records write BRKB, filings BRK.B: one symbol, one filer."""
110
+ from conftest import observation
111
+ obs = pl.DataFrame([
112
+ observation("0000000010", "ticker", "BRK.B", date(2015, 1, 1)),
113
+ observation("0000000010", "ticker", "BRK.B", date(2020, 1, 1)),
114
+ observation("0000000010", "name", "Berkshire Hathaway Inc", date(2020, 1, 1)),
115
+ ], strict=False)
116
+ bridge = _bridge(obs, [_ftd("084670702", "BRKB", "BERKSHIRE HATHAWAY INC CL B", date(2018, 1, 1))])
117
+ row = bridge.row(0, named=True)
118
+ assert row["cik"] == "0000000010" and row["match_confidence"] == "high"
119
+ assert row["ticker"] == "BRKB", "the published ticker is the one the record stated"
120
+
121
+
122
+ def test_a_fund_is_not_the_company_that_shares_its_ticker():
123
+ """SPDR's MDY matched Midway Gold by ticker and date. A fund whose name shares
124
+ no word with anything the filer was called is refused, not attached."""
125
+ from conftest import observation
126
+ obs = pl.DataFrame([
127
+ observation("0000000020", "ticker", "MDY", date(2010, 1, 1)),
128
+ observation("0000000020", "ticker", "MDY", date(2012, 1, 1)),
129
+ observation("0000000020", "name", "Midway Gold Corp", date(2012, 1, 1)),
130
+ ], strict=False)
131
+ bridge = _bridge(obs, [_ftd("78467Y107", "MDY", "SPDR S&P MIDCAP 400 ETF TR UTS", date(2011, 1, 1))])
132
+ row = bridge.row(0, named=True)
133
+ assert row["cik"] is None
134
+ assert row["match_method"] == "name_conflict" and row["match_confidence"] == "none"
135
+
136
+
137
+ def test_one_collision_does_not_name_a_whole_fund_family():
138
+ """iShares' ICF once matched ICF International, and inheriting by CUSIP prefix
139
+ then gave that company's CIK to IVV, IWM, EFA and 71 more funds."""
140
+ from conftest import observation
141
+ obs = pl.DataFrame([
142
+ observation("0000000030", "ticker", "ICF", date(2010, 1, 1)),
143
+ observation("0000000030", "ticker", "ICF", date(2012, 1, 1)),
144
+ ], strict=False)
145
+ bridge = _bridge(obs, [
146
+ _ftd("464287564", "ICF", "ISHARES COHEN & STEERS REIT ETF", date(2011, 1, 1)),
147
+ _ftd("464287200", "IVV", "ISHARES CORE S&P 500 ETF", date(2011, 1, 1)),
148
+ ])
149
+ ivv = bridge.filter(pl.col("ticker") == "IVV").row(0, named=True)
150
+ assert ivv["cik"] is None and ivv["match_method"] == "unmatched"
151
+
152
+
153
+ def test_an_issuer_prefix_still_lends_its_filer_to_other_classes():
154
+ """The prefix rule is right for companies: a class A share of a company whose
155
+ common stock matched belongs to the same filer."""
156
+ from conftest import observation
157
+ obs = pl.DataFrame([
158
+ observation("0000000040", "ticker", "HEI", date(2010, 1, 1)),
159
+ observation("0000000040", "ticker", "HEI", date(2020, 1, 1)),
160
+ ], strict=False)
161
+ bridge = _bridge(obs, [
162
+ _ftd("422806109", "HEI", "HEICO CORP", date(2015, 1, 1)),
163
+ _ftd("422806208", "HEIXA", "HEICO CORP CL A", date(2015, 1, 1)),
164
+ ])
165
+ cls = bridge.filter(pl.col("cusip") == "422806208").row(0, named=True)
166
+ assert cls["cik"] == "0000000040" and cls["match_confidence"] == "medium"
167
+
168
+
169
+ def test_clearing_placeholders_are_marked():
170
+ from conftest import observation
171
+ obs = pl.DataFrame([observation("0000000050", "ticker", "XCEM", date(2015, 1, 1))], strict=False)
172
+ bridge = _bridge(obs, [
173
+ _ftd("19762B202", "XCEMZZZZ", "COLUMBIA ETF TR II", date(2015, 1, 1)),
174
+ _ftd("19762B203", "XCEM", "COLUMBIA ETF TR II", date(2015, 1, 1)),
175
+ ])
176
+ flags = dict(bridge.select("ticker", "standard_symbol").iter_rows())
177
+ assert flags == {"XCEMZZZZ": False, "XCEM": True}
178
+
179
+
180
+ def test_a_tie_between_two_filers_resolves_the_same_way_every_time():
181
+ """Two filers that each stated the symbol once are tied on every rank the
182
+ bridge sorts by. Without a last key the winner was whichever row the join
183
+ emitted first, and the same inputs in a different order gave a different
184
+ filer."""
185
+ from conftest import observation
186
+ obs = pl.DataFrame([
187
+ observation("0000000061", "ticker", "TIE", date(2011, 1, 1)),
188
+ observation("0000000062", "ticker", "TIE", date(2011, 1, 1)),
189
+ ], strict=False)
190
+ identifiers = build_identifiers(obs)
191
+ pairs = ftd_pairs(pl.DataFrame(
192
+ [_ftd("111111105", "TIE", "TIE CORP", date(2011, 1, 1))], strict=False))
193
+ forward = build_cusip_map_from_pairs(pairs, identifiers)
194
+ backward = build_cusip_map_from_pairs(pairs, identifiers.reverse())
195
+ assert forward.drop("inserted_at").equals(backward.drop("inserted_at"))