betcode-org / betfair

betfairlightweight - Betfair API-NG python wrapper (with streaming)
MIT License
433 stars 151 forks source link

RunnerCatalogue metadata can be empty/non-existent (eg non-horse events) #69

Closed oughtotrade closed 7 years ago

oughtotrade commented 7 years ago

In the betfair documentation, a RunnerCatalogue's metadata is not mandatory. For some sports/events, particularly non-horse racing, metadata is not returned. Betfair RunnerCatalog

However in bettingresources.py#L190, metadata is configured as mandatory.

Since release 1.1.2, list_market_catalogue method fails when it tries to make RunnerCatalogue resources as part of the MarketCatalogue resource.

In this traceback, debugging showed that there was no metadata in the runners returned by listMarketCatalogue: {u'handicap': 0.0, u'runnerName': u'San Antonio Spurs', u'selectionId': 237471, u'sortPriority': 1}

Traceback:

Traceback (most recent call last):
  File "anon-app.py", line 63, in <module>
    jobs.update_market_subscription_list()
  File "/home/anon/github/anon-app/jobs/job.py", line 185, in update_market_subscription_list
    market_id_list = self.betfair_api.betting.list_market_catalogue(market_filter, market_projection=market_projection, max_results=100, lightweight=False)
  File "/home/anon/.virtualenvs/anon-app/local/lib/python2.7/site-packages/betfairlightweight/endpoints/betting.py", line 158, in list_market_catalogue
    return self.process_response(response, resources.MarketCatalogue, elapsed_time, lightweight)
  File "/home/anon/.virtualenvs/anon-app/local/lib/python2.7/site-packages/betfairlightweight/endpoints/baseendpoint.py", line 100, in process_response
    return [resource(elapsed_time=elapsed_time, **x) for x in result]
  File "/home/anon/.virtualenvs/anon-app/local/lib/python2.7/site-packages/betfairlightweight/resources/bettingresources.py", line 222, in __init__
    self.runners = [RunnerCatalogue(**i) for i in kwargs.get('runners', [])]
TypeError: __init__() takes exactly 6 arguments (5 given)
liampauling commented 7 years ago

Sorry missed this, just pushed 1.1.3 through to PyPi, let me know if you find anymore.

oughtotrade commented 7 years ago

No problem! :+1: