Placing multiple bets on a single request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brickwall3031
    Junior Member
    • Apr 2021
    • 14

    #1

    Placing multiple bets on a single request

    I tried to place the following bet on the API:
    ```
    {"jsonrpc": "2.0","method": "SportsAPING/v1.0/placeOrders","params": {"marketId": ["1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107063"],"instructions": [{"selectionId": ["2", "3", "8", "5", "6", "7", "10", "7044482"],"handicap": ["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "3.5"],"side": ["BACK", "BACK", "BACK", "BACK", "BACK", "BACK", "BACK", "BACK"],"orderType": "LIMIT","limitOrder": {"size": ["0.09", "0.09", "16.54", "0.09", "0.09", "20.1", "0.09", "50.9"],"price": ["1000.0", "1000.0", "5.6", "1000.0", "1000.0", "9.6", "1000.0", "1.82"],"persistenceType": "LAPSE"}}]},"id": 1}
    ```
    However I got the following error message:

    ```
    {'jsonrpc': '2.0', 'error': {'code': -32602, 'message': 'DSC-0018'}, 'id': 1}
    ```
    the docs are suggesting i am missing a field ("A parameter marked as mandatory was not provided") but I don't see which one? Can you place multiple bets on a single request like the above or do they have to be split up into individual bets?
  • bfexplorer
    Senior Member
    • Sep 2018
    • 212

    #2
    Of course, you can place multiple bets through api, here is my short code for a bot using PlaceBets:

    https://gist.github.com/StefanBelo/3...2a8798d2497c10

    Comment

    • jabe
      Senior Member
      • Dec 2014
      • 705

      #3
      Originally posted by brickwall3031 View Post
      I tried to place the following bet on the API:
      ```
      {"jsonrpc": "2.0","method": "SportsAPING/v1.0/placeOrders","params": {"marketId": ["1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107060", "1.188107063"],"instructions": [{"selectionId": ["2", "3", "8", "5", "6", "7", "10", "7044482"],"handicap": ["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "3.5"],"side": ["BACK", "BACK", "BACK", "BACK", "BACK", "BACK", "BACK", "BACK"],"orderType": "LIMIT","limitOrder": {"size": ["0.09", "0.09", "16.54", "0.09", "0.09", "20.1", "0.09", "50.9"],"price": ["1000.0", "1000.0", "5.6", "1000.0", "1000.0", "9.6", "1000.0", "1.82"],"persistenceType": "LAPSE"}}]},"id": 1}
      ```
      However I got the following error message:

      ```
      {'jsonrpc': '2.0', 'error': {'code': -32602, 'message': 'DSC-0018'}, 'id': 1}
      ```
      the docs are suggesting i am missing a field ("A parameter marked as mandatory was not provided") but I don't see which one? Can you place multiple bets on a single request like the above or do they have to be split up into individual bets?
      That's an interesting interpretation!

      You seem to have twigged that in JSON square brackets denote an array (which may contain 0 or 1 or more items). Curly brackets do not

      What you've done is assume - correctly - that instructions is an array, but incorrectly that the items within instructions are also arrays. What you needed to do was this:

      instructions: [{bet1 instructions}, {bet2 instructions}, {bet3 instructions}, etc]

      So it'll look something like this:

      instructions: [
      {"selectionId":"48671", "handicap":"0", "side":"LAY", "orderType":"LIMIT", "limitOrder":{"size": "2.2", "price": "3", "persistenceType": "LAPSE"}},
      {"selectionId":"122301", "handicap":"0", "side":"LAY", "orderType":"LIMIT", "limitOrder":{"size": "4", "price": "6", "persistenceType": "LAPSE"}}, {"selectionId":"23741", "handicap":"0", "side":"BACK", "orderType":"LIMIT", "limitOrder":{"size": "5.34", "price": "1.4", "persistenceType": "LAPSE"}},
      etc
      ]

      Comment

      • geoffw123
        Senior Member
        • Mar 2014
        • 250

        #4
        As Jabe says, your structuring of the data is not close to correct, also you dont need the multiple marketId's either. Here is an example of a working placeOrder JSON string for 3 multiple BACK bets.

        Code:
        {"jsonrpc":"2.0","method":"SportsAPING/v1.0/placeOrders","params":{"marketId":"1.188549489","instructions":[{"orderType":"LIMIT","selectionId":10040289,"handicap":0.0,"side":"BACK","limitOrder":{"size":2.0,"price":2.3,"persistenceType":"PERSIST"}},{"orderType":"LIMIT","selectionId":13104412,"handicap":0.0,"side":"BACK","limitOrder":{"size":2.0,"price":12.0,"persistenceType":"PERSIST"}},{"orderType":"LIMIT","selectionId":11461775,"handicap":0.0,"side":"BACK","limitOrder":{"size":2.0,"price":16.0,"persistenceType":"PERSIST"}}],"customerRef":"11:49:14_00002453","marketVersion":null,"customerStrategyRef":null,"locale":null},"id":1}

        Comment

        • LiamP
          Junior Member
          • Oct 2015
          • 284

          #5
          https://github.com/liampauling/betfair

          Comment

          • brickwall3031
            Junior Member
            • Apr 2021
            • 14

            #6
            thanks all, above makes sense. geoffw123 on the market Ids bit, how will it differentiate what bets you are putting on which market? in my original example i have 7 bets on the first market id and 1 bet on the second, how would the API know which is which? (I know the selection ids and handicap can differentiate but not necessarily)

            Comment

            • jabe
              Senior Member
              • Dec 2014
              • 705

              #7
              Originally posted by brickwall3031 View Post
              thanks all, above makes sense. geoffw123 on the market Ids bit, how will it differentiate what bets you are putting on which market? in my original example i have 7 bets on the first market id and 1 bet on the second, how would the API know which is which? (I know the selection ids and handicap can differentiate but not necessarily)
              I've had a look at the documents and each placeOrders call can only place bets for one market, so you'll need to have two calls in the case you mention, one for each market.

              Comment

              • brickwall3031
                Junior Member
                • Apr 2021
                • 14

                #8
                interesting, thanks. Would I be much worse off doing a series of single bets instead of combining them like above? (thinking it may be awkward to program a way to populate the json string with a combination of bets). Would the risk of price moves/bets not being matched be much greater?

                Comment

                • LiamP
                  Junior Member
                  • Oct 2015
                  • 284

                  #9
                  Originally posted by brickwall3031 View Post
                  interesting, thanks. Would I be much worse off doing a series of single bets instead of combining them like above? (thinking it may be awkward to program a way to populate the json string with a combination of bets). Would the risk of price moves/bets not being matched be much greater?
                  Use betfairlightweight and focus on the fun stuff instead?

                  Comment

                  Working...
                  X