listMarketProfitAndLoss: Return market profit and loss

View source: R/listMarketProfitAndLoss.R

listMarketProfitAndLossR Documentation

Return market profit and loss

Description

listMarketProfitAndLoss Retrieve profit and loss for a given list of OPEN markets. The values are calculated using matched bets and optionally settled bets

Usage

listMarketProfitAndLoss(
  marketIds,
  includeSettledBetsValue = NULL,
  includeBspBetsValue = NULL,
  netOfCommissionValue = NULL,
  suppress = FALSE,
  sslVerify = TRUE
)

listMarketPandL(
  marketIds,
  includeSettledBetsValue = NULL,
  includeBspBetsValue = NULL,
  netOfCommissionValue = NULL,
  suppress = FALSE,
  sslVerify = TRUE
)

Arguments

marketIds

Vector<String>. A set of market ID strings from which the corresponding market profit and losses will be returned. Required. No default.

includeSettledBetsValue

Boolean. Option to include settled bets (partially settled markets only). This parameter defaults to NULL, which Betfair interprets as false. Optional.

includeBspBetsValue

Boolean. Option to include Betfair Starting Price (BSP) bets. This parameter defaults to NULL, which Betfair interprets as FALSE. Optional.

netOfCommissionValue

Boolean. Option to return profit and loss net of user's current commission rate for this market, including any special tariffs. This parameter defaults to NULL, which Betfair interprets as FALSE. Optional.

suppress

Boolean. By default, this parameter is set to FALSE, meaning that a warning is posted when the listMarketPandL call throws an error. Changing this parameter to TRUE will suppress this warning.

sslVerify

Boolean. This argument defaults to TRUE and is optional. In some cases, where users have a self signed SSL Certificate, for example they may be behind a proxy server, Betfair will fail login with "SSL certificate problem: self signed certificate in certificate chain". If this error occurs you may set sslVerify to FALSE. This does open a small security risk of a man-in-the-middle intercepting your login credentials.

Value

Response from Betfair is stored in listPandL variable, which is then parsed from JSON as a data frame of at least two varialbes (more if the optional parameters are included). The first column records the market IDs, while the corresponding market P&Ls are stored within a list.

Note on listPandLOps variable

The listPandLOps variable is used to firstly build an R data frame containing all the data to be passed to Betfair, in order for the function to execute successfully. The data frame is then converted to JSON and included in the HTTP POST request. If the listMarketPandL call throws an error, a data frame containing error information is returned.

See Also

loginBF, which must be executed first. Do NOT use the DELAY application key. The DELAY application key does not support price data.

listClearedOrders to retrieve your profit and loss for CLOSED markets

Note that listMarketPandL does not include any information about the value of your bets on the markets e.g. value of profit/loss if you were to cashout at current prices. It simply returns the money you'd win/lose if specific selections were to win. If you wish to calculate your cashout position, then we'll need to design a new function combining listCurrentOrders and listMarketBook (it's on the to-do list).

Examples

## Not run: 
Return the P&L (net of comission) for the requested markets. The actual
market IDs are unlikely to work and are just for demonstration purposes.

listMarketProfitAndLoss(marketIds = c("1.122323121","1.123859413"),
               netOfCommission = TRUE)

## End(Not run)

#' \dontrun{
Return the P&L (net of comission) for the requested markets. The actual
market IDs are unlikely to work and are just for demonstration purposes.

listMarketPandL(marketIds = c("1.122323121","1.123859413"),
               netOfCommission = TRUE)
}


phillc73/abettor documentation built on June 10, 2022, 4:43 p.m.