No announcement yet.

how to obtain the Greyhound names

  • Filter
  • Time
  • Show
Clear All
new posts

  • devon0sandwich
    Thanks so much for this! There are a lot of posts asking about this kind of thing and your solution worked for me. I had to play around with it a bit though. I've pasted my code incase anyone wants another example but it's basically the same thing. I was going to upload it as a .py but the site wont let me. This looks really bad to read but if you paste it into vscode or similar it is easier to understand.

    # processes the runnerbooks and collates the data into a DataFrame
    # (same code as betfair tutorial but i added market_catalogues arg and deleted some columns)
    def process_runner_books(runner_books, market_catalogues):
    This function processes the runner books and returns a DataFrame with the best back/lay prices for each runner
    best_back_prices = [runner_book.ex.available_to_back[0].price if runner_book.ex.available_to_back 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 else 1000.0
    for runner_book in runner_books]

    selection_ids = [runner_book.selection_id 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]
    runners = [m_cat_runner.runner_name for m_cat_runner in market_catalogues[0].runners]

    df = pd.DataFrame({
    'Runners' : runners,
    'Selection ID': selection_ids,
    'Best Back Price': best_back_prices,
    'Best Lay Price': best_lay_prices,
    'Status': statuses,
    'Removal Date': scratching_datetimes,
    return df

    # Get a list of all events as objects
    aus_all_events = trading.betting.list_events()

    # get first event
    first = aus_all_events[0]

    # event id
    eventId =
    print('eventId = ' + str(eventId))

    # now get market id
    market_catalogue_filter = betfairlightweight.filters.market_filter(event_ids =[eventId])
    market_catalogues = trading.betting.list_market_catalogue(
    max_results='1', # just get 1
    marketId = market_catalogues[0].market_id
    print('marketId = ' + str(marketId))

    # now runners
    # Create a price filter. Get all traded and offer data
    price_filter = betfairlightweight.filters.price_projection(price_ data=['EX_BEST_OFFERS'])
    # Request market books
    market_books = trading.betting.list_market_book(
    # Grab the first market book from the returned list
    market_book = market_books[0]
    runners_df = process_runner_books(market_book.runners, market_catalogues)

    Leave a comment:

  • Testify467
    started a topic how to obtain the Greyhound names

    how to obtain the Greyhound names

    since it appears that dogs generally have been assigned multiple Selection ID numbers (and a new # can be introduced at any time), the only way to definitively know that a dog you are monitoring is who you think it is, would be by name (just using the Track Name, Race #, and Trap # would not be foolproof in the case where a dog scratched and a reserve dog was put in its place - this may have to be my fallback method if the dog name cannot be easily obtained). I recall reading a similar post about finding the horse names for a race, and it seemed rather complicated. Where in the process are the names of the dogs, they are not in the runner book apparently. Any info that can point me in the right direction would be appreciated.

    have made some progress, I can now print a market catalog which apparently contains or is of type Runner Catalog. I return 20 results, the 1st of which is:

    0 [RunnerCatalogue: 23746584, RunnerCatalogue: 2....

    so the final remaining issue is to retrieve the name from this 'Runner Catalog'. Another post (for a similar question regarding horse names), goes on to say:

    "The returned MarketCatalogue object will then contain a runners field. This is of type RunnerCatalog which contains the name of the runner (in the runnerName field)".

    All attempts to now use runnerName or runner_name, result in an error, so I'm stuck, although very close I believe.

    i finally got it after a lot of trial and error. Seems like the key point is in bold. The resulting market_catalogues
    can then be inspected one-by-one to get the current selection id # for the dog, and the name.

    # MARKET CATALOG dog names
    market_catalogue_filter = betfairlightweight.filters.market_filter(

    market_catalogues = trading.betting.list_market_catalogue(

    # Create a DataFrame for each market catalogue
    market_catalogues = pd.DataFrame({
    'Runners' : [market_cat_object.runners for market_cat_object in market_catalogues]})

    print market_catalogues
    description = market_catalogues['Runners'][2] # ie. gives the 3rd row of dogs or exacta bet combinations
    print description[0] # 1st dog id # or exacta bet combo (like 1-2)
    print description[0].runner_name # 1st dog name
    Last edited by Testify467; 03-06-2020, 01:08 PM.