tennisScraper: Visualise current betting odds for a specific tennis match

Description Usage Arguments Value See Also Examples

Description

tennisScraper returns the current betting odds (exchange & bookies combined) for a specific tennis match. This information can then be used as the basis of particular trading strategies.

Usage

1
2
tennisScraper(type, match, inplay = NULL, tennis_links = NULL,
  numAttempts = 5, sleepTime = 0)

Arguments

type

string. Determines the type of input used to match up the Betfair exchange and Oddschecker. There are three options: df, name and id. df: A data frame should be passed to the function as the match parameter (see below); name: the name (or part of a name) of a tennis player should be passed to the function as the match parameter; id: a betfair event id (e.g. 20234123) or market id (e.g. 1.23121132) should be passed to the function as the match parameter.

match

dataframe (output from abettor:istMarketCatalogue call) or string (player name or event/market id). The class of this parameter should be specified in the type parameter (see above). A dataframe is the recommended choice, as it involves the least computational work. If a string is passed, then the function finds the event on the Betfair exchange that corresponds to that player name or event/market id. Required. No default.

inplay

boolean. Only relevant when type is not df. Setting inplay to TRUE means that only inplay teniis matches will be searched for a matching player name or market/event id. Setting inpay to FALSE means inplay matches will be excluded from the search. Finally, NULL means that both inplay and preplay matches will be searched. Tennis odds can change rapidly inplay (possibly after a every point). The Oddschecker feed may not be quick enough to capture these quick changes. So, if you intend to use this function for arbing, be aware that inplay arbs can arise from old odds still being on the Oddschecker site. Optional. Default is NULL.

tennis_links

<character>. A vector of tennis match page links on the oddschecker page. If not provided, the function scrapes all the match page links on the Oddschecker tennis page. As links are quite static, to speed up function, you can pass a vector of links to function. Consult the tennis tutorial on github to see how you can generate this vector of links.

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.

Value

If successful, this function will return a dataframe. The columns represent the current betting data for each player/doubles team. 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 (match has finsihed, match is not covered by Betfair/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 cases where the actuals couldn't be scraped from Oddschecker. For example, -1 means that no price was listed for that particular player.

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; 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
21
22
23
24
25
26
27
28
29
30
## 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

all_matches=listMarketCatalogue(eventTypeIds = "2",marketTypeCodes = "MATCH_ODDS")
tennisScraper("df", all_matches[1,])

# If we want to return data for numerous races, we'd need to loop the matches dataframe

for(i in 1:nrow(all_matches)){
print(all_matches[i,]$event)
print(tennisScraper("df", all_matches[i,]))
}

# But if we don't have a data frame, we can also pass a player's name (case insensitive)

tennisScraper("name", "djokovic")

# Alternatively, if we know the event id or market id of Djokovic's match on the Betfair exchange

tennisScraper("id", "27916958") # event id

tennisScraper("id", "1.126673586") #market id


## End(Not run)

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