Using VB2008 to acccess the Betfair API: A tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • davecon
    Junior Member
    • Dec 2010
    • 86

    #631
    GetBet Status

    Hi gkr

    GetBet and getMUBets Status returns M if the Bet is both Part Matched and Fully Matched
    Continue to use GetBet but to monitor your status and to place bets etc it is best to use

    .remainingSize
    .requestedSize

    So for example

    If .remainingSize = .requestedSize Then 'It is UnMatched

    If .remainingSize > 0 And .remainingSize < .requestedSize Then 'It is Partially Matched

    If .remainingSize = 0 Then 'It is Fully Matched

    There is also a .matchedSize

    Also be aware that there is a Known Issue in GetBet
    "The requestedSize field is always zero for voided or lapsed bets"

    This problem will occur when there is a withdrawn horse in the race

    To overcome this always use the Keep option when placing your bets then any Unmatched portion of your bet will not be cancelled and the Reduction Factor will be applied to your bets(Cancel or UnKeep it before the Off if you dont want to keep in running)

    Hope this helps
    Dave
    Last edited by davecon; 16-06-2011, 10:48 AM.

    Comment

    • gkr
      Junior Member
      • May 2011
      • 2

      #632
      Hi Dave

      Appreciation
      Thank you very much
      Now its clear for me.

      Comment

      • NFLMAN
        Junior Member
        • Jun 2010
        • 17

        #633
        Filtering markets

        What's the best way to filter out unwanted markets. For example, say I wanted to display all of the currently available mens tennis singles matches at all events. I've been doing it by filtering to the tennis eventTypeID but then I've further filtered by creatings substrings of the .MarketName string but this method is a bit hit and miss.

        Basically, all I want is a list of all tennis singles matches.

        How would I do this in a cleverer manner?


        Thanks in advance

        Comment

        • karas
          Junior Member
          • Feb 2010
          • 1

          #634
          matched bets of a specific market

          Hi there. quick question. is it possible through for the api to retrieve all the matched bets of a market, one by one as it happens in a list, and not just my own but all the matched bets of a specific market. thanx

          Comment

          • Mumbles0
            Junior Member
            • Jan 2009
            • 240

            #635
            Tennis markets

            NFLMAN,

            You can also look at the menuPath string. If you study this for a while you should see a pattern emerge and gain some insight into how Betfair name market groups.

            A current example:
            \Tennis\Group A\Wimbledon 2011\Mens Tournament\First Round Matches\A Murray v Gimeno Traver

            You can filter this for "Mens Tournament" and "First Round Matches". This obviously won't work for "Second Round Matches", etc. but you refine the filter as you go along.

            Comment

            • Mumbles0
              Junior Member
              • Jan 2009
              • 240

              #636
              Bets matched on a market

              karas,

              No. you can only see your own bets with the bet status calls getMUBets, getBet, getCurrentBets etc.

              However, if you analyse the data returned by getMarketTradedVolumeCompressed you can gain some insight into current betting matching on a market.

              Comment

              • MarkL
                Junior Member
                • Oct 2008
                • 29

                #637
                Originally posted by karas View Post
                Hi there. quick question. is it possible through for the api to retrieve all the matched bets of a market, one by one as it happens in a list, and not just my own but all the matched bets of a specific market. thanx
                You're better off using one of the historical data services available to get that kind of information.

                Try http://solutions.betfair.com and look for Historical Data.

                Comment

                • NFLMAN
                  Junior Member
                  • Jun 2010
                  • 17

                  #638
                  Originally posted by Mumbles0 View Post
                  NFLMAN,

                  You can also look at the menuPath string. If you study this for a while you should see a pattern emerge and gain some insight into how Betfair name market groups.

                  A current example:
                  \Tennis\Group A\Wimbledon 2011\Mens Tournament\First Round Matches\A Murray v Gimeno Traver

                  You can filter this for "Mens Tournament" and "First Round Matches". This obviously won't work for "Second Round Matches", etc. but you refine the filter as you go along.
                  Thanks Mumbles.

                  I'm getting there......

                  I've added this after calling getAllMarkets:

                  Code:
                  'Unpack response into readable format and assign to AllMarkets
                              Dim AllMarkets As New UnpackAllMarkets(oMarketsResp.marketData)
                              With AllMarkets
                                  For i = 0 To .marketData.Length - 1 'Loop through all records in AllMrkets
                                      With .marketData(i)
                                          .marketName = "MATCH ODDS" 'Filter fo Match Odds markets
                                          .noOfRunners = 2 'Filter for 2 participants (don't think this matters)
                                          If InStr(.menuPath, "Round Matches") And InStr(.menuPath, "Womens Tournament") Then 'Further filters to find only ladies singles matches 
                                              Print("MarketID=" & .marketId & " Event Start: " & .eventDate & " " & .menuPath)
                                              Dim oMarketReq As New BFUK.GetMarketReq       'Create GetMarket request object
                                              Dim oMarketResp As BFUK.GetMarketResp     'Create GetMarket response object
                                              With oMarketReq
                                                  .header = oHeaderUK()
                                                  .marketId = AllMarkets.marketData(i).marketId
                                          End With
                  
                                          
                                              oMarketResp = BetFairUK.getMarket(oMarketReq)    'Call the API
                                              With oMarketResp
                  
                                                  Print("ErrorCode = " & .errorCode.ToString)
                                                  If .errorCode = BFUK.GetMarketErrorEnum.OK Then
                  
                                                      With .market
                                                          If UCase(.name) = "MATCH ODDS" Then
                                                              For j = 0 To .runners.Length - 1
                                                                  With .runners(j)
                                                                      Print(.name & " Selection ID: " & .selectionId)
                                                                  End With
                                                              Next j
                                                          Else
                                                              Print("NO BET")
                                                          End If
                                                      End With
                                                  End If
                                              End With
                                          End If
                                      End With
                                  Next i
                              End With
                  This will print something like this:

                  MarketID=102995053 Event Start: 21/06/2011 14:00:00 \Tennis\Group A\Wimbledon 2011\Womens Tournament\First Round Matches\Wozniacki v Parra Santonja
                  ErrorCode = OK
                  Caroline Wozniacki Selection ID: 2309522
                  Arantxa Parra Santonja Selection ID: 2309573


                  This is exactly what I want but after a few correct prints like this I start to get this:

                  MarketID=102995087 Event Start: 21/06/2011 17:30:00 \Tennis\Group A\Wimbledon 2011\Womens Tournament\First Round Matches\An Rodionova v Hlavackova
                  ErrorCode = API_ERROR


                  Once the errors start I do not get any correct data again. I was thinking I was throttling it but that's a different message, yes? I can't see any references to what this error means. Any ideas?

                  Comment

                  • BigSprout
                    Junior Member
                    • Feb 2011
                    • 60

                    #639
                    Hi NFLMan,

                    on the free API, you are only allowed 5 calls per minute to "GetMarkets", this may be your problem.

                    How many correct prints do you get and is it consistent each minute?

                    Let us know how it goes

                    cheers

                    re-reading your code again:
                    You are making a call for every "womens tournament round matches" so you would be exceeding the throttle limits after 5 calls in every minute
                    Last edited by BigSprout; 21-06-2011, 01:33 AM.

                    Comment

                    • Mumbles0
                      Junior Member
                      • Jan 2009
                      • 240

                      #640
                      NFLMAN,

                      I agree with BigSprout. Note that there are 2 errorCodes in the response object.

                      When oMarketResp.errorCode returns API_ERROR then the errorCode in the response header will give you more information. Try something like this

                      Code:
                        With oMarketResp   
                           
                          Print("ErrorCode = " & .errorCode.ToString)
                          If .errorCode = BFUK.GetMarketErrorEnum.API_ERROR Then Print("HeaderCode = " & .header.errorCode.ToString)
                      
                          ...........
                      or call the CheckHeader sub.

                      You will probably see that the API_ERROR is in fact EXCEEDED_THROTTLE.

                      Comment

                      • NFLMAN
                        Junior Member
                        • Jun 2010
                        • 17

                        #641
                        Thanks guys,

                        I'll test it out when I get home.

                        If this is indeed the case, are there any more 'throttle generous' calls I can make that will give me the SelectionID's I require?

                        Cheers

                        Comment

                        • NFLMAN
                          Junior Member
                          • Jun 2010
                          • 17

                          #642
                          I think I can answer my own question here. I have found the reference guide :-) Looks like GetCompleteMarketPricesCompressed can do this. 60 calls/minute should be quick enough for my needs.

                          And I can confirm that the error was EXCEEDED_THROTTLE
                          Last edited by NFLMAN; 21-06-2011, 11:28 PM.

                          Comment

                          • beans
                            Junior Member
                            • Jun 2009
                            • 6

                            #643
                            Hi, back in step 2 we created the BetfairGL object for the BFGlobalService. I was just wondering if we are limited to only one of these objects in our application?
                            The reason I ask is I am trying to change my old application to an ASYNC capable version. I had classes for each type of call which shared a BFGlobalService stored in a module. Now I want to change to ASYNC I have a problem in that each class now needs it's own BFGlobalService object in order to 'Handle' the async response. Is this a problem? Does it use up lots of unnecessary memory or is it fine to create multiple versions of the service object?

                            Comment

                            • BigSprout
                              Junior Member
                              • Feb 2011
                              • 60

                              #644
                              Hi Beans,
                              you need to change this:
                              Code:
                                  Dim BetfairGL As New BFGlobal.BFGlobalService
                              to this to to be able to use Async on the global server

                              Code:
                                  Dim [B][COLOR="Red"]WithEvents[/COLOR][/B] BetfairGL As New BFGlobal.BFGlobalService
                              I converted most of my calls to Async mode and this was the only major change needed (please note, my naming of the global server may be different to Mumbles)

                              Comment

                              • Mumbles0
                                Junior Member
                                • Jan 2009
                                • 240

                                #645
                                Beans,

                                You can have as many instances of the BFGlobalService (or BFExchangeService) class as you want. Go ahead, it's fairly efficient, besides, you have lots of memory.

                                Looks like you have realized that, with async calls, you need a separate service object on each form (or class) which accesses the API, in order to handle the resulting "completed" events. (Of course each service object variable should be declared with the WithEvents keyword as BigSprout points out.)

                                Having said this, did you know that it’s possible to put all of your async API calls into a single class? Here, data from the API can be returned to the calling program using Event properties defined in this class. If you are interested I can show you how to do this.

                                Comment

                                Working...
                                X