A Prediction Based Model for Forex Markets Combining Genetic Algorithms and Neural Networks

A Prediction Based Model for Forex Markets Combining Genetic Algorithms and Neural Networks

A prediction based model for forex markets combining Genetic Algorithms and Neural Networks Rui Miguel Hungria Furtado Thesis to obtain the Master of Science Degree in Telecomunications and Computer Science Engineering Supervisor: Prof. Rui Fuentecilla Maia Ferreira Neves Examination Committee Chairperson: Prof. Ricardo Jorge Fernandes Chaves Supervisor: Prof. Rui Fuentecilla Maia Ferreira Neves Member of the Committee: Prof. Aleksandar Ilic October 2018 ii To my family and friends iii iv Acknowledgments First I would like to thank my supervisor, Prof. Rui Neves, who provided weekly support throughout the thesis development without being extremely strict about the path needed to achieve the established goals. He completely allowed thesis to be my own work, but guided me through the right direction whenever needed. Second, I want to thank my colleagues that gave me the strength and advises to finish this work. It was a pleasure to share with you this academic journey that now comes to an end. Finally I want to thank to my family and closer ones. Without your patience and unconditional support this thesis would not be possible. v vi Resumo Investir em mercados financeiros e´ sempre uma tarefa complexa e incerta. De modo a aumentar as pequenas possibilidades de obter uma rentabilidade que ultrapasse o ´ındice de mercado, os investidores recorrem a uma serie´ de tecnicas´ que tem como objetivo tentar determinar futuros pontos de entrada e sa´ıda do mercado. Esta tese propoe˜ um sistema de trading otimizado para o Foreign Exchange Market, normalmente con- hecido por FOREX. Para desempenhar tal tarefa e´ usada uma Feedforward Neural Network (FNN), que re- cebe como input um conjunto de indicadores tecnicos´ (TI) calculados a partir de dados historicos´ de mercados FOREX, com uma amostragem horaria.´ O sistema foi estruturado seguindo uma metodologia de Supervised Learning para criac¸ao˜ das target variables, convertendo retornos horarios´ em um sinal binario,´ transposto para um problema de classificac¸ao.˜ De modo a obter o melhor conjunto de parametrosˆ usados para gerar os indicadores tecnicos´ e os hiper-parametrosˆ da rede neuronal, foi desenvolvida uma Estrategia´ Evolutiva (ES), baseada num Algoritomo Genetico´ (GA), dado que fazer uma busca exaustiva usando pelo espac¸o de resul- tados iria conduzir a um tempo de espera demasiado grande. O Algoritomo Genetico´ providencia tambem´ um processo automatico´ de Feature Selection, de modo a seleccionar apenas as features mais relevantes. O sistema proposto foi testado com dados historicos´ de 5 diferentes mercados, de modo a serem tes- tadas diferentes condic¸oes˜ de investimento. As estrategias´ produzidas sao˜ posteriormente avaliadas contra estrategias´ de investimento classicas.´ Os resultados obtidos demonstram que esta abordagem e´ capaz de superar a estrategia´ Buy & Hold (B&H) no mercado GBP/USD, alcanc¸ando um resultado medio´ de 14,19% de retorno de investimento (ROI), contra 10,69 % de ROI para B&H. O sistema tambem´ superou a estrategia´ Sell& Hold (S&H) para o par USD/CHF, alcanc¸ando um resultado de 4,45% de ROI contra 4,09% para o S&H. E´ tambem´ discutido o uso de Batch Normalization como tecnica´ de pre-processamento´ durante o desenvolvi- mento de cada estrategia´ de mercado. Palavras-chave: Algoritmos Geneticos,´ Aprendizagem Profunda, Aprendizagem Automatica,´ Otimizac¸ao˜ de Funcionalidades, FOREX, Analise´ Tecnica´ vii viii Abstract Investing in financial markets is always a complex and difficult task. To raise the small chances of beating the market, investors usually rely on several techniques that attempt to determine the underlying trading signal, and hopefully predict future market entry and exit points. This thesis proposes a trading system optimized for the Foreign Exchange Market, widely known as FOREX. To perform such task, we use a Feedforward Neural Network (FNN), that take as input features a set of technical indicators (TI), calculated using FOREX hourly data. A supervised learning approach was considered to create the target variables, converting hourly returns into a binary trading signal, suitable for a classification problem. To get the best combination of parameters used to generate each TI and FNN hyper- parameters, we deployed an Evolutionary Strategy (ES) based on a Genetic Algorithm (GA), since making an exhaustive search through the entire feature space would be an unfeasible task. The GA also deploys an automatic Feature Selection (FS) mechanism that enables the FNN to use only relevant features for the given problem. The proposed system is tested with real hourly data from 5 different markets, each one exhibiting different behavior during the sampled time. The produced investment strategies are compared with classical trading strategies for the sake of comparision. The achieved results show that this approach is capable to outperform the Buy and Hold strategy (B&H) in the GBP/USD market, achieving an average result of 14.19% of Return of Investment (ROI), against 10.69% of ROI for B&H. The system also outperformed the Sell&Hold (S&H) strategy for the USD/CHF, achieving a result of 4.45% of ROI against 4.09% for S&H. Furthermore, it is also discussed the usage of Batch Normalization as preprocessement technique during the development of each market strategy. Keywords: Genetic Algorithms, Deep Learning, Machine Learning, Feature Optimization, FOREX, Technical Analysis ix x Contents Acknowledgments...............................................v Resumo..................................................... vii Abstract..................................................... ix List of Tables.................................................. xiii List of Figures................................................. xv Nomenclature.................................................. xvii Glossary....................................................1 1 Introduction 1 1.1 Motivation.................................................2 1.2 Main Contribuitions............................................2 1.3 Goals...................................................3 1.4 Document structure...........................................3 2 Background 5 2.1 Market trading..............................................5 2.1.1 FOREX market..........................................6 2.1.2 Financial data...........................................7 2.1.3 Technical Analysis........................................8 2.1.4 Trend following TI........................................9 2.1.5 Momentum oscillators...................................... 11 2.1.6 Volatility.............................................. 17 2.1.7 Other indicators......................................... 18 2.2 Machine Learning............................................ 19 2.2.1 Artificial Neural Networks.................................... 20 2.2.2 Genetic Algorithms........................................ 26 2.3 Related Work............................................... 30 2.3.1 Related works on Neural Networks............................... 30 2.3.2 Related works on Genetic Algorithms............................. 32 3 Implementation 35 3.1 Model overview.............................................. 35 3.2 User input................................................. 36 xi 3.2.1 Data................................................ 37 3.3 Feature calculation............................................ 38 3.4 Optimization............................................... 39 3.4.1 Population generation...................................... 40 3.4.2 Model creation.......................................... 41 3.4.3 Fitness computation....................................... 44 3.4.4 GA operators........................................... 44 3.5 Model prediction............................................. 45 3.6 Market simulation............................................. 47 4 Results 49 4.1 FOREX Data............................................... 49 4.1.1 Data statistics........................................... 51 4.2 Evaluation metrics............................................ 52 4.2.1 Classification metrics...................................... 52 4.2.2 Financial metrics......................................... 53 4.3 Experimental setup............................................ 54 4.4 Case study A - Simple prediction.................................... 55 4.4.1 Classification results....................................... 55 4.4.2 Market simulator......................................... 58 4.5 Case study B.1 - Accuracy as fitness function............................. 60 4.5.1 Classification results....................................... 60 4.5.2 Market Simulator......................................... 61 4.6 Case study B.2 - ROI as fitness function................................ 62 4.6.1 Classification results....................................... 62 4.6.2 Market Simulator......................................... 63 4.7 Case Study 3 - Further investigation on profitable markets...................... 64 4.7.1 Benchmark comparisons.................................... 65 4.7.2 USD/CHF............................................. 66 4.7.3 GBP/USD............................................. 68 4.7.4 GBP/USD without Batch Normalization............................ 69 4.7.5 Feature selection results..................................... 71 4.7.6 Fitness evolution......................................... 74 4.7.7 Topology evolution........................................ 76 5 Conclusions 81 5.1 Future Work...............................................

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    108 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us