Using VB2008 to acccess the Betfair API: A tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts

  • Mumbles0
    replied
    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.

    Leave a comment:


  • karas
    replied
    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

    Leave a comment:


  • NFLMAN
    replied
    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

    Leave a comment:


  • gkr
    replied
    Hi Dave

    Appreciation
    Thank you very much
    Now its clear for me.

    Leave a comment:


  • davecon
    replied
    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.

    Leave a comment:


  • gkr
    replied
    Mumbles0 many thanks for this useful thread.

    I want to ask a question

    I place a bet back Unmatched and i want to know if all the bet matched (no partially-matched) and then i put a lay bet.

    Now i am doing this

    I place the bet and so i have the betId.

    Then i call GetBet and i check betStatus.

    If the return is "M" i place the lay

    Is this correct or i must change my code and follow step 20 ?

    Leave a comment:


  • Mumbles0
    replied
    LionKing,

    I don't know a great deal about VBA, but I believe this can be done. You can use VB2010 to make a DLL that can be called from Excel using VBA. There would be restrictions on the type of objects that can be passed as parameters.

    Grantay has done some work in this area. See this post.

    Leave a comment:


  • LionKing
    replied
    Excel

    Hi all
    Can we build dll api functions that we invoke thur vba procedures in friendly excel?
    thks

    Leave a comment:


  • antonello273
    replied
    Thank you so much I've been helpful.
    PS Forum super useful.

    Leave a comment:


  • Mumbles0
    replied
    getAllMarkets does not return any data for eventTypeIds 13, 14 or 15.

    Step 18 may help you.

    Leave a comment:


  • antonello273
    replied
    Evant 13-14-15

    Who can help me to solve my problem concerning the events 13-14-15?

    Leave a comment:


  • Speedbird
    replied
    Thank you Mumbles0. Runs perfect.... so far. Will do my best not be a nuisance

    Leave a comment:


  • Mumbles0
    replied
    Speedbird.

    I am surprised you managed to get it to run at all.

    The 3 declaration statements don’t belong in the Print sub. Put them at the top of the class like this:

    Code:
    Public Class Speedbird
    
      Dim oHeaderGL As New BFGlobal.APIRequestHeader
      Dim BetfairGL As New BFGlobal.BFGlobalService
      Const SessTokFile = "C:\Betfair\SessToken.txt"
    
      Sub Print(ByVal Message As String)
        With tLog
          .SelectionStart = .Text.Length
          .SelectedText = vbCrLf & Message
        End With
      End Sub
    
      ...........
      ...........
    What on earth are these functions for ???????????

    Code:
      Private Function BetfairGL() As Object
        Throw New NotImplementedException
      End Function
    
      Private Function oHeaderGL() As BFGlobal.APIRequestHeader
        Throw New NotImplementedException
      End Function
    I guess you added them to resolve the "not declared" compiler errors which occurred because you put the declarations in the wrong place.

    I’m not surprised you get the NotImplementedException because that’s what you are asking for.

    Leave a comment:


  • Speedbird
    replied
    New Kid.... somewhat lost

    Mumbles0... thanks for a brilliant initiative. I'm brand new at this and evidently bloody stupid, so pls be nice. I've been trying to follow your step by step guide but get stuck at an early stage (running the login...as soon as I run it an error mssg is coughed up telling me the NotImplementedException is unhandled). It also screams at me that the 'SessTokFile' is not declared.
    What am I missing? Would you mind checking my code thus far? (I'm using VB 2010 Express).
    Thank you very much

    Public Class TestForm
    Sub Print(ByVal Message As String)
    Dim oHeaderGL As New BFGlobal.APIRequestHeader
    Dim BetfairGL As New BFGlobal.BFGlobalService
    Const SessTokFile = "C:\Betfair\SessToken.txt"
    With tLog
    .SelectionStart = .Text.Length
    .SelectedText = vbCrLf & Message
    End With
    End Sub
    Sub CheckHeader(ByVal Header As BFGlobal.APIResponseHeader)
    With Header
    Print("HeaderCode = " & .errorCode.ToString)
    oHeaderGL.sessionToken = .sessionToken
    End With
    End Sub

    Private Sub bLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bLogin.Click
    Print("*** Login ***")
    Dim oLoginReq As New BFGlobal.LoginReq
    Dim oLoginResp As BFGlobal.LoginResp
    With oLoginReq
    .username = "acc name"
    .password = "password"
    .productId = 82 'For free API
    End With
    oLoginResp = BetfairGL.login(oLoginReq) 'Call the API
    With oLoginResp
    CheckHeader(.header)
    Print("ErrorCode = " & .errorCode.ToString)
    End With
    End Sub

    Private Sub bLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bLogout.Click
    Print("*** Logout ***")
    Dim oLogoutReq As New BFGlobal.LogoutReq
    Dim oLogoutResp As BFGlobal.LogoutResp
    oLogoutReq.header = oHeaderGL
    oLogoutResp = BetfairGL.logout(oLogoutReq) 'Call the API
    With oLogoutResp
    CheckHeader(.header)
    Print("ErrorCode = " & .errorCode.ToString)
    End With
    End Sub

    Private Sub bKeepAlive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bKeepAlive.Click
    Print("*** KeepAlive ***")
    Dim oKeepAliveReq As New BFGlobal.KeepAliveReq
    Dim oKeepAliveResp As BFGlobal.KeepAliveResp
    oKeepAliveReq.header = oHeaderGL
    oKeepAliveResp = BetfairGL.keepAlive(oKeepAliveReq) 'Call the API
    CheckHeader(oKeepAliveResp.header)
    End Sub

    Private Function BetfairGL() As Object
    Throw New NotImplementedException
    End Function

    Private Function oHeaderGL() As BFGlobal.APIRequestHeader
    Throw New NotImplementedException
    End Function

    Private Sub TestForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    My.Computer.FileSystem.WriteAllText(SessTokFile, oHeaderGL.sessionToken, False)
    End Sub

    Private Sub TestForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    oHeaderGL.sessionToken = My.Computer.FileSystem.ReadAllText(SessTokFile)
    End Sub

    Private Sub bEvents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bEvents.Click
    Print("*** Events ***")
    Dim oEventsReq As New BFGlobal.GetEventTypesReq 'Create the request object
    Dim oEventsResp As BFGlobal.GetEventTypesResp 'Create a variable for the response object
    oEventsReq.header = oHeaderGL() 'Load request parameters
    oEventsResp = BetfairGL.getActiveEventTypes(oEventsReq) 'Call the API
    With oEventsResp
    CheckHeader(.header) 'Check response header
    Print("ErrorCode = " & .errorCode.ToString)
    If .errorCode = BFGlobal.GetEventsErrorEnum.OK Then 'Check the response errorcode
    For i = 0 To .eventTypeItems.Length - 1 'Process the received data
    With .eventTypeItems(i)
    Print(.name & " (" & .id & ")")
    End With
    Next
    End If
    End With

    End Sub
    End Class

    Leave a comment:


  • antonello273
    replied
    Events 13-14-15

    Hello everyone, I am again asking for your help, some of you have solved how to download the events 13-14-15?, Thank you all.

    Leave a comment:

Working...
X