LSTM versus Transformers: A Practical Comparison of Deep Learning Models for Trading Financial Instruments

Daniel K. Ruiru, Nicolas Jouandeau, Dickson Odhiambo

2024

Abstract

Predicting stock prices is a difficult but important task of the financial market. Often two main methods are used to predict these prices; fundamental and technical analysis. These methods are not without their limitations which has led to the use of machine learning by analysts and investors as they try to gain an edge in the market. In this paper, a comparison is made between recurrent neural networks and the Transformer model in predicting five financial instruments; Gold, EURUSD, GBPUSD, S&P500 Index and CF Industries. This comparison starts with base models of LSTM, Bidirectional LSTM and Transformers. From the initial experiments, LSTM and Bidirectional LSTM have consistent results but with more trainable parameters. The Transformer model then has few trainable parameters but has inconsistent results. To try and gain an edge from their respective advantages, these models are combined. LSTM and Bidirectional LSTM are thus combined with the Transformer model in different variations and then trained on the same financial instruments. The best models are then trained on the larger datasets of the S&P500 index and CF Industries (1990-2024) and their results are used to make a simple trading agent whose profit and loss margin (P/L) is compared to the 2024 Q1 returns of the S&P500 index.

Download


Paper Citation


in Harvard Style

Ruiru D., Jouandeau N. and Odhiambo D. (2024). LSTM versus Transformers: A Practical Comparison of Deep Learning Models for Trading Financial Instruments. In Proceedings of the 16th International Joint Conference on Computational Intelligence - Volume 1: NCTA; ISBN 978-989-758-721-4, SciTePress, pages 543-549. DOI: 10.5220/0012981100003837


in Bibtex Style

@conference{ncta24,
author={Daniel K. Ruiru and Nicolas Jouandeau and Dickson Odhiambo},
title={LSTM versus Transformers: A Practical Comparison of Deep Learning Models for Trading Financial Instruments},
booktitle={Proceedings of the 16th International Joint Conference on Computational Intelligence - Volume 1: NCTA},
year={2024},
pages={543-549},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0012981100003837},
isbn={978-989-758-721-4},
}


in EndNote Style

TY - CONF

JO - Proceedings of the 16th International Joint Conference on Computational Intelligence - Volume 1: NCTA
TI - LSTM versus Transformers: A Practical Comparison of Deep Learning Models for Trading Financial Instruments
SN - 978-989-758-721-4
AU - Ruiru D.
AU - Jouandeau N.
AU - Odhiambo D.
PY - 2024
SP - 543
EP - 549
DO - 10.5220/0012981100003837
PB - SciTePress