Betting Assistant exposes some functions through a COM interface. You can call these functions from VBA (Visual Basic for Applications) in programs such as Excel, Access and Word.

 

To use these functions you must add a reference to BettingAssistantCom to your application (in the code editor select 'Tools|References' and add the reference). If the reference is not listed then you need to re-install Betting Assistant from http://www.gruss-software.co.uk/Betting_Assistant_Beta/Betting_Assistant_Beta.msi It is recommended that you uninstall any previously installed versions first.

 

 

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.

Here are some examples  
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

 

refreshRate: double

Set or retrieve refresh rate in seconds. Minimum allowed value is 0.2

 

Examples

ba.refreshRate=1

currentRefreshRate=ba.refreshRate

 

 

marketId:long

Current market id

 

Events

 

pricesUpdated

Description

This event is fired on each refresh of the currently displayed market.

 

Example

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

 

cancelAllBets():string

Description

Cancels all unmatched bets in currently displayed market. Returns empty string if successful or error message.

 

getBalance(exchangeId:integer): Balance

Parameters

exchangeId: 1=UK server, 2=Australian server

Description

Returns current balance in a Balance object.

 

getBet(ref:string): BetDetail

Parameters

ref: Bet reference

Description

Returns current status of a single bet in a BetDetail object.

 

getBets(): Bet()

Description

Returns all matched and unmatched bets for the currently displayed market in an array of Bet object

 

getEvents(eventId:integer): BfEevent()

Parameters

EventId: id of event returned from getSports or getEevents

Description

Returns a list of events linked to the eventId in an array of BfEevent objects.

 

getPrices(): Price()

Description

Returns last refreshed prices for all selections in currently displayed market in an array of Price object.

 

getSaddleCloth(horse as string): integer

Parameters

horse: name of horse

Description

Return saddlecloth number of horse.

 

getSports(): BfSport()

Description

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()

Parameters

odds: odds to lay at for each selection

stake: stake to lay at for each selection

Description

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

Parameters

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

Description

Loads markets into quick pick list. Returns an empty string if successful or an error message.

  

openMarket(eventId:integer,exchangeId:integer): string

Parameters

EventId: event id of market as retrieved in getEvents

exchangeId: selects UK or Australian exchange. 1=UK, 2=Australian

Description

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

Parameters

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

Description

Places a bet on 1 selection and returns bet reference or error message received from Betfair’s server.

 

setIPAddress(ip:string)

Parameters

ip: ip address of the computer where Betting Assistant is running.

Description

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

Parameters

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)

Description

Set quick pick list auto select options (use in conjunction with loadQuickPickList function. Returns empty string if successful or error message.

 

 

Objects

 

 

Balance

Field                                        Description

availBalance:double                  current balance available to bet with

balance:double                          total balance including ignoring current exposure

exposure:double                       current exposure of outstanding bets.

 

Bet

Field                                        Description

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

 

BetDetail

Field                                        Description

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

 

BfEvent

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)

 

BfSport

Field                                        Description

sport:string                                name of sport

sportId:integer                          id number of sport

 

Price

Field                                        Description

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