phillc73 / abettor

An R package for connecting to the online betting exchange Betfair, via their API-NG product, using JSON-RPC.
Other
51 stars 36 forks source link

Error when placing more than two lay/back bets #19

Open bcaneco opened 7 years ago

bcaneco commented 7 years ago

Hi,

The function placeOrders() doesn't seem to allow for more than 2 simultaneous back/lay orders, returning "Error: Expectation Failed".

placeOrders( marketId = "1.130459350", selectionId = as.character(c(10463405, 10463405, 11160430)), betSide = rep("LAY", 3), betType = "LIMIT", betSize = rep(as.character(2), 3), reqPrice = rep(as.character(1.2), 3), persistenceType = rep("LAPSE", 3) ) Error: Expectation Failed

Am I wrongly specifying any of the arguments? Or is there a limit on the number of bets per request imposed by the betfair API?

Looking at the betfair's API documentation on placing orders, it reads: "The limit of place instructions per request is 200 for the UK/AUS Exchange (...)"

In any case, I must also add that the package works a treat - you've than an excellent job!

Many thanks in advance, Bruno

phillc73 commented 7 years ago

Honestly, I've never tried (or even considered) the possibility of placing such simultaneous orders. I'd have to look deeper to figure out what's failing.

As a workaround, have you tried iterating through a list? That is, rather than repeating the individual items within the placeOrders() function, loop through a list of selectionIDs and executing placeOrders() three times, once for each ID.

bcaneco commented 7 years ago

Thanks for your reply Phil.

That's precisely what I've done - running placeOrders() looped over selectionIDs. :)

That, however, led to another issue: due to small time delays in the API's answer to placeOrders(), some of the requests seem to get stumbled on the top of each other between iterations. As a result, some of the requests are not placed. Setting a little waiting period (1sec) between iterations solved the problem.

It'd still be great to be able to place 2+ simultaneous bets in one request inside placeOrders() though! Specially for inplay betting, when market volatility is so high that 1sec lags can display inconvenient price shifts.

Cheers

phillc73 commented 7 years ago

Thanks for the further feedback. I'll leave this issue open as something for me to investigate, specifically how to place faster simultaneous orders.

Soccerama commented 3 years ago

I had a look at this and managed to use a single placeOrder instruction to place back bets on Home, Draw and Away outcomes for a single Premier League game. Not sure if the httr related changes fixed this or if there is some other explanation.as I didn't check before those changes. I'd be interested to hear if you can get it to work now.

I used numbers for betSize and reqPrice but tested using characters for betSize and it still seemed to work. Agree that the issue of bets not being placed because of the delay is a problem and haven't worked out to solve that one yet. Suspect that checking the response in your code would help.

Should add that I only tested this with LIMIT bets as I only do sports so don't have the option of doing SP - and don't have a detailed understanding of it.

phillc73 commented 3 years ago

Based on @Soccerama feedback placing simultaneous bets should work. @bcaneco any chance you can confirm this?

I'll leave this issue open for a week or so before closing if no further feedback.