Specification and Performance Optimisation of Real-Time Trading
Total Page:16
File Type:pdf, Size:1020Kb
Imperial College London Department of Computing Specification and Performance Optimisation of Real-time Trading Strategies for Betting Exchange Platforms Polyvios Tsirimpas Submitted in part fulfilment of the requirements for the degree of Doctor of Philosophy in Computing of Imperial College London and the Diploma of Imperial College, February 2015 I declare that this thesis was composed by me alone, and that the work that it presents is my own except where otherwise stated. The copyright of this thesis rests with the author and is made available under a Creative Commons Attribution Non-Commercial No Derivatives licence. Researchers are free to copy, distribute or transmit the thesis on the condition that they attribute it, that they do not use it for commercial purposes and that they do not alter, transform or build upon it. For any reuse or redistribution, researchers must make clear to others the licence terms of this work. i Abstract Since their introduction in June 2000, betting exchanges have revolutionised the nature and practice of betting. Betting exchange markets share some similarities with financial markets in terms of their operation. However, in stark contrast to financial markets, there are very few quantitative analysis tools available to support the development of automated betting exchange trading strategies. This thesis confronts challenges related to the generic specification, back-testing, optimisation and execution of parameterised automated trading strategies for betting exchange markets, and presents a related framework called SPORTSBET. The framework is built on an open-source event-driven platform called URBI, which, to date, has been mainly used to develop applications in the domains of robotics and artificial intelligence. SPORTSBET consists of three main components, each of which addresses a hitherto-unmet research challenge. The first is UBEL, a novel generic betting strategy specification language based on the event-driven scripting language of URBI, which can be used to specify parameterised betting strategies for markets related to a wide range of sports. The second is a complex event processor which is capable of synchronising multiple data streams and either replaying them on an historical basis with dynamic market re-construction, in order to quantify strategy performance, or executing them in real time with either real or virtual capital. The final component is an optimisation platform whereby strategy parameters are automatically refined using a stochastic search heuristic in order to improve strategy performance. Explicitly, the optimisation process involves stochastic initialisation, intermediate stochastic selection and acceptance of the candidate solution. To demonstrate the applicability and effectiveness of SPORTSBET, case studies are presented for betting strategies for a range of sports. As illustrated in the case studies, the SPORTSBET optimisation platform implements Walk-Forward Analysis for the robust parameterisation of betting exchange trading strategies without overfitting. Nonetheless, the outcomes should be carefully interpreted, while numerous tests of a strategy are recommended. ii Acknowledgements I would like to thank the following people, without whom this thesis would never have been possible: My supervisor, Dr William Knottenbelt, for his patience, inspiration, guidance and con- stant enthusiasm throughout my research. My family, for their love, support and encouragement. Rocio Alvarez for her constant support during my research. Tom Freeman and Tom Large from Betfair for their support throughout this research. Betfair for providing me with the funding to do my PhD. iii In most betting shops you will see three windows marked “Bet Here”, but only one window with the legend “Pay Out”. Jeffrey Bernard (1932-1997) iv Contents Declaration i Abstract ii Acknowledgements iii 1 Introduction 1 1.1Motivation....................................... 1 1.2 Aims and Objectives ................................. 5 1.3Contributions..................................... 6 1.4 Outline ......................................... 8 1.5 Statement of Originality and Publications ..................... 9 2 Background Theory 11 2.1IntroductiontoBettingMarkets........................... 11 2.1.1 HistoryofSportsBetting........................... 11 2.1.2 Bookmakermodel............................... 13 2.1.3 BettingExchangemodel........................... 16 2.2FinancialandBettingStrategies........................... 21 v vi CONTENTS 2.2.1 Arbitrage and Trading ............................ 22 2.2.2 Trading Systems ............................... 25 2.2.3 Trading Strategies . ........................... 27 2.2.4 The Trading Strategy Development Process ................ 30 2.3 Previous Research ................................... 31 2.3.1 F-TRADEcasestudy............................. 32 2.3.2 FinancialProgrammingLanguages..................... 33 2.4 Event-Driven Programming ............................. 34 2.4.1 Events..................................... 34 2.4.2 Event Stream Processing ........................... 36 2.4.3 Complex Event Processing .......................... 36 2.4.4 Event-driven Programming Languages ................... 37 2.5 Stochastic Optimisation ............................... 43 2.5.1 Overfitting................................... 45 2.5.2 Cross-Validation ............................... 45 3 UBEL: a Universal Betting Exchange Language 47 3.1UBELArchitecture.................................. 47 3.2UBELMotivationandBenefits........................... 48 3.2.1 TheNeedforaDSL............................. 48 3.2.2 DSLApproaches............................... 50 3.2.3 ComparisonwithXML............................ 51 3.3 UrbiScript Basic Features .............................. 53 CONTENTS vii 3.4 UBEL Implementation ................................ 58 3.4.1 Terminology .................................. 59 3.4.2 UBEL classes ................................. 59 3.4.3 UBEL’s Global objects ............................ 78 3.4.4 UBEL’sGlobalFunctions.......................... 78 3.5 Strategies examples . ................................. 83 4 SPORTSBET Architecture 86 4.1 Design philosophy of SPORTSBET ......................... 86 4.1.1 List of desired properties/utilities and their implications ......... 87 4.1.2 Desiredpropertiessolutions......................... 91 4.2SPORTSBETcomponents.............................. 91 4.3Bettingexchangemarketsimulator......................... 93 4.3.1 Complexity .................................. 93 4.3.2 SPORTSBETsynchronisationapproach.................. 95 4.3.3 Back-testingandSimulationchallenges................... 96 4.3.4 Bettingchallenges............................... 99 5 SPORTSBET Optimisation Platform 103 5.1Introduction......................................103 5.2SPORTSBETSearchMethod............................104 5.3 Objective Function ..................................109 5.4Walk-ForwardAnalysis................................110 viii CONTENTS 6 SPORTSBET: Third-Party Interface Integration and Implementation Issues114 6.1ExchangesAPI....................................114 6.2 SPORTSBET library to call Betfair services ....................117 6.3InferringEventDataandOutcome.........................120 6.4SPORTSBET’sUserInterface............................122 6.5SPORTSBETDatabase...............................133 7 Strategy Examples and Case Studies 136 7.1 Tennis Strategies ...................................136 7.1.1 Simple Trading ................................136 7.1.2 Lay the First Set Winner ...........................139 7.1.3 High Frequency Trading Strategy ......................142 7.2HorseRacingStrategies...............................146 7.2.1 Live Algorithmic Trading ...........................146 7.2.2 Simple Trading ................................149 7.2.3 Walk-ForwardAnalysis............................152 7.3FinancialStrategy..................................155 7.4FootballStrategies..................................159 7.4.1 BacktheHomeTeam.............................159 7.4.2 BacktheFavourite..............................161 7.4.3 LayTheDraw.................................162 7.4.4 AdvancedLayTheDraw...........................163 8 Conclusion 167 8.1 Summary of Achievements ..............................167 8.2FutureWork......................................169 A UBEL functions 171 A.1HedgingFunctions..................................171 A.2OddsControlfunctions ...............................174 A.3 Dutching functions ..................................175 A.4Executionfunctions..................................177 B Betfair API services and Price Increments 178 Bibliography 182 ix x List of Tables 2.1Overroundinbettingmodels............................. 19 2.2 Arbitrage opportunities between different betting providers in a single tennis match – no commission included ........................... 24 3.1 UrbiScript Variable Types .............................. 54 3.2 UrbiScript Time Operators .............................. 55 6.1BetfairAPIBasicServices..............................116 7.1 High frequency trading strategy results in tennis ..................143 7.2 Trading strategy results in tennis ..........................146 7.3 Horse racing algorithmic trading results .......................149 7.4 Horse racing algorithmic trading results .......................151 7.5Walk-ForwardEfficiency...............................153 7.6 Optimisation process of Time Windows 4 - 5 - 6 for a dutch horse racing trading strategy........................................154