Using VB2008 to acccess the Betfair API: A tutorial

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

  • BigSprout
    replied
    Hi granted,
    I tried using left/right mouse clicks but the right didn't seem to work on a button, that's why I tried and suggested using a panel.

    My simplistic solution would be to use panels in the size of a button whereby left/right mouse clicks will then register - load panels at run time instead of buttons.

    Others with more experience may be able to offer a simpler solution.

    cheers

    Leave a comment:


  • granted
    replied
    detecting Right Click....

    i have seen on some programs that when you left click the price it places the back bet but when you right click it, it places a lay bet

    this is what i am trying to figure out...the buttons don't exist until you load the market, so the form that holds the buttons doesnt exist in visual basic, so how do they detect right click and then set the bet to be a lay instead of a back bet

    Leave a comment:


  • BigSprout
    replied
    granted,
    just incase you are trying to write code to use either the left or right mouse click on a control e.g a panel(pStats):

    Code:
        Private Sub pStats_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pStats.MouseClick
            If e.Button = Windows.Forms.MouseButtons.Left Then Print("Left")
            If e.Button = Windows.Forms.MouseButtons.Right Then Print("Right")
        End Sub

    Leave a comment:


  • BigSprout
    replied
    granted,
    not sure if I understand your question fully, but I will answer as I have interpreted it:

    I was trying to figure out how to use the mouses left click on a button..

    does anyone know how i can impement the left mouse button to press a button on a form?
    If you place a button on your form e.g. "Button1"
    Place the cursor over the button and double click on it with the left mouse button - this will put the code, if you have named your button something other than "Button1" then this will automatically be substituted:

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            
        End Sub
    Enter this line in the Sub so it shows like this:
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Print("I have clicked the left mouse button")
        End Sub
    Run the program, place your cursor over the button and left click on the mouse, if you have the print sub written, this will show:

    "I have clicked the left mouse button"

    If this doesn't answer your question then you may have to be a little more specific of your requirements

    Of course this option may be more in line with what you are trying to do:
    Code:
        Private Sub Button1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick
            If e.Button = Windows.Forms.MouseButtons.Left Then Print("I have clicked the left mouse button")
        End Sub
    cheers
    Last edited by BigSprout; 02-07-2011, 10:21 AM.

    Leave a comment:


  • granted
    replied
    Left Mouse Click - how to use it

    I was trying to figure out how to use the mouses left click on a button..

    i tried:

    Code:
    if mousebuttons = windows.forms.mousebuttons.left then
    ....of course this didnt work.

    does anyone know how i can impement the left mouse button to press a button on a form?

    thanks

    Leave a comment:


  • antonello273
    replied
    Thanks i solved not by putting the codes, but taking all the markets available.

    However, i have noticed that i am not returns no football match, you place the code that i wrote.

    PHP Code:
     Print("*** Markets ***")
                
    Dim oMarketsReq As New bfuk.GetAllMarketsReq
                Dim oMarketsResp 
    As bfuk.GetAllMarketsResp
                With oMarketsReq
                    
    .header oHeaderUK()
                    
    ReDim .eventTypeIds(0) : .eventTypeIds(0) = Val(IdEvento.Text)  'For horse racing
                    ' 
    ReDim .countries(1) : .countries(0) = "GBR" : .countries(1) = "ZAF"
                    
    .fromDate Now
                    
    .toDate Now.AddDays(1)
                
    End With
                oMarketsResp 
    BetFairUK.getAllMarkets(oMarketsReq)  'Call the UK API
                With oMarketsResp
                    CheckHeader(.header)
                    Print("ErrorCode = " & .errorCode.ToString)
                    If .errorCode = bfuk.GetAllMarketsErrorEnum.OK Then
                        Dim AllMarkets As New UnpackAllMarkets(.marketData)   '
    Create an object and unpack the string
                        Dim Names 
    As String(), TodaysCard As New List(Of MarketDataType)

                        
    With AllMarkets
                            
    For 0 To .marketData.Length 1
                                Names 
    = .marketData(i).menuPath.Split("\")   'This is the filter
                                If Names.Length = 4 AndAlso Not Names(3).StartsWith("
    Daily") Then

                                    TodaysCard.Add(.marketData(i))    'Add win markets only
                                End If

                                With .marketData(i)

                                End With
                            Next
                        End With
                        TodaysCard.Sort(New CompareMarketTimes)   'Sort according to market times 
                        For Each Race In TodaysCard    'Print the card
                            With Race
                                Names = .menuPath.Split("
    \")
                                'ListBox2.Items.Add(.marketId & " " & .marketStatus & "  " & .marketName & "  " & .menuPath)
                                ListBox2.Items.Add(.marketId & " " & .eventDate.ToLocalTime.TimeOfDay.ToString & " " & Names(3) & " 
    " & .marketName)

                                'Print(.eventDate.ToLocalTime.TimeOfDay.ToString & " " & .marketId & " " & Names(3) & " 
    " & .marketName)
                            End With
                        Next


                    End If
                End With 

    Leave a comment:


  • BigSprout
    replied
    Antonello,

    Step 5 in this tutorial covers the call to "GetAllMarkets" - in the API6 documentation it states that ISO3 country codes are used.

    Here is a site that lists Countries and their ISO3 codes:

    http://www.fao.org/countryprofiles/iso3list.asp

    cheers

    Leave a comment:


  • antonello273
    replied
    European countries

    I need another aid you tell me how do i download the markets for the european countries?

    Leave a comment:


  • antonello273
    replied
    Thanks i tried and it works.



    P.S. excellent forum and help me a lot

    Leave a comment:


  • BigSprout
    replied
    Antonello,
    I think you have omitted a line of coding to fill in the header, without this you are not sending your Session Token and thus will get a "NO_SESSION" error:

    Code:
    Dim oSaldoReq As New bfuk.GetAccountFundsReq
    Dim oSaldoResp As bfuk.GetAccountFundsResp
    
    [B]oSaldoReq.header = oHeaderUK()
    [/B]
    oSaldoResp = BetFairUK.getAccountFunds(oSaldoReq)
    
    With oSaldoResp
    CheckHeader(.header)
    Print("Il Saldo disponibile è = " & .availBalance)
    End With

    Leave a comment:


  • antonello273
    replied
    I have tried to write this code, but the result is error NO_SESSION

    Dim oSaldoReq As New bfuk.GetAccountFundsReq
    Dim oSaldoResp As bfuk.GetAccountFundsResp

    oSaldoResp = BetFairUK.getAccountFunds(oSaldoReq)

    With oSaldoResp
    CheckHeader(.header)
    Print("Il Saldo disponibile è = " & .availBalance)
    End With


    Can you help me to solve the problem?
    Last edited by antonello273; 30-06-2011, 10:13 AM.

    Leave a comment:


  • antonello273
    replied
    thank you so much

    Leave a comment:


  • Mumbles0
    replied
    antonello273,

    GetAccountFunds returns your account balance in the .availBalance parameter of the response.

    Leave a comment:


  • antonello273
    replied
    balance betfair

    Good day to all, you can say to me as I can visualize the balance of my account betfair? , I have tried but it exits to me alone

    Leave a comment:


  • rphi6876
    replied
    Slow Bet Placement

    Hi,

    My bot has the ability to place bets under $5 by sending in a lay (back) at 1.01 (1000) then updating the bet to the approriate size which creates a new bet then updating the newly created bet to the desired price. The orignal bet at 1.01 or 1000 is then cancelled. All of these steps are done asyncronously. This works fine and takes a bit over 1 second to complete. However I also have a timer that fires every second resulting in a call to getMUBetsAsync, getMarketTradedVolumeCompressedAsync, getCompleteMarketPricesCompressedAsync and getMarketPricesCompressedAsync. When this timer is running placing an undersized bet now takes roughly ten seconds (this is an average of over 200 bets placed and not an anomoly). I am thinking that when placeBetsCompleted and updateBetsCompleted get a result from betfair the thread they are on has a low priority? But dont really have any idea. Any suggestions if there is a way to make handling these completed calls high priority or perhaps another possible explanation for this problem.
    As a side not this is not a result of a slow internet connection as using software made by others this problem does not occur.
    Cheers

    Leave a comment:

Working...
X