Problem with ReplaceOrders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OzPunter
    Junior Member
    • Apr 2009
    • 161

    #1

    Problem with ReplaceOrders

    Hi,
    I haven't contributed for a long time but I have been using the API successfully for years. When I originally developed my code base I ran into a problem with ReplaceOrders that I couldn't solve at that time, so I got around the problem by using a different strategy by canceling the bet and resetting the price and placing a new bet, while it works OK it's time consuming and clumsy.

    So I have been going over my code base and tidying up some of my sloppy code, which brings me to ReplaceOrders again.

    There are two almost identical functions, newPrice and newSize.. The newPrice function works fine, the newSize function fails every time giving a HTTP/1.1 400 Bad Request error, suggesting that the URL failed.. ( This error message is misleading)

    The URL in question is,
    https://api.betfair.com/exchange/bet...replaceOrders/ and is identical for both functions.

    The Parameter string passed for newPrice is
    '{"marketId":"theMARKETID","instructions":[{"betId":"theBETID","newPrice":theNEWPRICE}]},"id":1,"jsonrpc":"2.0"}' with the relevant values inserted

    This parameter string is accepted and the new price is applied.

    The Parameter string passed for newSize is
    {"marketId":"theMARKETID","instructions":[{"betId":"theBETID","newSize":theNEWSIZE}]},"id":1,"jsonrpc":"2.0"} with the relevant values inserted

    The newSize parameter string throws the HTTP/1.1 400 Bad Request error, suggesting that the URL failed, so I've changed my code to ensure that the exact same URL and HTTPS setup is common to both, proving that the newSize parameter string causes the failure.

    When carrying out these operations manually on the website, both pass with the newSize function resulting in a new bet being created. While waiting for bets to be matched is becomes necessary to manipulate the size and price continuously and it is necessary to complete these processes in the shortest possible time but at the moment the process I have to use is to cancel a bet and create a new one.

    When the ruling Back or Lay price changes it is necessary to adjust both the bet price and the size of the bet , or to cancel the bet and create a new bet putting it at the end of the bet queue.

    Because it's not possible to change both the price and size in the same instruction I would really like to know why the newSize function fails and how to get it working.

    Kind Regards
    OzPunter



  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    I've just had a look at replaceOrders in the documentation. It uses ReplaceInstruction for specification of the change. However, there are only two pieces of information in ReplaceInstruction. These are betId and newPrice. There is no newSize, hence your problem.

    The replaceOrders deletes the old order(s) and creates new one(s). It would be interesting to know whether this action places the new orders at the same point in the orders queue as the old ones, or just puts them at the end of the queue.

    It looks like changing the price and size will require at least two separate requests. There are other ways to change the bet size. If you want to reduce it, you can do it via a partial cancel request. I'm trying to remember how to increase bets; it may be that you just place a new bet with size=additional amount, but if size < allowed minimum, place it, then partially cancel it (and, perhaps, replace it too, to put the price where you want it, since you may not wish to place a bet with a size you intend to reduce at a price where it might get matched).

    Hope that makes sense and helps.
    Last edited by jabe; 02-07-2019, 03:29 AM.

    Comment

    • OzPunter
      Junior Member
      • Apr 2009
      • 161

      #3
      Thank you Jabe, I will experiment with ReplaceInstruction, as you suggest. I was sure that ReplaceOrders had a newSize originally but it would not be the first time I've been wrong. I think a new bet order will ultimately end up at the end of the queue. What I'd really like to do is speed up the process of changing bets when the price changes, which happens frequently close to event start time.

      Thanks Again
      OzPunter

      Comment

      • jptrader
        Junior Member
        • Nov 2009
        • 82

        #4
        @OzPunter: I remember the API you talk about, where you used the same method for changing price and size of an order. I believe the API was called UpdateBets in API v6. With API-NG (is it still called that?) this changed. ReplaceOrders changes price only. To change size you can decrease size (as jabe writes) by cancelOrders. To increase size you just place another order. If you already have an unmatched order above minimum size for a selection, you can place new sub-minimum-size orders.

        Originally posted by jabe View Post
        The replaceOrders deletes the old order(s) and creates new one(s). It would be interesting to know whether this action places the new orders at the same point in the orders queue as the old ones, or just puts them at the end of the queue.
        @Jabe: I would be very surprised if the new orders would keep the old orders place in the queue, otherwise this loophole could make me very much money :-)

        Comment

        • jptrader
          Junior Member
          • Nov 2009
          • 82

          #5
          Also: Cancelling part of an order would make the remaining part of the partly cancelled order keep the place in the order queue.

          Comment

          • OzPunter
            Junior Member
            • Apr 2009
            • 161

            #6
            Thank you JpTrader, I haven't used the API documentation for a while, I find the new web version a little hard to follow, I am used to the good old PDF version that you can take away and read over a coffee/beer. It looks like my code is more out of date that I thought, so I'll go hunting for UpdateBets as suggested. Manipulating the bets close to start time is a real hassle..

            Thanks Again
            OzPunter

            Comment

            Working...
            X