Announcement

Collapse
No announcement yet.

How can I get ONE betID results not a total for ALL bets for a selection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I get ONE betID results not a total for ALL bets for a selection

    Hi

    I am testing one of the final parts of my BOT which was working fine under SOAP which is trading.

    For example I place lots of small bets on the same selection in a market, both LAY and BACK.

    Each record has a unique BetPK in my Database and if matched a unique BetID. I then use this BetID to get one record from listClearedOrders to work out whether it was settled or lapsed/voided/cancelled from the SizeSettled/SizeLapsed/SizeCancelled/SizeVoided amounts in the response.

    However yesterday I still had 100's of bets that remained with my status of M (matched - I wrote a method to keep the same status codes so my DB wouldn't need changing) and I could not get a response with a SizeSettled even though all of the bets had been settled (from the website).

    Even though I put the BetID and MarketID into the JSON request and requested a single record I got back a TOTAL Profit/Loss of ALL bets (7 bets) placed on that selection in the market.

    All I wanted was the single profit/loss for the BetID in question which was about £-3.35. Instead I got a total e.g £-6.29. It works fine for a single bet on a selection but not multiple bets.

    What JSON do I need to pass in to get a single result, e.g a single SizeSettled, MatchedAmount and Profit/Loss amount for a BetID value?

    I am "thinking" it might be to do with the GroupBy parameter.

    Can someone help.

    Here is the debug with the JSON


    So I am trying to get just one BetIDs settled status (profit or loss) NOT the combination (sum) of all bets placed on that selection. Which is what it looks like it is doing.

    I have highlighted the relevant debug and JSON so you can see.

    In GetBetDetails for BetPK: 1618781; BetID: 54064157480; Current BetStatus: M; Market Status: CLOSED;
    This market is not open so check for settled, voided, lapsed and cancelled bets;
    Call listClearedOrders;
    In GetClearedStatus for BetPK: 1618781; BetID: 54064157480; SettledOnly: False;
    Look for BetID: 54064157480; Selection: 10058606;
    Get Settled, Lapsed, Voided and Cancelled orders to check for this bets status;
    EndPoint = https://api.betfair.com/exchange/betting/json-rpc/v1/;
    Calling: SportsAPING/v1.0/listClearedOrders With args: {"betStatus":"SETTLED","betIds":["54064157480"],"groupBy":"MARKET","marketIds":["1.120072203"],"includeItemDescription":false,"locale":null,"fro mRecord":0,"recordCount":1};
    try and get response;
    Got Response: {"jsonrpc":"2.0","result":{"ClearedOrders":[{"eventTypeId":"7","eventId":"27513887","marketId" :"1.120072203","selectionId":10058606,"handicap":0 .0,"placedDate":"2015-08-16T13:46:46Z",
    "persistenceType":"LAPSE","orderType":"LIMIT","sid e":"BACK","settledDate":"2015-08-16T14:47:17Z","betCount":7,"commission":0.0,"price Matched":0.0,
    "priceReduced":false,"sizeSettled":0.0,"profit ":-6.29,"sizeCancelled":0.0}],"moreAvailable":false},"id":1};

    EndPoint = https://api.betfair.com/exchange/betting/json-rpc/v1/;

    So if I had tried to update my one record for my single open bet that I am trying to get a result for (lapsed, settled, cancelled or voided etc) I would have ended up putting £-6.29 in all 7 rows in my database.

    When in reality I want each BetIDs profit or loss so if I did a SUM on my Profit/Loss column in the DB for that Selection (7 rows) it would equal £-6.29 not £-44.03!

    I would have thought the BetID parameter along with the market ID would have filtered the result for that single BetID: 54064157480 - not the combination of all bets on that selection both lays and back bets. It works with single bets on one selection not multiple bets on the same selection.

    So the question I really need answering is what JSON request do I need to pass to the API to get a single bets profit loss NOT the combined total for all bets placed on a selection?

    Thanks for your help in advance.

    Rob

  • #2
    If you want info on single bets, you should not groupBy MARKET. Try groupBy BET instead.

    Comment


    • #3
      Hi

      Thanks, I thought it might be something to do with the grouping.

      I will try that out.

      Thanks!

      Rob

      Comment


      • #4
        Hi

        Thanks that worked a treat.

        I so wish I didn't have to write thousands of lines of code for this new API when the old one (and my old BOT) ran perfectly.

        Thanks

        Rob

        Comment

        Working...
        X