Data Collection README
Project: Hybrid Topic and Domain-Adaptive Modelling for Financial Risk and Forecasting Student: S2880814 | Supervisor: Prof Tiejun Ma Phase covered: Phase 1 — Data Pipeline (IPP §3.1.1, Milestone M1)
What Phase 1 Required (from the IPP Report)
Section 3.1.1 of the report specifies four things that must exist before Phase 2 (DAPT) can begin:
| Report Requirement | Where stated |
|---|---|
| Item 1A text corpus, sentence-tokenised, temporal split 2006–2024 / 2025 / 2026 | §3.1.1, Figure 1 (Ph.1 DATA PIPELINE box) |
| CIK–PERMNO linkage for volatility label assignment | §3.1.1 bullet 1 |
| CIK–SIC 2-digit linkage for sector-view positive-pair construction (Phase 3) | §3.1.1 bullet 2 |
| 30-day realised volatility labels (lagged + forward) aligned to filing dates | §3.1.1, §3.1.5, Milestone M1 |
The output of Phase 1 is Milestone M1: "Clean corpus, temporal split indices, volatility labels".
Dataset Inventory
Raw / Source Data (inputs — not generated by scripts)
| File | Size | Source | Report Role |
|---|---|---|---|
sp500_1A/ (folder, 8,247 .pickle files) |
~1 GB | Shared by Sunnie Li (enquire actual source) | Primary text corpus — Item 1A Risk Factor sections from S&P 500 10-K filings, 2006–2025. Used as the sole text input for all five phases (§3.1.1: "Item 1A is selected as the sole text source"). Each file is named {TICKER}_{YEAR}.pickle and contains a plain string. |
sp500_union_constituents(1).csv |
~50 KB | Shared by Sunnie Li (enquire actual source) | Universe definition — 656 unique CIK/ticker pairs representing all firms that were ever S&P 500 constituents. Used as the spine for all linkage and data-collection scripts. |
ticker_cik_mapping(1).csv |
~30 KB | Shared by Sunnie Li (enquire actual source) | Auxiliary cross-reference; superseded by sp500_union_constituents for pipeline use. |
ccm_linking_table.csv |
~2.1 MB | WRDS CRSP/Compustat Merged (CCM) — downloaded via WRDS web query | Raw CCM linking table: maps CIK → GVKEY → PERMNO/PERMCO with link type and date range. Input to build_permno_linkage.py. |
all_sp500_prices_2000_2024_delisted_include.csv |
~253 MB | FINSABER dataset (waylonli/FINSABER-reproduce on HuggingFace) |
Daily stock prices 2000–2024 for all S&P 500 firms including delisted. Columns: date, open, high, low, close, adjusted_close, volume, symbol. Used to compute volatility labels for all filings up to and including fiscal year 2024. Replaces WRDS CRSP for the training period, keeping the pipeline free of institutional data for 2006–2024. |
crsp_2025_daily.csv |
~9.5 MB | WRDS CRSP Annual Update → Stock Version 2 (CIZ) → Daily Stock File — query crsp_2025_daily (ID 11299163) |
Daily stock prices for 2025 (Jan–Dec). 159,093 rows across 647 PERMNOs. Columns: PERMNO, HdrCUSIP, Ticker, PERMCO, DlyCalDt, DlyPrc, DlyRet, ShrOut. Required for volatility labels on 2025 filings (validation set per §3.1.1 temporal split). CRSP data is accessed under the University's institutional licence and will not be redistributed (§3.4 Ethics). |
Intermediate / Derived Data (generated by scripts)
| File | Rows | Script | What it contains | Report Requirement met |
|---|---|---|---|---|
permnos_for_wrds.txt |
647 lines | (helper, no script) | One PERMNO per line — used to upload the PERMNO list to the WRDS query form to pull crsp_2025_daily.csv. |
— |
permno_linkage.csv |
656 | scripts/build_permno_linkage.py |
Clean CIK → PERMNO mapping. Columns: ticker, cik, permno, permco, sic_ccm, gvkey, linktype, linkprim, linkdt, linkenddt. Deduplicates CCM to best link per CIK (LINKPRIM=P preferred, then active, then latest). 651/656 matched (99.2%); 5 unmatched (ETN, ACV, PARA, DAY, CPWR). |
CIK–PERMNO linkage (§3.1.1 bullet 1) — required for assigning volatility labels to filings. |
filings_index.csv |
11,447 | scripts/build_filings_index.py |
EDGAR submissions API output for all 656 CIKs. Columns: ticker, cik, sic, sic_description, fiscal_year, filing_date, report_date, has_pickle. Covers 10-K and 10-K405 filings from fiscal years 2006–2025. has_pickle=True for 8,105 rows — these are the filings with text in sp500_1A/. |
CIK–SIC 2-digit linkage (§3.1.1 bullet 2) — SIC codes needed for inter-firm sector-view positive pairs in Phase 3 contrastive fine-tuning. Also provides the fiscal-year index aligning filing dates to return windows (§3.1.1 bullet 3). |
volatility_labels.csv |
8,105 | scripts/compute_volatility_labels.py |
30-day annualised volatility windows for every filing with a pickle file. Columns: ticker, cik, sic, sic_description, fiscal_year, filing_date, report_date, lagged_vol_30d, fwd_vol_30d. Price sources: FINSABER (2000–2024) → CRSP 2025 → yfinance fallback (ETN). Coverage: 7,695/8,105 filings have both windows (94.9%). |
30-day realised volatility labels (§3.1.1, §3.1.5) — fwd_vol_30d is the prediction target throughout Phases 2–5. lagged_vol_30d is the AR(1) baseline feature. Annualised as std(log-returns) × √252. |
Phase 1 Final Output
| File | Rows | Script | Description |
|---|---|---|---|
feature_table.parquet |
8,105 | scripts/build_feature_table.py |
Milestone M1 deliverable. Joins filings index + PERMNO linkage + volatility labels into a single row-per-filing table. Columns: ticker, cik, permno, permco, gvkey, sic, sic_description, fiscal_year, filing_date, report_date, lagged_vol_30d, fwd_vol_30d, embedding (NaN placeholder), topic_vector (NaN placeholder), linktype, linkprim. The embedding and topic_vector columns are filled in Phase 2 and Phase 4 respectively. |
feature_table_preview.csv |
8,105 | scripts/build_feature_table.py |
Human-readable CSV version of the feature table (without placeholder columns). For inspection only. |
Coverage Summary
| Metric | Value |
|---|---|
| Firms in S&P 500 universe | 656 |
| Firms with at least one Item 1A filing | 485 |
| Total filings with Item 1A text (has_pickle) | 8,105 |
| Filings with PERMNO assigned | 8,079 (99.7%) |
| Filings with both vol labels | 7,695 (94.9%) |
| Date range (filing dates) | 2006-02-22 → 2026-03-02 |
| Unique SIC codes | 179 |
| Temporal split | Train ≤ 2024 · Val 2025 · Test 2026 |
Temporal Split (§3.1.1)
The report mandates a strictly forward-looking split to prevent leakage from base-model pre-training data:
| Split | Filing fiscal years | Filings (approx.) | Used in |
|---|---|---|---|
| Train | 2006 – 2024 | ~7,600 | Phase 2 DAPT MLM, Phase 3 contrastive FT, Phase 4 BERTopic |
| Val | 2025 | ~380 | Phase 2 perplexity checkpoint selection; Phase 3 FinMTEB intrinsic eval |
| Test | 2026 (YTD) | ~125 | Phase 5 downstream volatility forecasting (held-out, never seen during training) |
The split boundary is applied via filing_date (not report_date) per §3.1.1: "filing_date defines the temporal boundary".
Scripts Reference
| Script | Input(s) | Output | Purpose |
|---|---|---|---|
scripts/inspect_Item_1A_dataset.py |
sp500_1A/ |
(console) | Inspect pickle corpus structure |
scripts/build_permno_linkage.py |
ccm_linking_table.csv, sp500_union_constituents(1).csv |
permno_linkage.csv |
CIK → PERMNO mapping |
scripts/investigate_unmatched.py |
ccm_linking_table.csv |
(console) | Debug 5 unmatched tickers |
scripts/build_filings_index.py |
sp500_union_constituents(1).csv, EDGAR API |
filings_index.csv |
Filing dates + SIC codes |
scripts/compute_volatility_labels.py |
filings_index.csv, all_sp500_prices_2000_2024_delisted_include.csv, crsp_2025_daily.csv |
volatility_labels.csv |
30-day vol windows |
scripts/build_feature_table.py |
filings_index.csv, permno_linkage.csv, volatility_labels.csv |
feature_table.parquet, feature_table_preview.csv |
Phase 1 final table |
scripts/sanity_check_vol(delete_later).py |
volatility_labels.csv |
(console) | Vol label validation |
Notes on Data Access and Ethics (§3.4)
- EDGAR data is publicly available and freely accessible via the SEC submissions API. No licence restrictions.
- FINSABER prices are sourced from the HuggingFace dataset
waylonli/FINSABER-reproduce(public). No redistribution restrictions for research use. - WRDS/CRSP data (
crsp_2025_daily.csv,ccm_linking_table.csv) is accessed under the University of Edinburgh's institutional licence. Per §3.4 of the report: "CRSP data will be accessed exclusively through WRDS under the University's institutional licence and will not be redistributed or retained beyond the project period." These files must not be shared outside the project. - No personal data, human subjects, or proprietary datasets are used.