Thursday 11 February 2010

Building Our First Bot - Part II, Framework

Last post, we looked at how out 'bot would make money. This post, we'll put the framework in place. The framework is the outline of the code we'll be using. One of the nice things about this framework is that it is pretty language-independent. With just a little work, it can be converted to pretty much any language: Ruby, VBA, Java, etc. I shall, of course, be using Python - and will probably implement it in Resolver down the road.

The main program loop will look something like this:
Evaluate Status

if No Open or Matched Bets:
Offer To Back
else if Unmatched Offer to Back:
See if Conditions for Backing Still Exist
Move or Cancel Bet if they do not
else if Unmatched Offer to Lay:
Do Nothing For Now (we're doing this simply, remember)
else if Matched Offer to Back:
Record the Matched Bet
Create new Offer to Lay
else if Matched Offer to Lay:
Record the Matched Bet
Offer To Back

This is the simplest kind of pseudo-code. Moving it into more real Python gets us this:

import betfair
betfairGateway = betfair.BetfairGateway(username, password, productID)

marketID = xx
selectionID = xx

while not MarketInPlay():

status = EvaluateStatus()

if status == 'No Open or Matched Bets':
if ConditionsExistToBack():
OfferToBack()

elif status == 'Unmatched Offer to Back':
if not MyBestBestBet():
CancelBets()

if ConditionsExistToBack():
OfferToBack()

elif status == 'Unmatched Offer to Lay':
# Do Nothing For Now (we're doing this simply, remember)
pass

elif status == 'Matched Offer to Back':
RecordMatchedBackBet()
OfferToLay()

elif status == 'Matched Offer to Lay':
RecordMatchedLayBet()
if ConditionsExistToBack():
OfferToBack()

Now, while we're not quite at a working, trading 'bot, we have the outline in place. Tomorrow (or in the next few days), I'll fill in the missing methods, and transition the 'bot to Resolver One.

Next week (when I'm back in the UK, with reliable Internet access again...), I'll set it up and running.

4 comments:

  1. Online Casino Games
    Royal1688 It is a way to play online games that bring you to the rich with the use of online games. All online gambling games are designed to meet the needs of the modern man. At the risk of online gambling games. Online Casino Games The fun of betting on the online games that give customers the full enjoyment of gambling. The game is easy to understand, so you can play the online game of luck on our site like a professional. I have to go with other users. Free Online Bets on the internet. Opportunities for entertainment with online casino games that bring wealth to you. We provide good service all the time. Do not miss the chance to win online games that give you enjoyment. There are also new games that are updated every moment, so customers do not miss every game is coming. Play all the games with online gambling that will make you like to bet on a real risky place. Goldclub Slot

    ReplyDelete
  2. I'd like to comment on your excellent article. Very readable
    สล็อตxoauto

    ReplyDelete