COM Class - Football

Please post any questions regarding the program here.

Moderator: 2020vision

COM Class - Football

Postby xdg99667 » Sun Jun 26, 2011 10:28 am

Hi all,

following on from Gary's kind help and work for me on this thread (http://gruss-software.co.uk/forum/viewt ... highlight=)

I have used what he has shown me to create a process that will loop through each market (eg over / under 2.5) of each game (eg Liverpool Vs Chelsea) of each fixture list (eg Fixtures 13th August)

I've been testing it on Irish games (as the prem ones aren't developed yet)

Just though that it may be useful to anyone trying to do the same, or to see another COM example

(originally based on the test_BA_COM.xls file...)



Code: Select all

Dim WithEvents ba As BettingAssistantCom.ComClass
Dim currentMarketId As String, marketUpdated As Boolean, fixtureIDx As Integer, marketIDx As Integer, matchIDx As Integer
Dim cont2 As Integer
Dim events As Variant
Dim x As Integer

Dim Matches As Variant
Dim Markets As Variant
Dim Leagues As Variant
Dim Fixtures As Variant


Dim Got_Extra As Boolean
Dim Finished As Boolean

Sub Get_Data()
   
               
    Finished = False
    fixtureIDx = 0
    Sheets("Premiership").Cells.ClearContents
   
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
    End If
   
    sports = ba.getSports()
   
    For Each sport In sports
       
        'Debug.Print sport.sport
       
        If sport.sport = "Soccer" Then
       
        events = ba.getEvents(sport.sportId)
           
            For Each evnt In events

                        'Debug.Print evnt.eventname
                       
                        If evnt.eventname = "Irish Soccer" Then
                       
                            Leagues = ba.getEvents(evnt.eventID)
                                For Each league In Leagues
                                   
                                    If league.eventname = "Airtricity Premier Division" Then
                                        Fixtures = ba.getEvents(league.eventID)
                                            For Each fixture In Fixtures
                                                Debug.Print fixture.eventname
                                                If Left(fixture.eventname, 8) = "Fixtures" Then
                                                   Matches = ba.getEvents(fixture.eventID)
                                                        For Each Match In Matches
                                                           
                                                            matchIDx = 0
                                                           Markets = ba.getEvents(Match.eventID)
                                                                For Each market In Markets
                                                                    cont2 = 5
                                                                    marketIDx = 0
                                                                    openNextMarket
                                                                    Exit Sub

                                                            Next market
                                                        Next Match
                                                End If
                                            Next fixture
                                    End If
                                Next league
                        End If
                       
            Next evnt
   End If
   
   Next sport
   
   
End Sub

Private Sub openNextMarket()
        On Error GoTo 0
       
        Dim found As Boolean
   
    While marketIDx <= UBound(Markets) And Not found
   
           
            found = True
            currentMarketId = Markets(marketIDx).eventID
            marketUpdated = False
            Got_Extra = False
           
                    If marketIDx <= UBound(Markets) Then
                    Debug.Print "Opening market id:" & Markets(marketIDx).eventID & " - " & Matches(matchIDx).eventname & " : " & Matches(matchIDx).eventID&; " : " & Markets(marketIDx).eventname
                    result = ba.openMarket(Markets(marketIDx).eventID, Markets(marketIDx).exchangeId)
                    marketIDx = marketIDx + 1
                   
                    If marketIDx = UBound(Markets) Then
                    GoTo Check_If_Last_Market_In_Game
                    Else
                    Exit Sub
                    End If
                   
                    End If
                   
   
    marketIDx = marketIDx + 1
    Wend
   

   
   
   
Check_If_Last_Market_In_Game:

If marketIDx > UBound(Markets) And matchIDx <> UBound(Matches) Then
    ' we have reached the last market (market.eventname), in that particular match (match.eventname) so
    ' we need to load up the markets array for the next match
    'MsgBox markets(marketIDx).eventname
    matchIDx = matchIDx + 1

On Error Resume Next
    Markets = ba.getEvents(Matches(matchIDx).eventID)
        For Each market In Markets
            cont2 = cont2 + 5
            marketIDx = 0
            openNextMarket
            Exit Sub
        Next market
End If
   
   
If marketIDx = UBound(Markets) And matchIDx = UBound(Matches) Then
    ' we have reached the last market (market.eventname), in that particular match (match.eventname)
    ' in that fixture list - so
    ' we need to load up the matches and then markets array for the next fixture
    'MsgBox markets(marketIDx).eventname
    fixtureIDx = fixtureIDx + 1
    matchIDx = 0
    marketIDx = 0
   
    On Error Resume Next

        Matches = ba.getEvents(Fixtures(fixtureIDx).eventID)
            Markets = ba.getEvents(Matches(matchIDx).eventID)
                For Each market In Markets
                    cont2 = cont2 + 5
                    openNextMarket
                    Exit Sub
                Next market
End If
   
     
   
   
End Sub

Private Sub ba_pricesUpdated()

If Not marketUpdated Then
        prices = ba.getPrices()
        If prices(0).marketId = currentMarketId Then    ' - "Z1" holds acount of the jockeys
            marketUpdated = True
           
            x = 5
       
            For Each priceItem In prices
               
                With Worksheets("Premiership")

                    .Cells(cont2, 2).Value = [A1]
                    .Cells(cont2, 3).Value = priceItem.Selection
                    .Cells(cont2, 4).Value = Markets(marketIDx - 1).eventID ' market ID
                    .Cells(cont2, 5).Value = Sheets("Win Market").Range("Y" & x).Value ' -additional column - selection ID

                    x = x + 1
                    cont2 = cont2 + 1
                   
                End With
                               

               
            Next
                   
                    openNextMarket
           

            cont2 = cont2 + 1
           
        End If
    End If
   
End Sub

Private Sub CommandButton1_Click()
Get_Data
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
   
    On Error GoTo 0
   
    If Target.Columns.Count = 16 Then ' And Finished = False Then
   
       
        If Sheets("Win Market").Range("Z1").Value = True And Got_Extra = False Then
            Got_Extra = True

        End If
       
       
        If Sheets("Win Market").[N3] = currentMarketId And Got_Extra = True Then
            ba_pricesUpdated
            'openNextMarket
        End If
       
    End If
End Sub



Gary
xdg99667
 
Posts: 22
Joined: Wed Jan 27, 2010 11:39 am

Return to Help

Who is online

Users browsing this forum: No registered users and 47 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.