# LOBench accepted-manuscript code Run commands **from this `code/` directory**. Download the public panel to the adjacent directory `../deidentified_50stock_panel/`. This snapshot contains the experiment implementations and configurations for the accepted IEEE Transactions on Big Data manuscript. Public configurations use `asset_NNN` identifiers and the existing NPZ files. The classification code maps labels `-1, 0, 1` to class indices `0, 1, 2` internally. ## Environment and checks Python 3.12 is recommended. Install dependencies in a virtual environment and select a PyTorch build appropriate for your GPU if needed: ```bash python -m pip install -r requirements.txt python -m unittest discover -s experiments/tbd_revision/tests -v python smoke_test.py ``` The validation environment is recorded in `environment-tested.json`. Results can vary with software versions and hardware. The smoke test checks execution on a small subset, not agreement with reported scores. ## Main 50-stock comparison ```bash python experiments/tbd_revision/scripts/train_representation_baselines.py \ --config experiments/tbd_revision/configs/final_revision_ashare50_adaptation_3seed.json ``` This runs the three main encoders (`timae`, `lobgrid_timae`, `simlob2026`), three seeds, and direct training, frozen probing, and full fine-tuning. Pooled pretraining uses the five-asset training set specified in the configuration. Validation selects checkpoints; test labels are not used for fitting. For one formal case, preserve the hyperparameters and restrict the case list: ```bash python experiments/tbd_revision/scripts/train_representation_baselines.py \ --config experiments/tbd_revision/configs/final_revision_ashare50_adaptation_3seed.json \ --stocks asset_001 --methods timae --seeds 2026 ``` Results and checkpoints are written under `experiments/tbd_revision/outputs/`. ## Reconstruction and imputation The reconstruction structural-weight experiment uses the original two configurations: ```bash python experiments/tbd_revision/scripts/run_representation_task_suite.py \ --config experiments/tbd_revision/configs/final_revision_ashare5_structural_tick_3seed.json python experiments/tbd_revision/scripts/run_representation_task_suite.py \ --config experiments/tbd_revision/configs/final_revision_lobgrid_structural_tick_3seed.json python experiments/tbd_revision/scripts/run_representation_task_suite.py \ --config experiments/tbd_revision/configs/final_revision_imputation_structural_3seed.json ``` Run the nine supplementary architecture adapters with: ```bash python experiments/tbd_revision/scripts/run_architecture_task_coverage.py \ --config experiments/tbd_revision/configs/final_revision_architecture_task_coverage.json ``` These are benchmark implementations under a shared task and decoder, not a claim to reproduce each original method's published score. ## Additional prediction and sensitivity experiments Use `train_representation_baselines.py --config` with these configurations: | Configuration | Experiment | |---|---| | `final_revision_ashare5_pooled_3seed.json` | Five-stock pooled pretraining | | `final_revision_ashare5_local_3seed.json` | Five-stock local pretraining | | `final_revision_ashare50_tlob_supervised_3seed.json` | Supervised TLOB-based reference | All runner paths below start with `experiments/tbd_revision/scripts/` and all configurations are under `experiments/tbd_revision/configs/`. ```bash python experiments/tbd_revision/scripts/run_absolute_prediction_baselines.py \ --config experiments/tbd_revision/configs/final_revision_ashare50_adaptation_3seed.json \ --results-dir experiments/tbd_revision/outputs/absolute_baselines python experiments/tbd_revision/scripts/run_hyperparameter_sensitivity.py \ --base-config experiments/tbd_revision/configs/final_revision_ashare5_hyperparameter_base.json \ --output-root experiments/tbd_revision/outputs/hyperparameters \ --variants baseline latent64 latent256 width64 width128 heads2 heads8 mask20 mask60 lr100 lr1000 batch64 batch256 wd0 wd1e4 python experiments/tbd_revision/scripts/run_label_threshold_retraining.py \ --base-config experiments/tbd_revision/configs/final_revision_label_threshold_retraining.json \ --output-root experiments/tbd_revision/outputs/label_threshold \ --variants threshold0001 threshold0005 threshold0010 ``` `profile_final_revision_complexity.py` measures parameter counts and timing. The `summarize_*.py` scripts aggregate generated case outputs. Consult each runner's `--help` for input and output paths, and compare runtime measurements only on equivalent hardware. ## Experiments requiring additional data **FI-2010:** obtain the official files and set the source paths in `final_revision_fi2010_decpre_train_only_data.json`. Run `experiments/tbd_revision/src/prepare_fi2010_official.py --config` with that file, then the common training runner with `final_revision_fi2010_decpre_train_only_local_3seed.json`. Preserve the normalization variant and chronological boundaries. **LOBSTER:** obtain source files under the provider's terms and set `raw_root` in `final_revision_lobster_corrected_natural.json`. Run `experiments/tbd_revision/src/prepare_nasdaq_lobster.py --config` with that file, then the common training runner with `final_revision_lobster_local_3seed.json`. **Five-stock training history:** the article compares seven versus 237 training dates with the same year-end holdout. The public January panel cannot substitute for those inputs. `prepare_training_duration_pilot.py` with `training_duration_pilot_data.json` prepares the two conditions when the authorized 2019 source data are available. The four `training_duration_{short10,full_year}{,_pooled}.json` configurations use the common trainer. The preparation example uses alias-based CSV filenames; the data custodian must map the authorized source files locally. **Raw-feed reconstruction:** `data_pipeline.py`, the external adapters, and the A-share preprocessing configuration describe the processing pipeline. The private source-to-alias mapping is not distributed. Reproduction from this repository begins with the processed tensors unless the relevant source data are supplied separately. ## Packaging changes - Replaced A-share identifiers with the existing public aliases and removed machine-specific input paths. - Pointed public A-share configurations to `../deidentified_50stock_panel/`. - Added loading of `natural_train_idx` when a public NPZ lacks legacy `train_idx`; legacy indices retain precedence. - Reused the manifest reader for architecture-coverage normalization, including scale validation. - Preserved relative trading-day groups when absolute timestamps are absent. - Added tests and a bounded CPU smoke check. Model equations, losses, and formal experiment hyperparameters were not changed. `RELEASE.json` and `checksums.sha256` identify this code snapshot. Publication details remain pending; use the repository's `CITATION.bib`.