Passing multiple betIds for cancelling bets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • steve88
    Junior Member
    • Dec 2018
    • 10

    #1

    Passing multiple betIds for cancelling bets


    I have avoided using the python function betfairlightweight.filters.cancel_instruction because seemingly it only takes a single betId. I have built my own string for the instructions field, see example below. But it typically doesn't accepted by the exchange and is rejected. Any ideas what I'm doing wrong? Instructions_String = [{'betId': '199563656722'}, {'betId': '199563649740'}, {'betId': '199563657652'}, {'betId': '199563657654'}, {'betId': '199563656423'}, {'betId': '199563656724'}, {'betId': '199563656424'}, {'betId': '199563656425'}, {'betId': '199563656426'}, {'betId': '199563649744'}, {'betId': '199563649745'}, {'betId': '199563656427'}, {'betId': '199563651106'}, {'betId': '199563651959'}, {'betId': '199563651960'}, {'betId': '199563651961'}, {'betId': '199563649739'}, {'betId': '199563656725'}, {'betId': '199563656726'}, {'betId': '199563642204'}, {'betId': '199563642205'}, {'betId': '199563656728'}]
    order = trading.betting.cancel_orders( market_id = '1.23472634287', instructions = Instructions_String, )
  • LiamP
    Junior Member
    • Oct 2015
    • 284

    #2
    At a guess it’s because betId should be an integer, do you get an error?

    Comment

    • geoffw123
      Senior Member
      • Mar 2014
      • 250

      #3
      Hi

      Post the full JSON strings that you are sending down the wire and the response back, it should be fairly easy to spot the problem then.

      Comment

      • steve88
        Junior Member
        • Dec 2018
        • 10

        #4
        Dumb question. I'm using pycharm. How do I print the json strings for this command: order = trading.betting.cancel_orders( market_id = '1.23472634287', instructions = Instructions_String, )?

        Comment

        • LiamP
          Junior Member
          • Oct 2015
          • 284

          #5
          Originally posted by steve88 View Post
          Dumb question. I'm using pycharm. How do I print the json strings for this command: order = trading.betting.cancel_orders( market_id = '1.23472634287', instructions = Instructions_String, )?
          Easiest way is the following:

          Code:
          bet_ids = [199602103325, 199602103474]
          instructions = [filters.cancel_instruction(bet_id) for bet_id in bet_ids]
          cancel_order = trading.betting.cancel_orders(market_id='1.170322166', instructions=instructions)
          print(cancel_order._response.request.body)
          
          {"jsonrpc":"2.0","method":"SportsAPING\/v1.0\/cancelOrders","params":{"marketId":"1.170322166","instructions":[{"betId":199602103325},{"betId":199602103474}]},"id":1}
          But the error raised will also show it.

          Note that the market_id is invalid or have you changed it?

          Comment

          • geoffw123
            Senior Member
            • Mar 2014
            • 250

            #6
            Hi

            I do it a different way than Liam suggested, I use a free App called Fiddler 4, which allows you to view the data going up and down the wire in different formats. You can click on the JSON tab or the Raw Tab to see it in both formats. Monitoring the actual comms removes any doubt as to what your software is doing at the lower levels.

            Comment

            • jabe
              Senior Member
              • Dec 2014
              • 705

              #7
              I'm pretty sure that numeric strings can be passed to integer variables. In certain cases, I have recommended putting what appear to be numbers within strings - it's a must for market ids, otherwise a market id like 1.2345670 will become 1.234567.

              Comment

              Working...
              X