Year
2025
Role
End-to-end — feature engineering, model, training pipeline
Stack
- PyTorch
- Transformer
- Time2Vec
- MACD
- RSI
- Bollinger Bands
- ATR
Financial machine learning
Quantitative Trading System
A quantitative trading system built from scratch in PyTorch — a Transformer classifying BUY/SELL/HOLD from technical indicators and Time2Vec embeddings over 3.4M training samples.
- A quantitative trading system built from scratch in PyTorch using a Transformer model to predict BUY/SELL/HOLD signals from financial indicators and historical trading data, with a processing pipeline of 3.4M training samples and 351K development samples.
- The system incorporates features such as log-volume, technical indicators (MACD, RSI, Bollinger Bands, ATR), and Time2Vec with two-step normalization.
- Achieved Validation Accuracy of 92.75% and Test Accuracy of 92.50%.

- Validation accuracy
- 92.75%
- Test accuracy
- 92.50%
- 0.25pt gap — no overfit
- Training samples
- 3.4M
- plus 351K dev
The problem
Framing a market as a classification problem is the first decision that matters, and most of the work is downstream of it. I framed each timestep as a three-way label — BUY / SELL / HOLD — over a window of price history and derived indicators, and built the whole pipeline in PyTorch rather than assembling it from a backtesting framework.
Features
Raw OHLCV is a poor input; the model spends capacity rediscovering transformations that are cheap to compute directly. The feature set:
- Log-volume rather than raw volume — volume is heavy-tailed to the point where the untransformed series lets a handful of days dominate every batch.
- Trend and momentum — MACD, RSI.
- Volatility — Bollinger Bands, ATR. These matter because the same absolute price move means something entirely different in a quiet regime than a violent one.
- Time2Vec for temporal encoding. A Transformer has no inherent notion of time ordering, and sinusoidal position encoding assumes fixed intervals. Time2Vec learns periodic and linear components of time directly, which suits a series where the meaningful periodicities are what the model should discover rather than what I should hardcode.
Normalisation runs in two steps, which is the detail that makes or breaks a financial time series: normalising across the whole series leaks future statistics into past windows, and the model learns to exploit information it would not have had.
Scale and result
3.4M training samples, 351K development samples. Final accuracy: 92.75% validation, 92.50% test.
The quarter-point gap between validation and test is the number I actually check. A model that memorises its way to a high validation score shows a large gap here; this one does not, which suggests the learned features generalise across the split rather than fitting the validation window.
An honest caveat
Classification accuracy is not profitability. A model can be right about direction most of the time and still lose money if it is wrong on the moves that carry the most magnitude, and this project measures the former, not the latter. Turning these signals into a strategy requires position sizing, transaction costs and slippage — none of which are in scope here. What the project demonstrates is the modelling pipeline, not a trading edge.