OPTIMIZING STRATEGIES FOR VWAP BASED TRADING ALGORITHMS K.P.H.C. WIJETUNGE This Dissertation was Submitted to the Department of Computer Science and Engineering of the University of Moratuwa in Partial Fulfillment of the requirements for the Degree of MSc in Computer Science. Department of Computer Science and Engineering University of Moratuwa, Sri Lanka November/2008 ` i Declaration The work included in this report was done by me, and only by me, and the work has not been submitted for any other academic qualification at any institution Name : K.P.H.C. Wijetunge. Signature :____________________ Date :____________________ I certify that the declaration above by the candidate is true to the best of my knowledge and that this report is acceptable for evaluation for the CS6999 MSc Project Name of Supervisor : Dr. Sanath Jayasena. Signature :____________________ Date :____________________ Name of Supervisor : Dr. Sanith Wijesinghe. Signature :____________________ Date :____________________ ` ii Abstract In this thesis I propose optimization strategies to an existing VWAP algorithm. The report provides information on the extent of literature review done to acquire the knowledge required to complete the identified research. The content included provides a detailed overview of the algorithmic trading domain in general and then attempts to provide an insight in to VWAP algorithms and some basic concepts used in algorithmic trading. As the main research work I describe in detail the optimizations proposed and provide test results to justify my claims. The results were obtained through the tests carried out using back testing techniques on actual market data obtained from New York stock exchange. ` iii Acknowledgment I would like to acknowledge my research supervisors Dr. Sanith Wijesinghe and Dr. Sanath Jayasena who created the interest in me about algorithmic trading and then guided me on various aspects of real research work and encouraged me on making this project a success, amidst their really busy schedules. My sincere thanks must go to Prof. Gihan Dias and Mrs Vishaka Nanayakkara for the guidance and the inputs they gave in shaping my research work. In addition I would like to express my sincere gratitude to Mr. Hemantha Jayawardena the Chief Deployment Officer at MillenniumIT software Ltd, Sri Lanka, for permitting me to use MillenniumIT’s resources to complete my project. I also wish to thank all my managers and colleagues at my employer MillenniumIT Software Ltd., for being very flexible with me and supporting me on various ways in making this research project a reality. Finally, a big thank you to my parents, my wife and my sister who have been very supportive during this period. ` iv Table of Contents DECLARATION ....................................................................................................................................... I ABSTRACT...............................................................................................................................................II ACKNOWLEDGMENT........................................................................................................................ III TABLE OF CONTENTS ....................................................................................................................... IV LIST OF FIGURES................................................................................................................................ VI LIST OF TABLES.................................................................................................................................VII LIST OF ABBREVIATIONS................................................................................................................ IX CHAPTER 1 – INTRODUCTION ..........................................................................................................1 1.1 ALGORITHMIC TRADING - HOW IT WORKS.........................................................................................1 1.2 PROJECT OBJECTIVE ..........................................................................................................................3 1.3 MOTIVATION......................................................................................................................................4 1.4 COMPLEXITY OF THE RESEARCH .......................................................................................................4 1.5 PROJECT SCOPE ..................................................................................................................................5 1.6 DELIVERABLES ..................................................................................................................................5 1.7 RESOURCE REQUIREMENTS................................................................................................................6 CHAPTER 2 - LITERATURE REVIEW...............................................................................................7 2.1 INTRODUCTION TO THE DOMAIN .......................................................................................................7 2.1.1 Practical Usage of Trading Algorithms ...................................................................................7 2.1.2 Trading Algorithm Development Process ................................................................................8 2.1.3 Where algorithmic components fit in trade cycle ....................................................................9 2.2 REASONS FOR SELECTING A VWAP ALGORITHM............................................................................10 2.3 WHAT IS A VWAP ALGORITHM ......................................................................................................10 2.3.1 Overview .................................................................................................................................10 2.3.2 Technical explanation.............................................................................................................12 2.4 THE DEFINITION OF A TRADING STRATEGY ....................................................................................12 2.5 OTHER IMPORTANT CONCEPTS........................................................................................................13 2.5.1 Price Dynamics .......................................................................................................................13 2.5.2 Temporary Market Impact......................................................................................................14 2.5.3 Capture of Trading Trajectories.............................................................................................15 2.5.4 Market Capitalization .............................................................................................................15 2.5.5 Prediction Accuracy of a VWAP algorithm. ..........................................................................16 2.6 KEY TECHNIQUES USED...................................................................................................................16 2.6.1 Back Testing............................................................................................................................16 2.6.2 Principal component analysis (PCA) .....................................................................................16 CHAPTER 3 – TECHNICAL SPECIFICATION OF THE BASE ALGORITHM........................17 3.1 INTRODUCTION ................................................................................................................................17 3.2 EXAMPLE IMPLEMENTATION ...........................................................................................................17 CHAPTER 4 – METHODOLOGY & SOFTWARE TOOLS............................................................23 4.1 INTRODUCTION ................................................................................................................................23 4.2 DATA FORMATTING TOOL................................................................................................................25 4.3 ALGORITHM SIMULATOR.................................................................................................................25 4.3.1 Design and Usage ...................................................................................................................25 4.3.2 Modifications for Feedback strategy......................................................................................26 4.3.3 Modifications for Identification of optimum number of drips ...............................................26 4.4 GRAPH GENERATING SCRIPTS ..........................................................................................................27 CHAPTER 5 – EXPERIMENTS & RESULTS ...................................................................................28 5.1 INTRODUCTION ................................................................................................................................28 ` v 5.2 PROCEDURE FOR DETERMINING THE BEST ALGORITHM.................................................................29 5.3 FEEDBACK STRATEGY .....................................................................................................................30 5.3.1 Introduction.............................................................................................................................30 5.3.2 Test plan for establishing results for the Feed Back Strategy ...............................................32 5.3.2.1 Test Scenarios ......................................................................................................................32 5.3.2.2 Test plan for testing the Original Algorithm.......................................................................33 5.3.2.3 Test plan for establishing results for the algorithm with base feedback strategy: ............33 5.3.3. Results ....................................................................................................................................34 5.4 HEURISTICS TO IMPROVE PERFORMANCE OF THE BASE FEEDBACK STRATEGY. ..............................36 5.4.1 Introduction.............................................................................................................................36 5.4.2 Heuristic one ...........................................................................................................................36 5.4.2.1 Test plan for establishing results for the first Heuristic .....................................................37 5.4.2.2 Results ..................................................................................................................................37 5.4.3 Heuristic two ...........................................................................................................................39 5.4.3.1 Test plan for establishing results for the second Heuristic ................................................40 5.4.3.2 Results ..................................................................................................................................40 5.5 IDENTIFICATION OF THE OPTIMUM NUMBER OF DRIPS ...................................................................42 5.5.1 Introduction.............................................................................................................................42 5.5.2 Test plan for establishing results for Identification of optimum number of drips.................45 5.5.3 Results .....................................................................................................................................46 CHAPTER 6 – CONCLUSION .............................................................................................................50 REFERENCES.........................................................................................................................................52 APPENDIX A: FORECASTING THE VOLUME CURVE ..............................................................54 ` vi List of Figures . Figure 1 : GE trade volume for February 1st 2006......................................................18 Figure 2 : GE trade price and VWAP variation for February 1st 2006 .......................18 Figure 3 : GE cumulative trade volume for February 1st 2006 ...................................20 Figure 4 : Usage of software tools ...............................................................................24 Figure 5 : graphical representation of the best algorithm selection process ................30 Figure 6 : Variation in the VWAP achieved................................................................43 ` vii List of Tables Table 1 : Sample Results..............................................................................................21 Table 2 : Sample Values ..............................................................................................29 Table 3 : Test Cases for Testing Base feedback Strategy............................................33 Table 4 : Results for mid cap instruments when 20 days was used for testing............34 Table 5 : Results for high cap instruments when 20 days were used for testing .........34 Table 6 : Results for low cap instruments when 20 days were used for testing ..........34 Table 7 : Results for mid cap instruments when 10 days were used for testing ..........34 Table 8 : Results for high cap instruments when 10 days were used for testing .........35 Table 9 : Results for low cap instruments when 10 days were used for testing ..........35 Table 10 : Test cases for testing the first heuristic to improve the feedback strategy .37 Table 11 : Results for mid cap instruments when 10 days were used for testing ........37 Table 12 : Results for high cap instruments when 10 days were used for testing .......37 Table 13 : Results for low cap instruments when 10 days were used for testing ........38 Table 14 : Results for mid cap instruments when 20 days were used for testing ........38 Table 15 : Results for high cap instruments when 20 days were used for testing .......38 Table 16 : Results for low cap instruments when 20 days were used for testing ........38 Table 17 : Results for mid cap instruments when 30 days were used for testing ........38 Table 18 : Results for high cap instruments when 30 days were used for testing: ......39 Table 19 : Results for low cap instruments when 30 days were used for testing ........39 Table 20 : Test cases for second heuristic ...................................................................40 Table 21 : Results for low cap instruments when 20 days were used for testing ........40 Table 22 : Results for low cap instruments when 30 days were used for testing ........41 Table 23 : Results for low cap instruments when 10 days were used for testing ........41 Table 24 : Results for mid cap instruments when 10 days were used for testing ........41 Table 25 : Results for mid cap instruments when 20 days were used for testing ........41 Table 26 : Results for mid cap instruments when 30 days were used for testing ........41 Table 27 : Results for high cap instruments when 10 days were used for testing .......42 Table 28 : Results for high cap instruments when 30 days were used for testing .......42 Table 29 : Results for high cap instruments when 20 days were used for testing .......42 Table 30 : Results for high cap instruments when 10 days were used (size 10000000.) ......................................................................................................................................46 Table 31 : Results for mid cap instruments when 10 days were (size 10000000).......46 Table 32 : Results for low cap instruments when 10 days were (size 10000000). ......46 Table 33 : Results for high cap instruments when 20 days were used (size 10000000). ......................................................................................................................................46 Table 34 :Results for mid cap instruments when 20 days were used (size 10000000). ......................................................................................................................................46 Table 35 : Results for low cap instruments when 20 days were used (size 10000000). ......................................................................................................................................47 Table 36 : Results for low cap instruments when 20 days were used (size 10000000). ......................................................................................................................................47 Table 37 : Results for mid cap instruments when 30 days were used (size 10000000). ......................................................................................................................................47 Table 38 : Results for low cap instruments when 30 days were used (size 10000000). ......................................................................................................................................47 ` viii Table 39 Results for high cap instruments when 10 days were (size 1000000). ........47 Table 40 : Results for mid cap instruments when 10 days were used (size 1000000).48 Table 41 : Results for low cap instruments when 10 days were used (size 1000000).48 Table 42 : Results for high cap instruments when 20 days were used (size 1000000). ......................................................................................................................................48 Table 43 : Results for mid cap instruments when 20 days were used (size 1000000).48 Table 44 : Results for low cap instruments when 20 days were used (size 1000000).48 Table 45 : Results for high cap instruments when 30 days were used (size 1000000). ......................................................................................................................................49 Table 46 : Results for mid cap instruments when 30 days were used (size 1000000).49 Table 47 : Results for low cap instruments when 30 days were used (size 1000000).49 Table 48: PCA algorithm output..................................................................................55 ` ix List of Abbreviations VWAP - Volume Weighted Average Price NYSE - New York Stock Exchange PCA - Principle Component Analysis TAQ - Trade and Quote