is Bet matched?

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

    #16
    Thanks Tony

    Can I just ask are you in the UK or AUS ? My assumption is that UK. I am in Aus and I cannot get the Betting visualizer to even work ? I am wondering if other Aussies have this problem. Hmmm may post the question.

    Anyway I tried just calling listCurrentOrders with no args as shown below but I get nothing

    Code:
    Calling: SportsAPING/v1.0/listCurrentOrders With args: {}
    
    Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}
    The URI I am calling is https://api-au.betfair.com/exchange/...v1/json-rpc/v1 Can you tell me what you are using ? Maybe is a JSON v JSON RPC difference.


    Hey does Betfair have classes for listCurrentOrders and listClearedOrders similar to what they provided for the VB net APING example ??


    What class/datatype/variable do you use to get the response? I created several classes based on the betfair data and have posted above - maybe this is why I am having errors. I have the following code in my VB NET JsonRpcClient.vb module.

    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        'BET_IDS is defined as "betIds
                args(MARKET_IDS) = marketIds  'MARKET_IDS is defined as  "marketIds"
                args(ORDER_PROJECTION) = OrderProjection
    
                Return Invoke(Of CurrentOrderSummaryReport)(LIST_CURRENT_ORDERS, args)
            End Function
    Last edited by Guest; 29-04-2014, 02:33 PM.

    Comment

    • tkw141
      Junior Member
      • Nov 2013
      • 18

      #17
      Yes, I'm in the UK.

      And I'm using 'https://api.betfair.com/exchange/betting/json-rpc/v1'

      I'm not using VB so can't help you there.

      You are getting a correct response from your request, but no orders shown, as if you don't have any open currently.

      This is a daft question, but are you 100% positive that you have an open order with the Betfair account that is being used by your program? I'd double check this. Are you using test accounts / other accounts and switching between them?

      Tony

      Comment

      • Guest

        #18
        yeah you have to ask. I do have a current bet for the League 2014 premiers being my Bronco team. This bet has been matched and I can see it in Betfair. However after your question I thought maybe the ListCurrentOrders is only applicable to orders made by my bot.

        So here my bot places a bet in market for a future race (in 2 hours).

        Code:
        Calling: SportsAPING/v1.0/placeOrders With args: {"marketId":"2.100951097","instructions":[{"orderType":"LIMIT","selectionId":8493136,"handicap":0.0,"side":"BACK","limitOrder":{"size":5.0,"price":12.0,"persistenceType":"LAPSE"}}],"customerRef":"Troy3","locale":null}
        
        Got Response: {"jsonrpc":"2.0","result":{"status":"SUCCESS","errorCode":"ERROR_IN_MATCHER","marketId":"2.100951097","instructionReports":[{"status":"SUCCESS","errorCode":"INVALID_BET_SIZE","instruction":{"orderType":"LIMIT","selectionId":8493136,"handicap":0.0,"side":"BACK","limitOrder":{"size":5.0,"price":12.0,"persistenceType":"LAPSE"}},"betId":"3727451117","placedDate":"2014-04-29T23:39:58Z","averagePriceMatched":0.0,"sizeMatched":0.0}],"customerRef":"Troy3"},"id":1}
        
        PlaceExecutionReport error code is: 0
        InstructionReport error code is: 0
        CustomerREF Troy3
        Error Code 0
        Bet ID 3727451117
        Market ID 2.100951097
        Status to string SUCCESS
        Looks good - I can see the Bet come up in my bot on the screen. Note the bet is NOT matched as its odds are above the asking, therefore the bet comes up on the lay side as expected waiting to be taken. I also can see it on the Betfair website if I log in.


        I also tested a bet on a UK race (ie using UK endpoints) and I get the same NO RESPONCE


        Does my Bet need to be taken (matched) to be shown in ListCurrentOrders ?
        Last edited by Guest; 30-04-2014, 12:55 AM.

        Comment

        • betdynamics
          Junior Member
          • Sep 2010
          • 534

          #19
          You should get unmatched bets returned if your orderProjection is set to ALL (or EXECUTABLE)
          Last edited by betdynamics; 30-04-2014, 07:47 AM.

          Comment

          • Guest

            #20
            Hmmm no - I think I will ask the betfair guys.

            Here is a current bet in the market, Bet id 3550545168



            Here is the JSON call and again response with nothing
            Code:
            Calling: SportsAPING/v1.0/listCurrentOrders With args: {"betIds":["3550545168"],"marketIds":null,"orderProjection":"ALL","dateRange":null,"orderBy":"BY_MATCH_TIME","sortDir":"EARLIEST_TO_LATEST","fromRecord":0,"recordCount":1000}
            
            Got Response: {"jsonrpc":"2.0","result":{"moreAvailable":false},"id":1}

            Comment

            • Guest

              #21
              Working

              OK I got it working by using some code from davecon and I just hardcoded the JSON string shown below:

              Code:
                      strRequest = "{""jsonrpc"": ""2.0"", ""method"":""SportsAPING/v1.0/listCurrentOrders"",""params"":{}" & ", ""id"": 1}"
                      Debug.Print("CALLING " & strRequest & vbCrLf)
              
                      myJSON_Response = CreateJSON_TEST_Request(myBFdata.sKeyInUse, myBFdata.sSessionID, strRequest)
                      Debug.Print("RESPONSE " & myJSON_Response.ToString & vbCrLf)

              and the response
              Code:
              RESPONSE {"jsonrpc":"2.0","result":{"currentOrders":[{"betId":"3550545168","marketId":"2.100768838","selectionId":23401,"handicap":0.0,"priceSize":{"price":27.0,"size":10.0},"bspLiability":0.0,"side":"BACK","status":"EXECUTION_COMPLETE","persistenceType":"LAPSE","orderType":"LIMIT","placedDate":"2014-03-06T09:42:17.000Z","matchedDate":"2014-03-06T22:43:19.000Z","averagePriceMatched":27.0,"sizeMatched":10.0,"sizeRemaining":0.0,"sizeLapsed":0.0,"sizeCancelled":0.0,"sizeVoided":0.0}],"moreAvailable":false},"id":1}
              I also noted that it didn't matter what ID I set 1, or 2. I assumed it should be 2 for AUSTRALIA?

              I will now try to work out why the VB NET code I was building up did not work and post here at a later date.


              PS. Thanks to bnl, betdynamics, for assisting me solve this issue (oh and Dave who gave me some code back in Jan)
              Last edited by Guest; 03-05-2014, 03:51 AM.

              Comment

              • betdynamics
                Junior Member
                • Sep 2010
                • 534

                #22
                Instead of printing out:

                Code:
                Calling: SportsAPING/v1.0/listCurrentOrders With args: {"betIds":["3550545168"],"marketIds":null,"orderProjection":"ALL","dateRange":null,"orderBy":"BY_MATCH_TIME","sortDir":"EARLIEST_TO_LATEST","fromRecord":0,"recordCount":1000}
                can you get it to print out the ACTUAL full json string that it is sending?

                Comment

                • Guest

                  #23
                  Thanks betdynamics. I did what you said by printing out the returned JSON string from the Deserialize(Of T)(ByVal json As String) function to help my debug. In the end it was me causing the error. It would have been nice had betfair put together the below classes to save me a lot of time, but now I have gone through this I have learnt a fair bit and should be right here on in.


                  I now know what my listCurrentOrders error was. I was getting a JSON string with the correct parameters being passed back HOWEVER I was trying to force the response into the CurrentOrderSummaryReport and CurrentOrderSummary Classes which I had defined INCORRECTLY. In the CurrentOrderSummary class I created I had:

                  error 1) "betIds" when it should have just been "betId"

                  error 2) variable priceSize was defined as a List of priceSize when it should have just been priceSize.

                  I have now correct the classes below which means you can call the listCurrentOrders and then drill down through the class to get the data, ie


                  Code:
                  Dim listCurrentOrders As CurrentOrderSummaryReport
                  listCurrentOrders = clientBF.listCurrentOrders()
                  
                  Debug.Print(listCurrentOrders.CurrentOrderSummary(0).marketId)
                  Debug.Print(listCurrentOrders.CurrentOrderSummary(0).priceSize.Price)
                  Classes and 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
                  [/QUOTE]
                  Last edited by Guest; 04-05-2014, 02:52 PM.

                  Comment

                  • racrego
                    Junior Member
                    • Feb 2014
                    • 8

                    #24
                    current order list

                    based on your code, i have the following class :

                    Imports System
                    Imports System.Collections.Generic
                    Imports System.Linq
                    Imports System.Text
                    Imports Newtonsoft.Json
                    Imports Newtonsoft.Json.Converters


                    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)

                    <JsonProperty(PropertyName:="marketId")> _
                    Public Property marketId() As String

                    <JsonProperty(PropertyName:="selectionId")> _
                    Public Property selectionId() As Long

                    <JsonProperty(PropertyName:="handicap")> _
                    Public Property Handicap() As Double

                    <JsonProperty(PropertyName:="priceSize")> _
                    Public Property priceSize() As Double

                    <JsonProperty(PropertyName:="bspLiability")> _
                    Public Property bspLiability() As Double

                    <JsonProperty(PropertyName:="side")> _
                    Public Property Side() As String

                    <JsonProperty(PropertyName:="status")> _
                    Public Property Status() As String

                    <JsonProperty(PropertyName:="persistenceType")> _
                    Public Property PersistenceType() As String

                    <JsonProperty(PropertyName:="orderType")> _
                    Public Property OrderType() As String

                    <JsonProperty(PropertyName:="placedDate")> _
                    Public Property placedDate() As Date

                    <JsonProperty(PropertyName:="matchedDate")> _
                    Public Property matchedDate() As Date

                    <JsonProperty(PropertyName:="averagePriceMatched") > _
                    Public Property averagePriceMatched() As Double

                    <JsonProperty(PropertyName:="sizeMatched")> _
                    Public Property sizeMatched() As Double

                    <JsonProperty(PropertyName:="sizeRemaining")> _
                    Public Property sizeRemaining() As Double

                    <JsonProperty(PropertyName:="sizeLapsed")> _
                    Public Property sizeLapsed() As Double

                    <JsonProperty(PropertyName:="sizeCancelled")> _
                    Public Property sizeCancelled() As Double

                    <JsonProperty(PropertyName:="sizeVoided")> _
                    Public Property sizeVoided() As Double

                    <JsonProperty(PropertyName:="regulatorAuthCode") > _
                    Public Property regulatorAuthCode() As String

                    <JsonProperty(PropertyName:="regulatorCode")> _
                    Public Property regulatorCode() As String

                    End Class

                    <JsonConverter(GetType(StringEnumConverter))> _
                    Public Enum SortDir
                    EARLIEST_TO_LATEST
                    LATEST_TO_EARLIEST
                    End Enum

                    and the aditional code :

                    Dim objJson = JsonConvert.DeserializeObject(Of CurrentOrderSummaryReport)(strCatalogue)


                    Dim listCurrentOrders As CurrentOrderSummaryReport
                    'listCurrentOrders = clientBF.listCurrentOrders()

                    PrintLog(listCurrentOrders.CurrentOrderSummary(0). betIds)
                    PrintLog(listCurrentOrders.CurrentOrderSummary(0). OrderType)
                    PrintLog(listCurrentOrders.CurrentOrderSummary(0). sizeMatched)

                    but i always get a null reference, can you help me?

                    thanks

                    Comment

                    Working...
                    X