by nanook » Sat May 14, 2011 7:24 am
I found a visual basic program on the internet that does (I think) return this information and is available from the free API. See the module below. When I run this I get non-zero values for .totalBspBackAmount and .totalBspLayAmount (at least for prices 1.01 and 1000) before the market goes in play and the SP is calculated. The values returned are the values in the Betfair price page for each horse under the Betfair Starting Price Backers' stake and Layers' liability columns. Depending on liquidity, there is usually a non-zero value for price = 1.01 (SP Backers' stake) and price = 1000 (Layers' liability). There are sometimes values for prices in between which I assume are SP limit bets.
This actually appears to work fine. The problem I'm having is getting the data into the excel sheet that contains my VBA code and that's why I started looking at the BA COM feature hoping there was something equivalent and I could get the data directly from BA. But as I'm probably the only nutcase on the planet thinking about this, don't worry about it - I'll look for a workaround. Thanks anyway.
Module Unpack2
Class RunnerInfoType
Public selectionID As Integer
Public sortOrder As Integer
Public totalAmountMatched As Double
Public lastPriceMatched As Double
Public handicap As Double
Public reductionFactor As Double
Public vacant As Boolean
Public asianLineID As Integer
Public farBSP As Double
Public nearBSP As Double
Public actualBSP As Double
Public prices As PricesType()
End Class
Class PricesType
Public price As Double
Public backAmount As Double
Public layAmount As Double
Public totalBspBackAmount As Double
Public totalBspLayAmount As Double
End Class
Class UnpackCompleteMarketPricesCompressed
Public marketID As Integer
Public delay As Integer
Public removedRunners As String
Public runnerInfo As RunnerInfoType() = {}
Private Const ColonCode = "&%^@" 'the substitute code for "\:"
Sub New(ByVal MarketPrices As String) 'Unpack the data string
Dim Mprices, Field, Part As String(), k, n, m As Integer
Mprices = MarketPrices.Replace("\:", ColonCode).Split(":") 'Split the runner data fields
Field = Mprices(0).Replace("\~", "-").Split("~") 'Split the market data fields
marketID = Field(0) 'assign the market data
delay = Field(1)
removedRunners = Field(2).Replace(ColonCode, ":")
n = UBound(Mprices) - 1
ReDim runnerInfo(n)
For i = 0 To n 'for each runner
Part = Mprices(i + 1).Split("|") 'split runner string into 2 parts
Field = Part(0).Split("~") 'split runner into fields
runnerInfo(i) = New RunnerInfoType
With runnerInfo(i) 'assign the runner parameters
.selectionID = Field(0)
.sortOrder = Field(1)
.totalAmountMatched = Val(Field(2))
.lastPriceMatched = Val(Field(3))
.handicap = Val(Field(4))
.reductionFactor = Val(Field(5))
.vacant = (Field(6).ToLower = "true")
.asianLineID = Field(7)
.farBSP = Val(Field(8))
.nearBSP = Val(Field(9))
.actualBSP = Val(Field(10))
Field = Part(1).Split("~") 'split price info
m = UBound(Field) \ 5 - 1 'm = number of prices - 1
ReDim .prices(m) : k = 0
For j = 0 To m
.prices(j) = New PricesType
With .prices(j) 'load the price array
.price = Val(Field(k + 0))
.backAmount = Val(Field(k + 1))
.layAmount = Val(Field(k + 2))
.totalBspBackAmount = Val(Field(k + 3))
.totalBspLayAmount = Val(Field(k + 4))
k += 5
End With
Next
End With
Next
End Sub
End Class
End Module