Hi,
I'm using the market book/runnerbook python code provided on the betfair tutorial page: https://betfair-datascientists.githu...t-market-books (extract below). But whenever I run it I get 3 issues.
Firstly the Total Matched amount is always 0.
Secondly, the best back and lay amounts don't line up with the website. I've updated the price filter to include visualised bets. But its still different.
Thirdly, I can't get more market depth than 3 prices despite updating the ex_best_offers_overides to a higher number.
What am I doing wrong?
Any help is appreciated.
Updated price filter:
price_filter = betfairlightweight.filters.price_projection( price_data = ['EX_BEST_OFFERS'], virtualise = True, ex_best_offers_overrides={ 'best_prices_depth': 10 } )
Tutorial Code:
def process_runner_books(runner_books): ''' This function processes the runner books and returns a DataFrame with the best back/lay prices + vol for each runner
aram runner_books: :return: ''' best_back_prices = [runner_book.ex.available_to_back[0].price if runner_book.ex.available_to_back[0].price else 1.01 for runner_book in runner_books] best_back_sizes = [runner_book.ex.available_to_back[0].size if runner_book.ex.available_to_back[0].size else 1.01 for runner_book in runner_books] best_lay_prices = [runner_book.ex.available_to_lay[0].price if runner_book.ex.available_to_lay[0].price else 1000.0 for runner_book in runner_books] best_lay_sizes = [runner_book.ex.available_to_lay[0].size if runner_book.ex.available_to_lay[0].size else 1.01 for runner_book in runner_books] selection_ids = [runner_book.selection_id for runner_book in runner_books] last_prices_traded = [runner_book.last_price_traded for runner_book in runner_books] total_matched = [runner_book.total_matched for runner_book in runner_books] statuses = [runner_book.status for runner_book in runner_books] scratching_datetimes = [runner_book.removal_date for runner_book in runner_books] adjustment_factors = [runner_book.adjustment_factor for runner_book in runner_books] df = pd.DataFrame({ 'Selection ID': selection_ids, 'Best Back Price': best_back_prices, 'Best Back Size': best_back_sizes, 'Best Lay Price': best_lay_prices, 'Best Lay Size': best_lay_sizes, 'Last Price Traded': last_prices_traded, 'Total Matched': total_matched, 'Status': statuses, 'Removal Date': scratching_datetimes, 'Adjustment Factor': adjustment_factors }) return df
price_filter = `betfairlightweight`.filters.price_projection( price_data=['EX_BEST_OFFERS'] ) # Request market books market_books = trading.betting.list_market_book( market_ids=['1.150038686'], price_projection=price_filter ) # Grab the first market book from the returned list as we only requested one market market_book = market_books[0] runners_df = process_runner_books(market_book.runners) runners_df
I'm using the market book/runnerbook python code provided on the betfair tutorial page: https://betfair-datascientists.githu...t-market-books (extract below). But whenever I run it I get 3 issues.
Firstly the Total Matched amount is always 0.
Secondly, the best back and lay amounts don't line up with the website. I've updated the price filter to include visualised bets. But its still different.
Thirdly, I can't get more market depth than 3 prices despite updating the ex_best_offers_overides to a higher number.
What am I doing wrong?
Any help is appreciated.
Updated price filter:
price_filter = betfairlightweight.filters.price_projection( price_data = ['EX_BEST_OFFERS'], virtualise = True, ex_best_offers_overrides={ 'best_prices_depth': 10 } )
Tutorial Code:
def process_runner_books(runner_books): ''' This function processes the runner books and returns a DataFrame with the best back/lay prices + vol for each runner
aram runner_books: :return: ''' best_back_prices = [runner_book.ex.available_to_back[0].price if runner_book.ex.available_to_back[0].price else 1.01 for runner_book in runner_books] best_back_sizes = [runner_book.ex.available_to_back[0].size if runner_book.ex.available_to_back[0].size else 1.01 for runner_book in runner_books] best_lay_prices = [runner_book.ex.available_to_lay[0].price if runner_book.ex.available_to_lay[0].price else 1000.0 for runner_book in runner_books] best_lay_sizes = [runner_book.ex.available_to_lay[0].size if runner_book.ex.available_to_lay[0].size else 1.01 for runner_book in runner_books] selection_ids = [runner_book.selection_id for runner_book in runner_books] last_prices_traded = [runner_book.last_price_traded for runner_book in runner_books] total_matched = [runner_book.total_matched for runner_book in runner_books] statuses = [runner_book.status for runner_book in runner_books] scratching_datetimes = [runner_book.removal_date for runner_book in runner_books] adjustment_factors = [runner_book.adjustment_factor for runner_book in runner_books] df = pd.DataFrame({ 'Selection ID': selection_ids, 'Best Back Price': best_back_prices, 'Best Back Size': best_back_sizes, 'Best Lay Price': best_lay_prices, 'Best Lay Size': best_lay_sizes, 'Last Price Traded': last_prices_traded, 'Total Matched': total_matched, 'Status': statuses, 'Removal Date': scratching_datetimes, 'Adjustment Factor': adjustment_factors }) return df price_filter = `betfairlightweight`.filters.price_projection( price_data=['EX_BEST_OFFERS'] ) # Request market books market_books = trading.betting.list_market_book( market_ids=['1.150038686'], price_projection=price_filter ) # Grab the first market book from the returned list as we only requested one market market_book = market_books[0] runners_df = process_runner_books(market_book.runners) runners_df


Comment