Proposal and Analysis of Stock Trading System Using Genetic Algorithm and Stock Back Test System Abstract: In recent years, many brokerage firms and hedge funds use a trading system based on financial engineering and many algorithms. On the other hand, many personal investors judge their trade by their intuition or advices from stock analysts. Therefore, there are a big gap of a trading method between the institutional investors and the personal investors. The objective of this paper is to propose a new stock trading system using a genetic algorithm and a stock back test system. Using the proposed system, we aim to analyze stock trading strategies and the performance. 1. Introduction In recent years, Japanese stock trades by personal stock traders become more active than before because of a deregulation of a stock charge and the improvement of internet infrastructures of stock trading. But behinds of successful personal investors, many other personal investors have lost their asset and bankrupted themselves in the worst case. As a reason of this fact, many personal investors do not have even any basic financial literacy. Investors should have to balance a lose probability and a lose risk of their trade when you lost and especially in the case of high leveraged margin trading. There are many personal investors who use a technical index when they select stocks or judge entry timing but there may be only few investors who verify the statistical effectiveness of technical indexes. To use a technical index which was not confirmed its statistical effectiveness is the same as to select stocks and judge their entry timing by a horoscope. Thus such investors can not become a wise investor. On the other hand, many brokerage firms and hedge funds are using a trading system called an algorithmic trading system that uses financial engineering, various computer algorithms and many soft computing methods. Like this, there is a big gap of a trading method between personal investors and institutional investors. Spreading of methods of trading strategy analysis and progressing of financial literacy for the personal investors is necessary to bridge the gap of a trading method. Back Test is one of a confirming method of a trading strategy using a technical index. This method simulates a trading strategy using past stock data and analyze the simulation result. There are many kinds of stock back test software, from free wares to expensive and high function ones. But there are infinite combinations of technical indexes and it is impossible to test all combinations of technical indexes because of a time constraint. The objective of this paper is to propose an optimum trading strategy searching method using a hybrid system of GA(Genetic Algorithm, GA) and Back test. It becomes possible to search the optimum stock trading strategy in a specific term. In addition, the proposed method can widen a searching range to increase by adding new buying or selling conditions.
2. Stock Back Test System Our back test system written in C++/CLR programming language targets only a spot trading and provides a function to deduct charges from an asset at each trading. The upper limit of the sum of the investment money is 90% of the total asset. There are many other scientific papers, the theme of which is stock price prediction and improving of its stock trade performance [1]~[3]. They are using GA, Neural Network Genetic Network Programming[4] and many other algorithms. In recent researches, an artificial stock market has proposed as a method of analyzing the circulation structure of stock market[5]. Some of these papers simulated real stock trading under unreal conditions, for example an architect designed a system buys stocks with the close value when the system judges to buy. In this case, the system can not buy stocks with the close value in the real trading. Simulated results under unreal conditions such proposed systems are unreliable one. We try to simulate the stock trading under condition actually near real trading. The system provides two types of trade timing; 1) to buy some stock with an open value of the next day when the system judges to buy. 2) to sell some stock with an open value of the next day when the system judges to sell. Slippage is not considered in these two cases. Figure 1 shows the flow of the stock back test system. condition has its own criterion value, the system judges to buy when all selected conditions are satisfied the criteria. The criterion value can change in a previously decided range. Figure 2 shows the sample of a buying judge. Figure 2, Outline of buying judgment rules There are two cases of selling timing; profit taking and loss cut. The system can set a selling criterion value to each of the selling conditions. Of course, the criterion value takes plus in the case of profit taking and it takes minus value in the case of loss cut. 3. Searching of a trading strategy using GA In this paper, we search the optimum trading strategy in a specific term using a GA which is shown in Table 1. Table 1, Feature of GA Figure 1, Flow chart of the back test system There are 15 buying conditions and every All chromosomes have 16 genes, gene numbers 1~14 are information of buying conditions and their criterion values and gene numbers 15 and 16 are information of selling conditions and their criterion values. Gene numbers 1~6, 7~10, 11~14 are logical sum combined each other and each groups are logical product combined. Figure 3 shows the structure of the chromosome used in the GA.
In this paper, we verified the performance of the proposed system by two kinds of experiments. Experiment_1, shows the back test result using an optimum trading strategy searched by the GA(GA strategy). Table 2 shows all experimental conditions, term of data used in the GA and back test. Table 2, Conditions of the first experiment Figure 3, structure of a chromosome Chromosomes of the first generation are made from random gene array combinations. In the uniform crossover process, genes are crossed with set of buying or selling conditions and their criterion values. And in the mutation process, one set of conditions and its criterion values gene is selected randomly from selected chromosomes, after that new gene is selected from 15 buying conditions if the selected condition gene is a buying condition and its criterion is decided randomly in a given range. In a case where the selected gene shows a selling condition, its criterion is decided randomly a plus or minus value in a given range according to the type of the condition: loss cut or profit taking. Figure 4 shows a flow chart of chromosome operation in the mutation process. In Experiment_1, also 5% strategy is used in the back test to compare with the GA strategy, the 5% strategy on all ways takes long position, loss cut and profit taking when the ±5% loss or profit is occurred. Experiment_2 shows results of back test using three kinds of a chromosome evaluation function under the condition 2 shown in Table 2. Back tests are repeated three times in each test and their results show the average of all tests. Table 3 shows all the chromosome evaluation functions used in the GA. Table 3, Chromosome evaluation functions 7 stocks are used in the two kinds of experiments. All of these companies have enough aggregated market value and have not done stock split within three years. Table 4 shows all the stocks used in the back test. Table 4, Back test adopted brands Figure 4, Flow of the mutation method 4. Experiment of back test results using optimum trading strategies.
5. Experimental result Tables 5~9 show the results of the experiments. Table 9, Experiment 2 with Condition 2 Table 5, Experiment 1 with Condition 1 Table 6, Experiment 1 with Condition 2 Table 7, Experiment 1 with Condition 3 Table 8, Experiment 1 with Condition 4 6. Discussion According to the results of Experiment 1, the number of trades and the percentage of wins of GA strategy are smaller than that of 5% strategy in all experimental conditions. The reason of this result is because the product of percentage of wins and asset is used as an evaluation function. Therefore chromosomes with high percentage of wins and small number of trades are selected. Probably, the GA strategy has much more no holding days than 5% strategy considering the number of trades, max holding term and minimum holding term of GA strategy and 5% strategy. This result shows that the GA strategy missed the chance to takes a profit but it also can avert the risk of price falling down. In fact, the GA strategy decreased the asset smaller than the 5% strategy in the case where the price changing ratio takes a minus value. In addition, the max drawdown which shows the biggest loss ratio in the back test of the GA strategy is smaller than that of the 5% strategy. Therefore, the risk of the GA strategy is smaller than that of the 5% strategy. In addition, in the case of experiment 1 with Condition 2, the asset increase ratio of the GA strategy is much smaller than that of the 5% strategy. To analyze this reason, a result of the back test of two stocks under condition 2 in Table 10, stock chart of code 4502 is shown in Figure 5 and stock chart of code7203 is shown in Figure 6. The left part of the each stock chart shows the
term used in the GA and the right part of the each stock chart shows the term used in the back test. Table 10, Result of the back test of 2 stocks back test term is big, particularly in code 7203. Thus the GA strategy was not effective in the back test term. According to the result of Experiment 2 shown in Table 9, the asset increasing ratio is highest in the case of using only an asset as the evaluation function, and in the case of using the percentage of wins and the number of trades added to asset, the performance of each added items are improved but the asset increasing ratio is decreased compared with the first case. This result supports that the evaluation function and the result of the back test is closely related. Therefore, it is necessary to verify that the return and risk of an evaluation function is balanced. Figure 5, Stock chart of code 4502 Figure 6, Stock chart of code 7203 2 1 in Table 10 shows the ratio of an asset increasing ratio to a price changing ratio. According to this result, the estrangement of an asset increasing ratio and a price changing ratio of code 4502 is bigger than that of code 7203. In addition, according to Figure 5 and 6, the inclination of a straight line joins a start point and an end point of the stock price in the GA term and the back test term is changed much particularly in the case of code 7203. Therefore, the difference of stock trends in a GA term and a 7. Conclusions In this paper, we proposed the method to search the optimum stock trading strategy using the GA and used the optimum stock trading strategy to an unknown term. The result of the two kinds of experiments, back test performance is decrease compared with their price changing ratio when a stock trend changes so much in the GA term and the back test term is demonstrated. Only few buying and selling conditions are used in the proposed system. This system can not judge which stock should be bought and the system do not hold any stocks in many days. Stock data are collected using an original stock data download system, but this system is not applied to a stock split, therefore the term of all the collected stock data is short. Thus the system can not search the optimum strategy in the long term. In the future, the stock data download system should be improved to be able to apply to the stock split and collect a long term stock data. Then the GA back test system can find the optimum strategy in the long term. This proposed system does not have a stock selecting function. Therefore, the optimum trading strategy is often optimized to a narrow range of only one stock. The performance of the optimum trading strategy is greatly influenced by the performance of the selected stock. On the other hand, the optimum trading strategy searched by using a stock selecting function is optimized in
more wide a searching range. References [1] Youngohc Yoon, Swales G, Predicting Stock Price Performance: A Neural Network Approach, System Sciences 1991 Twenty-Fourth Annual Hawaii International Conference. Vol.4, pp.156-162, 1991 [2] Matthias G. Schuster, A Multiobjective Genetic Programming Approach for Pricing and Hedging Derivative Securities, [3] Brent Doeksen, Ajith Abraham, Johnson Thomas and Marcin Paprzycki, Real Stock Trading Using Soft Computing Models, Information Technology: Coding and Computing, 2005. ITCC 2005, Vol.2, pp.162-167, 2005 [4] Yamashita T, Hirasawa K, Jinglu Hu, Application of multi-branch neural networks to stock market prediction, Neural Networks, 2005.IJCNN 05, Vol.4, pp.2544-2548, 2005 [5] W.B. Arthur, Asset Pricing Under Endogenous Expectations in an Artificial Stock Market SFI Studies in the Sciences of Complexity, Vol.27 in 1997.