siddharthmb/stocks-ohlcv
Viewer • Updated • 26.7M • 394
How to use kyLELEng/patchtst-cross-sectional-return-forecast with Transformers:
# Load model directly
from transformers import AutoTokenizer, PatchTSTForPrediction
tokenizer = AutoTokenizer.from_pretrained("kyLELEng/patchtst-cross-sectional-return-forecast")
model = PatchTSTForPrediction.from_pretrained("kyLELEng/patchtst-cross-sectional-return-forecast")This model is a PatchTSTForPrediction model trained to forecast future cross-sectional stock return distributions.
siddharthmb/stocks-ohlcvohlcv.csvAAPL, MSFT, AMZN, GOOGL, NVDA, TSLA, AMD, INTC, ADBE, ORCL, CSCO, IBM, JPM, BAC, V, MA, AXP, JNJ, PG, KOPatchTSTConfig(
context_length=512,
prediction_length=64,
num_input_channels=20,
patch_length=16,
patch_stride=8,
d_model=128,
num_hidden_layers=4,
num_attention_heads=4,
distribution_output="student_t",
loss="nll",
scaling="std",
)
Student-t output is used because financial returns are heavy-tailed.
Validation:
{
"loss": 40.24222278594971,
"mae": 3.3909754753112793,
"mse": 15.027800559997559,
"directional_accuracy": 0.5080167271784233,
"flattened_ic": 0.002849485427271254,
"cross_sectional_ic": 0.008907554652154311,
"cross_sectional_rank_ic": 0.008295830343493587
}
Test:
{
"loss": 38.46169090270996,
"mae": 3.328381299972534,
"mse": 14.407476425170898,
"directional_accuracy": 0.534091938405797,
"flattened_ic": 0.00037866420310066716,
"cross_sectional_ic": 0.00456014569165105,
"cross_sectional_rank_ic": 0.009876399072214697
}
NLL/loss is the primary metric because this is a probabilistic forecasting model.
Research and experimentation with probabilistic multi-asset return forecasting. This is not a production trading system or investment advice.