is Bet matched?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bnl
    Junior Member
    • Nov 2012
    • 108

    #1

    is Bet matched?

    Hi!
    If I place a bet with PERSIST flag,
    and the bet is matched during in-play,
    how can I find out via the api-ng if it was matched?
    it seems that listCurrentOrders is only good before
    the race is settled
    Code:
    2013-11-20 17:35:09.872 RPC. : posting: {"method":"SportsAPING/v1.0/listCurrentOrders", "jsonrpc":"2.0", "id":15, "params":{"betIds":["31842324833"], "placesDateRange":{}}}
    2013-11-20 17:35:09.916 RPC.Bet_Is_Matched : Got reply: {"id":15, "jsonrpc":"2.0", "result":{"moreAvailable":false, "currentOrders":[{"marketId":"1.111937147", "betId":"31842324833", "handicap":0.00000E+00, "orderType":"LIMIT", "sizeCancelled":0.00000E+00, "bspLiability":0.00000E+00, "selectionId":5473866, "sizeVoided":0.00000E+00, "status":"EXECUTION_COMPLETE", "matchedDate":"2013-11-20T16:32:16.000Z", "placedDate":"2013-11-20T15:29:52.000Z", "sizeLapsed":0.00000E+00, "side":"BACK", "priceSize":{"size":3.00000E+01, "price":2.00000E+01}, "regulatorCode":"MALTA LOTTERIES AND GAMBLING AUTHORITY", "sizeMatched":3.00000E+01, "persistenceType":"PERSIST", "sizeRemaining":0.00000E+00, "averagePriceMatched":2.00000E+01}]}}
    which is fine, I got EXECUTION_COMPLETE in this case.
    But for an order that has a settled market I get an empty reply

    Code:
    2013-11-20 20:34:08.912 RPC. : posting: {"method":"SportsAPING/v1.0/listCurrentOrders", "jsonrpc":"2.0", "id":15, "params":{"betIds":["31846248762"], "placesDateRange":{}}}
    2013-11-20 20:34:08.936 RPC.Bet_Is_Matched : Got reply: {"id":15, "jsonrpc":"2.0", "result":{"moreAvailable":false, "currentOrders":[]}}
    The bet above was matched at in-play. But I did not poll
    between the in-play and end of race, thus missing the match.
    How can I get the matching status of a bet after the race is settled?

    /Björn
  • BetfairDeveloperProgram
    Administrator
    • Oct 2008
    • 680

    #2
    Hi Björn

    listCurrentOrders can be used to check the status of your unmatched or matched bets.

    The listClearedOrders call (due to be released on the 16th December) will enable you to check details of your bets following market settlement.

    Thanks

    Neil

    Comment

    • bnl
      Junior Member
      • Nov 2012
      • 108

      #3
      Ok, then listClearedOrders is what I am looking for.
      Thanks
      /Björn

      Comment

      • Guest

        #4
        ListCurrentOrders ????

        I am trying to code up ListCurrentOrders. I have a bet in the market for Broncos as 2014 RL premiers so hopefully ListCurrentOrders should return this bet.



        Here is the JSON response to my call which provides no data ???
        Code:
        Calling: SportsAPING/v1.0/listCurrentOrders With args: {"betIds":["3550545168"]}
        
        Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}

        This time with no parameters which should return all current orders" ... again nothing ????
        Code:
        Calling: SportsAPING/v1.0/listCurrentOrders With args: {}
        
        Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}
        so can anyone tell me what I may be doing wrong ????

        Comment

        • Guest

          #5
          NOW FIXED - 4 MAY 2013: I have now fixed these classes so they are correct.



          BTW. I am using the VB.NET API_NG example code and have included some the additional coded I have added including classes to make it easier to drill down through the data. Hopefully this is correct and it helps someone else out.


          Code for IClient.vb
          Code:
                  Function listCurrentOrders(ByVal betIds As IList(Of String), ByVal marketIds As IList(Of String), ByVal OrderProjection? As OrderProjection, ByVal placedDateRange As TimeRange, ByVal dateRange As TimeRange, ByVal OrderBy As OrderBy, ByVal SortDir As SortDir, ByVal intfromRecord As Integer, ByVal intrecordCount As Integer) As CurrentOrderSummaryReport
          Code for JsonRpcClient.vb
          Code:
          Public Function listCurrentOrders(ByVal betIds As IList(Of String), ByVal marketIds As IList(Of String), ByVal OrderProjection? As OrderProjection, ByVal placedDateRange As TimeRange, ByVal dateRange As TimeRange, ByVal OrderBy As OrderBy, ByVal SortDir As SortDir, ByVal intfromRecord As Integer, ByVal intrecordCount As Integer) As CurrentOrderSummaryReport Implements IClient.listCurrentOrders
                      Dim args = New Dictionary(Of String, Object)()
          
                      args(BET_IDS) = betIds
                      'args(MARKET_IDS) = marketIds               TO ADD LATER
                      'args(ORDER_PROJECTION) = OrderProjection   TO ADD LATER
          
                      Return Invoke(Of CurrentOrderSummaryReport)(LIST_CURRENT_ORDERS, args)
                  End Function

          CurrentOrderSummaryReport and CurrentOrderSummary Classes including ENUMS
          Code:
          Imports System
          Imports System.Collections.Generic
          Imports System.Linq
          Imports System.Text
          Imports Newtonsoft.Json
          Imports Newtonsoft.Json.Converters
          
          'TROY ADDED THIS CODE HERE BASED ON BETFAIR WEBSITE 23 APR 2014
          Namespace API_NG.TO
              Public Class CurrentOrderSummaryReport
                  <JsonProperty(PropertyName:="CurrentOrderSummary")> _
                  Public Property CurrentOrderSummary() As List(Of CurrentOrderSummary)                   'The list of current orders returned by your query. This will be a valid list (i.e. empty or non-empty but never 'null').
          
                  <JsonProperty(PropertyName:="moreAvailable")> _
                  Public Property moreAvailable() As Boolean                                                'Indicates whether there are further result items beyond this page. Note that underlying data is highly time-dependent and the subsequent search orders query might return an empty result.
              End Class
          
              Public Class CurrentOrderSummary
                  <JsonProperty(PropertyName:="betId")> _
                  Public Property betIds() As ISet(Of String)                     'The bet ID of the original place order.
          
                  <JsonProperty(PropertyName:="marketId")> _
                  Public Property marketId() As String                            'The market id the order is for.
          
                  <JsonProperty(PropertyName:="selectionId")> _
                  Public Property selectionId() As Long                           'The selection id the order is for.
          
                  <JsonProperty(PropertyName:="handicap")> _
                  Public Property Handicap() As Double?                           'The handicap of the bet.
          
                  <JsonProperty(PropertyName:="priceSize")> _
                  Public Property priceSize() As PriceSize               'The price and size of the bet.
          
                  <JsonProperty(PropertyName:="bspLiability")> _
                  Public Property bspLiability() As Double                          'Not to be confused with size. This is the liability of a given BSP bet.
          
                  <JsonProperty(PropertyName:="side")> _
                  Public Property Side() As Side                                  'BACK/LAY
          
                  <JsonProperty(PropertyName:="status")> _
                  Public Property Status() As OrderStatus                         'Either EXECUTABLE (an unmatched amount remains) or EXECUTION_COMPLETE (no unmatched amount remains).
          
                  <JsonProperty(PropertyName:="persistenceType")> _
                  Public Property PersistenceType() As PersistenceType            'What to do with the order at turn-in-play.
          
                  <JsonProperty(PropertyName:="orderType")> _
                  Public Property OrderType() As OrderType                        'BSP Order type.
          
                  <JsonProperty(PropertyName:="placedDate")> _
                  Public Property placedDate() As Date                            'The date, to the second, the bet was placed.
          
                  <JsonProperty(PropertyName:="matchedDate")> _
                  Public Property matchedDate() As Date                           'The date, to the second, of the last matched bet fragment (where applicable) 
          
                  <JsonProperty(PropertyName:="averagePriceMatched")> _
                  Public Property averagePriceMatched() As Double                   'The average price matched at. Voided match fragments are removed from this average calculation.
          
                  <JsonProperty(PropertyName:="sizeMatched")> _
                  Public Property sizeMatched() As Double                           'The current amount of this bet that was matched.
          
                  <JsonProperty(PropertyName:="sizeRemaining")> _
                  Public Property sizeRemaining() As Double                         'The current amount of this bet that is unmatched.
          
                  <JsonProperty(PropertyName:="sizeLapsed")> _
                  Public Property sizeLapsed() As Double                            'The current amount of this bet that was lapsed.
          
                  <JsonProperty(PropertyName:="sizeCancelled")> _
                  Public Property sizeCancelled() As Double                         'The current amount of this bet that was cancelled.
          
                  <JsonProperty(PropertyName:="sizeVoided")> _
                  Public Property sizeVoided() As Double                            'The current amount of this bet that was voided.
          
                  <JsonProperty(PropertyName:="regulatorAuthCode")> _
                  Public Property regulatorAuthCode() As String                     'The regulator authorisation code.
          
                  <JsonProperty(PropertyName:="regulatorCode")> _
                  Public Property regulatorCode() As String                         'The regulator Code
          
              End Class
          
              <JsonConverter(GetType(StringEnumConverter))> _
              Public Enum SortDir
                  EARLIEST_TO_LATEST                                  'Order from earliest value to latest e.g. lowest betId is first in the results.
                  LATEST_TO_EARLIEST                                  'Order from the latest value to the earliest e.g. highest betId is first in the results.
              End Enum
          End Namespace
          Last edited by Guest; 04-05-2014, 02:26 PM. Reason: wrong code posted

          Comment

          • betdynamics
            Junior Member
            • Sep 2010
            • 534

            #6
            Try setting a value for OrderProjection ?

            Comment

            • Guest

              #7
              Originally posted by betdynamics View Post
              Try setting a value for OrderProjection ?
              Thanks Betdynamics, I did try with OrderProjection but again no real response

              Code:
              Calling: SportsAPING/v1.0/listCurrentOrders With args: {"marketId":"2.100768838","orderProjection":"ALL"}
              
              Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}

              Comment

              • betdynamics
                Junior Member
                • Sep 2010
                • 534

                #8
                How old is the market? Is it still active?

                Can you repeat the exercise via the Visualiser for an active market?

                [Update]
                I have just created a bet and successfully looked at it via the visualiser (although you have to click on the + button to see the bet id and then the info button to see the details)
                Last edited by betdynamics; 24-04-2014, 11:33 AM.

                Comment

                • Guest

                  #9
                  Hey mate - thanks for your reply. It is good to know people out there helping others

                  Just on the visualizers, it might be an Australian thing but the account visualizer works ok, but the betting one has never worked for me (regardless of endpoint UK or AUS).

                  With regards to that bet I showed above, it is a current market (setup about 4 months ago) and I have a current bet on it.

                  I have also gone to Betfair - looked up a current horse race, placed a high bet on it like Horse 1 to win at 80:1 and still I can't get any details on the bet through the ListcurrentOrders call ?

                  Do you have the full JSON parameter call for ListCurrentOrders and ListClearedOrders ? For instance is the following JSON call correct ?

                  Code:
                  Calling: SportsAPING/v1.0/listCurrentOrders With args: {"marketId":"2.100947624","orderProjection":"ALL"}

                  Also here is a call to ListClearedOrders which takes around 3 seconds to return a response, and doesn't return what I would expect. The response I do get looks like help on the call ..

                  Code:
                  Calling: SportsAPING/v1.0/listClearedOrders With args: {"betStatus":"SETTLED","includeItemDescription":false}
                  
                  Got Response: {"jsonrpc":"2.0","result":{"betStatus":"SETTLED","side":"BACK","groupBy":"EVENT_TYPE","includeItemDescription":false,"fromRecord":0,"recordCount":0},"id":1}
                  Last edited by Guest; 27-04-2014, 11:50 AM.

                  Comment

                  • betdynamics
                    Junior Member
                    • Sep 2010
                    • 534

                    #10
                    Here is what I get:

                    Code:
                    17:10:44:121,{"jsonrpc":"2.0","method":"SportsAPING/v1.0/listCurrentOrders","params":{"betIds":[],"marketIds":["1.113801671","1.113801667"],"fromRecord":0,"recordCount":0},"id":1}
                    Code:
                    17:10:44:223,{"jsonrpc":"2.0","result":{"currentOrders":[{"betId":"36746080515","marketId":"1.113801671","selectionId":58805,"handicap":0.0,"priceSize":{"price":3.8,"size":2.0},"bspLiability":0.0,"side":"LAY","status":"EXECUTION_COMPLETE","persistenceType":"PERSIST","orderType":"LIMIT","placedDate":"2014-04-27T17:09:53.000Z","matchedDate":"2014-04-27T17:09:53.000Z","averagePriceMatched":3.8,"sizeMatched":2.0,"sizeRemaining":0.0,"sizeLapsed":0.0,"sizeCancelled":0.0,"sizeVoided":0.0,"regulatorCode":"GIBRALTAR REGULATOR"}],"moreAvailable":false},"id":1}
                    Last edited by betdynamics; 27-04-2014, 06:15 PM.

                    Comment

                    • Guest

                      #11
                      Hey how is ID=1 passed ? and what does that mean. I can't see anything info about this under https://api.developer.betfair.com/se...tCurrentOrders

                      Comment

                      • betdynamics
                        Junior Member
                        • Sep 2010
                        • 534

                        #12
                        It's part of the standard JSON-RPC message format.

                        Here's the example on the API-NG Getting Started page:

                        Code:
                        {
                           "params": {
                              "filter": {
                                 "eventTypeIds": [1]
                              }
                           }, 
                           "jsonrpc": "2.0", 
                           "method": "SportsAPING/v1.0/listCompetitions", 
                           "id": 1
                        }
                        https://api.developer.betfair.com/se...ed+with+API-NG

                        I have no idea what the "id" is for, or whether it is necessary.

                        I have it in all of my calls to the API.

                        Comment

                        • Guest

                          #13
                          Ta mate

                          Programing other stuff atm, and I haven't got ListCurrentOrders OR ListClearedOrders to work yet for me but as soon as I do I will post to this forum telling all what my mistake was.

                          Its a pity that the betfair team don't include an example in each of the code on how to use these calls. For instance I have based my bot on the free API NG VB NET example that was provided which shows you listEventTypes, MarketCatalog, MarketBook, and PlaceOrder.

                          Below are the four functions from there JsonRpcClient.vb module.

                          Code:
                                 Public Function listEventTypes(ByVal marketFilter As MarketFilter, Optional ByVal locale As String = Nothing) As IList(Of EventTypeResult) Implements IClient.listEventTypes
                                      Dim args = New Dictionary(Of String, Object)()
                                      args(FILTER) = marketFilter
                                      args(JsonRpcClient.LOCALE) = locale
                                      Return Invoke(Of List(Of EventTypeResult))(LIST_EVENT_TYPES_METHOD, args)
                                  End Function
                          
                                  Public Function listMarketCatalogue(ByVal marketFilter As MarketFilter, ByVal marketProjections As ISet(Of MarketProjection), ByVal marketSort As MarketSort, Optional ByVal maxResult As String = "1", Optional ByVal locale As String = Nothing) As IList(Of MarketCatalogue) Implements IClient.listMarketCatalogue
                                      Dim args = New Dictionary(Of String, Object)()
                                      args(FILTER) = marketFilter
                                      args(MARKET_PROJECTION) = marketProjections
                                      args(SORT) = marketSort
                                      args(MAX_RESULTS) = maxResult
                                      'args(JsonRpcClient.LOCALE) = locale
                                      Return Invoke(Of List(Of MarketCatalogue))(LIST_MARKET_CATALOGUE_METHOD, args)
                                  End Function
                          
                                  Public Function listMarketBook(ByVal marketIds As IList(Of String), ByVal priceProjection As PriceProjection, Optional ByVal orderProjection? As OrderProjection = Nothing, Optional ByVal matchProjection? As MatchProjection = Nothing, Optional ByVal currencyCode As String = Nothing, Optional ByVal locale As String = Nothing) As IList(Of MarketBook) Implements IClient.listMarketBook
                                      Dim args = New Dictionary(Of String, Object)()
                                      args(MARKET_IDS) = marketIds
                                      args(PRICE_PROJECTION) = priceProjection
                                      args(ORDER_PROJECTION) = orderProjection
                                      args(MATCH_PROJECTION) = matchProjection
                                      'args(JsonRpcClient.LOCALE) = locale
                                      args(CURRENCY_CODE) = currencyCode
                                      Return Invoke(Of List(Of MarketBook))(LIST_MARKET_BOOK_METHOD, args)
                                  End Function
                          
                                  Public Function placeOrders(ByVal marketId As String, ByVal customerRef As String, ByVal placeInstructions As IList(Of PlaceInstruction), Optional ByVal locale As String = Nothing) As PlaceExecutionReport Implements IClient.placeOrders
                                      Dim args = New Dictionary(Of String, Object)()
                          
                                      args(MARKET_ID) = marketId
                                      args(INSTRUCTIONS) = placeInstructions
                                      args(CUSTOMER_REFERENCE) = customerRef
                                      args(JsonRpcClient.LOCALE) = locale
                          
                                      Return Invoke(Of PlaceExecutionReport)(PLACE_ORDERS_METHOD, args)
                                  End Function
                          I have gone to code up CancelOrders which was straight forward, but am having probs with the ListCurrentOrders and ListClearedOrders.


                          I shall plug on .....


                          oh and on the ID=1, not sure either - I do see that in the Function below (which serializes up the JSON call) that the ID=1 is thrown in.
                          Code:
                          Public Function Invoke(Of T)(ByVal method As String, Optional ByVal args As IDictionary(Of String, Object) = Nothing) As T
                          
                              <code above removed>
                          
                              Dim [call] = New JsonRequest With {.Method = method, .Id = 1, .Params = args}
                          
                              <code below removed>
                          Last edited by Guest; 29-04-2014, 12:02 AM.

                          Comment

                          • tkw141
                            Junior Member
                            • Nov 2013
                            • 18

                            #14
                            Originally posted by troyedwards8 View Post
                            Hey mate - thanks for your reply. It is good to know people out there helping others

                            Just on the visualizers, it might be an Australian thing but the account visualizer works ok, but the betting one has never worked for me (regardless of endpoint UK or AUS).

                            With regards to that bet I showed above, it is a current market (setup about 4 months ago) and I have a current bet on it.

                            I have also gone to Betfair - looked up a current horse race, placed a high bet on it like Horse 1 to win at 80:1 and still I can't get any details on the bet through the ListcurrentOrders call ?

                            Do you have the full JSON parameter call for ListCurrentOrders and ListClearedOrders ? For instance is the following JSON call correct ?

                            Code:
                            Calling: SportsAPING/v1.0/listCurrentOrders With args: {"marketId":"2.100947624","orderProjection":"ALL"}

                            Also here is a call to ListClearedOrders which takes around 3 seconds to return a response, and doesn't return what I would expect. The response I do get looks like help on the call ..

                            Code:
                            Calling: SportsAPING/v1.0/listClearedOrders With args: {"betStatus":"SETTLED","includeItemDescription":false}
                            
                            Got Response: {"jsonrpc":"2.0","result":{"betStatus":"SETTLED","side":"BACK","groupBy":"EVENT_TYPE","includeItemDescription":false,"fromRecord":0,"recordCount":0},"id":1}

                            Hi Troy,

                            You have a typo in your listCurrentOrders:
                            marketId should be marketIds
                            I spotted this as I have made this exact mistake many times...marketId, marketIds, phah :-)

                            Also, you need to use [ ] around the market Id list:
                            Code:
                            {"marketIds":["2.100947624"],"orderProjection":"ALL"}
                            I use listCurrentOrders without any parameters as this returns all current orders:
                            Code:
                            {}

                            As for listClearedOrders, I don't use it, but I'd recommend putting double quotes around false:
                            Code:
                            {"betStatus":"SETTLED","includeItemDescription":"false"}
                            Hope that helps,
                            Tony

                            Comment

                            • tkw141
                              Junior Member
                              • Nov 2013
                              • 18

                              #15
                              I've just run listClearedOrders in the Visualiser with a betStatus = SETTLED.
                              This creates the following request:
                              Code:
                              {"betStatus":"SETTLED","settledDateRange":{}}
                              This listed my settled bets.

                              I also tried with includeItemDescription = false which created the following request:
                              Code:
                              {"betStatus":"SETTLED","settledDateRange":{},"includeItemDescription":"false"}
                              This also listed my settled bets

                              Tony

                              Comment

                              Working...
                              X