Closed pjmcdermott closed 5 years ago
Further debugging has narrowed it down to an issue with the MARKET_DESCRIPTION response for market_id '1.152169316':
>>> sport_filter=betfairlightweight.filters.market_filter(event_type_ids=[1], in_play_only=False, market_ids=['1.152169316'])
>>> market=API.betting.list_market_catalogue(filter=sport_filter,market_projection=['MARKET_DESCRIPTION'])
Traceback (most recent call last):
File "/home/paul/.virtualenvs/tf_betting/lib/python3.6/site-packages/betfairlightweight/endpoints/baseendpoint.py", line 107, in process_response
return [resource(elapsed_time=elapsed_time, **x) for x in result]
File "/home/paul/.virtualenvs/tf_betting/lib/python3.6/site-packages/betfairlightweight/endpoints/baseendpoint.py", line 107, in <listcomp>
return [resource(elapsed_time=elapsed_time, **x) for x in result]
File "/home/paul/.virtualenvs/tf_betting/lib/python3.6/site-packages/betfairlightweight/resources/bettingresources.py", line 257, in __init__
kwargs.get('description') else None
TypeError: __init__() missing 1 required positional argument: 'marketType'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/paul/.virtualenvs/tf_betting/lib/python3.6/site-packages/betfairlightweight/endpoints/betting.py", line 158, in list_market_catalogue
return self.process_response(response, resources.MarketCatalogue, elapsed_time, lightweight)
File "/home/paul/.virtualenvs/tf_betting/lib/python3.6/site-packages/betfairlightweight/endpoints/baseendpoint.py", line 109, in process_response
raise InvalidResponse(response=result)
betfairlightweight.exceptions.InvalidResponse: Invalid response received: [{'marketId': '1.152169316', 'marketName': 'Top On Christmas Day 2018', 'description': {'persistenceEnabled': True, 'bspMarket': False, 'marketTime': '2018-08-20T18:00:00.000Z', 'suspendTime': '2018-08-20T18:00:00.000Z', 'bettingType': 'ODDS', 'turnInPlayEnabled': True, 'regulator': 'GIBRALTAR REGULATOR', 'marketBaseRate': 5.0, 'discountAllowed': True, 'wallet': 'UK wallet', 'rules': '<b>Market Information</b><br>For further information please see <a href=http://content.betfair.com/aboutus/content.asp?sWhichKey=Rules%20and%20Regulations#undefined.do style=color:0163ad; text-decoration: underline; target=_blank>Rules & Regs</a>.<br><br> Which team will be top of this league on the 25th December? The market will be settled based on league position as of 25th December regardless of games played and any postponements/abandonments. At the start of this league all unmatched bets will be cancelled and the market reopened. Customers are responsible for managing their own positions at all times in this market. Competition Rules Apply.<br><br>', 'rulesHasDate': False, 'priceLadderDescription': {'type': 'CLASSIC'}}, 'totalMatched': 56.58}]
It seems to me the issue is that betfairlightweight
assumes that the marketType
field is mandatory, when this is not always the case.
According to the docs it is mandatory field on the response so this looks like a Betfair error but to be honest this isn’t the first time we have had something like this.
Calls to list_market_catalogue() with a large value for max_results results in a exception during processing of the returned data (at least today, 2018-12-15):
betfairlightweight
appears to think that the API response is invalid.Interestingly, using a small number for
max_results
(=20) appears to work:Possibly the issue is with a response for a specific market?
In fact, the call works for a range of values for
max_length
up to 39, suggesting that it may be an issue with the response for the 40th market today (2018-12-15 at 20:52 GMT):