horseScraper: Visualise current betting odds for a specific horse race

Description Usage Arguments Details Value Note on race.time variable See Also Examples

Description

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.

Usage

1
horseScraper(race, suppress = FALSE, numAttempts = 5, sleepTime = 0)

Arguments

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 scrapePage). Optional. Default is 5.

sleepTime

integer. This parameter specifies the amount of time (in seconds) the function waits following a failed scraping attempt. Optional. Default is zero.

Details

Note on horseScraper: Currently, this function does not support horse races in Australia and New Zealand.

Value

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.

Note on race.time variable

The API returns the event start time in UTC. During Daylight Savings Time (DST), we need to an hour manually.

See Also

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

Examples

 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)

dashee87/betScrapeR documentation built on May 14, 2019, 6:12 p.m.