getEx() every time null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • General Api
    Junior Member
    • May 2014
    • 9

    #1

    getEx() every time null

    Every time I try to get exchange price, from a Java code, as well as from virtualizer, the response is null.
    For example see this simple screenshot of virtualizer.

    Oops.
    I had to click on every single runner to get prices of that runner in virtualizer.
    So the problem is only in may java code, which I explain in the next post int this same thread.
    Attached Files
    Last edited by General Api; 29-05-2014, 03:03 PM. Reason: The problem is not there in virtualizer
  • General Api
    Junior Member
    • May 2014
    • 9

    #2
    However I can't figure out the problem in Java code. I get a list of MarketBooks

    List<MarketBook> marketBookReturn = jsonOperations.listMarketBook(marketIds, priceProjection,orderProjection, matchProjection, currencyCode,applicationKey, sessionToken);

    Then get a specific market book from list

    MarketBook mb = marketBookReturn.get(0);

    which in turn gives me runners of that marketbook

    List<Runner> runners = mb.getRunners();

    But the problem comes then.

    for (Runner runner : runners) {
    System.out.println(runner.getSelectionId()) ; //gives correct answer
    System.out.println("Last price traded: " + runner.getLastPriceTraded()) ; // this is also ok
    System.out.println("Exchange price: " + runner.getEx()) ; //but this one returns null
    }
    Edit

    Comment

    • altisw
      Junior Member
      • Dec 2012
      • 5

      #3
      Hi General API, have you found a solution yet (I'm stuck on the same)?
      I believe the problem is within the request itself: a System.out as below
      Code:
      System.out.println("ListMarketBook return:" + marketBookReturn.toString());
      will return the following:
      Code:
      ListMarketBook return:[{marketId=1.114445964,isMarketDataDelayed=false,status=OPEN,betDelay=0,bspReconciled=false,complete=true,inplay=false,numberOfWinners=1,numberOfRunners=8,numberOfActiveRunners=8,lastMatchTime=Sat Jun 28 08:07:01 BST 2014,totalMatched=3183.47,totalAvailable=21019.54,crossMatching=false,runnersVoidable=false,version=771507669,runners=[{selectionId=8574934,handicap=0.0,status=ACTIVE,adjustmentFactor=40.7,lastPriceTraded=2.36,totalMatched=2114.53,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8606737,handicap=0.0,status=ACTIVE,adjustmentFactor=33.3,lastPriceTraded=3.25,totalMatched=755.53,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8632309,handicap=0.0,status=ACTIVE,adjustmentFactor=7.7,lastPriceTraded=12.0,totalMatched=97.22,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8469653,handicap=0.0,status=ACTIVE,adjustmentFactor=6.1,lastPriceTraded=19.0,totalMatched=63.37,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8652132,handicap=0.0,status=ACTIVE,adjustmentFactor=5.6,lastPriceTraded=18.5,totalMatched=50.9,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8652131,handicap=0.0,status=ACTIVE,adjustmentFactor=3.8,lastPriceTraded=7.0,totalMatched=57.18,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8652130,handicap=0.0,status=ACTIVE,adjustmentFactor=2.1,lastPriceTraded=44.0,totalMatched=18.47,removalDate=null,sp=null,ex=null,orders=null,matches=null,}, {selectionId=8521307,handicap=0.0,status=ACTIVE,adjustmentFactor=0.7,lastPriceTraded=190.0,totalMatched=26.24,removalDate=null,sp=null,ex=null,orders=null,matches=null,}],}]
      Observe the ex=null. Maybe missing some parameters when make the request.
      Altin...

      Comment

      • gus
        Senior Member
        • Jan 2009
        • 134

        #4
        when yo do runner.getEx() what is retuned is an Object that contains, two json lists:

        availableToLay
        and
        availableToBack

        so in my app ( i use json.simple), I have something like:

        Code:
        double bestLayPrice  = -1;
        double bestBackPrice  = -1;
        double lastMatchedPrice  = -1;
        
        if(runner.containsKey("lastPriceTraded"))
        	lastMatchedPrice = (Double)runner.get("lastPriceTraded");
        
        JSONObject exObject = (JSONObject)runner.get("ex");
        JSONObject priceObject = null;
        
        JSONArray priceArray = (JSONArray)exObject.get("availableToLay");
        
        if(priceArray != null && priceArray.size() > 0)
        	{
        		priceObject = (JSONObject)priceArray.get(0);
        		
        		if(priceObject != null)
        			bestLayPrice = (Double)priceObject.get("price");
        	}
        					
        priceArray = (JSONArray)exObject.get("availableToBack");
        
        if(priceArray != null && priceArray.size() > 0)
        	{
        		priceObject = (JSONObject)priceArray.get(0);
        
        		if(priceObject != null)
        			bestBackPrice = (Double)priceObject.get("price");
        	}
        hope that makes some kind of sense!
        Last edited by gus; 28-06-2014, 08:26 PM. Reason: spelling!

        Comment

        • gus
          Senior Member
          • Jan 2009
          • 134

          #5
          Ooops, should have read your post properly, so you're getting ex=null

          that must be something missing from your request params as altisw says.

          here's my request, which does get the ex object:

          Code:
          https://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.114453677"]}
          which returns:

          -------
          [{"marketId":"1.114453677","status":"OPEN","betDela y":1,"totalAvailable":43699.81,"bspReconciled":tru e,"numberOfActiveRu
          nners":5,"version":771838065,"crossMatching":true, "inplay":true,"numberOfWinners":1,"totalMatched":5 10020.46,"complete":
          true,"lastMatchTime":"2014-06-28T19:46:12.558Z","runners":[{"ex":{"availableToLay":[{"price":4.5,"size":3.86}],"availabl
          eToBack":[{"price":3.85,"size":31.41}],"
          tradedVolume":[]},"lastPriceTraded":4.5,"totalMatched":259928.03," selectionId":5
          110789,"status":"ACTIVE","handicap":0.0,"adjustmen tFactor":33.3},{"ex":{"availableToLay":[{"price":5.5,"size":23.77}],"a
          vailableToBack":[{"price":5.1,"size":2.44}],"tradedVolume":[]},"lastPriceTraded":5.5,"totalMatched":77921.94,"s electionI
          d":8129724,"status":"ACTIVE","handicap":0.0,"adjus tmentFactor":22.0},{"ex":{"availableToLay":[{"price":3.3,"size":17.31}
          ],"availableToBack":[{"price":3.15,"size":5.6}],"tradedVolume":[]},"lastPriceTraded":3.3,"totalMatched":70224.02,"s elect
          ionId":6829772,"status":"ACTIVE","handicap":0.0,"a djustmentFactor":20.0},{"ex":{"availableToLay":[{"price":4.3,"size":7.
          38}],"availableToBack":[{"price":4.1,"size":16.71}],"tradedVolume":[]},"lastPriceTraded":4.3,"totalMatched":71247.68,"s e
          lectionId":7082819,"status":"ACTIVE","handicap":0. 0,"adjustmentFactor":15.6},{"ex":{"availableToLay" :[{"price":18.0,"siz
          e":4.65}],"availableToBack":[{"price":14.0,"size":11.65}],"tradedVolume":[]},"lastPriceTraded":16.0,"totalMatched":30698
          .77,"selectionId":2098357,"status":"ACTIVE","handi cap":0.0,"adjustmentFactor":9.1}],"numberOfRunners":5,"runnersVoidable
          ":false,"isMarketDataDelayed":false}]

          Comment

          • altisw
            Junior Member
            • Dec 2012
            • 5

            #6
            Thanks for your replies gus.
            From what I understood, to get prices, you have to set priceData as
            priceData.add(PriceData.EX_BEST_OFFERS);
            This will set runners to display the prices when selected.
            I'm using Java Sample code (and not a programmer by profession).
            Haven't seen on the code where ExchangePrices object is created(this is where null object is coming from) .
            Thanks.

            Comment

            • altisw
              Junior Member
              • Dec 2012
              • 5

              #7
              Originally posted by gus View Post

              here's my request, which does get the ex object:

              Code:
              https://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.114453677"]}
              How do you get the code of request?
              Thanks..

              Comment

              Working...
              X