Software companion

Wavelet-Based Short-Horizon Forecasting of BTCUSDT Returns

Overview

The pipeline is twelve callable stages, each a separate file, driven by one configuration struct. That structure is what makes the study’s comparison fair: the baselines and the neural models consume the same windows, the same normalizers and the same splits, and they are scored by the same evaluation code in the original return domain rather than in whatever space each model happened to train in.

The wavelet path is written defensively because its availability varies. The adapter prefers the toolbox dual-tree transform, falls back to a discrete wavelet decomposition, and falls back again to identity features, recording which path it took — and a configuration switch turns the fallbacks off entirely when a run must use the preferred transform or fail. That matters for a study whose headline is a comparison against wavelet features: a silent downgrade to identity features would have turned the result into an artifact of a missing toolbox.

The models are residual temporal convolutional networks, trained with repeated seeds and aggregated across them. The dual-branch variant encodes raw and wavelet features separately and fuses them, using a custom layer to split the concatenated feature vector back into its branches.

Implementation

Toolboxes
Deep Learning Toolbox for the neural stages, Wavelet Toolbox for the transforms, Parallel Computing Toolbox optionally for feature extraction and multi-seed training
Windows
A 256-bar lookback with forecast horizons of 30, 60 and 128 one-minute steps
Splits
Chronological 70/15/15 with a configurable buffer between blocks
Seeds
Three repeated seeds per model, aggregated into the test summary
Wavelet settings
Dual-tree preferred with a nearsym5_7 level-one filter; a four-level db4 decomposition as fallback; identity as the last resort, and a switch that forbids falling back at all
Models
Zero, last-value, mean and ridge-style multistep linear baselines, plus raw, wavelet and dual-branch residual temporal-convolutional networks
Metrics
MAE, RMSE, stepwise directional accuracy, cumulative directional accuracy and Pearson correlation, all in the return domain

Components

config/default_config.m, experiment_presets.m
The single configuration struct and the named presets, including the smoke preset
scripts/stage01–stage03
Loading and cleaning one-minute bars, computing log returns, and building chronological splits
scripts/stage04–stage05
Overlapping lookback and forecast windows, and the wavelet feature matrices
scripts/stage06–stage09
Baseline fitting and the raw, wavelet and dual-branch neural stages
scripts/stage10–stage12
Evaluation, figures, and the validation-based hyperparameter sweep
src/features/
The wavelet adapter with its preferred, fallback and identity paths
src/models/
The residual regressor trainer plus the custom forecast-regression and feature-slicing layers
src/normalization/
Normalizers fitted on the training split and applied unchanged downstream
src/evaluation/
Return-domain scoring and the across-seed aggregation
src/plotting/
Report styling, representative-example selection, figure export, and the figure source-data export
src/utils/create_run_context.m, create_report_bundle.m
Per-run output context and the report bundle assembled from it
src/io/download_binance_klines_csv.m
Optional direct download of the one-minute bar history

Stages

  1. stage01–02 Load and clean the one-minute CSV, deduplicate, sort, report missing minutes, and compute log returns.
  2. stage03 Build chronological train, validation and test splits with the configured buffer.
  3. stage04 Generate overlapping lookback and forecast windows for each horizon.
  4. stage05 Extract wavelet features, recording which transform path was used.
  5. stage06 Fit the four baselines.
  6. stage07–09 Train the raw, wavelet and dual-branch residual networks across seeds.
  7. stage10 Evaluate every model in the return domain and aggregate across seeds.
  8. stage11–12 Render figures and, optionally, run the validation-based hyperparameter sweep.

Reproducibility and validation

  • A deterministic fixture dataset drives an end-to-end smoke run, so the twelve stages can be exercised without the real bar history.
  • The wavelet adapter records the transform path it took, and require_preferred_method makes a fallback an error rather than a silent substitution.
  • All scoring happens in the original return domain, so a normalization choice cannot flatter one model relative to another.
  • Each run writes its own directory with a configuration snapshot, metrics tables, figures, model artifacts, metadata and the repository commit hash.
  • Figure source data is exported alongside every figure — the CSV exports behind the published figures come from this step, and are the data available on the research page.
  • 18 test files cover the stages individually plus end-to-end integration and the download wrapper.

Availability

The MATLAB sources are not publicly released, but this study is the one case where the numbers behind the figures are: the figure source-data exports the pipeline writes are published on the research page, together with a provenance manifest. The input series is one-minute bar history from a public exchange endpoint, and the repository includes the downloader for it.

Companion research

A controlled comparison of raw and wavelet features against matched linear and neural baselines for multi-step return forecasting.

Read the research report