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

Live odds #9

Closed NickNickC closed 8 years ago

NickNickC commented 8 years ago

Hi phillc73,

Is there a way to see inplay markets with abettor?

I have a live score scraper that I want to combine with the current live odds of a match to determine if a bet should be placed. Basically, if a bunch of scenarios with the score and the odds happen simultaneously I will get an alert from R through a text or email (in Australia we have to call betfair to place the bet so I can't automate the placing of the order).

Is it possible to get these odds in abettor or is there another way to get this?

thanks, Nick

phillc73 commented 8 years ago

@NickNickC Currently the package doesn't support inplay markets (well, to be honest, I've never looked at it), but it seems like a good enhancement so I will leave this open and mark it as such.

dashee87 commented 8 years ago

Hi guys,

I'm putting the finishing touches on an expanded listMarketCatalogue function, which will allow you to restrict the output to markets that are currently inplay. You'll hopefully see it in the coming days.

NickNickC commented 8 years ago

Thanks dashee87!!

This might be a stretch but can this feed also give live scores? I am scraping other websites at the moment to get live scores but it is a bit slow and I think betfair would update the fastest.

many thanks, Nick

dashee87 commented 8 years ago

Hi Nick,

I've had a quick look at football and tennis and it doesn't look like it would be too hard (the event Id is pretty much all you need). However, from my experience, the betfair live scores can be very unreliable (e.g. immediately after a disallowed goal). So I'd recommend using any scraper in combination with some API calls (e.g. check if the market has moved after a goal). Anyway, I should get a basic enough scraper done in the coming days.

David

marcvanderpeet12 commented 8 years ago

Hi guys,

@dashee87 I am trying to fetch inplay odds using the abettor API but I could not find it yet. Am I overlooking it?

phillc73 commented 8 years ago

Have a look at the listMarketCatalogue() function.

From the documentation:

#' @param turnInPlayEnabled Boolean. Restrict to markets that will turn in play
#'   if TRUE or will not turn in play if FALSE. Optional. Default is NULL, which
#'   means that both market types are returned.
#'
#' @param inPlayOnly Boolean. Restrict to markets that are currently in play if
#'   TRUE or not inplay if FALSE. Optional. Default is NULL, which means that
#'   both inplay and non-inplay markets are returned.
#'
#' # Return market catalogues for all football matches currently inplay,
#' restricted to Match Odds market types and sorted by the amount traded.
#' listMarketCatalogue(eventTypeIds = c("1"),marketTypeCodes = c("MATCH_ODDS"),
#'                    inPlayOnly = TRUE, MarketSort = "MAXIMUM_TRADED")
#' }
#'

I hope that helps.

Please do report back if it worked for you!

marcvanderpeet12 commented 8 years ago

Hi Phil, thanks for your quick reply.

It does not seem to work. If I want to list inplay tennis matches I do:

 listMarketCatalogue(eventTypeIds = c("2"), marketTypeCodes = c("MATCH_ODDS"), inPlayOnly =    TRUE, marketSort = "MAXIMUM_TRADED")

It returns:

data frame with 0 columns and 0 rows

While there are currently matches inplay. Any thoughts where this goes wrong?

phillc73 commented 8 years ago

Sorry, not immediately. I will try to have a look as soon as I can, most likely over the weekend.

marcvanderpeet12 commented 8 years ago

Sweet thanks!

dashee87 commented 8 years ago

Hi @marcvanderpeet12

You'll have to check this yourself, but I suspect the issue is with the fromDate parameter. Its default is two hours (as in, it only returns events that were scheduled to start at most two hours ago). When I set this value, I had football in mind. But it probably needs to be bigger for other sports (e.g. tennis and cricket). Hopefully, this will solve your problems. If not, let me know.

listMarketCatalogue(eventTypeIds = c("2"), marketTypeCodes = c("MATCH_ODDS"), inPlayOnly = TRUE, marketSort = "MAXIMUM_TRADED",fromDate = (format(Sys.time()-7200*10, "%Y-%m-%dT%TZ")))

marcvanderpeet12 commented 8 years ago

Works like a charm! Thanks for the quick reply guys and big thumbs up for the package!

phillc73 commented 8 years ago

Good news! @marcvanderpeet12 please do submit any improvement suggestions. Thanks for the quick response @dashee87. I think I'm also going to close this open issue now.