Lay price for equivalent Betfair starting price

Post Reply
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

I am using the historical Betfair starting price to build an api application. I have used the following website to get the Betfair starting price https://promo.betfair.com/betfairsp/prices.

As my application has developed I have been looking at laying my bets. The data found in the above website only has the back price. Is there somewhere where I can get the lay price for the corresponding Betfair starting price?

I have had a look at the Betfair historical data website but this not really appropriate as it has all prices prior to the race. The previous website was great as I could write some python code that scraped the website and appended the excel sheets together and therefore having a large amount of easy to use data. I have also considered simulating the corresponding lay price but this is not really a satisfactory solution.
User avatar
Dallas
Posts: 22713
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

If you mean the BSP that is both a back and lay price
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

Ok great that saves me a lot of work actually. I've had a look through the documentation and I think I understand how it is calculated. Basically, it balances all the back starting prices and lay starting prices. Is this correct?

Also, would this example hold true? Let's say the very instant before the race the starts and betting suspended the back price is 2.1 and the lay price is 2.2 would an estimated starting price be 2.15 be accurate?
User avatar
Dallas
Posts: 22713
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

Yes it balances out backers Vs Layers who have taken SP to find an average for everyone but doesn't just find a middle price, SP can often be several ticks away from the last back and lay price
User avatar
firlandsfarm
Posts: 2722
Joined: Sat May 03, 2014 8:20 am

Dallas wrote:
Thu Apr 04, 2019 10:44 pm
... SP can often be several ticks away from the last back and lay price
,,, And can produce some interesting Books …

11/01/2019 19:30 Dundalk Book=109%
04/03/2019 19:45 Wolverhampton Book=94%

These are a couple of extremes for 2019 but they show how it can be … the trouble is you never know in advance. :(
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

My dependent variables in my model are the size of the order and if to back or lay selection. While my independent variable is the BSP.

So I will try to predict the BSP the instance before the race using multiple linear regression using available prices and volume at which they are available on both back and lay market.

@firlandsfarm when you say 109% and 94% what do you mean by this?
User avatar
firlandsfarm
Posts: 2722
Joined: Sat May 03, 2014 8:20 am

u18sc11 wrote:
Fri Apr 05, 2019 10:44 am
@firlandsfarm when you say 109% and 94% what do you mean by this?
The BSP Book% … Sum(1/SPodds). So in those examples BSP was 9% 'over book' in one case and 6% 'under book' in the other.
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

@firlandsfarm cheers.

Is there anywhere I can get the historical data for the last traded price prior to the starting price bets been taken?

This would help with my linear regression model.
LinusP
Posts: 1873
Joined: Mon Jul 02, 2012 10:45 pm

u18sc11 wrote:
Fri Apr 05, 2019 1:45 pm
@firlandsfarm cheers.

Is there anywhere I can get the historical data for the last traded price prior to the starting price bets been taken?

This would help with my linear regression model.
Unless you are backing inplay how will you get/use that variable when betting?
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

So doing my analysis I used the BSP odds to determine back or lay and size. Clearly, that variable only comes available after the race has started so not really usable when I use my application live.

To overcome this I have estimated the odds just prior to the race start by adding some noise to the BSP. I then use this as the independent variable. From this I determine the size of the order and if it is back or lay. The order is then placed at the BSP price.

The potential problem with this solution is that the odds just prior to the BSP odds becoming available (race start) may, in reality, be distributed in some sort of pattern which my model does not capture. This pattern could be that the BSP might be closer to the lay price or back price under certain conditions.

I did use a multiple linear regression model which used: Maximum price placed before the off, Minimum price placed before the off, Maximum price placed in-play, Minimum price placed in-play, Amount traded before 11am GMT, Amount traded before the off and Amount traded in-play to predict the BSP price but this was pretty useless.

I think adding the prices available and volume at which they are available would increase the accuracy of the multiple linear regression model but Betfair historical data is relatively opaque and I am not currently able to add this right now. Though this may change in the future.
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

I have been digging deeper into the Betfair api and it is possible to get the Near price which is the price if the race was to start at that very moment. The code required is:

def getMarketBookBestOffers(marketId):

global market_book_result, market_ID

print ('Calling listMarketBook to read prices for the Market with ID :' + marketId)
market_book_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params": {"marketIds":["' + marketId + '"],"priceProjection":{"priceData":["SP_TRADED"]}}, "id": 1}'
"""
print(market_book_req)
"""
market_book_response = callAping(market_book_req)
"""
print(market_book_response)
"""
market_book_loads = json.loads(market_book_response)
try:
market_book_result = market_book_loads['result']
return market_book_result
except:
print ('Exception from API-NG' + str(market_book_result['error']))
exit()

The thing that changes for the market_book_req string is "SP_TRADED".

The closer this code is run to the start of the race the better estimate of the BSP price.
LinusP
Posts: 1873
Joined: Mon Jul 02, 2012 10:45 pm

u18sc11 wrote:
Fri Apr 12, 2019 12:04 pm
I have been digging deeper into the Betfair api and it is possible to get the Near price which is the price if the race was to start at that very moment. The code required is:

def getMarketBookBestOffers(marketId):

global market_book_result, market_ID

print ('Calling listMarketBook to read prices for the Market with ID :' + marketId)
market_book_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params": {"marketIds":["' + marketId + '"],"priceProjection":{"priceData":["SP_TRADED"]}}, "id": 1}'
"""
print(market_book_req)
"""
market_book_response = callAping(market_book_req)
"""
print(market_book_response)
"""
market_book_loads = json.loads(market_book_response)
try:
market_book_result = market_book_loads['result']
return market_book_result
except:
print ('Exception from API-NG' + str(market_book_result['error']))
exit()

The thing that changes for the market_book_req string is "SP_TRADED".

The closer this code is run to the start of the race the better estimate of the BSP price.
If you are using python you should use my library, much easier ;)

https://github.com/liampauling/betfair
u18sc11
Posts: 7
Joined: Mon Mar 11, 2019 5:23 pm

Ah nice, I'll be having a swatch of that then.
Post Reply

Return to “Betfair Data”