CoolFace
Modelpublic

Yousafza1/financial-price-forecasting

sourceHugging Faceupdated 11d agoView on Hugging Face
0likes
Model Card

Multi-market price forecasting with PatchTST

Forecasts next-step (configurable horizon) log returns for crypto, forex, stocks and indices from free public data (yfinance + Binance/ccxt). Model: channel-independent PatchTST with RevIN, ~150–300K params — the top-tier architecture in a 918-experiment controlled benchmark on crypto/forex/index data (arXiv 2603.16886), and cheap enough for a T4.

Why these choices

  • —Target is log return, not price. Price targets break under cross-asset scale differences (BTC ~$100k vs EURUSD ~1.08) and the random walk. RevIN instance normalization inside the model handles the rest of the shift.
  • —Direction is measured, not promised. MSE-trained models score ~50% directional accuracy at short horizons in controlled studies; treat directional accuracy and the naive-strategy Sharpe as the honest metrics, with a binomial z-test against 50%.
  • —Leakage is guarded three ways: trailing-window feature statistics only, chronological 70/15/15 splits with pred_len purge rows at boundaries, and windows built strictly inside each split.

Pipeline

python download_data.py --out-dir data/raw --start 2017-01-01
python build_dataset.py --raw-dir data/raw --out-dir data/features --pred-len 1
python train_patchtst.py --data-dir data/features \
    --hub-model-id Yousafza1/patchtst-financial-daily
FileRole
download_data.pyDaily OHLCV: 8 Binance pairs (ccxt, paginated), 6 forex pairs, 10 stocks, 7 indices (yfinance, throttled + retried)
build_dataset.pyFeatures: logret, hilorange, vol20, volume_z (trailing-only stats) + split metadata
train_patchtst.pyPatchTST training, early stopping, test metrics, optional Hub push

Defaults: seq_len=96, pred_len=1, d_model=128, e_layers=3, n_heads=4, d_ff=256, patch_len=16, stride=8, Adam lr=1e-4, batch 128. These follow the reference configs in yuqinie98/PatchTST (pinned commit 204c21e, cloned automatically at train time).

Known biases and limits (read before trusting results)

  • —Survivorship bias: stock/index ticker lists are today's constituents; delisted names are absent.
  • —Crypto history starts at listing date (SOL/DOGE have no 2017 data).
  • —Forex has no volume — volume_z is 0 there; range and returns carry it.
  • —yfinance is unofficial and rate-limits; the downloader throttles and retries, but re-runs should expect occasional failures per ticker.
  • —Realistic expectation: near-zero-to-small edge. A ~52–55% directional accuracy with positive test Sharpe would already be a strong result.

Costed run plan (to execute when compute budget is granted)

From Jobs pricing:

StageHardwareEst. wall-clockEst. cost
Data download + build (30 markets, daily)cpu-basic ($0.01/h)~20–40 min~$0.01
Smoke train (same script/shape, ~50 steps)a10g-small ($1.00/h)~10 min~$0.02
Full train (~30 epochs, ~250K windows)a10g-small ($1.00/h)~2–3 h~$2–3
Chronos-2 zero-shot baseline (CPU)cpu-basic ($0.01/h)~30 min~$0.01

Each submission reserves its worst case (price × timeout) and settles to minutes actually used. A $5 budget covers the full pipeline with headroom; a $15 budget allows 3 seeds + a pred_len=5 variant.