All projects

Hull Tactical Market Prediction with Temporal Attention

Custom Temporal Attention mechanism in PyTorch for market regime prediction, with a differentiable Sharpe Ratio Loss that optimizes directly for risk-adjusted returns.

Python
PyTorch
Temporal Attention
Time-Series
Quantitative Finance

Problem

Standard MSE-based training objectives for market prediction don't align with the actual goal of maximizing risk-adjusted returns.

Approach

Implement a custom Temporal Attention mechanism from scratch to capture non-linear market regimes, paired with a differentiable Sharpe Ratio Loss backpropagated end-to-end.

Architecture

Time-series input → custom Temporal Attention encoder → prediction head. Loss: differentiable Sharpe Ratio = mean(returns) / std(returns).

Results

15% improvement over MSE baselines in backtesting.

Lessons learned

Loss function design is the most impactful choice in financial ML — optimizing for what you actually care about (Sharpe ratio) beats optimizing a surrogate (MSE).