Market_not_open_for_bsp_betting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itzafugazi
    Junior Member
    • Jul 2017
    • 2

    #1

    Market_not_open_for_bsp_betting

    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:

    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}
    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.
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    I didn't know there was an option to bet on the Sportsbook via API.

    Comment

    • betdynamics
      Junior Member
      • Sep 2010
      • 534

      #3
      The API only supports betting on the Exchange.

      Your "Sportsbook" bet is actually attempting to place a BSP (MARKET_ON_CLOSE) bet on the Exchange, so I suspect you were attempting to place it on a market that did not support BSP or you were placing the bet when the market was InPlay (BSP bets can only be placed before a market goes InPlay).

      Comment

      • itzafugazi
        Junior Member
        • Jul 2017
        • 2

        #4
        Thanks for the quick reply, that would make sense. Saved me from banging my head against the wall for days to come! Cheers.

        Comment

        • LiamP
          Junior Member
          • Oct 2015
          • 284

          #5
          By the way requests has json loading built in so you can do the following:

          Code:
          return response.json()
          Like so:
          https://github.com/liampauling/betfa...ndpoint.py#L48

          Comment

          Working...
          X