Wednesday, 14 April 2010

The Betting AI (Artificial intelligence) - user interface and input data

Previous part of the betting ai design.
Next part of the betting ai design.

User interface

As a trading analyst I want to run the market simulation from a command line interface as presented below:

app_name marketData=[market_data_file] traderImpl=[trader_impl_class]

  • app_name - Name of the application, e.g. market_simulator

  • marketData - Text file with market data that will be used for the simulation. Go to the next chapter 'Input data' for more details.

  • traderImpl - Fully classified name of the trader implementation class that the simulation will be executed for. Go to the next chapter 'Input data' for more details.

After simulation is started, the following output is presented on the screen:

[BEGINNING Of THE OUTPUT]

Simulation is started.
Simulation progress: 1% 2% 3% 4% 5% 6% ....................................................... .................................................................................................................
..................................100%
Simulation is finished in 23 sec.

Expected profit report for trader com.dk.bettingai.trader.SimpleTraderImpl:

Catt 7th Apr: 14:10 7f Claim Stks    expProfit=28 expAggrProfit=28  mBets=34 uBets=17
Catt 7th Apr: 14:40 1m6f Hcap       expProfit=4   expAggrProfit=32  mBets=27 uBets=2
...
Nott 7th Apr: 17:20 1m Hcap         expProfit=-6  expAggrProfit=136 mBets=45 uBets=57
-------------------------------------------------------------------------------------
TotalExpectedProfit=136 TotalMatchedBets=457 TotalUnmachedBets=262
[END Of THE OUTPUT]

Definitions:
  • expProfit - Expected market profit based on all matched bets on the market placed by trader.

  • expAggrProfit- Expected profit for the market and all prior markets. 

  • mBets - Number of matched bets on the market placed by trader.

  • uBets - Number of unmatched bets on the market placed by trader.

  • TotalExpectedProfit - Expected profit for all markets and all matched bets placed by trader.

  • TotalMatchedBets - Number of all matched bets for all markets placed by trader.

  • TotalUnmatchedBets - Number of all unmatched bets for all markets placed by trader.

Input data

To run the market simulation, user has to provide the historical market data and the trader implementation class.

The historical market data is provided as a text file, that contains the number of events for the market management and the bet placement. The list below presents all possible event types:
  • CREATE_MARKET
    • Market id, market name, event name, number of winners, market time.
    • List of selections: selection id, selection name.

  • TURN_MARKET_INPLAY
    • Market id.

  • SETTLE_MARKET
    • Market id, list of selection ids for winners.

  • PLACE_BET
    • Bet size, bet price, bet type (back/lay), market id, selection id.

  • CANCEL_BET
    • Bet id.

The trader implementation class implements the following interface:

Interface name: Trader
Interface operations: 
  • execute():void

  • setBetexPublicApi(betexPublicApi: BetexPublicApi):void

BetexPublicApi:
  • getActiveMarkets
    • Input - None.
    • Output -  All markets that are not closed. The following attributes are returned: market id, market name, event name, market time.

  • getMarketData
    • Input - Market id.
    • Output - All back and lay stakes for each price on the exchange for a given market. 
    • Output - Market id, market name, event name, selection ids/names, number of winners, market status (active/in play/settled), market time.
    • Output - matched amounts at each price on all of the runners.

  • placeBet - Place a bet on a betting exchange. 
    • Input: Bet size, bet price, bet type (back/lay), market id, selection id

  • cancelBet - Cancel a bet.
    • Input - Bet id.
    • Output - None.

  • getBets - Returns bets for a given user on a betting exchange
    • Input: User id, bet status (matched, unmatched, matched_unmatched, settled, cancelled, lapsed)
    • Output: List of bets (bet id, bet size, bet price, bet type, market id, selection id, bet status).

References