Monday, 19 April 2010

The Betting AI (Artificial intelligence) - domain model, components, deployment

Previous part of the betting ai design.

Domain model

  • Betting Exchange - " a form of bookmaking in which the operator offsets its risk perfectly through technology, such that the effect to the customer is that customers are seen to bet between themselves..." - from Wikipedia.
  • Market - "...The market is where you place a bet on an event. Any given event, such as a soccer match, may have a number of different markets: for example, Match Odds, a Handicap and First Goalscorer markets. This is the place to view the odds and have a bet..." - from Betfair help.
    • market id - Unique  market id.
    • market name - e.g. Match Odds or Place market
    • event name - e.g. Mat Utd vs Arsenal
    • market state - active/in play/settled
    • selection id - Unique selection id, e.g. 100 for Manchester United and 101 for Arsenal.
    • selection name - e.g. Arsenal
  • Bet - "...A ‘Back’ bet is a bet on something to happen – a horse to win a race, a football team to win, a person to be evicted from Big Brother etc. It’s just like the bet you’d regularly place with a traditional bookmaker or tote, or even with your mates..." - from Betfair help. "...Laying a bet means you are betting on something not to happen – a match not to end in a draw, a horse not to come in first, a rugby team not to win by over 7 pts etc..." - from Betfair help
    • bet price - Bet odds. Chances of winning written in a decimal format = 1/probability, e.g. 1/0.5 = 2 ( fifty-fifty).
    • bet size, e.g. 20£
    • bet type - Back or lay.
    • market id/selection id - Unique id of a particular selection in a given market.
    • bet status - Unmatched, matched, cancelled (by user), lapsed (by a betting exchange, e.g. when market is turned in play), settled.
  • Historical market data - Represents the whole market life cycle: market creation, bet placement, turning market in play, bet placement in play and market settlement. It allows to replay a market from the past.
  • Trader - Responsible for analysing market and taking appropriate bet placement decision. The aim of bet placement is to guarantee the highest profit with the lowest risk. There are two types of traders, a real trader that is represented by human and artificial trader that is represented by computer software. The main aim of this project is to provide a simulation environment for testing artificial traders.
  • Expected profit - This is a measure that tells, what would be the profit in a long term if the same market was processed many times. For instance if the expected market profit is 10, then it means that for 100 'exactly the same' markets the profit would be 1000. It may happen that for the first market the profit will be -23 and for the next market it will be 12, but in total, based on a theory of probability it should be approximately 1000.

Component design

  • User - A person who is using the market simulation. Usually it's a market analyst or a real trader.
  • Simulator App - Provides a command line interface to the market simulation. Read the configuration of the historical market data and the trader implementation, runs simulation and displays expected profit report on the screen.
  • Simulator - Does exactly the same as a simulator application, but provides application programming interface instead of command line interface.
  • Market Event Processor - Parses historical market event in a string format, e.g. CREATE_MARKET and calls appropriate method on a betting exchange, e.g. createMarket(market:Market)
  • Trader - Analyses markets on a betting exchange and places bets.
  • Expected Profit Calculator - Reads matched bets for user (e.g. trader) from a betting exchange and calculates expected market profit report.
  • Betex - It's a betting exchange that provide peer-to-peer betting services.

Flow of control:
  1. User starts the market simulator giving the path to the file with the historical market data and the name of the trader implementation class. After the market simulation is finished the market expected profit report for the trader is printed on the screen.
  1. The Simulator Application calls the Simulator component with the input parameters provided by the user.
  1. The Simulator component reads the file with historical market data and for each historal market event, calls both MarketEventProcessor and Trader. After all historical market events are processed, it calls the ExpectedProfitCalculator to get the market expected profit report.

Deployment design

  • Java VM - The Betting AI application will be written in the Scala programming language that is running within the Java virtual machine.
  • Scala - The scala language distribution, contains scala libraries that are required to run scala applications.
  • Betting AI application - Binaries of the betting ai application, contains start script to run market simulation.
  • Historical market data file - This file contains historical market data that is used for market simulation.
  • Trader implementation class - This file contains trader implementation that market simulation is executed for.


Project home page: