cancelBets: cancelBets

Description Usage Arguments Author(s) Examples

Description

Betfair cancelBets

Usage

1
cancelBets(bets = list(), service = Exchange)

Arguments

bets

bets

service

service

Author(s)

colin@betwise.co.uk

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
31
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(bets=list(), service=Exchange)
{
  if(!is.list(bets)) {
    l <- list()
    for(x in bets){
      l[length(l)+1] <- list(CancelBets=list(betId=x))
    }
    names(l) <-rep( "CancelBets",length(l))
    bets <- l
  }
  v <- .bfapi(call("cancelBets", bets=bets), service=service)
  z <- .xmlp("errorCode", v)
  if(is.null(z)) return(v)
  if(z != "OK") return(z)
  x <- .xmlp("betResults", v)
  a1 <- unlist(strsplit(x,"><"))
  a2 <- a1[grep(".*>.*<.*",a1)]
  l  <- unique(sub("[ >].*","",a2))  # labels
  l <- sub("<","",l)
  v  <- sub(".*>(.*)<.*","\1",a2)   # values
  m  <- matrix(v, ncol=length(l), byrow=T)
  colnames(m) <- l
  x <- as.data.frame(m, stringsAsFactors=FALSE)
# XXX column type conversion
  x
  }

bwlewis/betfair documentation built on May 13, 2019, 9:05 a.m.