Lay price for equivalent Betfair starting price

Post Reply
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: 1871
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”