Por favor, use este identificador para citar o enlazar este ítem: https://hdl.handle.net/11000/36224

Predicción de Movimientos en los Principales Índices Bursátiles mediante Random Forest


Vista previa

Ver/Abrir:
 TFG José Luis Ruiz Solivella.pdf

1,63 MB
Adobe PDF
Compartir:
Título :
Predicción de Movimientos en los Principales Índices Bursátiles mediante Random Forest
Autor :
Ruiz Solivella, José Luis
Tutor:
Sainz-Pardo Auñón, José Luis
Editor :
Universidad Miguel Hernández
Departamento:
Departamentos de la UMH::Estadística, Matemáticas e Informática
Fecha de publicación:
2024
URI :
https://hdl.handle.net/11000/36224
Resumen :
Este trabajo se centra en la aplicación de técnicas de aprendizaje automático, específicamente el modelo Random Forest, para predecir los movimientos intradías en tres índices bursátiles: IBEX 35, DAX 40 y S&P 500. El objetivo del modelo es determinar si la variación del precio de cierre de un día es positiva o negativa respecto al precio de apertura, creando una herramienta que pueda replicar decisiones de inversión en las aperturas diarias de los mercados. La metodología del estudio se fundamenta en el análisis técnico, construyendo un conjunto de variables predictoras basadas en indicadores ampliamente utilizados, como Bandas de Bollinger, MACD, RSI, ATR y medias móviles. Estas variables técnicas se calcularon utilizando datos históricos descargados de Yahoo Finance, abarcando el periodo de enero de 2023 a enero de 2025. Con el fin de optimizar la selección de variables predictoras, se utilizó la métrica “Mean Decrease Gini” para determinar que variables tienen mayor impacto en los modelos eliminando las variables que aporten menos información con el fin de mejorar los resultados sin comprometer la eficiencia del modelo. La base de datos resultante se separó en dos subconjuntos. El primero el de train que abarcaba de junio de 2023 hasta junio de 2024 y el segundo el de prueba o test que abarcaba de julio de 2024 hasta enero de 2025 y que es donde se replicaría lo aprendido en el modelo mediante el entrenamiento para comprobar su eficiencia. Los hiperparámetros número de árboles de decisión (Ntree) y número de predictores por nodo (Mtry) se ajustaron mediante la prueba de diferentes configuraciones obteniendo unos valores de 160 para Ntree en los tres modelos. Por la parte de Mtry, se repitió 10 tanto en el modelo del DAX como en el del S&P500 mientras que para el IBEX se seleccionaron 5. Los resultados obtenidos destacaron la eficiencia del modelo para predecir patrones alcistas de los índices siendo el mejor en líneas generales el DAX con una precisión 2 (Accurancy) del 57.69%. A destacar también en el IBEX35 su sensibilidad superior al 80%. Por su parte el modelo del S&P500 a pesar de no mostrarse tan eficiente como los otros dos sirvió como comparativo de estos. Tras la evaluación de resultados se decidió realizar una simulación para contemplar la ganancia real que hubieran tenido los modelos en el periodo de prueba. Esta simulación se basó en comprar al inicio de la jornada bursátil siempre que el modelo lo predijera contemplando la salida de la operación en el cierre del mismo día. El capital de entrada sería acumulativo ya que tanto si se pierde como si se gana se debe contar con esta variación en el capital de entrada del siguiente día. Los resultados de esta simulación confirmaron la eficiencia del modelo tanto para el índice del IBEX como para el del DAX, consolidando a su vez al modelo de Random Forest como una herramienta óptima para el análisis bursátil.
This work focuses on the application of machine learning techniques, specifically the Random Forest model, to predict intraday movements in three stock market indexes: IBEX 35, DAX 40 and S&P 500. The objective of the model is to determine whether the variation of the closing price of a day is positive or negative with respect to the opening price, creating a tool that can replicate investment decisions at daily market openings. The methodology of the study is based on technical analysis, building a set of predictor variables based on widely used indicators, such as Bollinger Bands, MACD, RSI, ATR and moving averages. These technical variables were calculated using historical data downloaded from Yahoo Finance, covering the period from January 2023 to January 2025. In order to optimize the selection of predictor variables, the Mean Decrease Gini metric was used to determine which variables have the greatest impact on the models by eliminating variables that provide less information in order to improve the results without compromising the efficiency of the model. The resulting database was separated into two subsets. The first was the training subset from June 2023 to June 2024 and the second was the test subset from July 2024 to January 3 2025, where the model's learning was replicated through training to check its efficiency. The hyperparameters number of decision trees (Ntree) and number of predictors per node (Mtry) were adjusted by testing different configurations, obtaining values of 160 for Ntree in the three models. For the Mtry part, 10 were repeated in both the DAX and S&P500 models while 5 were selected for the IBEX. The results obtained highlighted the efficiency of the model in predicting bullish patterns of the indices, the DAX being the best in general terms with an accuracy (Accurancy) of 57.69%. The IBEX35 also stood out for its sensitivity of over 80%. On the other hand, the S&P500 model, although not as efficient as the other two, served as a comparison. After the evaluation of results, it was decided to carry out a simulation to contemplate the real profit that the models would have made during the test period. This simulation was based on buying at the beginning of the trading day as long as the model predicted it, contemplating the exit of the operation at the close of the same day. The entry capital would be cumulative since both losses and gains should be taken into account in the next day's entry capital. The results of this simulation confirmed the efficiency of the model for both the IBEX and DAX indexes, consolidating the Random Forest model as an optimal tool for stock market analysis.
Palabras clave/Materias:
Predicción bursátil
Machine learning
Random forest
Inteligencia artificial en finanzas
Área de conocimiento :
CDU: Ciencias puras y naturales: Biología
Tipo de documento :
info:eu-repo/semantics/bachelorThesis
Derechos de acceso:
info:eu-repo/semantics/openAccess
Attribution-NonCommercial-NoDerivatives 4.0 Internacional
Aparece en las colecciones:
TFG - Estadística Empresarial



Creative Commons La licencia se describe como: Atribución-NonComercial-NoDerivada 4.0 Internacional.