Description Usage Arguments Details Value Note on race.time variable See Also Examples
horseScraper
returns the current betting odds (exchange & bookies
combined) for a specific horse race. This information can then be used as the
basis of particular trading strategies.
1 | horseScraper(race, suppress = FALSE, numAttempts = 5, sleepTime = 0)
|
race |
dataframe (output from abettor:istMarketCatalogue call). Required. No default. |
suppress |
Boolean. A warning is posted when the race start is less than 15 mins away (data may not be reliable as prices change quite quickly just before the start). Setting this parameter to FALSE suppresses this warning. Default is TRUE. Optional. |
numAttempts |
integer. Specifies the number of attempts before aborting
this particular scraping attempt (see |
sleepTime |
integer. This parameter specifies the amount of time (in seconds) the function waits following a failed scraping attempt. Optional. Default is zero. |
Note on horseScraper
: Currently, this function does not support horse
races in Australia and New Zealand.
If successful, this function will return a dataframe. The columns represent the current betting data for each active horse in the race. This betting data consists of both exchange information (back/lay price and odds) and the odds offered by various bookies. If unsuccessful, an error dataframe is returned. There are various reasons why an error dataframe is returned (race has finsihed, race is not covered by Oddschecker, etc). The precise reason for the failure will be outlined in the error dataframe. Note that the data frame returned by this function may include non-positive integers. This is to cover specials cases where the actuals couldn't be scraped from Oddschecker. If SP (starting price) was listed as the price on Oddschecker, this is converted to 0; -1 means that nothing was listed for that race from that bookie; and -101 signifies a horse that is a non-runner at Oddschecker but still available on the exchange.
race.time
variableThe API returns the event start time in UTC. During Daylight Savings Time (DST), we need to an hour manually.
https://github.com/phillc73/abettor for general information on making betfair API calls. This function is reliant on numerous functions from this package: a valid session token must be present; the input for horseScraper is horse race data generated from an appropriate listMarketCatalogue call; current exchange price data is gathered from a listMarketBook call within horseScraper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
# Make sure that loginBF has been called, as this function requires
a valid session token.
# Only one race can be passed to function at a time. Let's have a look at the
current odds for an upcoming horse race. To do so, we call listMarketCatalogue
HRaces=listMarketCatalogue(eventTypeIds = "7",marketTypeCodes = "WIN")
horseScraper(HRaces[1,])
# If we want to return data for numerous races, we'd need to loop the HRaces dataframe
for(i in 1:nrow(HRaces)){
print(HRaces[i,]$event)
print(horseScraper(HRaces[i,]))
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.