Implementation of financial market regime identification models including traditional statistical approaches and deep learning methods (GRSTU), featuring a novel application of Temporal Fusion Transformers to regime classification.
The GRSTU model was introduced in the paper "A Dynamic Regime-Switching Model Using Gated Recurrent Straight-Through Units" by Nino Antulov-Fantulin, Alvaro Cauderan, and Petter N. Kolm (2024). The paper can be found on Portfolio Management Research.
We adapt Temporal Fusion Transformers from multi-horizon forecasting to regime identification by predicting future regime states across multiple time horizons and aggregating these predictions to classify current market regimes.
import numpy as np
import pandas as pd
from models.temporal_fusion_transformer import RegimeTFT
df = pd.read_csv('sp500.csv', parse_dates=['date'], index_col='date')
train_test_cutoff = np.datetime64('2003-01-02')
model = RegimeTFT(df['log_returns'], train_test_cutoff)
model.train()
predictions = model.predict()