Can't get the Market odds with listMarketBook?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Verganis
    Junior Member
    • Sep 2014
    • 6

    #1

    Can't get the Market odds with listMarketBook?

    Hello,
    newbie here.

    I have to get the odds for a single market of an event: let's say the market is "Over/Under 0.5 Goals" and the event is "Inter v Cagliari" for Italian serie A soccer.

    After getting the event id I get all the market (type of bet) for the match calling listMarketCatalogue. There I get the market id I want and with that I call listMarketBook using the filters:

    Code:
    { "marketIds" : ["1.115592631" ]
            },
                "id": 1}
    The response I get is the following
    Code:
    [
       {
          "status": "OPEN", 
          "isMarketDataDelayed": true, 
          "numberOfRunners": 2, 
          "complete": true, 
          "bspReconciled": false, 
          "runnersVoidable": false, 
          "betDelay": 0, 
          "marketId": "1.115592631", 
          "crossMatching": false, 
          "totalMatched": 0.0, 
          "version": 825009369, 
          "numberOfWinners": 1, 
          "inplay": false, 
          "numberOfActiveRunners": 2, 
          "totalAvailable": 0.0, 
          "runners": [
             {
                "handicap": 0.0, 
                "status": "ACTIVE", 
                "selectionId": 5851482
             }, 
             {
                "handicap": 0.0, 
                "status": "ACTIVE", 
                "selectionId": 5851483
             }
          ]
       }
    ]
    I don't see where is the value of the odd I asked for.
    TIA
  • betdynamics
    Junior Member
    • Sep 2010
    • 534

    #2
    You haven't told it to return any prices.

    To return prices, you need to specify the priceProjection parameter.

    Comment

    • Verganis
      Junior Member
      • Sep 2014
      • 6

      #3
      Originally posted by betdynamics View Post
      You haven't told it to return any prices.

      To return prices, you need to specify the priceProjection parameter.

      Ok great, now I get it.

      Another question: if I want to see the bet odds which are reported on the website which kind of PriceData should I set?


      I don't really get the difference between

      SP_AVAILABLE, SP_TRADED, EX_BEST_OFFERS, EX_ALL_OFFERS, EX_TRADED

      Thanks

      Comment

      • snowmoneky
        Junior Member
        • Feb 2014
        • 18

        #4
        I believe EX_BEST_OFFERS s what you want.

        Comment

        • betdynamics
          Junior Member
          • Sep 2010
          • 534

          #5
          And turn on Virtual prices.

          Comment

          • Verganis
            Junior Member
            • Sep 2014
            • 6

            #6
            Still can't get hold of betting odds, it's so frustrating.

            What I did now is:
            Code:
            # get betting markets (types of betting) for a match
                    json_req="""
                    { "marketIds" : ["1.115808950" ],
                        "priceProjection" :
                            { "priceData": ["EX_BEST_OFFERS"]
                            }
                    },
                        "id": 1}
                    """
            
            
                    url = endpoint + "listMarketBook/"
            
                    response = requests.post(url, data=json_req, headers=header)
                    print json.dumps(json.loads(response.text), indent=3)
            the response is the following

            Code:
            [
               {
                  "status": "OPEN", 
                  "isMarketDataDelayed": true, 
                  "numberOfRunners": 2, 
                  "complete": true, 
                  "bspReconciled": false, 
                  "runnersVoidable": false, 
                  "betDelay": 0, 
                  "marketId": "1.115808950", 
                  "crossMatching": false, 
                  "totalMatched": 0.0, 
                  "version": 836212495, 
                  "numberOfWinners": 1, 
                  "inplay": false, 
                  "numberOfActiveRunners": 2, 
                  "totalAvailable": 0.0, 
                  "runners": [
                     {
                        "handicap": 0.0, 
                        "status": "ACTIVE", 
                        "selectionId": 1485567, 
                        "ex": {
                           "availableToBack": [], 
                           "availableToLay": [], 
                           "tradedVolume": []
                        }
                     }, 
                     {
                        "handicap": 0.0, 
                        "status": "ACTIVE", 
                        "selectionId": 1485568, 
                        "ex": {
                           "availableToBack": [], 
                           "availableToLay": [], 
                           "tradedVolume": []
                        }
                     }
                  ]
               }
            ]
            I understand that the betting odds should appear in the "availableToLay" set but it turns out empty.

            What am I missing here?

            Thanks

            Comment

            • betdynamics
              Junior Member
              • Sep 2010
              • 534

              #7
              Try using your normal AppKey - rather than the one used with delayed prices

              Comment

              • Verganis
                Junior Member
                • Sep 2014
                • 6

                #8
                If I use my normal key the result I get is the following

                Code:
                [
                   {
                      "status": "OPEN", 
                      "isMarketDataDelayed": false, 
                      "numberOfRunners": 2, 
                      "complete": true, 
                      "bspReconciled": false, 
                      "runnersVoidable": false, 
                      "betDelay": 0, 
                      "marketId": "1.115808950", 
                      "crossMatching": false, 
                      "totalMatched": 0.0, 
                      "version": 836212495, 
                      "numberOfWinners": 1, 
                      "inplay": false, 
                      "numberOfActiveRunners": 2, 
                      "totalAvailable": 0.0, 
                      "runners": [
                         {
                            "handicap": 0.0, 
                            "status": "ACTIVE", 
                            "selectionId": 1485567, 
                            "ex": {
                               "availableToBack": [], 
                               "availableToLay": [], 
                               "tradedVolume": []
                            }
                         }, 
                         {
                            "handicap": 0.0, 
                            "status": "ACTIVE", 
                            "selectionId": 1485568, 
                            "ex": {
                               "availableToBack": [], 
                               "availableToLay": [], 
                               "tradedVolume": []
                            }
                         }
                      ]
                   }
                ]
                So not much of a difference as the output is concerned.

                The entire script code is as follows

                Code:
                cert_folder = 'certs/'
                        # login
                        session_token = None
                        user = 'verganis'
                        passw = 'mypassword!!'
                        payload = 'username={0}&password={1}'.format(user,passw)
                        headers = {'X-Application': 'DELAYED_KEY_HERE', 'Content-Type': 'application/x-www-form-urlencoded'}
                
                        resp = requests.post(
                            'https://identitysso.betfair.it/api/certlogin',
                            data=payload,
                            cert=(cert_folder+'client-2048.crt', cert_folder+'client-2048.key'),
                            headers=headers)
                
                        if resp.status_code == 200:
                            resp_json = resp.json()
                            print resp_json['loginStatus']
                            session_token = resp_json['sessionToken']
                            print resp_json['sessionToken']
                        else:
                            print "Request failed."
                            return
                
                
                        endpoint = "https://api.betfair.com/exchange/betting/rest/v1.0/"
                        header = { 'X-Application' : 'DELAYED_KEY_HERE',
                                   'X-Authentication' : session_token ,
                                   'content-type' : 'application/json' }
                
                
                        # get betting markets (types of betting) for a match
                        json_req="""
                        { "marketIds" : ["1.115808956" ],
                            "priceProjection" :
                                { "priceData": ["EX_BEST_OFFERS"]
                                }
                        },
                            "id": 1}
                        """
                
                
                        url = endpoint + "listMarketBook/"
                
                        response = requests.post(url, data=json_req, headers=header)
                        print json.dumps(json.loads(response.text), indent=3)
                What could it be?

                Comment

                • betdynamics
                  Junior Member
                  • Sep 2010
                  • 534

                  #9
                  Can you see prices if you look at the market in the visualiser?

                  Comment

                  • gus
                    Senior Member
                    • Jan 2009
                    • 134

                    #10
                    Don't know whether it will help because I use REST, but here's my call to listMarketBook for the Barclays's Premier Arsenal v Hull on 18 October Under/Over 0.5 Goals,

                    Code:
                    api.betfair.com/exchange/betting/rest/v1.0/listMarketBook/ {"priceProjection":{"exBestOffersOverrides":{"bestPri
                    cesDepth":1},"priceData":["EX_BEST_OFFERS"],"virtualise":false},"matchProjection":"ROLLED_UP_BY_AVG_PRICE","orderProject
                    ion":"ALL","marketIds":["1.115791079"]}
                    which does return lastPriceTraded and availableToBack and availableToLay:

                    [{"marketId":"1.115791079","status":"OPEN","betDela y":0,"totalAvailable":130459.52,"bspReconciled":fa lse,"numberOfActive
                    Runners":2,"version":835275792,"crossMatching":tru e,"inplay":false,"numberOfWinners":1,"totalMatched ":313.01,"complete":
                    true,"lastMatchTime":"2014-10-14T22:34:44.450Z","runners":[{"ex":{"availableToLay":[{"price":20.0,"size":26.0}],"availab
                    leToBack":[{"price":1.12,"size":7.93}],"tradedVolume":[]},"lastPriceTraded":21.0,"totalMatched":5.0,"selec tionId":585148
                    2,"status":"ACTIVE","handicap":0.0},{"ex":{"availa bleToLay":[{"price":1.06,"size":400.0}],"availableToBack":[{"price":1.
                    05,"size":56659.68}],"tradedVolume":[]},"lastPriceTraded":1.06,"totalMatched":308.01,"se lectionId":5851483,"status":"ACT
                    IVE","handicap":0.0}],"numberOfRunners":2,"runnersVoidable":false,"isMa rketDataDelayed":false}]

                    Comment

                    • Verganis
                      Junior Member
                      • Sep 2014
                      • 6

                      #11
                      Hello,
                      thanks to you all for the help.

                      Now I get to see some odds but I don't see any resamblance with the odds on the website.

                      The marketId I am using is about Under/Over 2.5 for Juventus - Sassuolo. Odds on the website are 1.75 for Over (selectionId:47973) and 2.05 for Under (selectionId:47972).

                      Now if I call the api with

                      Code:
                      { "marketIds" : ["1.115808956" ],
                                  "priceProjection" :
                                      {   "priceData": ["EX_BEST_OFFERS"]
                                      },
                                      "orderProjection": "ALL",
                                       "matchProjection":"ROLLED_UP_BY_AVG_PRICE",
                                      "virtualise":true,
                                      "currencyCode":"EUR"
                              },
                                  "id": 1}
                      The response is the following

                      Code:
                      [
                         {
                            "status": "OPEN", 
                            "isMarketDataDelayed": false, 
                            "numberOfRunners": 2, 
                            "complete": true, 
                            "bspReconciled": false, 
                            "runnersVoidable": false, 
                            "betDelay": 0, 
                            "marketId": "1.115808956", 
                            "crossMatching": false, 
                            "totalMatched": 0.0, 
                            "version": 841385150, 
                            "numberOfWinners": 1, 
                            "inplay": false, 
                            "numberOfActiveRunners": 2, 
                            "totalAvailable": 200.39, 
                            "runners": [
                               {
                                  "handicap": 0.0, 
                                  "status": "ACTIVE", 
                                  "selectionId": 47972, 
                                  "totalMatched": 0.0, 
                                  "ex": {
                                     "availableToBack": [
                                        {
                                           "price": 1.05, 
                                           "size": 95.24
                                        }, 
                                        {
                                           "price": 1.04, 
                                           "size": 96.15
                                        }
                                     ], 
                                     "availableToLay": [], 
                                     "tradedVolume": []
                                  }
                               }, 
                               {
                                  "handicap": 0.0, 
                                  "status": "ACTIVE", 
                                  "selectionId": 47973, 
                                  "totalMatched": 0.0, 
                                  "ex": {
                                     "availableToBack": [], 
                                     "availableToLay": [
                                        {
                                           "price": 22.0, 
                                           "size": 5.0
                                        }, 
                                        {
                                           "price": 27.0, 
                                           "size": 4.0
                                        }
                                     ], 
                                     "tradedVolume": []
                                  }
                               }
                            ]
                         }
                      ]
                      I set the virtual odds true because I have read on the forum that the website shows virtualized odds.

                      First of all I don't get why for 47973 I don't have data for "availableToBack" and viceversa for 47972 I don't have data for "availabletoLay". I am only interested in standard odds, nothing about trading odds, just "laying" odds. This is the first point.

                      The second is that I haven't found any explanation on the website about what "size" and "price" mean.

                      Besides that I don't see any connection between the website odds and the API odds.

                      Thanks for your help

                      Comment

                      • betdynamics
                        Junior Member
                        • Sep 2010
                        • 534

                        #12
                        Price is the odds.
                        Size is the amount available at those odds.

                        I don't know what market you are looking at, but the Over/Under 2.5 Goals market for the Juventus match is 1.115807167 (not 1.115808956)

                        Comment

                        • Verganis
                          Junior Member
                          • Sep 2014
                          • 6

                          #13
                          Yep, you were right.
                          Now I get result close to the website odds, still not exactly the same.

                          Over/Under 2.5 for Juventus-Sassuolo on the site: 1.75 for Over, 2.05 for Under. Plain odds, not exchange market.

                          If I use the following code for the request

                          Code:
                          { "marketIds" : ["1.115808946" ],
                                      "priceProjection" :
                                          {   "priceData": ["EX_ALL_OFFERS"],
                                          "exBestOffersOverrides":{"rollupModel":"STAKE","bestPricesDepth":10}
                                          },
                                          "orderProjection": "ALL",
                                           "matchProjection":"NO_ROLLUP",
                                          "virtualise":false,
                                          "currencyCode":"EUR"
                                  },
                                      "id": 1}
                          I get

                          Code:
                          [
                             {
                                "status": "OPEN", 
                                "isMarketDataDelayed": false, 
                                "numberOfRunners": 2, 
                                "complete": true, 
                                "bspReconciled": false, 
                                "runnersVoidable": false, 
                                "betDelay": 0, 
                                "marketId": "1.115808946", 
                                "crossMatching": false, 
                                "totalMatched": 0.0, 
                                "version": 841385136, 
                                "numberOfWinners": 1, 
                                "inplay": false, 
                                "numberOfActiveRunners": 2, 
                                "totalAvailable": 503.27, 
                                "runners": [
                                   {
                                      "handicap": 0.0, 
                                      "status": "ACTIVE", 
                                      "selectionId": 47972, 
                                      "totalMatched": 0.0, 
                                      "ex": {
                                         "availableToBack": [
                                            {
                                               "price": 2.0, 
                                               "size": 100.99
                                            }, 
                                            {
                                               "price": 1.99, 
                                               "size": 51.0
                                            }
                                         ], 
                                         "availableToLay": [
                                            {
                                               "price": 2.22, 
                                               "size": 45.49
                                            }, 
                                            {
                                               "price": 2.24, 
                                               "size": 44.99
                                            }
                                         ], 
                                         "tradedVolume": []
                                      }
                                   }, 
                                   {
                                      "handicap": 0.0, 
                                      "status": "ACTIVE", 
                                      "selectionId": 47973, 
                                      "totalMatched": 0.0, 
                                      "ex": {
                                         "availableToBack": [
                                            {
                                               "price": 1.84, 
                                               "size": 54.34
                                            }, 
                                            {
                                               "price": 1.82, 
                                               "size": 54.94
                                            }
                                         ], 
                                         "availableToLay": [
                                            {
                                               "price": 1.97, 
                                               "size": 50.99
                                            }, 
                                            {
                                               "price": 1.99, 
                                               "size": 50.49
                                            }, 
                                            {
                                               "price": 2.02, 
                                               "size": 49.99
                                            }
                                         ], 
                                         "tradedVolume": []
                                      }
                                   }
                                ]
                             }
                          ]
                          The closer they get to the site quotes is: 1.84 for Over (it was 1.75) and 2.0 for Under (it was 2.05).

                          I guess that there is a way to get just one result: the one that shows up on the website.

                          Plus: I use EX_ALL_OFFERS for PriceData but as I am not interested in the exchange market I guess EX means exchange, right? But if I use SP_TRADED / SP_AVAILABLE ( which I guess are for non-exchange odds) I get an almost empty response

                          Code:
                          [
                             {
                                "status": "OPEN", 
                                "isMarketDataDelayed": false, 
                                "numberOfRunners": 2, 
                                "complete": true, 
                                "bspReconciled": false, 
                                "runnersVoidable": false, 
                                "betDelay": 0, 
                                "marketId": "1.115808946", 
                                "crossMatching": false, 
                                "totalMatched": 0.0, 
                                "version": 841385136, 
                                "numberOfWinners": 1, 
                                "inplay": false, 
                                "numberOfActiveRunners": 2, 
                                "totalAvailable": 503.31, 
                                "runners": [
                                   {
                                      "handicap": 0.0, 
                                      "status": "ACTIVE", 
                                      "selectionId": 47972, 
                                      "totalMatched": 0.0
                                   }, 
                                   {
                                      "handicap": 0.0, 
                                      "status": "ACTIVE", 
                                      "selectionId": 47973, 
                                      "totalMatched": 0.0
                                   }
                                ]
                             }
                          ]
                          Thanks again

                          Comment

                          • betdynamics
                            Junior Member
                            • Sep 2010
                            • 534

                            #14
                            Your request does not appear to be for the OU 2.5 market (you are using marketId 1.115808946 and the OU 2.5 market should be 1.115807167) and you have virtual prices turned off.

                            I have just tested this on the visualiser and it shows the exact same prices between the listMarketBook call and the web site.

                            Under 2.5 ==> 2.06 back / 2.12 lay
                            Over 2.5 ==> 1.89 back / 1.94 lay

                            The web site shows virtual prices and returns the prices that can be obtained if you were betting with the minimum allowed stake (£2 in the UK). On the web site, there is a slider bar to change the rolled up stake value - if you slide that across then the odds change accordingly.

                            SP prices are Betfair Starting Prices (they still refer to markets on the Exchange).
                            Last edited by betdynamics; 18-10-2014, 12:38 AM.

                            Comment

                            Working...
                            X