Locate the program Excel.exe where your Microsoft Office program files are installed. A file named Excel.exe.config needs to be created in the same folder if it does not already exist. Edit the file with Notepad and insert the following lines.
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v1.1.4322"/>
</startup>
</configuration>
For communication to take place Betting Assistant must be running and the interface enabled in preferences.
The acception connections IP address must be set to the computer you wish to automate Betting Assistant from which is usually the same computer (ip address 127.0.0.1). This is to prevent unauthorised access as IP communication is used over port number 8000 and if this port is not blocked by your firewall then there is potential for Betting Assistant to be automated over the internet. Betting Assistant will only accept connections from the IP address you provide.
test_BA_COM.xls | Demonstrates getBalance, getSports, getEvents, openMarket, pricesUpdated, getPrices, layField, getBets, cancelAllBets and placeBet. Click the Start button and it will load the next UK horse racing market and start refreshing. |
getSaddleCloth_example.xls | Demonstrates using a custom function to get the saddlecloth number (complements normal Excel logging) |
BettingAssistantCom.ComClass reference
Properties |
Set or retrieve refresh rate in seconds. Minimum allowed value is 0.2
ba.refreshRate=1
currentRefreshRate=ba.refreshRate
Current market id
Events |
pricesUpdated
This event is fired on each refresh of the currently displayed market.
Dim WithEvents ba As
BettingAssistantCom.ComClass
Private Sub ba_pricesUpdated()
prices = ba.getPrices
i = 4
For Each priceItem In prices
i = i + 1
Cells(i, 1).Value =
priceItem.Selection
Cells(i, 2).Value = priceItem.backOdds1
Cells(i, 3).Value = priceItem.layOdds1
Cells(i, 4).Value = priceItem.lastMatched
Cells(i, 5).Value = priceItem.totalMatched
Next
End Sub
Functions |
Cancels all unmatched bets in currently displayed market. Returns empty string if successful or error message.
getBalance(exchangeId:integer): Balance
exchangeId: 1=UK server, 2=Australian server
Returns current balance in a Balance object.
ref: Bet reference
Returns current status of a single bet in a BetDetail object.
getBets(): Bet()
Returns all matched and unmatched bets for the currently displayed market in an array of Bet object
getEvents(eventId:integer): BfEevent()
Returns a list of events linked to the eventId in an array of BfEevent objects.
Returns last refreshed prices for all selections in currently displayed market in an array of Price object.
horse: name of horse
Return saddlecloth number of horse.
Returns list of available sports in an array of BfSport objects.
getUserName(): string
Description
Returns currently logged in Betfair username.
layField(odds:double,stake:double): string()
odds: odds to lay at for each selection
stake: stake to lay at for each selection
Lays every selection in the currently displayed market in Betting Assistant.
The function returns the bet refs in a string array. If the bet placement fails then each bet ref will contain the error message received from Betfair’s server.
loadQuickPickList(marketType:byte): string
marketType: 1 = UK Win (Horse Racing)
2 = UK Place (Horse Racing)
3 = Ireland Win (Horse Racing)
4 = Ireland Place (Horse Racing)
5 = US Win (Horse Racing)
6 = US Place (Horse Racing)
7 = AUS Win (Horse Racing)
8 = AUS Place (Horse Racing)
9 = RSA Win (Horse Racing)
10 = UK Grehounds
Loads markets into quick pick list. Returns an empty string if successful or an error message.
openMarket(eventId:integer,exchangeId:integer): string
Displays the market in in the current tab page in Betting Assistant. Returns empty string if successful or error message.
placeBet(selecId:integer,betType:string,odds:double,stake:double): string
selecId: index of selection, eg. To place a bet on the 3rd
selection down selecId=2
betType: “B” to back and “L” to lay.
Odds: required odds
Stake: required stake
Places a bet on 1 selection and returns bet reference or error message received from Betfair’s server.
setIPAddress(ip:string)
ip: ip address of the computer where Betting Assistant is running.
Sets the ip address that will be used for communicating with Betting Assistant. If your VBA application is running on the same PC then you do not need to set this, the default address 127.0.0.1 will be used.
setQuickPickAutoSelect(waitUntilAfterOff:boolean,timeBeforeOff:integer):
string
waitUntilAfterOff: wait until market has been suspended after scheduled off or turned in play before switching markets: true or false
timeBeforeOff: number of minutes before scheduled off to select market (eg. 1 = market will be selected 1 minute before scheduled off)
Set quick pick list auto select options (use in conjunction with loadQuickPickList function. Returns empty string if successful or error message.
Objects |
availBalance:double current balance available to bet with
balance:double total balance including ignoring current exposure
exposure:double current exposure of outstanding bets.
Selection:string name of selection
ref:string bet reference
betDate:string date and time of bet placement
betType:string type of bet: “B” for back and “L” for lay
stake:double bet stake
odds:double bet odds
matched:string matched status: “F” for matched and “U” for unmatched
selectionId:integer selection id
subMarket:integer sub market id (used in Asian markets)
marketId:integer market id
ref:string Bet reference
avgPrice:double Average odds matched
betStatus:string Matched status
betType:string “B” = back, “L” = lay
matchedDate:date Time bet was matched
matchedSize:double Matched stake
price:double Requested odds
remainingSize:double Portion of stake currently unmatched
requestedSize:double Requested stake
selectionId:integer id of selection
selectionName:string Name of selection
Field Description
eventName:string name of event
eventId:integer id of event
startTime:date scheduled start time of event
isMarket:boolean If true then this is a market and has no sub-events (ie. it can be used with openMarket)
exchangeId:integer
The Betfair exchange id (ie. UK or Australia)
sport:string name of sport
sportId:integer id number of sport
Selection:string name of selection
backOdds3:double 3rd best available price offered by layers
backOdds2:double 2nd best available price offered by layers
backOdds1:double best available price offered by layers
layOdds1:double best available price offered by backers
layOdds2:double 2nd best available price offered by backers
layOdds3:double 3rd best available price offered by backers
backMoney3:double money available to back at 3rd best available price offered by layers
backMoney2:double money available to back at 2nd best available price offered by layers
backMoney1:double money available to back at best available price offered by layers
backMoney1:double money available to lay at best available price offered by backers
layMoney2:double money available to lay at 2nd best available price offered by backers
backMoney3:double money available to lay at 3rd best available price offered by backers
liability:double current liability against selection
reductionFactor:double reduction factor of selection
lastMatched:double last matched price for selection
totalMatched:double total matched for selection
inPlay:boolean Indicates if market is in play
suspended:boolean Indicates if market is suspended