Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,106 +1,83 @@
|
|
| 1 |
-
# Data Collection README
|
| 2 |
-
**Project:** Hybrid Topic and Domain-Adaptive Modelling for Financial Risk and Forecasting
|
| 3 |
-
**Student:** S2880814 | **Supervisor:** Prof Tiejun Ma
|
| 4 |
-
**Phase covered:** Phase 1 — Data Pipeline (IPP §3.1.1, Milestone M1)
|
| 5 |
-
|
| 6 |
---
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
| 30-day realised volatility labels (lagged + forward) aligned to filing dates | §3.1.1, §3.1.5, Milestone M1 |
|
| 18 |
-
|
| 19 |
-
The output of Phase 1 is **Milestone M1**: *"Clean corpus, temporal split indices, volatility labels"*.
|
| 20 |
-
|
| 21 |
---
|
| 22 |
|
| 23 |
-
#
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|------|------|--------|-------------|
|
| 29 |
-
| `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. |
|
| 30 |
-
| `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. |
|
| 31 |
-
| `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. |
|
| 32 |
-
| `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`. |
|
| 33 |
-
| `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. |
|
| 34 |
-
| `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). |
|
| 35 |
|
| 36 |
---
|
| 37 |
|
| 38 |
-
##
|
| 39 |
-
|
| 40 |
-
| File | Rows | Script | What it contains | Report Requirement met |
|
| 41 |
-
|------|------|--------|-----------------|----------------------|
|
| 42 |
-
| `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`. | — |
|
| 43 |
-
| `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. |
|
| 44 |
-
| `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). |
|
| 45 |
-
| `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`. |
|
| 46 |
-
|
| 47 |
-
---
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
| File |
|
| 52 |
-
|------|------|--------
|
| 53 |
-
| `
|
| 54 |
-
| `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
---
|
| 57 |
|
| 58 |
-
##
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
| Firms with at least one Item 1A filing | 485 |
|
| 64 |
-
| Total filings with Item 1A text (has_pickle) | 8,105 |
|
| 65 |
-
| Filings with PERMNO assigned | 8,079 (99.7%) |
|
| 66 |
-
| Filings with both vol labels | 7,695 (94.9%) |
|
| 67 |
-
| Date range (filing dates) | 2006-02-22 → 2026-03-02 |
|
| 68 |
-
| Unique SIC codes | 179 |
|
| 69 |
-
| Temporal split | Train ≤ 2024 · Val 2025 · Test 2026 |
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
#
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|-------|--------------------|--------------------|---------|
|
| 79 |
-
| Train | 2006 – 2024 | ~7,600 | Phase 2 DAPT MLM, Phase 3 contrastive FT, Phase 4 BERTopic |
|
| 80 |
-
| Val | 2025 | ~380 | Phase 2 perplexity checkpoint selection; Phase 3 FinMTEB intrinsic eval |
|
| 81 |
-
| Test | 2026 (YTD) | ~125 | Phase 5 downstream volatility forecasting (held-out, never seen during training) |
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
---
|
| 86 |
|
| 87 |
-
##
|
| 88 |
|
| 89 |
-
|
|
| 90 |
-
|-------
|
| 91 |
-
|
|
| 92 |
-
|
|
| 93 |
-
|
|
| 94 |
-
| `scripts/build_filings_index.py` | `sp500_union_constituents(1).csv`, EDGAR API | `filings_index.csv` | Filing dates + SIC codes |
|
| 95 |
-
| `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 |
|
| 96 |
-
| `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 |
|
| 97 |
-
| `scripts/sanity_check_vol(delete_later).py` | `volatility_labels.csv` | *(console)* | Vol label validation |
|
| 98 |
|
| 99 |
---
|
| 100 |
|
| 101 |
-
##
|
| 102 |
|
| 103 |
-
- **EDGAR data**
|
| 104 |
-
- **
|
| 105 |
-
-
|
| 106 |
-
- No personal data, human subjects, or proprietary datasets are used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
tags:
|
| 4 |
+
- finance
|
| 5 |
+
- nlp
|
| 6 |
+
- sec-filings
|
| 7 |
+
- item-1a
|
| 8 |
+
- volatility
|
| 9 |
+
- bert
|
| 10 |
+
- bertopic
|
| 11 |
+
pretty_name: Dissertation Phase 1 Dataset — Hybrid Financial Risk Modelling
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Dissertation Dataset — Phase 1 Data Pipeline
|
| 15 |
|
| 16 |
+
**Project:** Hybrid Topic and Domain-Adaptive Modelling for Financial Risk and Forecasting
|
| 17 |
+
**Institution:** University of Edinburgh, School of Informatics
|
| 18 |
+
**Supervisor:** Prof Tiejun Ma
|
| 19 |
|
| 20 |
+
> This is a **private** research dataset. All files are used exclusively within the scope of this dissertation project and must not be redistributed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
---
|
| 23 |
|
| 24 |
+
## What This Repo Contains
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
This dataset repo holds all Phase 1 pipeline outputs needed to run Phases 2–5 of the dissertation. It is the single source of truth for the cluster environment.
|
| 27 |
|
| 28 |
+
| File | Size | Description |
|
| 29 |
+
|------|------|-------------|
|
| 30 |
+
| `sp500_1A.tar.gz` | ~440 MB | Item 1A Risk Factor text corpus — 8,247 pickle files, one per `{TICKER}_{YEAR}`, covering S&P 500 firms 2006–2025. Each pickle is a plain string of the full Item 1A section. |
|
| 31 |
+
| `feature_table.parquet` | ~0.2 MB | Phase 1 master table — 8,105 rows, one per filing. Columns: `ticker, cik, permno, sic, fiscal_year, filing_date, report_date, lagged_vol_30d, fwd_vol_30d`. Placeholder columns for `embedding` (Phase 2) and `topic_vector` (Phase 4). |
|
| 32 |
+
| `filings_index.csv` | ~0.9 MB | EDGAR submissions API output — filing dates, SIC codes, and `has_pickle` flag for all 656 CIKs. 11,447 total 10-K filings (2006–2025). |
|
| 33 |
+
| `volatility_labels.csv` | ~0.7 MB | 30-day annualised volatility windows per filing. `lagged_vol_30d` = AR(1) baseline; `fwd_vol_30d` = prediction target. 94.9% coverage. |
|
| 34 |
+
| `permno_linkage.csv` | <0.1 MB | CIK → PERMNO mapping from WRDS CCM. 651/656 firms matched. |
|
| 35 |
+
| `sp500_union_constituents(1).csv` | <0.1 MB | S&P 500 universe — 656 unique CIK/ticker pairs (historical constituents). |
|
| 36 |
+
| `README.md` | — | This file. |
|
| 37 |
|
| 38 |
---
|
| 39 |
|
| 40 |
+
## How to Download on the Cluster
|
| 41 |
|
| 42 |
+
```bash
|
| 43 |
+
# One-time login
|
| 44 |
+
huggingface-cli login
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
# Download all files
|
| 47 |
+
huggingface-cli download SarthakVishnu/dissertation-dataset \
|
| 48 |
+
--repo-type dataset \
|
| 49 |
+
--local-dir ~/dissertation/datasets/
|
| 50 |
|
| 51 |
+
# Unzip the Item 1A corpus
|
| 52 |
+
cd ~/dissertation/datasets/
|
| 53 |
+
tar -xzf sp500_1A.tar.gz && rm sp500_1A.tar.gz
|
| 54 |
+
```
|
| 55 |
|
| 56 |
+
---
|
| 57 |
|
| 58 |
+
## How Each File Is Used Per Phase
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
| Phase | Files Used |
|
| 61 |
+
|-------|-----------|
|
| 62 |
+
| **Phase 2 — DAPT** | `sp500_1A/` (MLM pretraining corpus, train split ≤2024) |
|
| 63 |
+
| **Phase 3 — Contrastive FT** | `sp500_1A/` + `filings_index.csv` (SIC codes for sector-view positive pairs) |
|
| 64 |
+
| **Phase 4 — BERTopic** | `sp500_1A/` + `feature_table.parquet` (per-filing topic vectors) |
|
| 65 |
+
| **Phase 5 — Ablation** | `feature_table.parquet` + `volatility_labels.csv` (downstream vol forecasting) |
|
| 66 |
|
| 67 |
---
|
| 68 |
|
| 69 |
+
## Temporal Split
|
| 70 |
|
| 71 |
+
| Split | Criterion | Approx. Filings | Role |
|
| 72 |
+
|-------|-----------|-----------------|------|
|
| 73 |
+
| Train | `filing_date < 2025-01-01` | ~7,700 | DAPT, contrastive FT, BERTopic |
|
| 74 |
+
| Val | `2025-01-01 ≤ filing_date < 2026-01-01` | ~280 | Perplexity checkpointing, FinMTEB eval |
|
| 75 |
+
| Test | `filing_date ≥ 2026-01-01` | ~125 | Held-out volatility forecasting |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
---
|
| 78 |
|
| 79 |
+
## Licence & Ethics
|
| 80 |
|
| 81 |
+
- **Item 1A text** and **EDGAR-derived data** are from publicly available SEC filings.
|
| 82 |
+
- **WRDS/CRSP-derived data** (`permno_linkage.csv`, `volatility_labels.csv`, `feature_table.parquet`) is used under the University of Edinburgh's institutional licence and must not be redistributed externally.
|
| 83 |
+
- No personal data or human subjects are involved.
|
|
|