I am trying to get the total amount of back bets matched at the actual Betfair Starting Price and the same for the lay bets. I am using the following code:
def full_function(market_ID):
global marketId, selectionId, size, df, total_liability
getMarketBookBestOffers(marketId = market_ID)
market_book_result[0]['runners'][0]['selectionId']
runner_ID_list = []
for i in market_book_result[0]['runners']:
if i['status'] == 'ACTIVE':
ID = i['selectionId']
runner_ID_list.append(ID)
near_price_list = []
for i in market_book_result[0]['runners']:
if i['status'] == 'ACTIVE':
backStakeTaken = i['sp']['backStakeTaken']
backStakeTaken.append(backStakeTaken)
data = {'selectionId': runner_ID_list,
'backStakeTaken': backStakeTaken}
print(data)
From this I an output where the BackStakeTaken is an empty list which looks like such:
Calling listMarketBook to read prices for the Market with ID :1.163700443 {'selectionId': [10050919, 21652963, 13064814, 14386722, 11412690, 18328826, 23760347, 20548487, 13285071, 19123620, 22749575, 16704295, 10065383, 18518540], 'backStakeTaken': [[...]]}
backStakeTaken was taken from the api documentation so I assume it should work. Am I doing something wrong?
If someone could enlighten me that would be great.
All the best,
Sandy
def full_function(market_ID):
global marketId, selectionId, size, df, total_liability
getMarketBookBestOffers(marketId = market_ID)
market_book_result[0]['runners'][0]['selectionId']
runner_ID_list = []
for i in market_book_result[0]['runners']:
if i['status'] == 'ACTIVE':
ID = i['selectionId']
runner_ID_list.append(ID)
near_price_list = []
for i in market_book_result[0]['runners']:
if i['status'] == 'ACTIVE':
backStakeTaken = i['sp']['backStakeTaken']
backStakeTaken.append(backStakeTaken)
data = {'selectionId': runner_ID_list,
'backStakeTaken': backStakeTaken}
print(data)
From this I an output where the BackStakeTaken is an empty list which looks like such:
Calling listMarketBook to read prices for the Market with ID :1.163700443 {'selectionId': [10050919, 21652963, 13064814, 14386722, 11412690, 18328826, 23760347, 20548487, 13285071, 19123620, 22749575, 16704295, 10065383, 18518540], 'backStakeTaken': [[...]]}
backStakeTaken was taken from the api documentation so I assume it should work. Am I doing something wrong?
If someone could enlighten me that would be great.
All the best,
Sandy


Comment