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.

3 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. จีคลับ Online gambling sites that can be played every day. Just like or want to gamble yourself all the time. Anyone who likes to gamble can play professionally. Have a play that anyone play. Can play in a friendly. Every day bets are fun and realistic bets.

    In addition, it is interesting to occasionally eat smoothies. It does not always benefit the body. If you do not like the way you drink it down. Green fruit juice. Full of benefits The smell of green and bitter taste, the drink will make your body can not absorb the benefits of the juice. If you do not want to lose fruits and vegetables, you should gradually drink it with a drink time of about 5-20 minutes, gradually sip gradually the body absorbs minerals and vitamins in the drink better.

    It is interesting to have a gambling game that will play every day. Gambling is like a good return every time. To play all. You can earn as you choose. It is a bet that will enjoy the things that people choose. Can play well with betting games to make more money. บาคาร่า

    ReplyDelete
  3. casa98asia online gambling We are direct representatives of casa98 website. The most popular service in Thailand. Online gambling All casinos can play casa98 through the web or on mobile phones (Iphone or Android), gambling websites and foreign gambling websites, which have a trustworthy security system as well as international standards. For the online betting through the Internet and it's sports betting online or casinos. Today's Web Available all day. They can be contacted by calling the vocabulary. Chat through the web or online, with professional staff waiting for service throughout the period without any stop. Take time to deposit no more than 5 minutes and withdraw up to 15 minutes with a lot of promotions if you choose. Online gambling with casa98 will require casa98asia fast service.

    ReplyDelete