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.
Lay price for equivalent Betfair starting price
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?
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?
- firlandsfarm
- Posts: 2720
- Joined: Sat May 03, 2014 8:20 am
,,, 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.
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?
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?
- firlandsfarm
- Posts: 2720
- Joined: Sat May 03, 2014 8:20 am
Unless you are backing inplay how will you get/use that variable when betting?
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.
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.
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.
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 easieru18sc11 wrote: ↑Fri Apr 12, 2019 12:04 pmI 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.
https://github.com/liampauling/betfair