scieee AI-readable full text Open interactive document viewer

A Trading Agent Framework Using Plain Strategies & Machine Learning

João Pedro Araújo Santos

Abstract

O mundo das mercados de apostas desportivas (trading) está em constante crescimento e com isso as pessoas estão a tentar melhorar os resultados do seu trading usando agentes automáticos de trading. Em analogia com os mercados financeiros, as operações de compra e venda são substituídas por apostas a favor e contra (Back and Lay respetivamente). Esta tese descreve uma framework para ser usada no desenvolvimento de agentes automáticos de trading nos mercados da Betfair, utilizando uma interface de programação escrita em Java. A Betfair processa mais de cinco milhões de transações diárias (como fazer uma aposta) que representa mais do que todas as trocas feitas nas bolsas de ações Europeias combinadas. A Betfair está disponível 24 horas por dia, 7 dias por semana. Neste trabalho foram desenvolvidos dois agentes de trading, DealerAgent e HorseLayAgent, de acordo com a framework supra mencionada. Os agentes mencionados atuam nos mercados "Para Ganhar" em corridas de cavalos do Reino Unido. Usam estratégias planas em conjunto com métodos de machine learning para melhorar os seus resultados de lucro/perda. Os agentes desenvolvidos foram submetidos a testes de viabilidade usando dados dos mercados "Para Ganhar" de corridas de cavalos do mercado de apostas Betfair, de Janeiro, Fevereiro e Maço de 2014.

Full text

FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO A Trading Agent Framework Using Plain Strategies & Machine Learning João Pedro Araújo Santos Mestrado Integrado em Engenharia Informática e Computação Supervisor: Ana Paula Rocha Co-supervisor: Rui Gonçalves July 18, 2014 A Trading Agent Framework Using Plain Strategies & Machine Learning João Pedro Araújo Santos Mestrado Integrado em Engenharia Informática e Computação Approved in oral examination by the committee: Chair: Doctor A. Augusto de Sousa External Examiner: Doctor Luís Paulo Reis Supervisor: Doctor Ana Paula Rocha July 18, 2014 Resumo O mundo das mercados de apostas desportivas (trading) está em constante crescimento e com isso as pessoas estão a tentar melhorar os resultados do seu trading usando agentes automáticos de trading. Em analogia com os mercados financeiros, as operações de compra e venda são substituídas por apostas a favor e contra (Back and Lay respetivamente). Esta tese descreve uma framework para ser usada no desenvolvimento de agentes automáticos de trading nos mercados da Betfair, utilizando uma interface de programação escrita em Java. A Betfair processa mais de cinco milhões de transações diárias (como fazer uma aposta) que representa mais do que todas as trocas feitas nas bolsas de ações Europeias combinadas. A Betfair está disponível 24 horas por dia, 7 dias por semana. Neste trabalho foram desenvolvidos dois agentes de trading, DealerAgent eHorseLayAgent, de acordo com a framework supra mencionada. Os agentes mencionados atuam nos mercados "Para Ganhar" em corridas de cavalos do Reino Unido. Usam estratégias planas em conjunto com métodos de machine learning para melhorar os seus resultados de lucro/perda. Os agentes desenvolvidos foram submetidos a testes de viabilidade usando dados dos mercados "Para Ganhar" de corridas de cavalos do mercado de apostas Betfair, de Janeiro, Fevereiro e Maço de 2014. i ii Abstract The world of online sports betting exchange (trading) is growing every day and with that people are trying to improve their trading by using automated trading. In analogy to the financial markets the buy and sell operations are replaced by betting for and against (Back and Lay). This thesis describes a framework to be used to develop automated trading agents at Betfair sports markets using a Java programming interface. Betfair processes more than five million transactions (such as placing a bet) every day which is more than all European stock exchanges combined. Betfair is available 24 hours a day 7 days a week. For this thesis were developed two trading agents, DealerAgent and HorseLayAgent, accordingly with the presented framework. The agents mentioned above act on To Win horse racing markets in United Kingdom. They use plain strategies together with machine learning methods to improve the profit/loss results. The developed agents were submitted to viability tests using data from Betfair To Win horse racing markets from January, February and March of 2014. iii iv Acknowledgements I would like to acknowledge the tireless effort made by Eng. Rui Gonçalves that, with its endless knowledge about online trading, helped me reaching the end of this journey. Also, Dra. Ana Paula Rocha had a very important role guiding me with her opinions and expertise in thesis development. Finally, I have to thank to my parents, sister and friends that always encouraged me to pursue my goals and be what I’ve always wanted to be, an Engineer. LIST OF TABLES xii Abbreviations API Application Programming Interface BF Betfair FEUP Engineering Faculty of Oporto University FPS Updates of prices (frames) per second GUI Graphical User Interface PL Profit/Loss SL Stoploss TS Trailing Stop WEKA Waikato Environment for Knowledge Analysis WOM Weight of Money xiii ABBREVIATIONS xiv Glossary Back Bet in favour of a selection (runner). Betting Exchange Entity that trade contracts on future events [FVN10]. Greenup Generate equal profit on all selections, regardless of the outcome [Sof05a]. In-Play The event has already started (is live) and not finished yet. Ladder Graphical interface used to trade that gives the trader an in depth perspective of the market [Tra14b]. Lay Bet against a selection (runner). Liquidity Quantity of money in circulation. Machine Learning A general inductive process that automatically builds an automatic text classifier by learning, from a set of preclassified documents, the characteristics of the categories of interest. [Seb02] Plain Strategy Strategy to be used for trading, by an agent, before implementing machine learning methods [Reb10]. A negative plain strategy is the one that has a predicted negative profit/loss results in long term. On the other hand, a positive one has a predicted positive profit/loss results. Runner One selection of the market. Stoploss Condition to minimize losses. Stopprofit Condition to establish a maximum profit. Trading Mechanism Buy and sell process after market forecasting. Weight of Money Quantity of money on each side (Back and Lay). Used to determine whether or not a price is going to lengthen or shorten. [Tra14a]. xv Chapter 1 Introduction Any person who is interested in sports events certainly also has his own opinions about the results, formations, moments of the game amongst others. And since it is this way, why not monetize this opinions and try to turn them profitable? This is the reason why there is now the online better (also called punter) concept. These are people available to invest some of their own money to, hopefully, have some profit with it. Usually, the greater the risk the greater the profit. Typically, a punter starts on a betting house like, the most known, Bwin [Lim14b], Betclic [Lim14a] amongst others. The bets made are called "simple bets" and are made against the house, where after an event analysis and the bet matched by the house, the better will have to wait until the end of the market (it could be football or tennis games, horse racing, etc.) to make a profit. What happens a lot of times with this kind of bets is that the punters can not predict events in a long term (e.g. final score of a game) and they can change their opinion during the game. Since they already placed a bet, they can only hope that the initial analysis is correct and that they profit from what they predicted even if it is against the event tendency. This led to appearence of online trading. Being a trader is like being an investor in the stock markets, but instead of betting in favor of a company they bet in favor of a team, a player, a horse, etc. As in any stock market, the price of the entity is always changing and being controlled by all the traders working on that market. In this case if you bet in favor of a team, for example to win, it means that someone else believed that the same team wouldn’t be able to win the game. In online trading, the bets are made against other traders instead of betting against the house as it happens in the "simple bets". By 2004, Betfair [Lim14d] was the world’s largest betting exchange, with more than 50,000 people placing bets each week on the many events the website features. Elections, major horse races, golf tournaments, and soccer matches inevitably trade more than 3,7 million Euros at a time. [DPSW05] It has the biggest traders base and it is where there is more money flowing than in any other betting exchange, like Betdaq [Int14]. In order to be a good trader in live events it is important to bo very fast, due to the fact that markets are always changing. It is also essential to use a good trading software as the ones described in 2.2 instead of a simple web interface, as it is the case of Betfair, where market updates 1 Introduction are considerably slower. If the trader wants an even faster way to trade, with the advantage of doing it automatically, the solution is automatic trading strategies (therefore called agents). These agents represent the trader on markets since they react to market changes in the way that he predifined, with a stable and well-defined set of preferences and actions depending on the clarity of the market [TZ88]. 1.1 Objectives The main goal of this thesis is to present a framework (chapter3) suitable for develop trading agents. This framework enables trading agents to improve the profit/loss results, by combining plain strategies together with machine learning methods. As a proof of concept, two examples of trading agents in horse races, are implemented and presented during this work. They were developed using the high level interface called JBet (section 2.2.5). This programming interface is written in Java and eases the development process of an agent, eliminating the direct communication layer with Betfair API’s at the same time that offers essential trading mechanisms that any good trader needs, such as trailing-stop, dutching, open trade, close trade, swing and scalping (section 2.1). The agents were submitted to several tests in different stages (defined on the framework) and both the results and conclusions are also presented in this thesis. 1.2 Problem Description Betfair betting exchange includes markets, e.g. tennis match or horse race. On each market there are runners, e.g. horses in a horse race. On runners the Back/Lay bets are placed. Back bet means that the runner will win, Lay bet that it will lose. Fig. 1.1 illustrates the classical view of a runner in the market. In the middle column at green is the price scale. The price can also be referred as odd. Bets are placed on a given price, which represents the chances of the runner win. E.g. the price 2.0 is a 50% of chances (1/2 = 0.5), price 1.01 is a 99% of chances (1/1.01 = 0.99), 1000 is a 0.1% of chances (1/1000 = 0.001). On the left side, next to the prices column, in pink is the amount column formed by the Lay bets. On the right side, the column in blue, next to the prices column, is the amount column formed by the Back bets. The first and fifth column represent our own unmatched bets. In this case (Fig. 1.1) we have the following bets placed (but not matched yet): • Lay of 10.00C at 4.30 (Lay [email protected]) • Back of 10.00C at 4.70 (Back [email protected]) • Back of 5.00C at 4.60 (Back [email protected]) The last column on the right, in gray, is the volume column which represents the amount matched at every price of the ladder since the market was open. If a bet is placed at a price that "the market" is willing to buy, the bet will be matched at the best price offered. For example, in the 2 Introduction market state of Fig. 1.1 if a Back bet [email protected] is placed (on the blue side) it will match [email protected] and [email protected] , and will leave the remaining [email protected] unmatched (waiting for someone to buy with a Lay bet). The traded volume information will be updated. This is how the prices move in the market. Since this bet was matched at two different prices, the global matched price of this bet can be calculated using equation 1.1. Figure 1.1: Ladder data example of a runner in the market [Lim14c] PriceAverage =∑n n=1(Pricen×Amountn) ∑n n=1(Amountn)(1.1) If a Back is placed above the best offer in the market (4.5 in Fig. 1.1), for example [email protected], it will stay in the market unmatched and, so for, waiting to be matched. The same happens to a Lay bet if it is placed at a lower price than the best offer (counter bet waiting to be matched). Only unmatched or partial unmatched bets can be canceled. The profit of a Back bet is calculated using equation 1.2 and the liability (in case of loss) of a Back bet is the amount of the bet itself. Pro fitBackBet =AmountBack ×(PriceBack −1)(1.2) The liability or amount in case of loss of a Lay bet is given by equation 1.3 and the profit is the amount of the bet itself. Basically the Lay is the "mirror" of Back. LiabilityLayBet =AmountLay ×(PriceLay −1)(1.3) Using combinations of Back/Lay it is possible to assure profit (or loss) before the end result of an event, using the price movement on the runner (odd variation). Example of a trade where it is not need to know end result of an event to have secure profit: 3 Introduction • Back of 2.00e at 2.12 (Back [email protected]) Matched • Lay of 2.00e at 2.10 (Lay [email protected]) Matched For a bet to be matched it must become the best offer in the market and it has to be purchased with a counter bet. When the runner is a winner, then the profit (Back bet) – loss (Lay bet) is: 2 × (2.12 - 1) – 2 × (2:10 - 1) = 2.24 × 2.20 = 0.04 When the runner is a looser, then the profit (Lay bet) – loss (Back bet) is: 2–2=0 Notice that if we have this kind of Back/Lay bet combination, on the same runner with the same amount at different prices, there will be profit (if the Back price is higher than the Lay price) or loss (if the Back price is lower than the Lay price) only if the runner in question wins the event. If any other runner wins the event and the combination of a Back/Lay bets have the same amount, the profit/loss will be 0. To distribute the profit/loss equal for all runners (outcomes) the amount of the bet used to close the trade must be recalculated. This process is called "do the greening" or "hedging". If a Back position is open on the market, the amount to close the position with the corresponded Lay bet is calculated using equation 1.4. CloseAmountLay =PriceOpenInBack PriceLayToClose ×AmountOpenInBack (1.4) If a Lay position is open on the market, the amount to close the position with the corresponded Back is calculated using equation 1.5. CloseAmountBack =PriceOpenInLay PriceBackToClose ×AmountOpenInLay (1.5) 1.3 Structure Besides the introduction, this report has 4 more chapters. In chapter 2the state of the art is approached with descriptions of trading tools, trading mechanisms and machine learning packages wich can be applied with the framework. Chapter 3describes the proposed trading agent framework, enhancing its main modules. In chapter 4it is shown the implementation of two trading agents in the horse racing scenario and in chapter 5it is presented the tests made and results that these two trading agents achieved. Finally, in chapter 6are presented some conclusions and pointed out directions to pursue in future work. 4 Chapter 2 State of the art In this chapter are presented, in 2.1, some well known trading mechanisms used by traders. In 2.2 are presented some existing tools that improve trading speeds at the same time that make available some of the trading mechanisms of 2.1. Finally, in 2.3, are presented and explained the machine learning packages wich can be used during the implementation of this work. 2.1 Trading Mechanisms Traders are constantly using trading mechanisms that represents a buy and sell process after market forecasting. The most common ones are Scalping, Swing, Trailing Stop and Dutching. The next sections will describe all of the already existent trading mechanisms and a new one with name Dealer. 2.1.1 Scalping Scalping is short term trading. A scalping trader looks to make lots of small profits, which in time add up. Scalping relies on lots of active participants in the market. Scalping works better in markets with high liquidity. The concept is simple, if a back bet is matched at a certain price, a lay bet must be placed right in the next lower price, or, if a lay bet is matched at a price a back bet must be placed right in the next higher price in the ladder to make profit. The profit/loss is equal to the difference, or spread, between the Back and Lay price. The Betfair betting exchange is an ideal place to trade in this way. Mainly in horse racing because there is high liquidity being matched in these markets, in particular just before the start of the race. Scalping the market means trading in the market tick by tick. One tick is one step in the prices scale of the ladder. For example if a Back at 2.12 is placed, one successful scalp will close the position with Lay at 2.10 (one tick down). If a trade starts with a back it means that the price was forecast to go down. If it is predicted to go up the scalp starts with a Lay bet. Figure 2.1 represents the state machine used to process one Back->Lay scalping (prediction for the prices to go down). One Lay->Back scalp will be a "mirror" of this state machine. The Price Back RequestPBR is the price where the agent enters the market. If the prices already 5 State of the art Both tennis and and soccer mathematical models offer traders a set of data and analysis that otherwise is impossible to get by just looking at the markets. Both offer a odd prediction model that tries to predict where odds will be if some events occur on the game. This way is possible to better assess the risk that trader is assuming even before making the bet. Of course this is only an indicative tool because is a prediction that may not be right. It is more of a guiding tool to help traders. Figures 2.8 and 2.9 present how the user interfaces for Soccer Mystic and Tennis trader are respectivly. Figure 2.8 is possible to see the odd prediction of match odds market when the Home team (Manchester United) scores the first goal of the game at minute 20th. It is possible to simulate up to 6 goals and see odd predictions on match odds, over/under, correct score and total goals markets. Figure 2.9 shows the functionality that enables a trader to check the probability that each of the players have to win the match (altough, it is possible to check the probability to win only the set). The column "Predicted Odds" ipresents the most interesting information as it tells the trader what the odds will be if any of the events described in the rows happens. This way the trader can focus his energies on trying to predict what will happen in the game, leaving the odd prediction to Bet Angel with this Tennis trader. Figure 2.6: Ladder interface of Bet Angel [Ang14] 12 State of the art Figure 2.7: Dutching interface of Bet Angel [Ang14] 2.2.4 BFExplorer The BFExplorer is not only a betting or trading platform for betfair, but also the platform that can be used to automate betting and trading systems. [Bel14a] The Bfexplorer PRO offers three types of user interface for bet placing, the market grid view similar to the user interface on betfair web pages (Figure 2.10), the selection list view (“ladder”) user interface for placing, updating and cancelling bets (Figure 2.11), and BFExplorer Trader for multi selection trading on the list view interface (Figure 2.11). After a bet is placed at betfair market, the selection where the bet was made is automatically added into the Watched selections window where it is possible to see the price/odds movement and traders’ current position. If the trader want to close the position (trade out with equal profit), simply click on Profit button, or on the Close position in the Watched Selections window. It is possible to monitor as many markets as the trader want, quickly switching among them through Watched Selection window or Market list. The application offers a set of Bet Wizards for placing bets when preset criteria are met, bet wizards for placing a bet and closing position, backing or laying all selections, back or lay dutching. As this application is used by traders, it offers trading strategies for any of mentioned user interface components and extensive bot script support both by built-in bots or customizable bot scripts. This unique feature allows the trader to write their own bot scripts in Visual Basic or 13 State of the art Figure 2.8: Soccer Mystic interface of Bet Angel [Tra12] C# programming languages. For users who are not familiar with any programming language the Bfexplorer offers a Bot Executor with Bot Criteria Editor which can be used to setup different scenarios for bet placing or trading by utilizing all offered bots (including customize bots). Such bot criteria is then used on the selection when needed, just by clicking on the start bot toolbar button or for fully automated solutions which can run on the Trade Opportunity Lookup service. The application supports the Excel automation as well. Bfexplorer offers any available information the trader can get from betfair, presenting the market data on charts where is possible to see the price/odds movement and weight of money in time, traded and available volume and market statistics. [Bel14b] 2.2.5 JBet JBet is a state of the art Java software framework developed at Department of Informatics Engineering in School of Engineering, Porto University (FEUP) used to create trading agents for betfair. JBet is the base software on wich this work was developed. It is a complex and powerful set of function calls to Betfair API in Java. JBet allows developers to interact with Betfair in a higher level making possible to develop agents without too much effort. JBet has already some trading mechanisms implemented. Each trading mechanism inside JBet is a set of predefined actions that 14 State of the art Figure 2.9: Tennis trader interface of Bet Angel [Ang14] Figure 2.10: Guided user interface of BFExplorer, simple betting [Bel14a] 15 State of the art Figure 2.11: Ladder interface of BFExplorer, multiple selections [Bel14a] should happen when it is triggered, independently of the market on wich it is used. The trading mechanisms already developed are the following: • Open • Close • Swing • Dutching • Trailing-stop • Scalping The working principles of each one of these trading mechanisms are detailed at 2.1. The innovation present at this piece of software is that it creates a high-level interface in Java for users to develop their own agents, without having to handle and know Betfair API from scratch. JBet also includes a simulation mode to test agents. At the moment there is not a user friendly GUI available, manily because this library is intended to be used by programmers that are comfortable with Java language, altough there is a ladder with read-only purposes to maintain track of trades created by agents. An example of this ladder is shown in figure B.1. For this thesis, JBet was extended with a new trading mechanism (Dealer of section 2.1.5) using the existent interfaces. 16 State of the art 2.2.6 Comparison Programming Interface Expansion Capability (Flexibility) Replay Simulation Mode Documentation Market Feeder Pro Proprietary scripting language Medium True Weak Good Gruss Bet Excel Medium False False Medium Bet Angel Excel/Triggers Weak False Weak Good BF Explorer Visual Studio Good False Weak Good JBet Java Good True Good Weak Table 2.1: Comparison between trading softwares Table 2.1 presents the most important features to be compared among the trading tools described in previous section. These features include the existence of a programming interface, expansion capability of each of the softwares compared, replay capacity, simulation mode and documentation. Concerning the programming interface, each software has it own programming interface. The most robust are JBet and BFExplorer because offer the possibility to use a real programming language with a lot of documentation, Java by JBet and Visual Basic and C# by BFExplorer. MarketFeeder Pro offers a proprietary scripting language and Gruss Bet and Bet Angel only offers the possibility to create triggers using Excel spresdsheets. Only BFExplorer and JBet are truly flexible allowing anyone to develop it’s own trading agents with the advantage for JBet that the most important trading mechanisms are already developed and ready to be used, like scalping, dutching, swing among others, explained in section 2.1. Regarding replay capacity, the clear winner is JBet as it allows to have limitless replay allowing this way to test strategies with unlimited past data for better future predictions. MarketFeeder Pro also have a replay functionality but is somewhat limited. It is called TimeWarp and only allows to replay with a limited ladder leaving some action on markets outside (Betfair log files). Only GrussBet has no simulation mode, but only JBet does this simulation the way it is supposed to be. Other softwares simulation modes do not account for market liquidity. This means that if someone is using simulation mode at, for example BF Explorer, and place a back bet with 500eit will be matched even if only 10eare available on market to match that back bet. So, simulation on this softwares are for purely test plain strategies with low value stakes. On the opposite side, JBet does this the right way. Using the 500eback bet example, only 10ewill be matched and the remaining 490ewill continue waiting to be matched. This way, it is not only possible to test plain strategies, but also the evolution of that strategies with increasing stakes and assess if it a short or long term strategy. Documentation is good in all softwares but JBet. It is a product in development and documentation needs more work because can be a little difficult to start programming using JBet and not have a way to know how it works. All other softwares have a reasonably good documentation. 17 State of the art 2.3 Machine Learning Packages This thesis uses machine learning techniques in order to optimize the results of the trading agents developed using the JBet interface described in 2.2.5. There are many machine learning software available in the market and the well known are probably RapidMiner created by the company with the same name [Rap14], WEKA (Waikato Environment for Knowledge Analysis) developed by Waikato University in New Zeland [Uni14b] and Encog made by Heaton Research [Res13]. Due to the documentation availability, ease of use with a very intuitive interface for model creation, model quantity to be used and export of these models for later integration in JBet code already developed by its creators (Department of Informatics Engineering in School of Engineering, Porto University) the choice for this thesis was the RapidMiner software. Anyway, every model developed during this work using RapidMiner can also be created in any other machine learning software with an adaptation of the exported model for integration with JBet. In this work, it is only consedered supervising learning, wich is a kind of learning that is done through the analysis of historical data. The historical data includes a set of examples (by now called ExampleSet). Each example contains a situation or input (described by a set of attributes) and the associated result or output (the class to be learned). Next paragraphs describe some of the existing supervising learning models included in the Rapid Miner software, suitable to be used in the optimization of the results of the trading agents considered in this work. It is important to mention that the description of the classifiers was taken from [AH12]. Decision Tree Generates a Decision Tree for classification of both nominal and numerical data. A decision tree is a tree-like graph or model. It is more like an inverted tree because it has its root at the top and it grows downwards. This representation of the data has the advantage compared with other approaches of being meaningful and easy to interpret. The goal is to create a classification model that predicts the value of a target attribute (often called class or label) based on several input attributes of the ExampleSet. In RapidMiner an attribute with label role is predicted by the Decision Tree operator. Each interior node of tree corresponds to one of the input attributes. The number of edges of a nominal interior node is equal to the number of possible values of the corresponding input attribute. Outgoing edges of numerical attributes are labeled with disjoint ranges. Each leaf node represents a value of the label attribute given the values of the input attributes represented by the path from the root to the leaf. Decision Trees are generated by recursive partitioning. Recursive partitioning means repeatedly splitting on the values of attributes. In every recursion the algorithm follows the following steps: 18 State of the art • An attribute A is selected to split on. Making a good choice of attributes to split on each stage is crucial to generation of a useful tree. The attribute is chosen depending upon a selection criterion usually based on the statistically significance of the attribute. • Examples in the ExampleSet are sorted into subsets, one for each value of the attribute A in case of a nominal attribute. In case of numerical attributes, subsets are formed for disjoint ranges of attribute values. • A tree is returned with one edge or branch for each subset. Each branch has a descendant subtree or a label value produced by applying the same algorithm recursively. In general, the recursion stops when all the examples or instances have the same label value, i.e. the subset is pure. Or recursion may stop if most of the examples are of the same label value. This is a generalization of the first approach; with some error threshold. However other halting conditions can be considered, such as: • There are less than a certain number of instances or examples in the current subtree. This can be adjusted by using the minimal size for split parameter. • No attribute reaches a certain threshold. This can be adjusted by using the minimum gain parameter. • The maximal depth is reached. This can be adjusted by using the maximal depth parameter. Pruning is a technique in which leaf nodes that do not add nothing significantly meaningful to the discriminative power of the decision tree are removed. This is done to convert an over-specific or over-fitted tree to a more general form in order to enhance its predictive power on unseen datasets. Pre-pruning is a type of pruning performed parallel to the tree creation process. Post-pruning, on the other hand, is done after the tree creation process is complete. Random Forest This operator generates a set of a specified number of random trees i.e. called a random forest. The resulting model is a voting model of all the trees. The representation of the data in form of a tree has the advantage compared with other approaches of being meaningful and easy to interpret. Each interior node of the tree corresponds to one of the input attributes. The number of edges of a nominal interior node is equal to the number of possible values of the corresponding input attribute. Outgoing edges of numerical attributes are labeled with disjoint ranges. Each leaf node represents a value of the label attribute given the values of the input attributes represented by the path from the root to the leaf. 19 State of the art Rule Induction This operator learns a pruned set of rules with respect to the information gain from a given set of examples (ExampleSet). The Rule Induction operator works similar to the propositional rule learner named ’Repeated Incremental Pruning to Produce Error Reduction’ [Coh95]. Starting with the less prevalent classes, the algorithm iteratively grows and prunes rules until no positive examples are left or the error rate is greater than 50%. Rule Set learners are often compared to Decision Tree learners. Rule Sets have the advantage to be easier to understand, representable in first order logic (easy to implement in languages like Prolog) and prior knowledge can be added easily. The major disadvantages of Rule Sets were that they scaled poorly with training set size and had problems with noisy data. The RIPPER algorithm (which this operator implements) pretty much overcomes these disadvantages. The major problem with Decision Trees is overfitting i.e. the model works very well on the training set but does not perform well on the validation set. Reduced Error Pruning (REP) is a technique that tries to overcome overfitting. After various improvements and enhancements over the period of time REP changed to IREP, IREP* and RIPPER. This operator uses two phases: the growing phase and the prunning phase. In the growing phase, for each rule greedily conditions are added to the rule until it is perfect (i.e. 100% accurate). The procedure tries every possible value of each attribute and selects the condition with highest information gain. In the prune phase, for each rule any final sequences of the antecedents is pruned with the pruning metric p/(p+n). k-Nearest Neighbor This operator generates a k-Nearest Neighbor model from the input ExampleSet. This model can be a classification or regression model depending on the input ExampleSet. The k-Nearest Neighbor algorithm is based on learning by analogy, that is, by comparing a given test example with training examples that are similar to it. The training examples are described by n attributes. Each example represents a point in an n-dimensional space. In this way, all of the training examples are stored in an n-dimensional pattern space. When an unknown example is given, a k-nearest neighbor algorithm searches the pattern space for the k training examples that are closest to the unknown example. These k training examples are the k "nearest neighbors" of the unknown example. "Closeness" is defined in terms of a distance metric, such as the Euclidean distance. The k-nearest neighbor algorithm is amongst the simplest of all machine learning algorithms: an example is classified by a majority vote of its neighbors, with the example being assigned to the class most common amongst its k nearest neighbors (k is a positive integer, typically small). If k = 1, then the example is simply assigned to the class of its nearest neighbor.The same method can be used for regression, by simply assigning the label value for the example to be the average of the values of its k nearest neighbors. It can be useful to weight the contributions of the neighbors, so that the nearer neighbors contribute more to the average than the more distant ones. 20 State of the art The neighbors are taken from a set of examples for which the correct classification (or, in the case of regression, the value of the label) is known. This can be thought of as the training set for the algorithm, though no explicit training step is required. The basic k-Nearest Neighbor algorithm is composed of two steps: Find the k training examples that are closest to the unseen example and take the most commonly occurring classification for these k examples (or, in the case of regression, take the average of these k label values). Naive Bayes This operator generates a Naive Bayes classification model. A Naive Bayes classifier is a simple probabilistic classifier based on applying Bayes’ theorem (from Bayesian statistics) with strong (naive) independence assumptions. A more descriptive term for the underlying probability model would be ’independent feature model’. In simple terms, a Naive Bayes classifier assumes that the presence (or absence) of a particular feature of a class (described by an attribute) is unrelated to the presence (or absence) of any other feature. For example, a fruit may be considered to be an apple if it is red, round, and about 4 inches in diameter. Even if these features depend on each other or upon the existence of the other features, a Naive Bayes classifier considers all of these properties to independently contribute to the probability that this fruit is an apple. The advantage of the Naive Bayes classifier is that it only requires a small amount of training data to estimate the means and variances of the variables necessary for classification. Because independent variables are assumed, only the variances of the variables for each label need to be determined and not the entire covariance matrix. Neural Net This operator learns a model by means of a feed-forward neural network trained by a back propagation algorithm (multi-layer perceptron). This operator cannot handle polynominal attributes. The coming paragraphs explain the basic ideas about neural networks, need-forward neural networks, back-propagation and multi-layer perceptron. An artificial neural network (ANN), usually called neural network (NN), is a mathematical model or computational model that is inspired by the structure and functional aspects of biological neural networks. A neural network consists of an interconnected group of artificial neurons, and it processes information using a connectionist approach to computation (the central connectionist principle is that mental phenomena can be described by interconnected networks of simple and often uniform units). In most cases an ANN is an adaptive system that changes its structure based on external or internal information that flows through the network during the learning phase. Modern neural networks are usually used to model complex relationships between inputs and outputs or to find patterns in data. 21 Framework 28 Chapter 4 Implementation In this secion will be explained how two trading agents that follows the framework presented in section 3were implemented using JBet. Also, to create them, was necessary to develop a new trading mechanism that extend JBet functionalities, whose implementation will also be described. 4.1 Dealer Agent According to Oxford Dictionary, a dealer is "a person who buys and sells goods" [Uni14a]. The first and most common synonym for "dealer" is trader. So in this context, we can assume that every trader that work on Betfair and other beting exchanges are dealers. This is true, regardless of the nature of the trader, wether it be a person or an automated trading mechanism. From the market perspective, everyone is an entity that open and close positions (buy and sell) and its nature is not relevant. 4.1.1 The Plain Strategy Stage The implemented agent follows a plain strategy for pre-live horse racing. It tries to take advantage of the market fluctuations (around an axisOdd) before each race start, placing a back and a lay simultaneously, and try to close with profit by matching both in a time frame. If it is not successful, a stoploss will be triggered and will try to close with loss at best price available. When agent is running, it will enter on horse races with more than 4 horses and at least one of that horses has the odd above 6.0 and lower than 12.0. These are horses that are not favourites to win the race, but at the same time have a suitable liquidity to be traded on. When remaining time to the start of the race is less than 5 minutes, the agent will create a dealer for each one of the horses filtered before. To create a dealer agent with JBet, that followed the principles described in section 2.1.5, it was necessary to create a trading mechanism inside JBet that followed those rules. This allows that, from now on, every JBet agent can use a dealer by simply invocate that trading mechanism not being dependent of the plain strategy and markets where it is used used, wether it be for horses, football, car racings, etc. 29 Implementation Figure 4.1: Class structure of dealer trading mechanism In Appendix A, figure A.1 shows the DealerAgent GUI with statistics fields resulting from the execution of one trading mechanism dealer. 4.1.2 Trading Mechanism Dealer The trading mechanism dealer is a set of predifined actions that, when invocated, will make a back and a lay bet simultaneously in different odds. This trading mechanism will then wait that both bets are matched to return a profit. In the case that market has a upward or downward tendency (making it impossible to match both bets), dealer will then trigger a stoploss condition to avoid biggers losses. As any other trading mechinism in JBet, dealer has 3 classes where everything is implemented. Figure 4.1 shows the class structure of the dealer trading mechanism and names of the three classes created. DealerOptions.java This class implements all the parameters needed to invoke a dealer. DealerPanel.java This class implements a graphical user interface to be invoked by agents that use the trading mechanism dealer. It is used JSwing to create JLabel’s and JComboBox’es allowing users to easily define DealerOptions.java parameters. If the implemented agent defines itself DealerOptions.java paramenters, it is not necessary to invoke DealerPanel.java. 30 Implementation Dealer.java This class implements all the dealer logic, creating necessary open and closing positions. This class extends the superclass TradeMechanism.java and manages all the listeners subscriptions that implement the TradeMechanismListener.java interface, following an event based architecture for the Dealer process (or mechanism). The parameters available to define the DealerOptions.java are shown in listing 4.1 and explained in detail in the next paragraphs.. 1private double stake; 2private double axisOdd; 3private int ticksBackProfit; 4private int ticksLayProfit; 5private int ticksLossBack; 6private int ticksLossLay; 7private int backOrLayStake; 8private double percentageOpen; 9private boolean insistOpen; 10 private boolean useIpKeep; 11 private int waitFramesOpen; 12 private int waitFramesBestPrice; 13 private boolean forceCloseOnStopLoss; 14 private boolean useStopProfifInBestPrice; 15 private boolean goOnfrontInBestPrice; 16 private int delayIgnoreStopLoss; 17 private int waitFramesLay1000; Listing 4.1: DealerOptions.java parameters available The trading mechanism dealer will use the values of each of these parameters to act on the market chosen by the agent and it is mandatory that all parameters have a value assigned for correct execution of the dealer. To prevent failures, all parameters have a default value. These default values represent the most common choice, although it is recommended to modify them to ensure that dealer will execute according to the will of the trader. Stake is the amount of money that dealer will use to open a position on market. As it will open two positions at the same time, the stake value will be used to open the position defined at backOrLayStake that can be a BetData.back or a BetData.lay. If the agent defines that the stake is to be used with a back, the lay stake will be calculated depending on the odds chosen (see equation 1.4). The odds to open positions are calculated using ticksBackProfit,ticksLayProfit and axisOdd parameters. Usually, axisOdd is the odd available at that moment to bet on and it is always updating to reflect market immediatly available odd. Using this odd, dealer will then calculate the odds to open positions using ticksBackProfit and ticksLayProfit. As an example, if axisOdd is 1.68 and ticksBackProfit and ticksLayProfit have a value of 1, dealer will open two positions at the same 31 Implementation time backing at 1.69 and laying at 1.67. This means that if the trade is successful and both postions are matched, the agent will have 2 ticks of profit. As a security measure, this trading mechaninsm also implements a stoploss functionality. ticksLossBack and ticksLossLay represent the ticks to wait until trigger the stoploss. Using the previous example, and assuming that both ticksLossBack and ticksLossLay have a value of 2, after backing and laying at 1.69 and 1.67 respectively, dealer will maintain the odds 1.71 and 1.65 in memory. If the market is in uptrend and reaches 1.71 before matching the lay bet at 1.67 it will trigger a stoploss cancelling the lay bet at 1.67 and opening a new lay, with recalculated stake, at market best price, returning in a loss for the agent. This works also if the market is in dowtrend and its mechanism is similar, but dealer will cancel the unmatched back position and will open a new one at best price. The percentageOpen parameter, by default 1.0, represents the required percentage to close the trade after the initial bet is matched. For example, if percentageOpen is set to 0.5, when the agent starts a trade and half of the stake is matched, it will move on to the next phase of the dealer. The insistOpen parameter is used if trader wants the agent to insist open a position even if the market is suspended. When the market reactivates, the agent will continue trying to open the previous unmatched position. The useIPKeep parameter is similar to the previous one, and if set to true, the agent will keep the bets even if the market turns in-play. By default, when a race starts (turn in-play), all the bets are cancelled. The waitFramesOpen and waitFramesBestPrice are the parameters that control the time to wait to match positions. When a trade is started, the two positions waiting to be matched will wait until the value waitFramesOpen be reached. This value represents the number of frames (updates of prices from the market, for this agent, 2 FPS) passed since the trade was started. When in need to close at best price, and in the same way as before, that position will wait the number of frames represented by waitFramesBestPrice. After the waitFramesBestPrice timeout, the trade mechanism will close where there is money available on the ladder. It is important to mention that when the agent starts a trade and the waitFramesOpen time is reached before one of the bets are matched, both are cancelled and it will not enter the market. The parameter forceCloseOnStopLoss is used when a stoploss condition is reached and in that case, agent will not try to close at best price and will close where there is money available to close the position. This parameter allows for faster closings in case of loss but with a penalty of at least one tick on the ladder since it does not use waitFramesBestPrice time. The parameter useStopProfitInBestPrice is useful for volatile markets. If the agent is in state of closing at best price and this parameter is set to true, it will always close that position on the original price requested. Even if the price changes to a better one when trying to close at best price, the agent will maintain the original one. This allows faster closings shortening the exposure time on market with the risk of loosing potential profit if the market is in favor of the agent forecasting. goOnFrontInBestPrice is also responsible for shortening the exposure time but in a different way. If the agent is in the state of closing at best price, and goOnFrontInBestPrice is set to true, the agent will close one tick below the immediate best offered price and not behind other best offers. 32 Implementation With the parameter delayIgnoreStopLoss different than 0 (by default delayIgnoreStopLoss = 0), from the moment where a position is opened, the agent will ignore the stoploss functionality for the number of frames defined, with the objective of waiting for market stabilization. If the market has an extremely low liquidity (e.g. market goes in-play and all the bets are cancelled), it is important to ignore stoploss until the market stabilizes (the liquidity fills again). Finally, when a result becomes impossible, the agent will wait the number of frames defined by waitFramesLay1000 to try to close in the worst price of the ladder (1000). The probability of closing here is extremely low so after this time the agent assumes the loss. 4.1.3 Machine Learning Stage Having already the plain strategy phase completed, with all the parameter optimization and refinement possible, is now the moment of apply the Machine Learning process. The start of this phase, as described in figure 3.1, its the creation of data for the model (train and test evaluation). This data is created from the executions on simulation mode of DealerAgent while plain strategy. In the end of each execution of each trading mechanism dealer, it is created one example for the model. The DealerAgent runs many trading mechanisms (one for each filtered horse on each race) that creates a set of examples. The data to be created is represented on listing 4.2. 1private double matchedAtStartMoment; 2private int runners; 3private double womDiffAtStartMoment; 4private double demandAtStartMoment; 5private double percentDiffBack; 6private double percentDiffLay; 7private boolean profit; Listing 4.2: Fields of the dataset to be created to use in model train and test of DealerAgent The values of 4.2 were chosen for model creation because they are the ones that better represent the market and it is with them that the model will choose to enter or not - run the dealer trading mechanism or not, for that horse. The market liquidity, represented by matchedAtStartMoment, is the total money traded on the runner. The lower this value get, there will be less market fluctuations. The number of horses in race, represented by int runners, is important to evaluate on wich race types there are better results. These two values (matchedatStartMoment and runners) are directly extracted from market without any kind of post-processing. On the contrary, all values presented in this paragraph are the result of post-processing some of the atomic market values. The first one to be calculated is the weight of money difference of market - womDiffAtStartMoment. To get to this value it is simply calculated the difference of weight of money between the present and a near past represented by 30 frames of market. The line of code where this calculation happens is represented in listing 4.3 33 Implementation 1ri.womDifAtStartMoment = Utils.getAmountBackFrame(rdAux, 30) - 2Utils.getAmountLayFrame(rdAux, 0); Listing 4.3: Calculation of weight of money difference The demandAtStartMoment represents the difference of demand between the moment a dealer is started and 30 frames in the past. Theorically, if the demand is greater in present than in the past, the market tendency is a downward one because there are more entities offering money than the ones accepting it. In the case of the demand be smaller in the present than it was in the past, the market has an upward tendency. The ideal range for this value is near zero, point where the market will be stabilized favouring the matching of both bets made at start of a trading mechanism dealer. The calculation of demandAtStartMoment is presented in listing 4.4 1ri.demandAtStartMoment = UtilsCollectData.getAmountMatchedVariationAVGAxisWindow 2(rdAux, 0, 30, 3); Listing 4.4: Calculation of demand at start moment The values percentDiffBack and percentDiffLay are representative of the existence of a support at immediatly next available odd where the dealer has started. This values represent a percentage in relation to the available amount waiting to be matched at the next odd relative to where dealer opened positions. In the case of the value of percentDiffBack be grater than 1.0, there is more money available on the next odd than in the odd where the bet was made. This evaluation is important because it represent a possible pressure point meaning that the prices could possible not pass that odd, avoiding the triggering of stoploss. Obviously, both percentageDifffBack and percentageDiffLay represents the support on the back and lay bets made by the dealer. Their calculation is made by the code in listing 4.5. 1double amountBackN=Utils.getAmountBackOddFrame(rdAux, oddBackN, 0); 2double amountLayN=Utils.getAmountLayOddFrame(rdAux, oddLayN, 0); 3 4double amountBack=Utils.getAmountBackOddFrame(rdAux, oddBack, 0); 5double amountLay=Utils.getAmountLayOddFrame(rdAux, oddLay, 0); 6 7double percentLay=(amountLay/amountLayN)*100.; 8double percentBack=(amountBack/amountBackN)*100.; Listing 4.5: percentageDiffBack and percentageDiffLay calculation The last value will be the target/label/output field for the machine learning model and it represents the success or insuccess of a trading mechanism dealer execution. It is a boolean that represents if there was profit on that dealer execution. In the case of the final profit, in euros, is equal or greater than zero, the boolean profit will assume the value true. 34 Implementation The listing 4.6 represents an example of a .csv file generated by DealerAgent. Each line represents one execution of a trading mechanism dealer. In one race could be executed several trading mechanism dealers depending on the number of horses with odds between 6.0 and 12.0, five minutes before the start of the race. However, it is created only one dealer in each eligible horse. 128989.22 10 96.38000000000001 -16.419833333333326 148.73555020653174 11.937690348993959 true 225662.33 10 -105.44 -4.901000000000015 14.099754267118284 26.89237334959133 true 322386.25 10 48.67999999999999 -27.237666666666666 14.335539613966947 213.80622837370242 true 44724.06 15 -7.669999999999998 0.054333333333333185 13.032015065913372 6.583419253828235 true 510091.13 15 -52.32 -1.4748333333333326 266.72705314009664 288.51617995264405 false 67024.83 6 31.909999999999997 -3.585999999999999 56.50704225352112 24.201286107992242 true 77542.65 6 -1.6799999999999926 -2.401333333333333 115.11207060765763 103.48107285524063 false 810112.96 6 1.6500000000000057 1.5066666666666673 106.53774089935762 318.1999501371229 false 92974.01 12 -7.08 -0.014166666666667046 102.56410256410258 164.03508771929828 true 10 5635.24 12 17.029999999999998 -0.4661666666666671 222.23816355810618 48.68701206529454 false 11 10283.04 9 -63.48000000000002 -3.9181666666666692 562.1270857913366 120.09025010801209 false Listing 4.6: File generated by a DealerAgent execution with values to use in train and test of model After the creation of data is completed, they are divided in two parts: one for training and other for testing and refining the model. In DealerAgent concrete case, the generated data represent 3 months of horse races that are divided in two months for training and one month for testing (January and February of 2014 for training and March of 2014 for testing). It is then loaded the training data to RapidMiner software. Figure 4.2 represents the loading of a part of the training data. The learning process of model was created using the scheme shown in figure 4.3. It was created this way, with all datamining classifiers suitable for use (accepting numerical input and nominal output). The classifier used in this example was Rule Induction as we can see in image 4.3. With the RapidMiner process created and the training data prepared, it is time for training the model. The results are presented in figure 4.4 and are a set of rules that the generated model will use at the time of testing the data. The test process is presented in figure 4.5. The table 4.1 represents the final values, obtained in phase "refinement of hyperparameters" of the framework, that are used to train the machine learning model, that uses a Rule Induction classifier. 35 Implementation Figure 4.2: Portion of the data to train the machine learning model in RapidMiner Figure 4.3: Learn process created in RapidMiner 36 Implementation Figure 4.4: Rules generated as result of the learning process of model in RapidMiner Figure 4.5: Testing process created in RapidMiner 37 Testing and Results Figure 5.1: Dealer Agent results with plain strategy (without model) for entire month of March of 2014 Figure 5.2: Dealer Agent results with rule induction classifier for entire month of March of 2014 (train set: January and February of 2014) 44 Testing and Results 5.2 Horse Lay Agent In section 4.2 was explained in wich way the empirical refinement of parameters was taking place, executing one agent for each possible odd combination and in the end select those with the best results. In figure 5.3 is possible to see an example of one combination that was a total failure. The image title is "2-3", wich means that were made lays at odd 2 in horses that in the start of the race had an odd of above 3. At the final of the test period, is possible to verify that this agent had a loss of about 150ewith stakes of 10e, that represents a considerable amount of loss for the time period tested (between 15 and 30 of January 2014). Furthermore, is possible to observe in the graphic that, although there is a positive peak in the beginning, the long term tendecy will be negative and for that reason is imperative to discard this agent. In images 5.4 and 5.5 is possible to observe the selected agents according to their results. The red line represents the execution of the agent only with the plain strategy and the blue line represents the same agent but this time with the aplication of the model on top of the plain strategy. The first note to take from images 5.4 and 5.5 is that with model the results improved. This happens because the agent always asks to model if it should enter a race or not and in races that the model think that will not have profit, its answer is negative, avoiding some potential loss. In both cases (5.4 and 5.5) the horses where the lays were made were clearly not favourites to win that race, with strating odds above 6, but in some moment of the race won advantage over other competitors and the lays made were matched. Is also important to mention that in both cases, the agents with only the plain strategy without the model (red lines), the results in the end of the testing were near zero profit/loss. In image 5.4 is possible to see that the agent with only the plain strategy was much of the time with a positive profit/loss but in the end of the test period suffered a loss resulting in a negative but near zero profit/loss. In image 5.6 is demonstrated the total profit/loss acheived with the two selected agents (5.4 and 5.5) having a final loss of 25ein the plain strategy case, but a 95eof profit when the model was applied to the plain strategy. 45 Testing and Results Figure 5.3: Horse Lay Agent results of plain strategy laying at 2 on horses with odd above 3 at race start from from January 15th to January 30th of 2014 (train set: December 15th of 2013 to January 14 of 2014) Figure 5.4: Horse Lay Agent results of laying at 3 on horses with odd above 6 at race start with and without rule induction classifier from from January 15th to January 30th of 2014 (train set: December 15th of 2013 to January 14 of 2014) 46 Testing and Results Figure 5.5: Horse Lay Agent results of laying at 4 on horses with odd above 6 at start of the race with and without rule induction classifier from January 15th to January 30th of 2014 (train set: December 15th of 2013 to January 14 of 2014) Figure 5.6: Horse Lay Agent combining 5.4 and 5.5 47 Testing and Results 48 Chapter 6 Conclusions and future work The first conclusion to take from this work is that a good plain strategy is essencial to have a profitable trading agent in long-term. Without it, no agent will be able to generate profit, the main reason for creating an agent. And as we can see in 5.1 and 5.2, the results with the agents implemented during this work were not the expected ones. DealerAgent, in 5.1, shows us that even though a plain strategy may sound good in paper, after implementing it the results may be completly different. Even without the machine learning stages described on the framework in 3, the results were negative when it was expected for the profit/loss to be at least near zero. With HorseLayAgent in 5.2, the results with only the plain strategy were slightly better than in DealerAgent. When the machine learning was implemented for HorseLayAgent the results were even better. This leads to the second conclusion of this thesis, that after several refinements of the plain strategy, implementing machine learning techniques to the agent can possibly improve the results. The two example agents of this work (DealerAngent and HorseLayAgent) shown that the profit/loss results were better when the machine learning stages defined on the framework were applied. It is important to say that, even though both agents were developed to work on horse racing markets, JBet and its trading mechanisms allow every Java programmer to create its own agents for any other sports market on Betfair exchange. The most difficult is, with no doubt, finding a good plain strategy. To find one, it is needed a great knowledge of the target markets and how they behave in different conditions. 6.1 Future Work Regarding the agents developed in this work, a greater time frame for training and testing is needed. DealerAgent possibly has no salvation even if it is trained with more data because the plain strategy behind is clearly a negative one. The same can not be applied to HorseLayAgent. It had a positive result after the machine learning implementation with a train set of only one month. 49 Conclusions and future work If this train set is extended, possibly the model will take better decisions when asked by the agent. So, for future work, the HorseLayAgent will be tested in more depth. Obviously, other work to be done in future is the creation of new agents with JBet. The possibilities to create new agents are virtually infinite. There are many types of markets on Betfair, and everyone has to find the ones where is more confortable with. The next agent to be developed can possibly be intended to use in footabll matches. The reasons for this is that in football matches, specially from England and Spain, there is always a lot of liquidity in circulation. 50 References [Ace13] AceOdds. A guide to dutching. Available at http://www.aceodds.com/ what-is-dutching.html, 2013. Last accessed: 2014-03-23. [AH12] Fareed Akthar and Caroline Hahne. Rapid Miner 5: Operator Reference, 2012. [Ang14] Bet Angel. Bet angel - the ultimate betfair toolkit. Available at http://www. betfair.com, 2014. Last accessed: 2014-05-30. [Bel14a] BeloSoft. Betfair trading software. Available at http://bfexplorer.net, 2014. Last accessed: 2014-05-29. [Bel14b] BeloSoft. Bfexplorer products. Available at http://bfexplorer.net/ Products.aspx, 2014. Last accessed: 2014-05-29. [Coh95] W.W. Cohen. Fast effective rule induction. In Proceedings of the Twelfth International Conference on Machine Learning, pages 115 – 23, San Francisco, CA, USA, 1995. [DPSW05] Mark Davies, Leyland Pitt, Daniel Shapiro, and Richard Watson. Betfair.com:: Five technology forces revolutionize worldwide wagering. European Management Journal, 23(5):533 – 541, 2005. [FVN10] Egon Franck, Erwin Verbeek, and Stephan Nüesch. Prediction accuracy of different market structures — bookmakers versus a betting exchange. International Journal of Forecasting, 26(3):448 – 459, 2010. Sports Forecasting. [Int14] Ladbrokes International. Betdaq - the people’s betting exchange. Available at http: //www.betdaq.com, 2014. Last accessed: 2014-06-21. [Lim13] Betfair Counterparty Services Limited. Betfair cash out. Available at https:// www.betfair.com/sport/cashout, 2013. Last accessed: 2014-05-25. [Lim14a] Betclic Limited. Bet online with betclic. Available at http://en.betclic.com, 2014. Last accessed: 2014-06-21. [Lim14b] Electraworks Limited. bwin - bet online. Available at http://www.bwin.com, 2014. Last accessed: 2014-06-21. [Lim14c] Talented Mavericks Limited. Betfair trading software. Available at http://www. geekstoy.com/en, 2014. Last accessed: 2014-06-20. [Lim14d] The Sporting Exchange Limited. Online betting - sportsbook and exchange at betfair.com. Available at http://www.betfair.com, 2014. Last accessed: 2014-0621. 51 REFERENCES [Mak14] Jim Makos. Bet angel: Sports trading software for betfair and betdaq. Available at http://jimmakos.com/bet-angel/, 2014. Last accessed: 2014-06-02. [Rap14] RapidMiner. Rapidminer studio. Available at http://rapidminer.com/ products/rapidminer-studio/, 2014. Last accessed: 2014-06-15. [Reb10] Paulo Rebelo. Plain strategies with expected positive value. Available at http://www.paulorebelotrader.com/en/2010/10/06/ plain-strategies-with-expected-positive-value/, 2010. Last accessed: 2014-05-17. [Res13] Heaton Research. Encog machine learning framework. Available at http://www. heatonresearch.com/encog, 2013. Last accessed: 2014-06-15. [RGP13] Ana Paula Rocha Rui Gonçalves and Fernando Lobo Pereira. High Level Architecture for Trading Agents in Betting Exchange Markets. In Advances in Information Systems and Technologies SE - 46, volume 206 of Advances in Intelligent Systems and Computing, pages 497–510. Springer Berlin Heidelberg, 2013. [Seb02] Fabrizio Sebastiani. Machine learning in automated text categorization. ACM Comput. Surv., 34(1):1–47, March 2002. [Sof05a] WellDone Creative Software. Auto-greenup function. Available at http: //marketfeeder.co.uk/screenshots/auto-green-up/, 2005. Last accessed: 2014-06-01. [Sof05b] WellDone Creative Software. Automated betfair trading software - marketfeeder pro - triggered automated betting bot. Available at http://marketfeeder.co.uk, 2005. Last accessed: 2014-05-30. [Sof10] Gruss Software. Betfair betting assistant. Available at http://www. gruss-software.co.uk, 2010. Last accessed: 2014-04-20. [Tra12] UK Football Trading. Best betfair trading software - bet angel. Available at http://www.ukfootballtrading.com/ bet-angel-betfair-trading-software/, 2012. Last accessed: 201405-29. [Tra14a] Betfair Pro Trader. Weight of money. Available at http://www. betfairprotrader.co.uk/2010/12/weight-of-money.html, 2014. Last accessed: 2014-06-20. [Tra14b] Traderline. Grid and ladder interfaces. Available at http://www.traderline. org/grid-ladder-interfaces, 2014. Last accessed: 2014-06-20. [TZ88] Richard H. Thaler and William T. Ziemba. Anomalies parimutuel betting markets: Racetracks and lotteries. volume 2, pages 161–174. 1988. [Uni14a] Oxford University. Definition of dealer in english. Available at http://www. oxforddictionaries.com/definition/english/dealer?q=dealer, 2014. Last accessed: 2014-05-01. [Uni14b] Waikato University. Machine learning group. Available at http://www.cs. waikato.ac.nz/ml/index.html, 2014. Last accessed: 2014-06-15. 52 Appendix A Dealer GUI Figure A.1: Dealer GUI presenting statistics from execution of one trading mechanism dealer 53