placeOrder operation on API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lonestar79
    Junior Member
    • Sep 2015
    • 11

    #1

    placeOrder operation on API

    Hello,

    I noticed that the placeOrder operation requires a marketID. This tells me that the function needs to be called separately for each market that we want to bet on. This would slow down my bot. Is it possible to bet on multiple markets with one call to the operation?

    On a separate note, is it possible to put multiple orders on the same market with one call to the function? If I can see a sample code for that, it would be very helpful.

    Thank you.
  • Merlin
    Junior Member
    • Jan 2009
    • 56

    #2
    Hi Lonestar79,

    you are quite right; a separate call to placeOrders is required for each market.

    If you look at the documentation, you will see that up to 200 orders for the same market can be placed with a single call - the instructions parameter is a list of PlaceInstructions.

    Sample code for doing that would depend on what language you are using, but would basically involve building your PlaceInstructions and adding them to the instructions array.

    Comment

    • lonestar79
      Junior Member
      • Sep 2015
      • 11

      #3
      Merlin,

      Thank you for the answer.

      May I ask a follow up please?

      I use Python language. When I send a placeOrder operation, my code stops and waits for answer before continuing to the rest of the code. Lets say I would like to trade on multiple markets. Once I put an order on one market, the code execution will stop until response is received. Same will occur for each market I am operating in. If the markets are fast moving, my code will always be left behind. Is there a way to deal with this problem? How can I ensure my code can continue without a pause?

      Comment

      • lonestar79
        Junior Member
        • Sep 2015
        • 11

        #4
        Can anyone shed light on this question? It seems to me that it would be impossible to trade on multiple markets (especially in-play) if the code execution is paused for 5 seconds every time an order is put on one market. I can't imagine people using bots to bet on multiple markets with that kind of delays. Am I missing something?

        Also: Is Betfair offering the same level of service for all participants regarding order placement? Is it possible to buy some sort of subscription so that we can put orders in multiple markets?

        Thanks for any help.

        Comment

        • jptrader
          Junior Member
          • Nov 2009
          • 82

          #5
          You would have to to rewrite your bot to place the orders asynchronously.

          Comment

          • lonestar79
            Junior Member
            • Sep 2015
            • 11

            #6
            JPTrader, thank you. Good point.

            Comment

            • Merlin
              Junior Member
              • Jan 2009
              • 56

              #7
              Lonestar79,

              as jptrader says, the usual solution to this is to use a threaded approach; certainly by putting each market in it's own thread, and possibly spawning a new thread to do the order placement. The connection to betfair can be re-used across these threads and there should be no problem with overlapping calls.

              There is no service offered by betfair to place orders on multiple markets with one call, but with a well designed bot, this shouldn't matter.

              One worrying point is that it takes 5 seconds to process a placeOrders call; this is by no means typical, and although the number of slow replies has increased over the last few months, if you are consistently getting times like this there is something wrong. Check if the bottleneck is in your code or in the connection to betfair - if you are not located in europe, you may need to look at using a VPS closer to the bf servers.

              cheers,

              Merlin

              Comment

              • jptrader
                Junior Member
                • Nov 2009
                • 82

                #8
                @Merlin, note that lonestar talks about inplay markets, where there are intentional delays of 5-12 seconds.

                Agree though, that the number of slow replies has increased during the last half year or so. Something to do with this?

                Comment

                Working...
                X