Cancel All Orders not just one

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

    #1

    Cancel All Orders not just one

    Hi guys - its been a while since I have been here Back in 2014 I had to write a heap of my own VB.NET Class wrappers to get stuff working so I was very happy when I checked out https://github.com/betfair/API-NG-sa...ng-sample-code and found all the new Class wrappers in the TO folder. Thanks.


    All right so I playing with the cancelOrders. I place a bet on market 2.101353863, which has betid 5908294219. I also place a reference on the bet "BackBetForTroy". Now when I call CancelOrder passing in all those parameters I have SUCCESS. Here is call and response.

    Calling: SportsAPING/v1.0/cancelOrders With args: {"marketId":"2.101353863","instructions":[{"betId":"5908294219"}],"customerRef":"BackBetForTroy"}

    Got Response: {"jsonrpc":"2.0","result":{"customerRef":"BackBetF orTroy","status":"SUCCESS","errorCode":"ERROR_IN_M ATCHER","marketId":"2.101353863","instructionRepor ts":[{"status":"SUCCESS","errorCode":"INVALID_BET_SIZE" ,"instruction":{"betId":"5908294219"},"sizeCancell ed":5.0,"cancelledDate":"0001-01-01T00:00:00"}]},"id":2}



    Anyway I tried to call cancelOrders passing in No details at all I was hoping it would cancel all bets. I also tried just passing in the market ID, but still an error. I tried canceling passing in market id and bet id, but leaving out my customer reference and again an error.

    So am I to assume that cancelOrders really requires ALL parameters passed?

    I read here https://api.developer.betfair.com/se...i/cancelOrders that If marketId and betId aren't supplied all bets are cancelled.
  • tkw141.
    Junior Member
    • Dec 2015
    • 3

    #2
    Hi Troy,

    You should be able to cancel all orders by simply calling the cancelOrders method without any parameters, as it says in the doc. The call should be:

    Code:
    [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/cancelOrders", "params": {}, "id": 1}]
    Hope that helps,
    Tony

    Comment

    • Guest

      #3
      Cancel all orders

      Thanks mate - yeah my JSON string was wrong. Thanks. I have posted my VB.NET code in case this helps someone else. My code is based on the API NG example.

      So in my IClient.vb code I simply have the two overriding functions declared:
      Function cancelOrders() As CancelExecutionReport

      Function cancelOrders(marketId As String, instructions As IList
      (Of CancelInstruction), customerRef As String) As CancelExecutionReport
      Then in my JsonRpcClient.vb the functions are:
      Public Function cancelOrders() As CancelExecutionReport Implements IClient.cancelOrders
      Dim args = New Dictionary(Of String, Object)()

      Return Invoke(Of CancelExecutionReport)(CANCEL_ORDERS_METHOD, args)
      End Function

      Public Function cancelOrders(marketId As String, instructions__1 As IList(Of CancelInstruction), customerRef As String) As CancelExecutionReport Implements IClient.cancelOrders
      Dim args = New Dictionary(Of String, Object)()
      args(MARKET_ID) = marketId
      args(INSTRUCTIONS) = instructions__1
      args(CUSTOMER_REFERENCE) = customerRef

      Return Invoke(Of CancelExecutionReport)(CANCEL_ORDERS_METHOD, args)
      End Function
      So if I want to cancel all orders I just call
      Dim CancelExecutionReportBF = New CancelExecutionReport()
      CancelExecutionReportBF = clientBF.cancelOrders()


      If I want to cancel a specific bet then I call
      CancelExecutionReportBF = clientBF.cancelOrders(MarketID, myCancelInsturctions, myCustomerRef)


      I guess with VB.NET function overriding which allows different functions to be called (of the same name) based on a different number of parameters passed in, I could write several different cancel orders functions

      Comment

      • Guest

        #4
        Error_in_matcher

        Hi guys just checking. I have of couple a CancelOrder functions in my VB bot. If I call the CancelOrders and pass no arguments then all bets are cancelled and I get a SUCCESS status, but I also get an ERROR_IN_MATCHER?


        Calling: SportsAPING/v1.0/cancelOrders With args: {}


        Got Response: {"jsonrpc":"2.0","result":{"status":"SUCCESS","err orCode":"ERROR_IN_MATCHER","instructionReports":[]},"id":2}


        Is this due to not passing in Market ID, Bet ID or Customer Ref?
        Last edited by Guest; 16-12-2015, 09:34 AM.

        Comment

        • tkw141.
          Junior Member
          • Dec 2015
          • 3

          #5
          Hi,

          When I cancel all orders using:

          Code:
          [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/cancelOrders", "params": {}, "id": 1}]
          I get the following response:

          Code:
          [{"jsonrpc":"2.0","result":{"status":"SUCCESS","instructionReports":[]},"id":1}]
          I'm on the UK market, so don't know if this is different for AUS market.

          Tony

          Comment

          • Guest

            #6
            Solved

            Arhhh found the error. There was a bug in the C# sample from BDP from when I copied the original code. The Sample has now been corrected

            All I had to do was update the ExecutionReportErrorCode to include the first ENUM "OK" which is value 0.


            Public Enum ExecutionReportErrorCode
            OK
            ERROR_IN_MATCHER
            PROCESSED_WITH_ERRORS
            BET_ACTION_ERROR
            INVALID_ACCOUNT_STATE
            INVALID_WALLET_STATUS
            INSUFFICIENT_FUNDS
            LOSS_LIMIT_EXCEEDED
            MARKET_SUSPENDED
            MARKET_NOT_OPEN_FOR_BETTING
            DUPLICATE_TRANSACTION
            INVALID_ORDER
            INVALID_MARKET_ID
            PERMISSION_DENIED
            DUPLICATE_BETIDS
            NO_ACTION_REQUIRED
            SERVICE_UNAVAILABLE
            REJECTED_BY_REGULATOR
            End Enum

            Comment

            Working...
            X