Hello,
New to Python and the API, so appologies if this is obvious, but I'm having trouble with a "MARKET_NOT_OPEN_FOR_BSP_BETTING" errorCode, and I'm not sure what I'm doing wrong.
Using the same marketId and selectionId, a request to place a bet on the Exchange works fine, but I receive the error on the Sportsbook.
Below are my basic functions for placing a bet on both the Exchange and Sportsbook:
And below is the response I get for the Sportsbook request:
Could somebody point me in the right direction on this please? If it makes any difference, this request was for today's tennis match, Isner v Muller.
New to Python and the API, so appologies if this is obvious, but I'm having trouble with a "MARKET_NOT_OPEN_FOR_BSP_BETTING" errorCode, and I'm not sure what I'm doing wrong.
Using the same marketId and selectionId, a request to place a bet on the Exchange works fine, but I receive the error on the Sportsbook.
Below are my basic functions for placing a bet on both the Exchange and Sportsbook:
Code:
def betfair_place_exchange_bet(market_id, selection_id, price, size):
# Place an Exchange bet on selection, returns details on status, reason if error, order type
json_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId":"' + str(market_id) + '","instructions":[{"selectionId":"' + str(selection_id) + '","handicap":"0","side":"BACK","orderType":"LIMIT","limitOrder":{"size":"' + str(size) + '","price":"' + str(price) + '","persistenceType":"LAPSE"}}],"customerRef":"autobetTest01"}, "id": 1}'
response = requests.post(betting_url, data=json_req, headers=header)
order = json.loads(response.text)
return order
def betfair_place_sportsbook_bet(market_id, selection_id, size):
# Place a Sportsbook bet on selection, returns details on status, reason if error, order type
json_req = '{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId": "' + str(market_id) + '", "instructions": [{"selectionId": "' + str(selection_id) + '", "handicap": "0", "side": "BACK", "orderType": "MARKET_ON_CLOSE","marketOnCloseOrder": {"liability": "' + str(size) + '"}}]}, "id": 1}'
response = requests.post(betting_url, data=json_req, headers=header)
order = json.loads(response.text)
return order
And below is the response I get for the Sportsbook request:
Code:
{'jsonrpc': '2.0', 'result': {'status': 'FAILURE', 'errorCode': 'BET_ACTION_ERROR', 'marketId': '1.132943103', 'instructionReports': [{'status': 'FAILURE', 'errorCode': 'MARKET_NOT_OPEN_FOR_BSP_BETTING', 'instruction': {'selectionId': 2474763, 'handicap': 0.0, 'marketOnCloseOrder': {'liability': 0.01}, 'orderType': 'MARKET_ON_CLOSE', 'side': 'BACK'}}]}, 'id': 1}


Comment