Add files using upload-large-folder tool
Browse files- README.md +75 -0
- data/corpus/test.parquet +3 -0
- data/corpus/train.parquet +3 -0
- data/corpus/validation.parquet +3 -0
- data/features/test.parquet +3 -0
- data/features/train.parquet +3 -0
- data/features/validation.parquet +3 -0
- data/labeled/test.parquet +3 -0
- data/labeled/train.parquet +3 -0
- data/labeled/validation.parquet +3 -0
- data/labeled_head32k/test.parquet +3 -0
- data/labeled_head32k/train.parquet +3 -0
- data/labeled_head32k/validation.parquet +3 -0
- generate_labels.py +79 -0
README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: mixed-cc0-text-and-derived-facts
|
| 4 |
+
language: [en]
|
| 5 |
+
pretty_name: SEC Filings → Forward-Return (US large-cap, 2000–2026)
|
| 6 |
+
size_categories: [100K<n<1M]
|
| 7 |
+
task_categories: [text-classification, tabular-regression, text-retrieval]
|
| 8 |
+
tags: [finance, sec, edgar, 8-k, 10-k, 10-q, forward-return, event-study, leak-free, time-series]
|
| 9 |
+
configs:
|
| 10 |
+
- config_name: labeled
|
| 11 |
+
data_files: [{split: train, path: data/labeled/train.parquet}, {split: validation, path: data/labeled/validation.parquet}, {split: test, path: data/labeled/test.parquet}]
|
| 12 |
+
- config_name: labeled_head32k
|
| 13 |
+
data_files: [{split: train, path: data/labeled_head32k/train.parquet}, {split: validation, path: data/labeled_head32k/validation.parquet}, {split: test, path: data/labeled_head32k/test.parquet}]
|
| 14 |
+
- config_name: features
|
| 15 |
+
data_files: [{split: train, path: data/features/train.parquet}, {split: validation, path: data/features/validation.parquet}, {split: test, path: data/features/test.parquet}]
|
| 16 |
+
- config_name: corpus
|
| 17 |
+
data_files: [{split: train, path: data/corpus/train.parquet}, {split: validation, path: data/corpus/validation.parquet}, {split: test, path: data/corpus/test.parquet}]
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# SEC Filings → Forward-Return (US large-cap, 2000–2026)
|
| 21 |
+
|
| 22 |
+
Leak-free, time-ordered SEC filings (8-K / 10-Q / 10-K) with objective **forward-return
|
| 23 |
+
labels** for ~610 current US large-cap names, through 2026. A *benchmark* ("can filing text
|
| 24 |
+
predict forward returns?"), not just a corpus.
|
| 25 |
+
|
| 26 |
+
## ⚖️ Licensing & provenance (read first — this is the honest part)
|
| 27 |
+
This repo deliberately separates two provenance classes:
|
| 28 |
+
|
| 29 |
+
| part | source | license |
|
| 30 |
+
|---|---|---|
|
| 31 |
+
| **Filing text + `accession,cik,ticker,form,file_date,period_of_report,doc_url,text_len`** | **SEC EDGAR** — US government work | **public domain / CC0** |
|
| 32 |
+
| **Labels** (`fwd_ret_*, excess_spy_*, direction_*, fwd_vol_*, entry_date`) | **derived numerical facts** computed from publicly observable split/dividend-adjusted closing prices | provided **as-is, no warranty**; see below |
|
| 33 |
+
|
| 34 |
+
- The underlying **price series is NOT included or redistributed** here. Labels are scalar
|
| 35 |
+
*derived returns* (facts), not vendor price data.
|
| 36 |
+
- **No proprietary classification.** The earlier `excess_sector` label (which needed a GICS
|
| 37 |
+
mapping) has been **removed**. Only market-relative excess (`excess_spy`, vs SPY) remains.
|
| 38 |
+
- **Full reproducibility:** `generate_labels.py` regenerates every label from *your own*
|
| 39 |
+
price source (any `date,ticker,adj_close` parquet). You can verify or rebuild labels
|
| 40 |
+
without relying on any redistributed price data.
|
| 41 |
+
- The **`corpus`** config (text only) is unambiguously **CC0**.
|
| 42 |
+
|
| 43 |
+
## Configs
|
| 44 |
+
- **labeled** — filing text + forward-return labels (headline).
|
| 45 |
+
- **labeled_head32k** — same, text truncated to 32k chars (HF-practical).
|
| 46 |
+
- **features** — tabular only (no text): metadata + labels, for quick baselines.
|
| 47 |
+
- **corpus** — ALL forms incl. foreign 6-K/20-F, text-only (CC0).
|
| 48 |
+
|
| 49 |
+
## Splits (walk-forward, 120-trading-day embargo)
|
| 50 |
+
train ≤ 2019 · validation 2020–2022 · test 2023–2026. Filings whose 120-td label window
|
| 51 |
+
crosses a split boundary are dropped from the earlier split (no peeking across boundaries).
|
| 52 |
+
|
| 53 |
+
## Labels (per horizon h ∈ {1,5,20,60,120} trading days; no `fwd_vol_1`)
|
| 54 |
+
`fwd_ret_h = adj_close[E+h]/adj_close[E]−1` · `excess_spy_h = fwd_ret_h − SPY` ·
|
| 55 |
+
`direction_h = sign(excess_spy_h)` · `fwd_vol_h` = realized daily-log-ret vol.
|
| 56 |
+
**Anchor E = first trading session STRICTLY AFTER `file_date`** (a filing at any intraday
|
| 57 |
+
time can't be traded that day → next session). `entry_date` is kept for transparency.
|
| 58 |
+
|
| 59 |
+
## ⚠️ Known limitations
|
| 60 |
+
- **Survivorship bias** — universe = *current* US large-cap names only. Fingerprint visible:
|
| 61 |
+
`excess_spy` mean ≈ 0 at 1–5d, rising to ~+2.6% at 120d. Use cross-sectional/excess, not
|
| 62 |
+
absolute long-horizon P&L. No point-in-time index membership.
|
| 63 |
+
- Foreign 6-K/20-F are text-only (in `corpus`), not price-labeled.
|
| 64 |
+
- **Not investment advice.** Research dataset; past returns ≠ future results.
|
| 65 |
+
|
| 66 |
+
## Baseline (bar to beat) — test split (2023–26), walk-forward
|
| 67 |
+
| model | input | accuracy | AUC | IC (Spearman) | L/S decile excess_20 |
|
| 68 |
+
|---|---|---|---|---|---|
|
| 69 |
+
| no-text floor (HistGBM) | form, text_len, season | 0.470 | 0.512 | +0.022 | −0.006 |
|
| 70 |
+
| text (TF-IDF + logistic) | head_32k filing text | 0.479 | 0.500 | −0.006 | −0.000 |
|
| 71 |
+
|
| 72 |
+
Both ~chance: predicting 20-day excess return from filing text out-of-sample is genuinely
|
| 73 |
+
hard, and naive text does not beat the no-text floor. The ~0.50 walk-forward AUC also
|
| 74 |
+
corroborates the labels are leak-free (a leaky setup would inflate it). Open challenge:
|
| 75 |
+
beat this (likely 8-K at short horizons, or modern encoders).
|
data/corpus/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3900b4dd6d84b36faf47224d1e68c689bff426d0ec4288dc2a44215d637c4518
|
| 3 |
+
size 697193855
|
data/corpus/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c85a49f87c5e453ac01a148ce4c7331b5e6e7f43ec79574f5efc2fc2f4b06744
|
| 3 |
+
size 4102681407
|
data/corpus/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4244e601d4f9dd30f09922332f1ba038344addf38b7f77ba4befadeaf067bcb4
|
| 3 |
+
size 593755655
|
data/features/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:66bb083ce9f05f4ddb30b58b44423273f55228d7ffbf21e391b5574ae9276909
|
| 3 |
+
size 3454130
|
data/features/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f169a65290d452fc443d0828724fc73cac2e6fb89b264352339a649f0eee8775
|
| 3 |
+
size 16763086
|
data/features/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:425a8dde835aea8eec58a289403e23ede33b1e160df6c670ac6ab6abdd05b0a0
|
| 3 |
+
size 2765889
|
data/labeled/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:57d0cf109c258cc13b37f9aa7efa1c566f562c7795d91f2dfef465e22b50aa9c
|
| 3 |
+
size 482984950
|
data/labeled/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:735380c9a87183f0351f8f2ed4601ce39a9b615f25f55c6ef6b44669094f8467
|
| 3 |
+
size 3195293325
|
data/labeled/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2bb943d8c4573def1f88fa6516c5032a039fc8de41d9bf03d3019146890f8bc1
|
| 3 |
+
size 368925483
|
data/labeled_head32k/test.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0574a90c6ca68f28fa3e449aec2321646ac2017e11351e12636a6990cfc3bccf
|
| 3 |
+
size 75540426
|
data/labeled_head32k/train.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:97a4ae02c1b1464d27af157d179ea78670e480c9d347171c2597d63985335996
|
| 3 |
+
size 349409068
|
data/labeled_head32k/validation.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00054c9e1246828e0232047025787c4fde1244dca2d2158911250b38b590e921
|
| 3 |
+
size 56978241
|
generate_labels.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""generate_labels.py — reproduce the forward-return LABELS for this dataset from
|
| 3 |
+
YOUR OWN price source (so the dataset needs no redistributed vendor price data).
|
| 4 |
+
|
| 5 |
+
You provide a long-format daily price parquet with columns: date, ticker, adj_close
|
| 6 |
+
(split+dividend adjusted). The script computes, for each filing in the `corpus`/`labeled`
|
| 7 |
+
text, leak-free forward-return labels and writes them next to the filings.
|
| 8 |
+
|
| 9 |
+
LEAK RULE (do not change): entry E = first trading session STRICTLY AFTER file_date.
|
| 10 |
+
Return uses adj_close at both ends. Horizons h ∈ {1,5,20,60,120} trading days.
|
| 11 |
+
Labels: fwd_ret_h, excess_spy_h (vs SPY adj_close), direction_h (sign excess_spy), fwd_vol_h.
|
| 12 |
+
(excess_sector is intentionally NOT computed here — it required a proprietary GICS mapping.)
|
| 13 |
+
|
| 14 |
+
Usage:
|
| 15 |
+
python generate_labels.py --filings filings.parquet --prices my_prices.parquet \
|
| 16 |
+
--spy SPY --out labels.parquet
|
| 17 |
+
"""
|
| 18 |
+
import argparse
|
| 19 |
+
import numpy as np, polars as pl
|
| 20 |
+
|
| 21 |
+
HZ = [1, 5, 20, 60, 120]
|
| 22 |
+
|
| 23 |
+
def win_ret(darr, aarr, dE, dX):
|
| 24 |
+
iE = np.searchsorted(darr, dE); iX = np.searchsorted(darr, dX)
|
| 25 |
+
okE = (iE < len(darr)) & (darr[np.clip(iE, 0, len(darr)-1)] == dE)
|
| 26 |
+
okX = (iX < len(darr)) & (darr[np.clip(iX, 0, len(darr)-1)] == dX)
|
| 27 |
+
r = np.full(len(dE), np.nan); ok = okE & okX
|
| 28 |
+
r[ok] = aarr[iX[ok]] / aarr[iE[ok]] - 1
|
| 29 |
+
return r
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
ap = argparse.ArgumentParser()
|
| 33 |
+
ap.add_argument("--filings", required=True, help="parquet with columns accession,ticker,file_date")
|
| 34 |
+
ap.add_argument("--prices", required=True, help="long parquet: date,ticker,adj_close")
|
| 35 |
+
ap.add_argument("--spy", default="SPY")
|
| 36 |
+
ap.add_argument("--out", default="labels.parquet")
|
| 37 |
+
a = ap.parse_args()
|
| 38 |
+
|
| 39 |
+
px = (pl.read_parquet(a.prices, columns=["date", "ticker", "adj_close"]).drop_nulls("adj_close")
|
| 40 |
+
.with_columns(pl.col("date").cast(pl.Date).cast(pl.Int32).alias("d")))
|
| 41 |
+
by = {t: (s.sort("d")["d"].to_numpy(), s.sort("d")["adj_close"].to_numpy())
|
| 42 |
+
for t, s in px.group_by("ticker")}
|
| 43 |
+
spy_d, spy_a = by[a.spy]
|
| 44 |
+
|
| 45 |
+
df = (pl.read_parquet(a.filings, columns=["accession", "ticker", "file_date"])
|
| 46 |
+
.with_columns(pl.col("file_date").cast(pl.Utf8).str.slice(0, 10)
|
| 47 |
+
.str.strptime(pl.Date, strict=False).cast(pl.Int32).alias("fd"))
|
| 48 |
+
.drop_nulls("fd").with_row_index("rid"))
|
| 49 |
+
N = df.height
|
| 50 |
+
out = {f"{p}_{h}": np.full(N, np.nan) for h in HZ for p in ("fwd_ret", "excess_spy", "fwd_vol")}
|
| 51 |
+
|
| 52 |
+
for tk, sub in df.group_by("ticker"):
|
| 53 |
+
tk = tk[0] if isinstance(tk, tuple) else tk
|
| 54 |
+
if tk not in by: continue
|
| 55 |
+
pd_, pa_ = by[tk]; rid = sub["rid"].to_numpy(); fd = sub["fd"].to_numpy()
|
| 56 |
+
E = np.searchsorted(pd_, fd, side="right"); n = len(pd_); hasE = E < n
|
| 57 |
+
if not hasE.any(): continue
|
| 58 |
+
Ec = np.clip(E, 0, n-1); dE = pd_[Ec]
|
| 59 |
+
for h in HZ:
|
| 60 |
+
X = E + h; okX = hasE & (X < n); Xc = np.clip(X, 0, n-1); dX = pd_[Xc]
|
| 61 |
+
ret = np.where(okX, pa_[Xc] / pa_[Ec] - 1, np.nan)
|
| 62 |
+
out[f"fwd_ret_{h}"][rid] = ret
|
| 63 |
+
out[f"excess_spy_{h}"][rid] = np.where(okX, ret - win_ret(spy_d, spy_a, dE, dX), np.nan)
|
| 64 |
+
vol = np.full(len(rid), np.nan)
|
| 65 |
+
for j in np.where(okX)[0]:
|
| 66 |
+
seg = pa_[Ec[j]:Xc[j]+1]
|
| 67 |
+
if len(seg) > 2: vol[j] = np.diff(np.log(seg)).std(ddof=1)
|
| 68 |
+
out[f"fwd_vol_{h}"][rid] = vol
|
| 69 |
+
|
| 70 |
+
cols = {"accession": df["accession"]}
|
| 71 |
+
for h in HZ:
|
| 72 |
+
for p in ("fwd_ret", "excess_spy", "fwd_vol"):
|
| 73 |
+
cols[f"{p}_{h}"] = pl.Series(out[f"{p}_{h}"]).fill_nan(None)
|
| 74 |
+
cols[f"direction_{h}"] = pl.Series(np.sign(out[f"excess_spy_{h}"])).fill_nan(None)
|
| 75 |
+
pl.DataFrame(cols).write_parquet(a.out)
|
| 76 |
+
print(f"wrote {a.out}: {N} rows")
|
| 77 |
+
|
| 78 |
+
if __name__ == "__main__":
|
| 79 |
+
main()
|