Full text
i Forecasting Sovereign Bonds Markets Using Machine Learning Tiago Alexandre Rodrigues de Sousa Vieira Forecasting the Portuguese Government Bond Using Machine Learning Approach Dissertation presented as partial requirement for obtaining the Master’s degree in Statistics and Information Management
ii NOVAInformationManagementSchool InstitutoSuperiordeEstatísticaeGestãodeInformação UniversidadeNovadeLisboa FORECASTINGSOVEREIGNBONDSMARKETSUSING MACHINELEARNING ForecastingthePortugueseGovernmentBondUsing MachineLearningApproach by TiagoAlexandreRodriguesdeSousaVieira DissertationpresentedasthepartialrequirementforobtainingaMaster'sdegreeinStatisticsand InformationManagement,withaspecializationinRiskAnalysisandManagement Advisor:MauroCastelli October2020
iii ACKNOWLEDGEMENTS First of all, I would like to express my gratitude towards my masters tutor, Professor Mauro Castelli. I would have not been able to engage so deeply in this project without all the support provided by him. For all support, as well as the encouragement to move forward, I would like to thank my mother, father and brothers. I am extremely grateful to my girlfriend for all time and patience devoted to this dissertation. Your support in the final steps of this project was essential. Finally, I would like to thank my friends for saying I would not be able to finish this dissertation. Your reverse encouragement was the key. It took time, but as you can see, I made it.
iv ABSTRACT Financial markets, due to their non-linear, volatile and complex nature turn any type of forecasting into a difficult task, as the classical statistical methods are no longer adequate. Many factors exist that can influence the government bonds yields and how these bonds behave. The consequence of the behaviour of these bonds are extended over geographies and individuals. As the financial markets grow bigger, more investors are trying to develop systematic approaches that are intended to predict prices and movements. Machine Learning algorithms already proven their value in predicting and finding patterns in many subjects. When it comes to financial markets, Machine Learning is not a new tool. It is already widely used to predict behaviours and trends with some degree of success. This dissertation aims to study the application of two Machine Learning algorithms - Genetic Programming (GP) and Long Short-Term Memory (LSTM) - to the Portuguese Government 10Y Bond and try to forecast the yield with accuracy. The construction of the predictive models is based on historical information of the bond and on other important factors that influence its behaviour, extracted through the Bloomberg Portal. In order to analyse the quality of the two models, the results of each algorithm will be compared. An analysis will be presented regarding the quality of the results from both algorithms and the respective time cost. In the end, each model will be discussed and conclusions will be taken about which one can be the answer to the main question of this study, which is “What will the Yield of the Portuguese Government 10Y Bond be on T+1?”. The results obtained showed that Genetic Programming can create a model with higher accuracy. However, Long Short-Term Memory should not be ignored because it can also point to good results. Regarding execution time, velocity is a problem when it comes to Genetic Programming. This algorithm takes more time to execute compared to LSTM. Long Short-Term Memory is considerably quicker to get results. In order to take the right decision about which model to choose one must keep in mind the priorities. In case accuracy is the priority, Genetic Programming will be the answer. Nevertheless, when velocity is the priority Long Short-Term Memory should be the choice. KEYWORDS Portuguese Government Bonds; Machine Learning; Genetic Programming; Long-Short-Term Memory; Financial Markets
v INDEX 1. Introduction .................................................................................................................. 1 1.1. Forecasting Problem .............................................................................................. 2 1.2. Research Objectives .............................................................................................. 3 1.3. Dissertation Design ................................................................................................ 4 2. Literature Review ......................................................................................................... 6 3. Financial Markets and Machine Learing ....................................................................... 9 3.1. Financial Markets .................................................................................................. 9 3.1.1. Portuguese Government Bonds ..................................................................... 9 3.2. Machine Learning ................................................................................................ 10 3.2.1. Genetic Programming .................................................................................. 11 3.2.2. Long Short-Term Memory ............................................................................ 19 4. Experimental Study..................................................................................................... 22 4.1. Methodology ....................................................................................................... 22 4.1.1. Data Description ........................................................................................... 22 4.1.2. Data Transformation .................................................................................... 23 4.1.3. Fitness Measure of Models .......................................................................... 25 4.1.4. Software Methodology................................................................................. 26 4.2. Genetic Programming Experimental Settings ..................................................... 26 4.3. Long Short-Term Memory Experimental Settings ............................................... 27 5. Results and Discussion ................................................................................................ 29 5.1. Comparison between Algorithms ........................................................................ 33 6. Conclusion .................................................................................................................. 35 7. Limitations and Future Works .................................................................................... 37 8. Bibliography ................................................................................................................ 38 9. Appendix ..................................................................................................................... 4 4 9.1. Portuguese Government Debt ............................................................................ 44 9.2. Data Pre-Processing ............................................................................................. 46 9.3. Genetic Programming .......................................................................................... 57 9.3.1. Genetic Programming- Fitness Train Models Analysis ................................. 57 9.3.2. Genetic Programming- Fitness Test Models Analysis .................................. 61 9.3.3. Genetic Programming- Execution Time Analysis ......................................... 65 9.4. Long Short-Term Memory ................................................................................... 66 9.4.1. Long Short-Term Memory- Fitness Train Models ........................................ 66
vi 9.4.2. Long Short-Term Memory- Fitness Validation ............................................. 70 9.4.3. Long Short-Term Memory- Evolution by Model .......................................... 74 9.4.4. Long Short-Term Memory- Statistical Test .................................................. 77 9.5. Comparation between Models ............................................................................ 78
vii FIGURES INDEX Figure 1- Research Methodology and Desing ............................................................................ 5 Figure 2- Representation of Genetic Programming Flow ........................................................ 13 Figure 3- Representation of GP Tree: 5x+5 .............................................................................. 14 Figure 4-Representation of Crossover Operator ...................................................................... 16 Figure 5- Representation of Mutation Operator ..................................................................... 17 Figure 6-Representation of Long Short-Term Memory Algorithms Flow ................................ 21 Figure 7-Evolution of Fitness Test through Generations (average of all runs) of Genetic Programming Models ....................................................................................................... 29 Figure 8-Evolution of Fitness Train through Generations (average of all runs) of Genetic Programming Models ....................................................................................................... 29 Figure 9-Boxplot of Fitness Test of all models without outliers in Genetic Programming ...... 30 Figure 10- Boxplot of Fitness Train of all models without outliers in Genetic Programming .. 30 Figure 11-Evolution of Fitness Train through Epochs (average of all runs) of Long Short-Term Memory Models ............................................................................................................... 31 Figure 12- Evolution of Fitness Validation through Epochs (average of all runs) of Long Short- Term Memory Models...................................................................................................... 31 Figure 13- Boxplot to Evaluation of Fitness Train through Epochs (average of all runs) of Long Short-Term Memory Models............................................................................................ 32 Figure 14- Boxplot to Evaluation of Fitness Validation through Epochs (average of all runs) of Long Short-Term Memory Models ................................................................................... 32 Figure 15- Boxplot with Fitness Errors of Genetic Programming ............................................ 33 Figure 16- Boxplot with Fitness Errors of Long Short-Term Memory ...................................... 33 Figure 17- Chart of Portuguese Governmenet Outstanding Debt Amount (25 March 2020) . 44 Figure 18- Evolution of Yield of Portuguese Government Bond 10 Years (With #NA Data) ... 44 Figure 19- Evolution of Yield of Portuguese Government Bond 10 Years (With Interpolated Data) ................................................................................................................................. 45 Figure 20- Descriptive Analysis of Yield Variable ..................................................................... 46 Figure 21- Descriptive Analysis of Net Change Basis Point Variable ........................................ 46 Figure 22- Descriptive Analysis of Highest Yield of Day Variable ............................................. 47 Figure 23- Descriptive Analysis of Lowest Yield of Day Variable ............................................. 47 Figure 24- Descriptive Analysis of Spread Bund Variable ........................................................ 48 Figure 25- Descriptive Analysis Bund Yield Variable ................................................................ 48 Figure 26- Descriptive Analysis of Bund Future Variable ......................................................... 49 Figure 27- - Descriptive Analysis of Swap 10Y Variable ........................................................... 49
viii Figure 28- Descriptive Analysis of Eurostoxx 50 Variable ........................................................ 50 Figure 29- Descriptive Analysis of VIX Index Variable .............................................................. 50 Figure 30- Descriptive Analysis of CPI Germany Variable ........................................................ 51 Figure 31- Descriptive Analysis of GDP Growth Portugal Variable .......................................... 51 Figure 32- Augment Dickey-Fuller Test on Yield and Net Change Basis Point Variables ......... 52 Figure 33- Auto-Covariance Function of Yield Variable ........................................................... 53 Figure 34- Auto-Covariance Function of Net Change Basis Point Variable .............................. 53 Figure 35- Seasonality Test on Yield Variable .......................................................................... 54 Figure 36- Seasonality Test on Net Change Basis Point Variable ............................................. 54 Figure 37- QS Statistics on Yield Variable ................................................................................. 55 Figure 38- QS Statistics on Net Change Basis Point Variable ................................................... 55 Figure 39- Correlation Matrix of Original Dataset ................................................................... 56 Figure 40- Correlation Matrix of Modified Dataset ................................................................. 56 Figure 41- Evolution of Fitness Train through Generations (average of all runs) of Genetic Programming Models ....................................................................................................... 57 Figure 42- Outliers Analysis on Fitness Train of Model 1, Genetic Programming ................... 58 Figure 43- Outliers Analysis on Fitness Train of Model 2, Genetic Programming ................... 58 Figure 44- Outliers Analysis on Fitness Train of Model 3, Genetic Programming ................... 59 Figure 45- Outliers Analysis on Fitness Train of Model 4, Genetic Programming ................... 59 Figure 46- Boxplot with Fitness Train distribution of models (With Outliers), Genetic Programming .................................................................................................................... 60 Figure 47- Boxplot with Fitness Train distribution of models (Without Outliers), Genetic Programming .................................................................................................................... 60 Figure 48- Evolution of Fitness Test through Generations (average of all runs) of Genetic Programming Models ....................................................................................................... 61 Figure 49- Outliers Analysis on Fitness Test of Model 1, Genetic Programming ..................... 62 Figure 50- Outliers Analysis on Fitness Test of Model 2, Genetic Programming ..................... 62 Figure 51- Outliers Analysis on Fitness Test of Model 3, Genetic Programming ..................... 63 Figure 52- Outliers Analysis on Fitness Test of Model 4, Genetic Programming ..................... 63 Figure 53- Boxplot with Fitness Test distribution of models (With Outliers), Genetic Programming .................................................................................................................... 64 Figure 54- Boxplot with Fitness Test distribution of models (Without Outliers), Genetic Programming .................................................................................................................... 64 Figure 55- Evolution of Execution Time through Generations (average of all runs) of Genetic Programming Models ....................................................................................................... 65
ix Figure 56- Evolution of Fitness Train through Epochs (average of all runs) of Long Short-Term Memory Models ............................................................................................................... 66 Figure 57- Outliers Analysis on Fitness Train of Model 1, Long Short-Term Memory ............. 67 Figure 58- Outliers Analysis on Fitness Train of Model 2, Long Short-Term Memory ............. 67 Figure 59- Outliers Analysis on Fitness Train of Model 3, Long Short-Term Memory ............. 68 Figure 60- Outliers Analysis on Fitness Train of Model 4, Long Short-Term Memory ............. 68 Figure 61- Outliers Analysis on Fitness Train of Model 5, Long Short-Term Memory ............. 69 Figure 62- Boxplot with Fitness Train distribution of models, Long Short-Term Memory ...... 69 Figure 63- Evolution of Fitness Validation through Epochs (average of all runs) of Long Short- Term Memory Models...................................................................................................... 70 Figure 64- Outliers Analysis on Fitness Validation of Model 1, Long Short-Term Memory .... 71 Figure 65- Outliers Analysis on Fitness Validation of Model 2, Long Short-Term Memory .... 71 Figure 66- Outliers Analysis on Fitness Validation of Model 3 Long Short-Term Memory ..... 72 Figure 67- Outliers Analysis on Fitness Validation of Model 4, Long Short-Term Memory .... 72 Figure 68- Outliers Analysis on Fitness Validation of Model 5, Long Short-Term Memory .... 73 Figure 69- Boxplot with Fitness Validation distribution of models, Long Short-Term Memory .......................................................................................................................................... 73 Figure 70- Evolution of Fitness Error in Model 1, Long Short-Term Memory ......................... 74 Figure 71- Evolution of Fitness Error in Model 2, Long Short-Term Memory ......................... 74 Figure 72- Evolution of Fitness Error in Model 3, Long Short-Term Memory ......................... 75 Figure 73- Evolution of Fitness Error in Model 4, Long Short-Term Memory ......................... 75 Figure 74- Evolution of Fitness Error in Model 5, Long Short-Term Memory ......................... 76 Figure 75- Boxplot with Fitness Erros of Genetic Programming .............................................. 78 Figure 76- Boxplot with Fitness Erros of Long Short-Term Memory ....................................... 78
4 In the past few years Portuguese Government Bonds yields suffered an enormous instability. The PGB 1.95% 15/06/2029 (the benchmark on 2019 to 10y of Portugal) went from 1.8% yield to 0.4% only in the past year. This instability has a long history in the last decade. After the 2012 crisis a lot of movements and trends happened and not all of them were discovered and/or analysed. Taking advantage of Machine Learning, this study aims to find more movements/trends in that period that were not already discovered. 1.3. DISSERTATION DESIGN Considering the goal of this study, the methodology will be data driven. This methodology will be divided in 5 stages: defining the problem (phase 1), developing an approach to the problem (phase 2), formulating a research design (phase 3), collecting/preparing/analysing data (phase 4) and preparing/presenting the report (phase 5). In phase 1, the problem is defined based on a real problem observed in financial markets. Looking at financial markets in Portugal the question “What will the yield of the Portuguese government 10Y Bond be on T+1?” is one of the most important questions to many players that play an important role every day. Phase 2 consists of defining the first steps of the study, considering the main goal. In order to answer the question (problem) defined in the last phase, Machine Learning algorithms are used to predict the yield of the bond. The two algorithms chosen were Genetic Programming and Long Short-Term Memory. Four hypotheses were defined Overall, GP models perform best in forecasting and have the best cost/benefit relationship; Overall, GP models perform best in forecasting but don’t have the best cost/benefit relationship; Overall, LSTM models perform best in forecasting and have the best cost/benefit relationship; Overall, LSTM models perform best in forecasting but don’t have the best cost/benefit relationship; The main problem of this study and the tools chosen to get the best answer result in more secondary questions, such as: Is it possible to forecast the precise yield of a bond? How accurate can this forecast be? What are the costs in terms of time and resources of this forecast? Can algorithms forecast the direction of the yield movement? In phase 3 the exploratory study starts, and the key variables and size of the sample are defined. It is on this phase that the structure of the equation to introduce in the models is defined, as well as all variables to collect from the sample.
5 Phase 4 is the main phase. The data is collected (from Bloomberg) and pre-processed to input to the algorithms. The data is split in training and test sets. To configure and apply these algorithms a one code library accessible online is used (for Genetic Semantic Genetic Programming) and a script is written in order to apply LSTM. Concerning the Genetic Programming approach, more specifically Geometric Semantic Genetic Programming (GSGP) the implementation used is freely accessible at http://gsgp.sourceforge.net, a script created and documented by Castelli and Vanneschi [18]. In phase 5 is the evaluation of the results of each algorithm regarding the goals and questions defined. To compare the models derived from both algorithms the Mean Absolute Error is used as measure of the error in both models. In the last phase, all information is summarized in a written report and presented to the public. The scheme bellow, figure 1, represents the research methodology and design adopted, as explained in the paragraphs above. Figure 1- Research Methodology and Desing
6 2. LITERATURE REVIEW There is a great amount of literature about forecasting financial markets and it includes a lot of different approaches, from sophisticated Machine Learning algorithms to classical statistical models. During the writing of this dissertation different studies were read and analysed in order to understand which approaches should be followed and in which context should they be used. Different markets, products and resources demand different models. Many of the most popular classical statistical models currently used by academic researchers have been mostly used to explain the behaviour of term structure interest rates. A partial listing of these interest rate models includes: Merton [18], Vasicek [20] or Cox, Ingersoll, and Ross [21]. Regarding all these models, modelling and forecasting the term structure of interest rates is by no means an easy endeavour. Long and short maturities are known to react quite differently to shocks hitting the economy. One of the most widely used statistical models for fitting the term structure of interest rates is Nelson’s Siegel Model [22]. This model is extensively used by central banks and monetary policy makers [23] [24] Fixed-income portfolio managers use the model to understand how to immunize their portfolios [25] [26]. In academic research, one example of the application of this model is to describe the spot rate curves of Deutsche Mark denominated bonds, in order to calculate the risk structure of interest rates [27]. Fabozzi, Martellini, and Priaulet [28] and Diebold and Li [29] compared this model against others for forecasting the term structure of interest rates and found it performs well, especially for longer forecast horizons. In 2007 Pooter [30] set up a showdown between the random walk, the original Nelson’s Siegel model (with and without macro factors) and the no arbitrage models (with and without macro factors). Interestingly, the authors of this last study mentioned that the predictive ability of individual models varies considerably over time with a prime example being the Nelson and Siegel. In this study it was found that models that incorporate macroeconomic variables seem more accurate in periods during which the uncertainty about the future path of interest rates is substantial. Whereas modelling interest rates movements over time is already an arduous task, accurately forecasting future rates is an equally difficult challenge. Regarding the Machine Learning approach, the suitability of this methodology for predictive analysis makes it particularly attractive for financial forecasting in the context of returns predictability, market movements and risk premia measurement [31]. Throughout the years, Machine Learning methodologies have helped to improve the empirical understanding of different asset prices, from forecasting or modelling term structures interest rates and stock market prices to currency exchange rates. When it comes to forecasting currency exchange rates, many approaches and algorithms were used by different researchers. All of them tried to achieve an efficient model that is able to provide a reliable prediction regarding the rate [32] [33]. Most of these studies prove that Machine Learning can be a valuable tool for this task, but further work will be necessary in order to achieve a reliable model. Due to its profitability and easiness of penetration, the stock market has been one of the most explored financial fields when it comes to Machine Learning. Algorithms such as Artificial Neural Networks were widely used for stock market prices prediction in many contexts. Dase R.K. and Pawar
7 D.D. [34] provide a review of the extended literature presented about the use of it along the last years. In this article we can observe how extensive the application can be for this type of tool. The most successful trading model in stock markets should be the most profitable one. Throughout the years, several reliable models were created by researchers and companies, demonstrating that, whether in bull or bear market, the models significantly outperform [35] [36]. So far, at this moment, it is possible to find a study or even a model for every regulated stock market and most of them show good results, meaning once again that Machine Learning can be a powerful help for forecasting asset prices but can also provide tools to create models that help in predicting financial crisis. A financial crisis can emerge from a series of local and/or regional market shocks and can evolve posteriori into a global financial crisis due to the interconnectedness of the financial markets. In order to prevent this type of events, or at least minimize their effects, this method can be again a way to find patterns and anticipate them [37]. Despite major advances in the term structure of interest rates modelling in the last years, little attention has been paid to the key practical problem of forecasting the yield curve. Interest rate point forecasting is crucial for bond portfolio management, and interest rate density forecasting is important for both derivatives pricing and risk management. Predicting a term structure is one of the most complex tasks in financial markets, due to the complexity of the underlying variables. Alongside with this complexity, the difficulty to join this market makes this field one of the most unexplored in financial markets. Despite all these, some Machine Learning algorithms were already studied in this context, such as Neural Networks [38][39] and the Gaussian Process [40]. Regardless the algorithm, the results of using Machine Learning for this task are quite satisfactory, turning it into a better choice for the medium- and long-term structures associated with the yield curve. With all the research done until the present moment, it is possible to understand that Machine Learning can be a respectable instrument that can allow the better understanding of all relationships between underlying variables and the forecast of behaviour of term structures of interest rates. All this knowledge will allow the stakeholders of financial markets to have a better perspective of the market and to take all necessary actions to manage their portfolios. Genetic Programming is not a completely new theme. The origins of GP go back at least to the 1950s and since then it has been the theme of a lot of research papers. One of the first descriptions was made by Koza (1992) – “Genetic Programming is a problem-solving approach in which computer programs evolve producing new individuals, based on Darwinian principle, changing the syntax of the parents without taking into account the semantics of the individuals, in order to solve a problem”. One of the most important insights in Genetic Programming was Genetic Semantic [41]. This new perspective provides new insights on the relation between program syntax and semantics, search operators, fitness landscape and allows for principled formal design of semantic search operators for different classes of problems. This new methodology in GP has a strong limitation of producing offsprings that are larger than their parents, creating programs with massive size. To overcome this limitation, Vanneschi, Castelli and Silva [43] introduced a new implementation, making it possible to use these operators in an efficient and useful way. This new approach was explored, and the applications were presented in four real life problems related to the electricity field and pharmacokinetics [44]. This study demonstrates that Genetic Semantic - Genetic Programming (GSGP) performs better than Standard Genetic Programming (in training data and test data) and with these new operators, GS-GP can be applied in many new problems. Throughout the years Genetic Programming has been applied in many problems regarding financial markets. The most common
8 one is forecasting prices of stocks [45] [46] [47] [48]. The good results show that GP can be a powerful instrument for forecasting prices. In Portugal, Genetic Programming was applied in the stock market context, in order to forecast the PSI-20 Index [15]. Long Short-Term Memory has been around since 1997 [49] but it only became popular recently because of the evolutions on Machine Learning and of the availability of programming interfaces that can handle this algorithm. The main advantage of Long Short-Term Memory is its ability to learn context-specific temporal dependence. Each unit remembers information for either a long or a short period of time without explicitly using an activation function within the recurrent components. In the last few years, Long Short-Term Memory became one of the most used algorithms in financial markets. Stock markets have been the choice par excellence to be the example of performance in forecasting using LSTM [50] [51]. When it comes to the Portuguese market, the literature is not as extensive as it is in other markets. Most of the literature concerns forecasting the stock market and its volatility using statistical models [52] [53] Despite the reduced literature, there are already some studies that apply Machine Learning to forecasting stock prices using different algorithms such as Genetic Programming [15] or Neural Networks [54]. Concerning the bonds market, it is still a very unexplored field in Portugal, and I could not find any study where a Machine Learning approach for sovereign bond yield prediction was used.
9 3. FINANCIAL MARKETS AND MACHINE LEARING 3.1. FINANCIAL MARKETS In a simple way, a bond is a contract that commits the issuer to make a predefined sequence of payments to investor until a specified terminal date. This fixed income instrument represents a loan made by an investor to a government or corporate. It can be characterized by different amounts, maturities, guarantees and coupons. Bond details include the maturity date (when the principal of the loan is due to be paid to the bond owner) and usually include the terms for variable or fixed interest payments made by the borrower, designed by coupons. The credit rating agencies (like Standard & Poor’s, Moody’s, and Fitch Ratings) can classify these bonds through the credit quality (risk) of the issuer and the guarantees of the bond. The market prices of bonds are based on their characteristics and they can be quoted by price or yield. The bond yield can be defined as the return investors realize on a bond. The yield is a function of the bond's price and its coupon. An inverse relationship occurs between yields and bond prices. When interest rates rise and exceed the coupon rate of a bond, the price of the bond decreases. The opposite happens when interest rates falls. The length of time to maturity defines the magnitude of impact in yield and price of the bond. The longer the maturity, the more volatile the fluctuations in price will be. For a basis point change in a bond yield, the magnitude of the respective change in the bond price will be greater for bonds with longer maturities. New issues of bonds are sold in the primary market, whereby the issuer of the bonds receives the incomes through the selling intermediary – the investment banker. Investors who have acquired bonds could sell them any time before maturity through the secondary markets. In other words, the buying and selling of widely traded bonds takes place in the secondary markets. These markets are important because they provide liquidity to the products, which also determines their prices. The bond markets do not work exactly like stock market, as there are some distinguishing differences. One distinctive characteristic is that bonds are low-risk assets. In some circumstances the risks can even be ignored. The Internet has provided accessibility to online secondary stock market, allowing trading to individual investors. However, the advent of online bond trading is much slower and not as widespread for various reasons. 3.1.1. Portuguese Government Bonds Portuguese Government Bonds represent a total debt of €145.496 million, with twenty-two bonds issued [11]. In a total of fifteen fixed rate bonds with maturities between one year and thirty. When it comes to short-term, a total of five treasury bills exist with maturities lower than one year. The placement of fixed income bonds in the primary market is ensured by a group of financial institutions to which IGCP has granted the status of Primary Dealers (OEVT) or Other Auction Participants (OMP). The status of OEVT and OMP is granted on the basis of an assessment of the capability of the financial institutions to consistently place and trade Portuguese Government debt instruments in
10 international, European or domestic markets, ensuring the access to a regular investor base and contributing to the liquidity of these instruments in the secondary market. In the secondary market, Portuguese Government Bonds are sold through nineteen primary dealers, which include some of the largest investment banks (Goldman Sachs International Bank, J.P. Morgan Securities) and largest banks in the world (Barclays Bank, Banco Santander). Primary Dealers (OEVT) are considered financial intermediaries for their capacity to place bonds and to ensure liquidity in the secondary market of these securities. Dealers quote bid and offer prices for these bonds in an Interdealer platform - MTS Portugal (reference market for public Portuguese debt market makers). 3.2. MACHINE LEARNING There is no consensus for a formal and worldwide definition of Machine Learning. Nevertheless, it can be described as a computational field that strives to create computer programs that repeatedly improve with their own experiences on data. The main concern of this field is to identify patterns in the data and to use these patterns to make predictions about unseen data or about the future. Machine Learning involves many other scientific fields, such as: mathematics, statistics, econometrics, probability, artificial intelligence, computational complexity theory, information theory, philosophy, neurobiology, and others. One of most consensual definitions of Machine Learning was written by Tom Mitchel: “A computer program is said to learn from an experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E.” [55]. Machine Learning can be described as the search for a “very large space of possible hypotheses to determine one that best fits the observed data and any prior knowledge held by the learner” [56]. The main result is the capability of the model to predict precisely when presented with new data. When a model is created, it is presented to the training data and it learns some rules based on that specific data. The main outcome of Machine Learning is the capability of the model to predict precisely, based on rules learned from previously seen data, when presented to new data. Machine Learning is simply an attempt to answer questions such as "How does learning performance vary with the number of training examples presented?" and "Which learning algorithms are most appropriate for various types of learning tasks?". The use of Machine Learning for predicting time-series, specifically in financial markets, has been successful so far. Nowadays, researchers and companies are trying to develop intelligent algorithms that can capture the hidden patterns inherent to financial markets in order to predict their behaviour more efficiently. In general, the most widespread approaches used by researchers can be divided in two: Statistical and econometrical like Linear Regression (LR), Autoregression Moving Average and ARIMA models. Nevertheless, these approaches involve many assumptions that are nonrealistic when it comes to financial markets.
11 Predictive models for forecasting market prices based on Machine Learning algorithms such as Artificial Neural Networks (ANN), Support Vector Machines (SVM), Genetic Programming (GP) and Long Short-Term Memory (LSTM). 3.2.1. Genetic Programming Genetic Programming (GP) uses the principles of the Darwinian evolution and evolutionary computation. This Machine Learning algorithm starts by building a possible solution arranged in a chromosome-like structure and applies data recombination operators to this structure in order to maintain important information. Genetic Programming is often used to learn and discover both the contents and structures of solutions. One of the most consensual definitions of Genetic Programming was given by Koza [7]: “Genetic Programming is a domain-independent problem-solving approach in which computer programs are evolved to solve, or approximately solve, problems. Genetic Programming is based on the Darwinian principle of reproduction and survival of the fittest and analogues of naturally occurring genetic operations such as Crossover (sexual recombination) and Mutation”. In the next paragraph each phase of the process involved in Genetic Programming is explained. In order to run a Genetic Algorithm four steps are necessary: 1. Representation space: In order to create a hypothesis space where the algorithm can be initiated, an initial population of random trees (programs) is generated. A randomly generated tree can be of any size. In practice, Koza [41] defines restrictions to maximum size of the initially generated trees. 2. Fitness Function: The fitness function can be defined as the measure of performance. It helps to quantify how accurate a candidate solution is. The function is the instrument that defines in Genetic Programming which candidate solutions or regions of the search space are adequate. 3. Parameters: When a Genetic Program is developed it is necessary to control some parameters, as they can affect how the program evolves and, consequently, its performance. Those parameters are: x Population Size: The value for this parameter depends on the complexity of the problem. However, generally, GP performs better on large populations. x Number of Generations: This parameter indicates the maximum number of generations created by the algorithm. x Probabilities of performing the genetic operators: There are two genetic operators: Mutation and Crossover. Traditionally, Crossover is applied more often, usually 90% of probability. Mutation is applied with much less significant probabilityaround 5%. x Selection Method: In this parameter defines how which individual genomes are chosen from a population for future breeding. The most common selection method is tournament selection. When using this method, the tournament size must also be specified.
12 x Population Initialization: To generate the initial population it is possible to use three methods - full method, growth method or ramped half-half. This last method is commonly used because it provides a more diverse initial population. 4. Termination Criterion: The termination criterion controls when the program stops. There are three kinds of termination conditions have been usually employed for Genetic Programming: x An upper limit on the number of generations is reached; x An upper limit on the number of evaluations of the fitness function is reached; x The chance of achieving significant changes in the next generations is excessively low; How Genetic Programming flows: [58] 1. Start with a randomly generated population, a set of possible candidate solutions to the problem. 2. Calculate the fitness measure (ƒ(x)) of each individual in the population. 3. Repeat the following steps until the maximum number of generations is reached: a. Randomly select a pair of individuals from the current population. These individuals will be considered the parents for the Crossover operation. Selection is done "with replacement," meaning that the same individual can be selected more than once to become a parent. b. With probability CR (Crossover Rate), Crossover the pair at a randomly chosen point (chosen with uniform probability) to form two descendants. If no Crossover takes place, form two descendants that are exact copies of their respective parents. 4. According to a probability MR (Mutation rate), mutate the two descendants at each locus and place the resulting individuals in the new population. 5. Replace the current population with the newly generated population. 6. Go to step 2.
13 3.2.1.1. Representation of Individuals Instead of the traditional lines of code, in Genetic Programming the programs are typically represented by syntax trees. The leaves of the tree represent the variables and constants in the program and these are called terminals. At the same time, the arithmetic operations (+, * and max) are internal nodes called functions. The group of acceptable functions and terminals creates the primitive set of Genetic Programming. The primitive set is what defines the search space, where we can find all the individuals that can be generated by the combination of primitives in all possible ways. Genetic Programming initiates with the selection of an initial population, randomly generated and defined by functions and terminals that are appropriate to the problem field. Therefore, when this algorithm starts, it must make a deduction about a rational set of functions and terminals for the problem. The idea behind this is to evolve programs that are hard to write and about which no one knows ahead of time exactly which functions and terminals will be required. The idea behind the creation of this initial population is to create a blind random search. The Terminal can involve constants, input variables and/or functions with no arguments. Depending on the problem, the computer program may be boolean-valued, integer-valued, real-valued, complex-valued, vector-valued, symbolic-valued, or multiple-valued. The Function Set, represented by the internal nodes of the trees, consists of standard arithmetic operations, standard programming operations, standard mathematical functions, logical functions, or domain-specific functions. In simple mathematical problems the arithmetic functions can be the simple operators (+,-,*,/). All elements in the function and terminal sets are defined by several arguments, which are called Arity. In order to apply Genetic Programming, the primitive set requires two proprieties. The possibility to produce solutions with the elements available - a property called sufficiency. Another important property is to ensure that the function set is well defined regarding all probable combinations of Figure 2- Representation of Genetic Programming Flow
20 LSTMs contain external information from the usual flow of the recurrent network in is gated cell. The information on this cell can be stored. The decision about what to store is taken by the cells themselves, which also decide when reads, writes and erasures are allowed via gateways that open and close. These gateways are like neural network nodes, deciding if the information is blocked or whether it passes, based on strength and importance which they filter with their own sets of weights. Those weights, like the weights that modulate input and hidden states, are adjusted via the recurrent networks learning process. That is, the cells learn when to allow data to enter, leave or be deleted through the iterative process of making deductions, backpropagating error, and adjusting weights via gradient descent. [60] Long Short-Term Memory Step-by-Step: [62] 1. To initiate the algorithm, it is necessary to decide which information is going to be passed to the cell state. The decision is taken by the sigmoid layer designated by “Forget Gate Layer”, it looks at and (as shown in figure 6 below). The outputs are numbers between 0 and 1 to each cell state . Here, the numbers close to one (or even one) mean that all corresponding information must be kept. Numbers close to zero (or even zero) represent unnecessary information that must be thrown out. 2. Regarding new information, it is necessary to understand which one are going to be store in cell state. This process has two stages: a. First, a sigmoid layer called the “input gate layer” chooses which values going to be update. b. Second phase is the creation of a vector, by a Tanh Layer, with new candidates values , that should be added to the state. 3. After the two steps above is combining the information that results from those and create an update to the state. 4. With the step above the old cell state its necessary updated the cell state into a new cell state (from previous one ). 5. The output of the flow is based on information of cell state, just need to be filtered: a. Its necessary run a sigmoid layer which will decide what information going to be the output. b. After that, put the cell state through Tanh Layer (to press the values to be in the interval of minus one and one) and multiply it by the output of the sigmoid gate. Those are the parts that going to be the output.
21 Figure 6-Representation of Long Short-Term Memory Algorithms Flow
22 4. EXPERIMENTAL STUDY 4.1. METHODOLOGY 4.1.1. Data Description The 10-year Portugal Government Bonds is one of the fixed maturity securities for which the bond market calculates a daily yield. This tenor is considered by all participants in financial markets as benchmark to sovereign bonds. In order to have an image of the future yield curve for Portugal, this tenor will be used. Despite not being available every day, it is possible to calculate a theoretic yield of a bond with a constant maturity in the 10-year benchmark by interpolating the daily term structure of interest rates. When it comes to the dataset used, each record (instance) represents data from a single week. The objective is to predict the bond yield at the next day (t + 1) considering a set of variables (reported in table 2) related to the bond yield. In this analysis the period between the 1st of January of 2005 and the 31st of March of 2020 was considered, resulting in a total of 5569 daily observations of historical daily data. This interval of time allows for the consideration of data from important periods, with high volatility, like the Financial Crisis of 2008, European Sovereign Debt Crisis and more recently the effect of the Covid-19 virus on Portuguese economy. The raw data used in the present study was extracted from a Bloomberg Terminal. Unfortunately, in some periods from 2005 and 2006 Bloomberg does not have data regarding the yield of 10Y Portugal benchmark. Due to this lack of information, linear interpolation was applied to Table 2- Description of Variables on dataset
23 fill in those periods (on figures 18-19 one can see the evolution of this variable with and without interpolation). 4.1.2. Data Transformation Understanding the dataset is an essential step to initiate the study. Studying the structure of variables and their behaviour through exploratory analysis is relevant in order to look for interesting and uncommon patterns in data. In order to begin this exploratory analysis some descriptive statistics were computed (see table 11 in appendix 9.2) for each variable (mean, standard deviation, minimum, maximum and quarters (1,2,3)). Descriptive statistics allow for the presentation of the raw data in a meaningful way, which results in a simpler interpretation of the data. After analysing the statistics resultant from the table mentioned above, one can see that there are most likely some outliers in many variables. For a start, Spread_Bund has an average of 257,52, whilst the standard deviation is 265,06. This may indicate the presence of dissonant values, that are confirmed by an analysis of the maximum value against the third quarter – 1481,5 versus 345,0. The same happens in variables Highest_Yield_of_Day, Lowest_Yield_of_Day, Bund_Yield, among others. Further analysis were made resorting to visual tools. Visualization plays an important role in time series analysis and forecasting. Since the present study concerns a time series, it was important to visualize the distribution and evolution of variables (independent and dependent) along the period. In appendix 9.2 one can find the charts with this analysis for each variable. (see figure 20-31) In the same analysis, the distribution of observations, with and without outliers was computed and designed. The objective of finding outliers is to investigate data objects which are different from or inconsistent with the majority of data. However, in bond market data, outliers are highly intermixed with regular data and it is difficult to judge whether an object is an outlier or not. One of the most common problems in time series analysis is stationarity. Without an uniform definition that can be unambiguously applied to finite time series, the question of stationarity is victim to all vagaries of statistics, almost to the point of subjectivity. In the most intuitive sense, stationarity means that the statistical properties of the process that generates a time series do not change over time. It does not mean that the series does not change over time, just that the way it changes does not itself change over time. The algebraic equivalent is, thus, a linear function, perhaps, and not a constant one; the value of a linear function changes as ࢞ grows, but the way it changes remains constant — it has a constant slope; one value that captures that rate of change. To determine the stationarity of the dependent variable chosen for this study, a chart with the evolution of yield and net change basis point was analysed. One of the most immediate conclusions is the nonstationarity of the yield. The evolution of this variable is volatile through the time. Since it is proven that the yield is non-stationary, the variable Net Change Basis Point can work as a substitute for it, as it is calculated as the amount that the yield has changed from one day to another in basis points. This variable evolves in a consistent way, around zero. Nevertheless, some statistical tests were applied to it in order to confirm this conclusion.
24 The Augmented Dickey-Fuller Test was the first test to be performed. This is one of the most common forms of Unit Root tests, where the alternative hypothesis is the stationary of the variable. After applying the test to the yield, there is no statistical evidence (p-value=0.7989, see figure 32 in appendix 9.2) that we can reject the null hypothesis (the variable follows a stationarity evolution). However, when this test is applied to the Net Change Basis Point, the result is different, prevailing statistical evidences that the null hypothesis can be rejected and, as consequence, that the variable follows a stationarity evolution. The autocovariance function (ACF) is defined as the sequence of covariances of a stationary process. In order to continue the stationarity analysis of the yield” and Net Change Basis Point, this test was applied, resulting in the same conclusions as the previous tests (see figure 33-34 in appendix 9.2). Seasonality can be described as a general systematic linear or nonlinear component that changes over time and does repeat. This characteristic is important when it comes to analysing time series. One simple approach to test seasonality is to fit a model with allows for seasonality if it is present and if the chosen model has a seasonal component, then the data is seasonal. When this approach was applied to the yield statistical evidence was found (p-value= 5.356377*10^-6, see figure 35 on appendix 9.2) that the additional seasonal component is significant. However, when applied to Net Change Basis Point the conclusion it’s the opposite, as there are no statistical evidences that a seasonal component is significant (p-value≈1, see figure 36 on appendix 9.2). Correlation analysis is another important tool for multivariate analysis in data pre-processing and exploration. Correlation examines relationships between variables. It is employed in this type of analysis before any statistical modelling or data analysis. In figure 40 on appendix 9.2 the correlation matrix for the variables of this study is presented. Regarding the previous analysis applying adjustments to the dataset structure was necessary in order to present it to algorithms like Genetic Programming and Long Short-Term Memory. The result of those adjustments was a new dataset with a new dependent variable and a reduction on the number of independent variables. In this new dataset the dependent variable is Net Change Basis, as it has a stationary evolution and does not have seasonality. The change in the dependent variable does not change the main goal of the study. The reduction in the number of independent variables was due to the correlation between them. The previous dataset had several variables that were highly correlated, causing complications for the forecasting task. In the table below a description of the new variables is presented. Table 3- Description of Variable on transformed dataset
25 Following data transformation work, outlier analysis is essential. Hawkins [63] formally defined the notion of an outlier as follows: “An outlier is an observation which deviates so much from the other observations as to arouse suspicions that it was generated by a different mechanism.”. Nevertheless, the balance between deleting outliers and loosing diversity necessary for Machine Learning algorithms is delicate. In order not to extinguish this diversity, only the extreme values of each variable were considered. It is important to understand that extreme values are a very specialized type of outliers, in other words, all extreme values are outliers, but the reverse may not be true. Through a boxplot analysis extreme values in “Net Change Basis Point” (all values >1.5 and <-1.5) and “GDP Growth Portugal” (all values <-2) were found and then eliminated. In order to have values for all observations in the dataset interpolation was used for replacing the extreme values eliminated in the previous analysis. Normalization is a pre-processing technique often applied in data preparation for Machine Learning. The purpose of normalization is to change the numeric values in the dataset to a common scale, without distorting differences in the ranges of values. In Machine Learning, not every dataset requires normalization. It is required only when variables have different ranges. Choi and Moon [64], demonstrate that normalization methods in Genetic Programming decreased the problem difficulties and led to remarkable improvements in performance. Considering the advantages of normalization, this technique was applied to the present dataset. The result of the previous transformations creates the final dataset as it will be presented to Genetic Programming and Long Short-Term Memory. 4.1.3. Fitness Measure of Models The root means square error (RMSE) has been used as a standard statistical metric to measure model performance in many studies for different fields. The mean absolute error (MAE) is another useful measure commonly used in model evaluation. Both have been used to assess model performance for many years. However, there is no consensus on the most appropriate metric for model errors [65]. Nevertheless, Cort J. Willmott and Kenji Matsuura [66] prove the existence of statistical evidence that the MAE is the most natural measure of average error magnitude, and that (unlike RMSE) it is an unambiguous measure of average error. Evaluations and inter-comparisons of average model performance error should be based on the MAE. Following this conclusion and the purpose of this study the Mean Absolute Error was chosen as the fitness measure to evaluate the model outcome from Genetic Programming and Long Short-Term Memory. The Mean Absolute Error (MAE) is calculated as an average of absolute differences between the target values and the predictions. The MAE is a linear score, which means that all the individual differences are weighted equally in the average. However, the same is not true for the RMSE. One important characteristic of this measure is that it penalizes huge errors, thus it is not that sensitive to outliers as the Mean Square Error is. Mathematically, it is calculated using this formula (3): (3) Where:
26 is the total number of observations; is the actual value of variable; is the predicted value of variable; Another important thing about the MAE is its gradients with respect to the predictions. The gradient is a step function and it takes -1 when is smaller than the target and +1 when it is larger. This is not defined when the prediction is exact, because when is equal to , we cannot evaluate gradient. It is not defined [67]. 4.1.4. Software Methodology For the initial analysis of the dataset, data transformation and design, the charts presented were made using R Studio Software. Concerning the Genetic Programming approach, more specifically Geometric Semantic Genetic Programming (GSGP) the implementation freely accessible at http://gsgp.sourceforge.net created and documented by Castelli and Vannesachi [18] was used. This is an open source C++ library and it provides a robust and efficient implementation of geometric semantic genetic operators for Genetic Programming. It implements the standard Genetic Programming algorithm, but with genetic operators entrenched the concept of the semantic. It is versatile and easily adaptable. Its implementation is straightforward, depending on set of configuration parameters. This library was applied to the dataset through the Cygwin software. Regarding Long Short-Term Memory, a script was written in Phyton language using Spyder through Anaconda Software, with an environment created for this specific purpose 4.2. GENETIC PROGRAMMING EXPERIMENTAL SETTINGS Regarding Genetic Programming four models were created using different settings. The purpose of this models is to choose the best model to compare with further LSTM models. Each model was run for forty iterations and the average of generations was computed individually. The function set used for Genetic Programming was predefined in the library used, containing only arithmetic operators. The terminal set consisted of six variables, summarized in table 4. The type of mutation used for each model was chosen at random for each mutation event, as in Vanneschi et al. (2014). “Model 1” started with a basis population of two hundred individuals, that evolved throughout one thousand generations. For initializing the population, the Ramped Half-and-Half method was used, with a maximum initial tree depth equal to six. When it comes to selection, the tournament method was used, with a tournament size of ten. In this model a crossover probability of 70% and mutation probability of 30% were considered. The main changes when it comes to “Model 2” were regarding the population size, the number of maximum generations and the maximum initial depth. In this model, a population size of five hundred individuals was set. These individuals evolved for one thousand and five hundred generations. The initialization of the population was achieved using the Ramped Half-and-Half method with a maximum initial depth equal to eight. Once again, the selection was performed using
27 the tournament method, with a tournament size of ten. In this model a crossover probability of 70% and mutation probability of 30% were considered. The construction of “Model 3” was a mix between the two previous models. In this model a population size of two hundred individuals was considered over two thousand generations. The Ramped Half-and-Half method was still the method chosen for initialization of the population, with a maximum initial depth equal to eight. When it comes to selection, the tournament method was used, with a tournament size of ten. In this model, a crossover probability of 70% and mutation probability of 30% were considered. “Model 4” is the most different model compared with other models. For this model, a population size of five hundred individuals was set, evolving for two thousand generations. For initializing the population, the Ramped Half-and-Half method was applied with a maximum initial depth equal to six. For selection, the tournament method was chosen, with a tournament size of ten. In this model a crossover probability of 70% and mutation probability of 30% were considered. The experimental results were evaluated by plotting the average error of the training and test sets. For each of the forty iterations, the best individual of each generation is stored alongside with the average fitness value per generation, which was then plotted. 4.3. LONG SHORT-TERM MEMORY EXPERIMENTAL SETTINGS Concerning Long-Short Term Memory a script was written for this specific study. Similarly, to Genetic Programming five models were defined, each one with specific parameters and characteristics. The models were run for forty iterations and the average of epochs was computed individually. On one of the first attempts on this algorithm it was possible to notice how more than three LSTM or GRU layers and more than five hundred epochs created an enormous overfitting of the model to the data. After some attempts, it was possible to conclude that for the purpose and for the data sample of this study one or two layers and no more than twenty-five epochs were enough. The first model was the simplest model possible. This model had one LSTM layer and only fifteen epochs. After analysing the results of the forty iterations, it was possible to conclude that there was Table 4- Genetic Programming settings to each Model
28 some space to increase the complexity of the model and to try to improve the results. The second model was created as result of this analysis. In this model the number of layers was increased to two LSTM layers, maintaining the number of epochs. Later, the type of layer was changed to a GRU layer. Similarly, to the LSTM layer, the GRU has gating units that modulate the flow of information inside the layer, without having separate memory cells. In the LSTM layer, the amount of the memory content that is seen, or used by other units in the network is controlled by the output gate. On the other hand, the GRU exposes its full content without any control. The process followed was the same as in LSTM. Initially one model was created with only one GRU layer and fifteen epochs. After comparing the results of the model that used LSTM and the model that used GRU, clear evidences were found that the results improve when using the GRU layer, especially in the validation dataset. In order to try to improve the model, two more models were developed. The first one had two GRU layers and fifteen epochs. The second one had two GRU layers, but the number of epochs was increased to twenty-five. The experimental results are evaluated by plotting the average error of the training and validation datasets. For each epoch the average fitness value is stored, over forty iterations. Table 5- Long Short-Term settings to each Model
29 5. RESULTS AND DISCUSSION The results presented in this chapter were obtained using the methodology described and settings presented in previous chapters. Concerning Genetic Programming, forty iterations have been performed on each of the four models. The results obtained are presented by plotting the average error on the training and test sets. In each generation, the best individual of the population (i.e., the one that has the smallest training error) was chosen and the value of its error on the training and test sets was stored. The reported plots contain the average of all the values collected at the end of each generation. This measure was preferred due to its higher robustness to outliers. In appendix 9.3 (figures 41-54) one can see the mean distribution of each model with and without outliers. Figures 7 and 8 (also in appendix 9.3.1 and 9.3.2) present, for the dataset taken into account, the training and test errors (MAE) through generations for the all the models considered. Figure 7-Evolution of Fitness Train through Generations (average of all runs) of Genetic Programming Models Figure 8-Evolution of Fitness Test through Ge nerations (average of all runs) of Genetic Programming Models
36 However, despite of this algorithm producing satisfactory results, one of the concerns of this study was the time consumption of the algorithms. On this issue, considering that each model was run forty times on both algorithms, Genetic Programming needs 140.74 seconds more per iteration than Long Short-Term Memory, on average. Depending on the purpose of the use of the models created by these algorithms this could be a problem. In a trading environment, 140.74 seconds (2.34 minutes) is a long time, as the market has a lot of volatility and a lot of variables can change on that time. Nevertheless, when the purpose of these models is hedging risk, planning investments or managing debt, the difference between execution time of models is residual and can be ignored. To summarise, this study provides an overview of two different algorithms from the field of Machine Learning - Genetic Programming and Long Short-Term Memory, two of the most used in predictions for financial markets. The focus was to predict Portuguese Government Yield on 10Y on next day (T+1) resorting to models constructed using these two different Machine Learning techniques. The results obtained showed Genetic Programming as the algorithm that can create the model with the finest accuracy. However, Long Short-Term Memory should not be ignored because it can also predict with a good accuracy. Regarding execution time, velocity is a problem of Genetic Programming. This algorithm takes more time to execute compared with other methodologies. Long Short-Term Memory is considerably quicker to get results. To take the right decision about which model to choose, one must take the priorities into consideration. In case of accuracy being the priority, Genetic Programming will be the answer, when velocity is the priority Long Short-Term should be the choice.
37 7. LIMITATIONS AND FUTURE WORKS Concerning future working, there are many possible approaches that can be explored. As referred to in this study, Portuguese Government Bonds yield has many consequences for many players in financial markets. Exploring more deeply the prediction of it is truly important. This study was written as a partial requirement for obtaining the Master’s degree in Statistics and Information Management. My formation was not focused on Advanced Analytics methodologies. As a consequence of my lack of knowledge in this area I recognize that there is space to improve the parameter settings and the script of each algorithm in order to obtain more accurate results. Other future work that could be explored is to compare Genetic Programming to classical (statistical) methodologies. In this study, this algorithm was compared with an artificial neural network but comparing a Machine Learning approach with linear models or any other classical model could give insides about the benefits (or not) of use this type of approach. Another way of exploring this topic is to compare Genetic Programming and Long Short-Term Memory with other Machine Learning algorithms, such as Support Vector Machine or Random Forests. Portuguese Government Bonds is a large topic to explore with many questions and approaches to be explored. On this study I just explored a part of this topic.
38 8. BIBLIOGRAPHY [1] Adam Hayes, 2019, Bond. Retrieved from: https://www.investopedia.com/terms/b/bond.asp. [2] Daniel Martin, Barnabás Póczos, Burton Hollifield, 2014, Machine learning-aided modeling of fixed income instruments. [3] Agência de Gestão da Tesouraria e da Dívida Pública – IGCP, 03 Janeiro 2020, Glossário. Retrieved from: https://www.igcp.pt/pt/menu-lateral/gestao-da-divida-publica/glossario/ [4] Agência de Gestão da Tesouraria e da Dívida Pública – IGCP, 03 Janeiro 2020, Apresentação. Retrieved from: https://www.igcp.pt/pt/menu-lateral/o-igcp-e-p-e/apresentacao/ [5] Agência de Gestão da Tesouraria e da Dívida Pública – IGCP, 03 Janeiro 2020, OEVT and OMP. Retrieved from: https://www.igcp.pt/en/1-4-399/market-participants/oevt-and-omp/ [6] Donald Michie, 1968, "Memo" Functions and Machine Learning, Experimental Programming Unit University of Edinburgh. [7] John R. Koza, 1997, Genetic Programming, Search Methodologies: Introductory Tutorials In Optimization And Decision Support Techniques pg. 127- 164. [8] R. Lakshman Naik, D. Ramesh, B. Manjula, Dr. A. Govardhan, 2012, Prediction of StockMarket Index Using Genetic Algorithm, Computer Engineering and Intelligent Systems. [9] Raghav Nandakumar, Uttamraj K., Vishal, Y. V. Lokeswari, 2018, Stock Price Prediction Using Long Short-Term Memory, International Research Journal of Engineering and Technology (IRJET) Volume: 05 Issue:03. [10] Securities Industry and Financial Markets Association, 2019, SIFMA- Capital Markets Fact Book 2019. [11] Data obtain through Bloomberg Terminal, 31/03/2020. [12] Bin weng, 2017, Application of machine learning techniques for stock market prediction, Faculty of Auburn University. [13] Sneha Soni, 2016, Applications of ANNs in Stock Market Prediction: A Survey, International Journal of Computer Science & Engineering Technology. [14] Swetava Ganguli, Jared Dunnmon, 2017, Machine Learning for Better Models for Predicting Bond Prices, Cornell University. [15] André Dinis Oliveira, Novembro 2016, Forecasting the PSI-20 index using a Machine Learning approach, NOVA Information Management School. [16] Will Kenton, 2019, Opportunity Cost. Retrieved from: https://www.investopedia.com/terms/o/opportunitycost.asp
39 [17] Arturo Estrella and Frederic S. Mishkin, 1996, The yield curve as a predictor of recessions in the United States and Europe, Current Issues in Economics and Finance Volume 2 Number 7. [18] Castelli, Mauro & Silva, Sara & Vanneschi, Leonardo, 2014, A C++ framework for geometric semantic Genetic programming. Genetic Programming and Evolvable Machines. [19] Merton R. C. (1973). Theory of rational option pricing, Bell Journal of Economics and Management Science 4: 141–183. [20] Vasicek O. (1977). An equilibrium characterization of the term structure, Journal of Financial Economics 5: 177–188. [21] Cox J., Ingersoll J. and Ross S., 1985, A theory of the term structure of interest rates, Econometrica 53: 385.407. [22] Charles R. Nelson and Andrew F. Siege, 1987, Parsimonious Modeling of Yield Curves, The Journal of Business Vol. 60, No. 4 (Oct., 1987), pp. 473-489. [23] Bank of International Settlements, 2005, Zero-coupon yield curves — Technical documentation. BIS Paper, 25. (pp. 1–37). [24] Laura Coroneo, Ken Nyholm & Rositsa Vidova-Koleva, 2008, How Arbitrage-Free is the Nelson- Siegel Model, Working Paper Series Nº874. [25] Barrett, W. R., Gosnell, T. F., Jr., & Heuson, A. J., 1995, Yield curve shifts and the selection of immunization strategies. Journal of Fixed Income, 53–64. [26] Hodges, S. D., & Parekh, N., 2006, Term structure slope risk: Convexity revisited. Journal of Fixed Income, 16(3), 54–59 [27] Dullmann, K., & Uhrig-Homburg, M., 2000, Profiting risk structure of interest rates: An empirical analysis for Deutschemark-denominated bonds. European Financial Management, 6, 367–388. [28] Fabozzi, F. J., Martellini, L., & Priaulet, P., 2005, Predictability in the shape of the term structure of interest rates. Journal of Fixed Income, 40–53. [29] Diebold, F. X., & Li, C. (2006). Forecasting the term structure of government bond yields. Journal of Econometrics, 130, 337–364. [30] Pooter, M.D., Ravazzolo, F., van Dijk, D., 2007, Predicting the Term Structure of Interest Rates: Incorporating Parameter Uncertainty, Model Uncertainty and Macroeconomic Information, Tinbergen Institute Discussion Papers 07-028/4. [31] Gu, Shihao, Bryan T. Kelly, and Dacheng Xiu, 2018, Empirical Asset Pricing via Machine Learning, Chicago Booth Research Paper 18-04, Chicago Booth [32] Joarder Kamruzzama, Ruhul A. Sarker, 2014, NN-Based Forecasting of Foreign Currency Exchange Rates. Neural Information Processing - Letters and Reviews Vol. 3, No. 2. [33] Minakhi Routa, Babita Majhib,c, Ritanjali Majhid, Ganapati Pandaea, 2014, Forecasting of currency exchange rates using an adaptive ARMA model with differential evolution-based training.
40 Journal of King Saud University - Computer and Information Sciences. Volume 26, Issue 1, January 2014, Pages 7-18 [34] Dase R.K., Pawar D.D, 2010, Application of Artificial Neural Network for stock market predictions: A review of literature. International Journal of Machine Intelligence, Volume 2, Issue 2, 2010, pp-14-17. [35] T. Kimoto, K. Asakawa, M. Yoda, M. Takeoka., 1990, Stock market prediction system with modular neural networks, IJCNN International Joint Conference on Neural Networks [36] Xiaowei Lin, Zehong Yang, Yixu Song, 2011, Intelligent stock trading system based on improved technical analysis and Echo State Network. Expert Systems with Applications Volume 38, Issue 9, September 2011, Pages 11347-11354. [37] Sotirios P. Chatzis, Vassilis Siakoulis, Anastasios Petropoulos, Evangelos Stavroulakis, Nikos Vlachogiannakis, 2018, Forecasting stock market crisis events using deep and statistical machine learning techniques. Expert Systems with Applications Volume 112, 1 December 2018, Pages 353- 371. [38] Cheng, W., Wagner, L. and Lin, C.H., 1996, Forecasting the 30-year U.S. Treasury bond with a system of neural networks, Journal of Computational Intelligence in Finance, vol. 4, pp. 10-16. [39] Din, A. ,2003, Forecasting interest rates using neural network models, Geneva Research Collaboration, Technical Report. [40] Rajiv Sambasivan, Sourish Das, 2017, A statistical machine learning approach to yield curve forecasting. 2017 International Conference on Computational Intelligence in Data Science (ICCIDS). [41] Koza, JR., 1992, Genetic Programming: On the Programming of Computers by Means of Natural Selection. MIT, Cambridge. [42] Alberto Moraglio, Krzysztof Krawiec, Colin G. Johnson, 2012, Geometric Semantic Genetic Programming. Parallel Problem Solving from Nature - PPSN XII pp 21-31. [43] Vanneschi L., Castelli M., Manzoni L., Silva S., 2013, A New Implementation of Geometric Semantic GP and Its Application to Problems in Pharmacokinetics. Genetic Programming. EuroGP 2013. Lecture Notes in Computer Science, vol 7831. [44] Leonardo Vanneschi, Sara Silva, Mauro Castelli and Luca Manzoni, 2014, Geometric Semantic Genetic Programming for Real Life Applications. Genetic Programming Theory and Practice XI pp 191- 209. [45] M. A. Kaboudan, 1999, Genetic Programming Prediction of Stock Prices. Computational Economics 16: 207–236, 2000. [46] R. Lakshman Naik, D. Rames , B. Manjula, Dr. A. Govardhan, 2012, Prediction of Stock Market Index Using Genetic Algorithm. Computer Engineering and Intelligent Vol 3, No.7, 2012.
41 [47] Alaa Sheta, Hossam Faris, Mouhammd Alkasassbeh, 2013, A Genetic Programming Model for S&P 500 Stock Market Prediction. International Journal of Control and Automation Vol.6, No.5 (2013), pp.303-314. [48] Mauro Castelli, Leonardo Vanneschi, Leonardo Trujillo, Aleš Popovič, 2017, Stock index return forecasting: Semantics-based genetic programming with local search optimizer. Int. J. Bio-Inspired Computation, Vol. 10, No. 3, 2017. [49] Sepp Hochreiter, Jürgen Schmidhuber, 1997, Long Short-Term Memory. Neural Computation Volume 9 Issue 8 November 15, 1997, p.1735-1780. [50] Kai Chen, Yi Zhou, Fangyan Da, 2015, A LSTM-based method for stock returns prediction: A case study of China stock market. 2015 IEEE International Conference on Big Data (Big Data). [51] Hansson, Magnus, 2017, On stock return prediction with LSTM networks. Department of Economics Lund University. [52] Martins, Graça, Gualter Couto e Piriquito Costa, 2002, Análise da volatilidade do prémio de risco do mercado de capitais português. Estudos de Gestão, VII(1):19-42. [53] Caiado, Jorge (2004). Modelling and forecasting the volatility of the portuguese stock index PSI- 20. Estudos de Gestão, IX(1):3-22. [54] Isfan, M., Menezes, R., Mendes, D. A., 2010, Forecasting the Portuguese stock market time series by using artificial neural networks. 7th International Conference on Applications of Physics in Financial Analysis Journal of Physics: Conference Series 221. [55] Tom M. Mitchell, 1997, Machine Learning, McGraw-Hill Science/Engineering/Mat. [56] Alexei Botchkarev, 2018, Performance Metrics (Error Measures) in Machine Learning Regression, Forecasting and Prognostics: Properties and Typology, Interdisciplinary Journal of Information, Knowledge, and Management, 2019, 14, 45-79. [57] Kenneth E. Kinnear, Jr, 1993, Generality and Difficulty in Genetic Programming: Evolving a Sort, Proceedings of the Fifth International Conference on Genetic Algorithms, S. Forrest, Ed., San Mateo, CA: Morgan Kaufmann. [58] Mitchell Melanie, 1999, An Introduction to Genetic Algorithms, A Bradford Book The MIT Press Cambridge, Massachusetts Fifth printing 1999. [59] Poli, Riccardo & Langdon, William & Mcphee, Nicholas., 2008, A Field Guide to Genetic Programming. [60] A Beginner's Guide to LSTMs and Recurrent Neural Networks. Retrieved from: https://pathmind.com/wiki/lstm#long [61] Felix Gers, 2001, Long Short-Term Memory in Recurrent Neural Networks, E´Cole Polytechnique Fe´De´Rale De Lausanne.
42 [62] Christopher Olah, 2015, Understanding LSTM Networks. Retrieved from: https://colah.github.io/posts/2015-08-Understanding-LSTMs/ [63] Hawkins D., 1980, Identification of Outliers, Chapman and Hall. [64] Choi, Sung-Soon & Moon, Byung, 2003, Normalization in Genetic Algorithms, pag.862-873. [65] Chai, Tianfeng & Draxler, R.R.., 2014, Root mean square error (RMSE) or mean absolute error (MAE)- Arguments against avoiding RMSE in the literature. Geoscientific Model Development. [66] Willmott, C. & Matsuura, K., 2005, Advantages of the Mean Absolute Error (MAE) over the Root Mean Square Error (RMSE) in Assessing Average Model Performance. [67] Georgios Drakos, 2018, How to select the Right Evaluation Metric for Machine Learning Models: Part 1 Regression Metrics. Retrieved from: https://bit.ly/3aVg2V3 [68] David Ruppert, David S. Matteson, 2015, Statistics and Data Analysis for Financial Engineering.
43
44 9. APPENDIX 9.1. PORTUGUESE GOVERNMENT DEBT Figure 14- Chart of Portuguese Governmenet Outstanding Debt Amount (25 March 2020) Figure 15- Evolution of Yield of Portuguese Government Bond 10 Years (With #NA Data)
45 Figure 16- Evolution of Yield of Portuguese Government Bond 10 Years (With Interpolated Data)
52 Table 11- Descriptive Statistics to all variables of Original Dataset Figure 29- Augment Dickey-Fuller Test on Yield and Net Change Basis Point Variables
53 Figure 30- Auto-Covariance Function of Yield Variable Figure 31- Auto-Covariance Function of Net Change Basis Point Variable
54 Figure 32- Seasonality Test on Yield Variable Figure 33- Seasonality Test on Net Change Basis Point Variable
55 Figure 34- QS Statistics on Yield Variable Figure 35- QS Statistics on Net Change Basis Point Variable
56 Figure 36- Correlation Matrix of Original Dataset Figure 37- Correlation Matrix of Modified Dataset
57 9.3. GENETIC PROGRAMMING 9.3.1. Genetic Programming- Fitness Train Models Analysis Figure 38- Evolution of Fitness Train through Generations (average of all runs) of Genetic Programming Models
58 Figure 39- Outliers Analysis on Fitness Train of Model 1, Genetic Programming Figure 40- Outliers Analysis on Fitness Train of Model 2, Genetic Programming
59 Figure 41- Outliers Analysis on Fitness Train of Model 3, Genetic Programming Figure 42- Outliers Analysis on Fitness Train of Model 4, Genetic Programming
60 Figure 43- Boxplot with Fitness Train distribution of models (With Outliers), Genetic Programming Figure 44- Boxplot with Fitness Train distribution of models (Without Outliers), Genetic Programming
61 9.3.2. Genetic Programming- Fitness Test Models Analysis Figure 45- Evolution of Fitness Test through Generations (average of all runs) of Genetic Programming Models
68 Figure 56- Outliers Analysis on Fitness Train of Model 3, Long Short- Term Memory Figure 57- Outliers Analysis on Fitness Train of Model 4, Long Short- Term Memory
69 Figure 58- Outliers Analysis on Fitness Train of Model 5, Long Short- Term Memory Figure 59- Boxplot with Fitness Train distribution of models, Long Short-Term Memory
70 9.4.2. Long Short-Term Memory- Fitness Validation Figure 60- Evolution of Fitness Validation through Epochs (average of all runs) of Long Short-Term Memory Models
71 Figure 61- Outliers Analysis on Fitness Validation of Model 1, Long Short-Term Memory Figure 62- Outliers Analysis on Fitness Validation of Model 2, Long Short-Term Memory
72 Figure 63- Outliers Analysis on Fitness Validation of Model 3 Long Short-Term Memory Figure 64- Outliers Analysis on Fitness Validation of Model 4, Long Short-Term Memory
73 Figure 65- Outliers Analysis on Fitness Validation of Model 5, Long Short-Term Memory Figure 66- Boxplot with Fitness Validation distribution of models, Long Short- Term Memory
74 9.4.3. Long Short-Term Memory- Evolution by Model Figure 67- Evolution of Fitness Error in Model 1, Long Short-Term Memory Figure 68- Evolution of Fitness Error in Model 2, Long Short-Term Memory
75 Figure 69- Evolution of Fitness Error in Model 3, Long Short-Term Memory Figure 70- Evolution of Fitness Error in Model 4, Long Short-Term Memory
76 Figure 71- Evolution of Fitness Error in Model 5, Long Short-Term Memory
77 9.4.4. Long Short-Term Memory- Statistical Test Table 12- Wilcoxon Rank-Sum Test to Long Short-Term Memory Models Errors