Tai Kam Fong, Jackie. Master of Science in E-Commerce Technology



Similar documents
Improved Trend Following Trading Model by Recalling Past Strategies in Derivatives Market

Trend Recalling Algorithm for Automated Online Trading in Stock Market

The Application of Trend Following Strategies in Stock Market Trading

Expert Systems with Applications

Technical Analysis. Technical Analysis. Schools of Thought. Discussion Points. Discussion Points. Schools of thought. Schools of thought

NEURAL networks [5] are universal approximators [6]. It

BROKER SERVICES AND PLATFORM

Technical Indicators Tutorial - Forex Trading, Currency Forecast, FX Trading Signal, Forex Training Cour...

THE TIME-SERIES ANALYSIS FOR INTERACTIONS AMONG RETURNS ON S&P 500, CSI300 AND HSI BEFORE AND AFTER THE BANKRUPTCY OF LEHMAN BROTHERS TANG WAI KEONG

Trend Following Algorithms for Technical Trading in Stock Market

Chapter 2.3. Technical Analysis: Technical Indicators

Chapter 2.3. Technical Indicators

Professional Trader Series: Moving Average Formula & Strategy Guide. by John Person

High Probability Trading Triggers for Gold & Silver

MATHEMATICAL TRADING INDICATORS

8 Day Intensive Course Lesson 5 Stochastics & Bollinger Bands

FREEFOREXEBOOK.ORG. Forex Trading

A Prediction Model for Taiwan Tourism Industry Stock Index

A Stock Trading Algorithm Model Proposal, based on Technical Indicators Signals

Technical analysis is one of the most popular methods

Take it E.A.S.Y.! Dean Malone 4X Los Angeles Group - HotComm January 2007

A New Approach to Neural Network based Stock Trading Strategy

Alerts & Filters in Power E*TRADE Pro Strategy Scanner

Online Tuning of Artificial Neural Networks for Induction Motor Control

The Logic Of Pivot Trading

Technical Analysis of the Futures Markets:

A STUDY ON EQUITY SHARE PRICE MOVEMENT OF SUN PHARMACEUTICALS INDUSTRIES LIMITED

Finanzdienstleistungen (Praxis) Algorithmic Trading

My Techniques for making $150 a Day Trading Forex *Note for my more Advanced Strategies check out my site: Click Here

Neural Network and Genetic Algorithm Based Trading Systems. Donn S. Fishbein, MD, PhD Neuroquant.com

An Automated Guided Model For Integrating News Into Stock Trading Strategies Pallavi Parshuram Katke 1, Ass.Prof. B.R.Solunke 2

Disclaimer: The authors of the articles in this guide are simply offering their interpretation of the concepts. Information, charts or examples

Callable Bull/ Bear Contracts (CBBC) Driving Investment Power

Welcome to the Next Generation of Trading Solutions by PandeLa - Intelligent Automated Trading.

Trend Determination - a Quick, Accurate, & Effective Methodology

How to use Hamzei Analytics CI and DCI Indicators By Fari Hamzei

Proceedings of the 9th WSEAS International Conference on APPLIED COMPUTER SCIENCE

Feasibility Study of Contractor Registration System and Contractor Grading System in Macau. Pun I Chung. Master of Science in Civil Engineering

Comparison of K-means and Backpropagation Data Mining Algorithms

THE MACD: A COMBO OF INDICATORS FOR THE BEST OF BOTH WORLDS

NEDBANK PRIVATE WEALTH STOCKBROKERS Graphical Analysis Manual

INFORMATION PAPER ON AFTER-HOURS FUTURES TRADING

BTBU Master of Control Theory and Control Engineering

Stochastic Oscillator.

COMPARATIVE ANALYSIS BETWEEN THE FUNDAMENTAL AND TECHNICAL ANALYSIS OF STOCKS

SAIF-2011 Report. Rami Reddy, SOA, UW_P

Technical Analysis SAmple InveSTIng plans 1

Problems often have a certain amount of uncertainty, possibly due to: Incompleteness of information about the environment,

Course Syllabus For Operations Management. Management Information Systems

How I Trade Profitably Every Single Month without Fail

The Trading System

Part I. Introduction

Contrarian investing and why it works

atching Currency Moves with The Schaff Trend Cycle Indicator

SYSTEMS, CONTROL AND MECHATRONICS

Fuzzy Candlestick Approach to Trade S&P CNX NIFTY 50 Index using Engulfing Patterns

Understanding the Technical Market Indicators

STREET SMARTS I. Planetary 2 Library. Introduction: Benefits: L I B R A R I E S

Theoretical Perspective

How to find the big winners in the stock market.

8 Day Intensive Course Lesson 3

Celestial Commodities Limited ("CCL") Electronic Trading Account - Hong Kong Futures and Options Trading Policy

A Practical Guide to Technical Indicators; (Part 1) Moving Averages

Technical analysis of Forex by MACD Indicator

An Empirical Comparison of Moving Average Envelopes and Bollinger Bands

(Refer Slide Time: 01:52)

Neural Network Stock Trading Systems Donn S. Fishbein, MD, PhD Neuroquant.com

Legislative Council Panel on Financial Affairs. Proposal of the Hong Kong Exchanges and Clearing Limited to introduce after-hours futures trading

Prediction of Stock Performance Using Analytical Techniques

HYBRID FIR-IIR FILTERS By John F. Ehlers

JUST SIT BACK AND LET THE GIRTH MODEL MAKE MONEY FOR YOU. Elham Negahdary

CS Standards Crosswalk: CSTA K-12 Computer Science Standards and Oracle Java Programming (2014)

SFT Simple Strategy. Version by Radim Frycka

Trading Binary Options Strategies and Tactics

Analyzing and Predicting Stock Market Using Data Mining Techniques A Review

Knowledge Based Descriptive Neural Networks

Turk s ES ZigZag Day Trading Strategy

CHART TRADING GUIDE 1

Ed Heath s Guerilla Swing Trading Plan (as of 1/22/13)

A GUIDE TO WL INDICATORS

ADX breakout scanning ADX breakouts can signal momentum setups as well as exit conditions for intraday and swing traders. FIGURE 1: AFTER ADX > 40

Cap Growth FX A Scandinavian Capital Markets Trading Strategy

Strategy Modeling and Classifier Training for Share Trading

EAGLE MOBILITY SOLUTIONS ENTERPRISE MOBILITY. SCHMIDT-iSOFT LIMITED Member of Schmidt Electronics Group

Getting Started with Recognia Intraday Trader

(NASDAQ: MNGA) Magnegas Corporation. Bullish. Investment Highlights

Chapter 19 WEAK HANDS VS STRONG HANDS

FUTURES TRADING SYSTEMS

Recognizing Informed Option Trading

Click on the below banner to learn about my revolutionary method to trade the forex market:

Automated Stock Trading and Portfolio Optimization Using XCS Trader and Technical Analysis. Anil Chauhan

Empirical Analysis of an Online Algorithm for Multiple Trading Problems

JetBlue Airways Stock Price Analysis and Prediction

Applied mathematics and mathematical statistics

Comparing Artificial Intelligence Systems for Stock Portfolio Selection

THE CYCLE TRADING PATTERN MANUAL

FUTURES STRATEGY: Short-term CCI p. 10. ADJUSTING TO stock index futures shift p. 14. STRADDLES, STRANGLES, and volatility p. 16

Map-like Wikipedia Visualization. Pang Cheong Iao. Master of Science in Software Engineering

IS MORE INFORMATION BETTER? THE EFFECT OF TRADERS IRRATIONAL BEHAVIOR ON AN ARTIFICIAL STOCK MARKET

Table of Contents. Preface. Chapter 1: TRADING BASICS. Chapter 2: BASIC TOOLS. Chapter 3: ADX. Chapter 4: ACCUMULATION LINE

Transcription:

Trend Following Algorithms in Automated Stock Market Trading by Tai Kam Fong, Jackie Master of Science in E-Commerce Technology 2011 Faculty of Science and Technology University of Macau

Trend Following Algorithms in Automated Stock Market Trading by Tai Kam Fong, Jackie A thesis submitted in partial fulfillment of the requirements for the degree of Master of Science in E-Commerce Technology Faculty of Science and Technology University of Macau 2011 Approved by Supervisor Date

In presenting this thesis in partial fulfillment of the requirements for a Master's degree at the University of Macau, I agree that the Library and the Faculty of Science and Technology shall make its copies freely available for inspection. However, reproduction of this thesis for any purposes or by any means shall not be allowed without my written permission. Authorization is sought by contacting the author at Address: Room N410, FST University of Macau Av. Padre Tomas Pereira Taipa, Macau Telephone: 66858880 Fax: 28838314 E-mail: JackieTai@gmail.com Signature Date

University of Macau Abstract Trend Following Algorithms in Automated Stock Market Trading by Tai Kam Fong, Jackie Thesis Supervisors: Dr. Simon Fong Master of Science in E-Commerce Technology Unlike financial forecasting, trend following[1] does not predict market movement, instead of prediction, it follows market trend. Once a trend is recognized, just jumps in and rides on it, taking benefit from both sides, enjoying the profits from ups and downs of the markets. Trend following trade has a long and successful history[2], it has been wildly used by professional traders, and can be applied to various markets. There are many forms of trend following, the traditional trading method is by human judgment and following trade strategies rules. That is the human spots out a trend, identifies the trade signal and places an order accordingly. Beyond rules and strategies, human judgment becomes the core element, it requires rational discipline and emotional control to stick with a trend, following precise rules through the market movements of upward and downward. However, as emotions are part of the human nature, this self-discipline is not always carried out. Therefore many trend traders failed to make profit. Today with the growth of computer power and Internet technology, trend following trade can be programmed and automated. Transaction executions that used to be performed by human could be replaced and automated by an automated trading system. Trade decisions that used to be made by human judgment, now are replaced by algorithms. Algorithms are free from human emotions, they execute precisely as how the codes instruct to trade so. Financial forecasting is always a hot topic in academic research, there many scholars who work on this field, plenty of research works are carried out. In general, there are two domains, one is the financial field, using economics models that rely on mathematical, statistical, time series forecasting to address the problem; this one belongs to the economics finance, models from this area use little of computer

algorithm. The other is computational field, using scientific models that base on intelligent algorithms such as machine learning, artificial neural network, expert system etc[3], that attempt to find an optimal solution for the problem. This is the area that researcher have been studying on. Among this computational domain, the adoption of this kind of algorithm or model somehow is not particularly popular in today financial market place. But on the other hand, there are very few academic researcher studies about trend following, yet the use of this technique is everywhere, and is widely applied on various of financial markets. So there must be some reasons behind this. In my opinion, models or algorithms that base on machine learning or neural network etc, are something I refer as black-box processing (e.g. tuning some internal weights), which means that we know what data input to the black-box, and what outcome will be the output, but how it produces, is not transparent and parameters setting is difficult to control. Perhaps these uncertainties are not favorable in financial trading practice. Most of the researchers, who work on this topic, tend to focus on predictive model because of intellectual endeavour. In this thesis study of major in e-commerce, we propose five trading algorithms that are based on a different type of model; we call it Reactive Model. The first one is derived from the concept of basic trade strategy, in which all trend followers try to systematize their trades. The basic premise is that the most profit is gained when a trade is synchronized to an enduring trend. The rules of this algorithm are statically formulated as the trade parameters remain unchanged once they have been defined. Based upon this initial concept of trading algorithm, some variants are introduced with incorporation of technical analysis concept. Technical analysis makes trade decision through technical indicators such as RSI, STC, and EMA etc, these indicators are changing dynamically according to the market situation. By adopting one or more of these indicators and by studying how they react to the market, we can form rules that are able to inherit this dynamic nature. By following these rules during

trade session, we update the trade parameters with the latest dynamic values attribute too. For improving the performance, we introduce fuzzy logic into our trade system, which forms our third and fourth versions of trading algorithms. The properties of these trading algorithms are generally built upon the experiences of previous trading algorithms, such as the membership definition and fuzzy sets generation. All these trading algorithms are later verified on Hang Sang Index futures market in a simulated environment, and the result is encouraging. These trading algorithms showing an outstanding performance in the wild bullish and bearish markets between the years of 2007 to 2009. However, during the year of 2010, they seem to be under performing, as they are no longer generating great profits. This is due to the large flip-flop changes of the market. It was observed that frequent market trend fluctuations deter trend following algorithms. To resolve this limitation, we present our last trading algorithm, namely Trend Recalling", it is considered to be adaptable to market behavioral changes. The concept of financial cycle was taken into account of our algorithm. This trading algorithm is also verified on Hang Sang Index futures contracts in simulated environment, and the result is inspiring. In this thesis we discuss on the design of an automated trading system, which incorporates these trend following algorithms, which is a core element of the system, and the application of this type of system in financial market. We also investigate how the market fluctuation can affect the overall performance, and bring new perspective to handling the financial cycles. One of our goals is to build up this automated trading system, which primarily operates on financial derivative market[4], such as the Hang Sang Index Futures Contract that trade on HKFE (Hong Kong Future Exchange) or the Dow Jones Industrial Average Index Futures Contract that trade on CBOT (Chicago Board of

Trade). In this thesis Hang Sang Index Futures is selected as the primary simulation market, although the system can be applied on any market theoretically. By using only historical market data, the system is able to react according to real-time market state, and make trade decision on its own. To reduce the overnight risk and cost-of-carry, trade will be performed on a daily basic only, which means no contracts will be carried overnight. The P&L (Profit and Loss) on each trade will be recorded and accumulated as the total of ROI (Return on Investment), which is a common indication for the performance of an investment in financial world. Contributions of this thesis research are summarized as follow: Developed an automated trading system prototype, which provides a cornerstone for future development, and experimental platform for evaluating trading algorithms and programmed. Proposed some innovative trading algorithms based on trend following concepts. Provided an alternative view and comparative of two kinds of trading algorithms (Predictive model vs. Reactive model).

TABLE OF CONTENTS List of Figures... iii List of Tables... vi List of Abbreviations... vii Chapter 1: Introduction...1 1.1 Derivatives Market...4 1.2 Futures Contract...5 1.3 Technical Analysis...6 1.3.1 Moving Average...7 1.3.1.1 Simple Moving Average...7 1.3.1.2 Exponential Moving Average...8 1.3.2 Relative Strength Index...9 1.3.3 Momentum Oscillator...10 1.3.4 Stochastic Oscillator...11 Chapter 2: System Design...12 2.1 System Overview...12 2.2 Use Cases...14 2.3 Class Diagram...16 2.4 State Diagram...18 2.5 Sequence Diagram...21 2.6 Database Design...22 2.7 External Rationale...33 2.8 Interface Design...34 Chapter 3: Trend Following...38 3.1 Static Trend Following (algorithm 1)...38 3.2 Experimental Simulation 1...43 3.3 Dynamic Trend Following (algorithm 2)...44 3.4 Experimental Simulation 2...46 Chapter 4: Fuzzy Trend Following...48

4.1 Fuzzy Logic Trend Following (Algorithm 3)...48 4.2 Experimental Simulation 3...51 4.3 Fluctuation Examination...52 4.4 Fuzzy Logic Trend Following with Volatility (Algorithm 4)...55 4.5 Experimental Simulation 4...59 Chapter 5: Trend Recalling...62 5.1 Financial Cycle...64 5.2 Trend Recallling Past Strategies Algorithm (Algorithm 5)...66 5.2.1 Preprocessing...67 5.2.2 Selection...69 5.2.3 Verification...71 5.2.4 Confirmation...72 5.3 Experimental Simulation 5...75 Chapter 6: Conclusion...78 6.1 Summary of Results...80 6.2 Verification By Other Data Set...82 6.3 Comparison with Predictive Models...84 6.4 Evaluation of System Response Time...90 6.5 Summary of Contributions...91 References...93 ii

LIST OF FIGURES Number Page Figure 1: An idea of automated trading system...2 Figure 2: Example of simple moving average...8 Figure 3: Example of exponential moving average...9 Figure 4: Example of Relative Strength Index...10 Figure 5: Example of momentum index...10 Figure 6: Example of Stochastic Oscillator Index...11 Figure 7: System overview of the designed ATS...13 Figure 8: General functions of the automated trading system...15 Figure 9: Classes design of the automated trading system...17 Figure 10: General system state flow...18 Figure 11: Decision-making and ordering state flow...20 Figure 12: Typical system operations sequence...22 Figure 13: Database conceptual design ER diagram...23 Figure 14: Database design detail ER diagram...24 Figure 15: External linkage of the ATS to third party system...33 Figure 16: ATS main interface design...34 Figure 17: Example of the main user interface design...35 Figure 18: Manual trade UI design...35 Figure 19: Manual trade UI example...35 Figure 20: Example of real-time chart user interface...36 Figure 21: Example of historical chart user interface...37 Figure 22: Illustration of P and Q applied on trend T...39 Figure 23: P and Q applied on smoothed trend EMA(T)...40 Figure 24: P and Q value range determination...41 Figure 25: By holding the other value constant, it is possible to have multiple values of P and Q that generate good profits...42 Figure 26: Simulation trade of Algorithm 1 verifies on Hang Seng Index Futures...43 iii

Figure 27: Daily profit and loss distribution of Algorithm 1 simulation...43 Figure 28: Illustration of dynamic P & Q rules and criteria...45 Figure 29: Simulation of Algorithm 2 compare with Algorithm 1 on HSI Future...47 Figure 30: Daily profit and loss distribution of Algorithm 2 simulation...47 Figure 31: First input variable membership definition...49 Figure 32: Second input variable membership definition...49 Figure 33: Center of gravity defuzzification output membership definition...49 Figure 34: Simulation of Algorithm 3 compared with Algorithms 1 and 2...51 Figure 35: Daily profit and loss distribution of Algorithm 3 simulation...52 Figure 36: Example of simulated market trend with fluctuation control...54 Figure 37: Fluctuation test result...54 Figure 38: First input variable membership definition...56 Figure 39: Second input variable membership definition...57 Figure 40: Third input variable membership definition...57 Figure 41: Center of gravity defuzzification output membership definition...57 Figure 42: Simulation result of Algorithm 4 compares with Algorithm 3...59 Figure 43: Daily profit and loss distribution of Algorithm 4 simulation...59 Figure 44: Result of all Algorithms compare with Hang Seng Index performance...61 Figure 45: Performance update of pervious trading algorithms...63 Figure 46: Financial Cycle...64 Figure 47: Market trend movement...65 Figure 48: Chart of 2009-12-07 and 2008-01-31 intra-day price trend...65 Figure 49: Trend recalling algorithm processes illustration...67 Figure 50: Example of EDM and preprocessing applied on 2009-12-17 day trend...68 Figure 51: Example of selection in 2009-12-07 with best fitness sample...70 Figure 52: Fitness test applied on 2009-12-07 during the middle of trade session...71 Figure 53: Fuzzy volatility membership definition summary...73 Figure 54: Simulation trade of Algorithm 5 during the year of 2010...75 Figure 55: Daily profit and loss distribution of this simulation...76 Figure 56: Performance comparison to CTAs/Managed futures funds....76 Figure 57: Simulation of first four algorithms during the year of 2007 to 2009...80 iv

Figure 58: Simulation results of all trading algorithms during the year of 2010...81 Figure 59: Simulation of first four algorithms on H-Share during 2007 to 2009...82 Figure 60: Simulation result of all trading algorithms on H-Share in 2010...83 Figure 61: Predictive model simulation trade result on HSI futures in 2010...86 Figure 62: Daily profit and loss distribution of predictive model simulation trade...87 Figure 63: Predictive model overnight contract simulation trading...88 Figure 64: Daily profit and loss distribution of predictive model overnight contract...88 Figure 65: Predictive model compare with Reactive model (trend recalling)...89 v

LIST OF TABLES Number Page Table 1: Fluctuation test result data...55 Table 2: Simulation result data of all trading algorithms...60 Table 3: Average error ratio of these trading algorithms...61 Table 4: Summary of this trading algorithm performance...75 Table 5: CTAs/Managed funds performance data in the year of 2010...77 Table 6: Simulation result data of first four trading algorithms from 2007 to 2009...80 Table 7: Average error ratio of first four trading algorithms during the simulation...81 Table 8: Simulation results data of all trading algorithms in the year of 2010...81 Table 9: Average error ratio of all trading algorithms during simulation...82 Table 10: Result data of first four algorithms on H-Share from 2007 to 2009...83 Table 11: Average error ratio of first four trading algorithms in H-Share...83 Table 12: Simulation result data of all trading algorithms on H- Share in 2010...84 Table 13: Average error ratio of all trading algorithms in H-Share...84 Table 14: Accuracy of predictive model generate by Oracle Crystal Ball....85 Table 15: Simulation trade result data of predictive and reactive model...89 Table 16: System response time evaluation data...90 vi

LIST OF ABBREVIATIONS HKFE CBOT HSI P&L ROI SMA EMA RSI MTM STC MACD ETF ATS API ER UI FCL IB Hong Kong Futures Exchange Chicago Board of Trade Hang Seng Index Profit and Loss Return on Investment Simple Moving Average Exponential Moving Average Relative Strength Index Momentum Oscillator Stochastic Oscillator Moving Average Convergence Divergence Exchange Traded Funds Automated Trading System Application Programming Interface Entity Relationship User Interface Fuzzy Control Language Interactive Brokers vii

ACKNOWLEDGMENTS I am very grateful to my thesis supervisors, Dr. Simon Fong, who gave me a lot of encouragement and support. He always gave me valuable guidance and suggestions all the time. I would like to give thanks to Mr. Johnny Leong who gave me much technical support. Moreover, I would like to give my appreciation to Dr. Angus Wong for his advices and insightful comments. Finally, I would like to acknowledge my family and friends support during my thesis research. viii