Moderator: 2020vision
by the_mathman » Sun Sep 12, 2010 4:24 pm
by the_mathman » Mon Sep 13, 2010 8:57 am
by GaryRussell » Mon Sep 13, 2010 9:01 am
Public Sub test()
If ba Is Nothing Then
Set ba = New BettingAssistantCom.ComClass
End If
sports = ba.getSports()
For Each sport In sports
'MsgBox sport.sport & sport.sportid
If sport.sportid = 13 Then 'Horse - Today races
events = ba.getEvents(sport.sportid)
cont = 1
For Each evnt In events
If Not (InStr(evnt.eventName, "(") > 0) Then
With Worksheets("Events")
.Cells(cont, 1).Value = evnt.eventId
.Cells(cont, 2).Value = evnt.eventName
' result = ba.openMarket(evnt.eventid, evnt.exchangeId)
End With
cont = cont + 1
result = ba.openMarket(evnt.eventId, evnt.exchangeId)
Do
prices = ba.getPrices()
Loop Until UBound(prices) > 0
While Val(prices(0).marketId) <> evnt.eventId
prices = ba.getPrices()
Wend
cont2 = 1
For Each priceItem In prices
With Worksheets("Horse")
.Cells(cont2, 1).Value = evnt.eventId
.Cells(cont2, 2).Value = priceItem.Selection
.Cells(cont2, 3).Value = priceItem.backOdds1
.Cells(cont2, 4).Value = priceItem.layOdds1
End With
cont2 = cont2 + 1
Next
End If
Next
End If
Next
End Sub
by the_mathman » Mon Sep 13, 2010 9:27 am
by GaryRussell » Mon Sep 13, 2010 9:31 am
the_mathman wrote:thank you Gary!
I try it this night.
A question:
for my purpose, the use of the command
result = ba.openMarket(evnt.eventId, evnt.exchangeId)
is required?
If I want to use the ba.getPrices() function for all the events, must i open all the markets?
thank you again
by xdg99667 » Mon Apr 18, 2011 1:24 pm
While Sheets(Win Market").[A1] = ""
DoEvents
Wend.
Public Sub test2()
If ba Is Nothing Then
Set ba = New BettingAssistantCom.ComClass
End If
sports = ba.getSports()
For Each sport In sports
'MsgBox sport.sport & sport.sportid
If sport.sportid = 13 Then 'Horse - Today races
events = ba.getEvents(sport.sportid)
cont = 1
cont2 = 5
For Each evnt In events
If Not (InStr(evnt.eventName, "(") > 0) Then
cont = cont + 1
'Debug.Print evnt.eventId; " : " & evnt.exchangeId
Sheets("Win Market").[a1] = ""
result = ba.openMarket(evnt.eventId, evnt.exchangeId)
Do
prices = ba.getPrices()
Loop Until UBound(prices) > 0
While Val(prices(0).marketId) <> evnt.eventId
prices = ba.getPrices()
Wend
While Sheets("Win Market").[a1] = ""
DoEvents
Wend
Debug.Print Sheets("Win Market").[a1]
cont2 = cont2 + 1
For Each priceItem In prices
With Worksheets("Horse")
.Cells(cont2, 2).Value = Sheets("Win Market").[a1]
.Cells(cont2, 3).Value = evnt.startTime
.Cells(cont2, 4).Value = evnt.eventId
.Cells(cont2, 5).Value = priceItem.Selection
.Cells(cont2, 6).Value = priceItem.backOdds1
.Cells(cont2, 7).Value = priceItem.layOdds1
End With
cont2 = cont2 + 1
Next
End If
Next
End If
Next
End Sub
by GaryRussell » Tue Apr 19, 2011 8:56 am
Public Sub test2()
Application.EnableEvents = false
If ba Is Nothing Then
Set ba = New BettingAssistantCom.ComClass
End If
sports = ba.getSports()
For Each sport In sports
'MsgBox sport.sport & sport.sportid
If sport.sportid = 13 Then 'Horse - Today races
events = ba.getEvents(sport.sportid)
cont = 1
cont2 = 5
For Each evnt In events
If Not (InStr(evnt.eventName, "(") > 0) Then
cont = cont + 1
'Debug.Print evnt.eventId; " : " & evnt.exchangeId
Sheets("Win Market").[a1] = ""
result = ba.openMarket(evnt.eventId, evnt.exchangeId)
Do
prices = ba.getPrices()
Loop Until UBound(prices) > 0
While Val(prices(0).marketId) <> evnt.eventId
prices = ba.getPrices()
Wend
While Sheets("Win Market").[a1] = ""
DoEvents
Wend
Debug.Print Sheets("Win Market").[a1]
cont2 = cont2 + 1
For Each priceItem In prices
With Worksheets("Horse")
.Cells(cont2, 2).Value = Sheets("Win Market").[a1]
.Cells(cont2, 3).Value = evnt.startTime
.Cells(cont2, 4).Value = evnt.eventId
.Cells(cont2, 5).Value = priceItem.Selection
.Cells(cont2, 6).Value = priceItem.backOdds1
.Cells(cont2, 7).Value = priceItem.layOdds1
End With
cont2 = cont2 + 1
Next
End If
Next
End If
Next
Application.EnableEvents = true
End Sub
by xdg99667 » Tue Apr 19, 2011 10:27 am
by xdg99667 » Tue Apr 19, 2011 2:34 pm
by GaryRussell » Tue Apr 19, 2011 2:57 pm
xdg99667 wrote:sorry just to add, there is nothing on the worksheet_change event but i will try turning events off.
I cant think of a way around it (the DoEvents loop) myself
Cheers, Gary
by xdg99667 » Wed Apr 20, 2011 12:41 pm
by GaryRussell » Wed Apr 20, 2011 2:50 pm
Dim WithEvents ba As BettingAssistantCom.ComClass
Dim currentMarketId As String, marketUpdated As Boolean, eventIdx As Integer
Dim cont2 As Integer
Dim events As Variant
Sub test2()
If ba Is Nothing Then
Set ba = New BettingAssistantCom.ComClass
End If
sports = ba.getSports()
For Each sport In sports
'MsgBox sport.sport & sport.sportid
If sport.sportid = 13 Then 'Horse - Today races
events = ba.getEvents(sport.sportid)
cont2 = 5
eventIdx = 0
openNextMarket
End If
Next
End Sub
Private Sub openNextMarket()
Dim found As Boolean
While eventIdx <= UBound(events) And Not found
If Not (InStr(events(eventIdx).eventName, "(") > 0) Then
found = True
currentMarketId = events(eventIdx).eventId
marketUpdated = False
'Debug.Print "Opening market id:" & events(eventIdx).eventId
result = ba.openMarket(events(eventIdx).eventid, events(eventIdx).exchangeId)
End If
eventIdx = eventIdx + 1
Wend
If eventIdx > UBound(events) Then Debug.Print "Finished."
End Sub
Private Sub ba_pricesUpdated()
If Not marketUpdated Then
prices = ba.getPrices()
If prices(0).marketId = currentMarketId And [N3] = currentMarketId Then
marketUpdated = True
Debug.Print [A1]
For Each priceItem In prices
With Worksheets("Horse")
.Cells(cont2, 2).Value = [A1]
.Cells(cont2, 3).Value = events(eventIdx - 1).startTime
.Cells(cont2, 4).Value = events(eventIdx - 1).eventid
.Cells(cont2, 5).Value = priceItem.Selection
.Cells(cont2, 6).Value = priceItem.backOdds1
.Cells(cont2, 7).Value = priceItem.layOdds1
End With
cont2 = cont2 + 1
Next
openNextMarket
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count = 16 Then
If [F2] = "Closed" Then openNextMarket
End If
End Sub
by xdg99667 » Thu Apr 21, 2011 12:08 am
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.