R/fills.R

Defines functions fills

Documented in fills

#' Get List of Most Recent Fills
#'
#' @name fills
#'
#' @description This is an auth based function. User must have valid api keys generated by GDAX which must be passed as mandatory arguments. The functions takes product_id as an optional param and returns a list of all previously filled orders.
#'
#' @param api.key Mandatory character value. This is the API key as generated by GDAX. Typically a 32 character value.
#' @param secret Mandatory character value. This is the API secret as generated by GDAX. Typically a 88 character value.
#' @param passphrase Mandatory character value. This is the passphrase as generated by GDAX. Typically a 11 character value.
#' @param product_id Optional character value for the currency pair. The default is \code{NULL} which is equivalent of 100 most recent fills. This param when provided is case insensitive and must be one of the valid currency-pair. The list of valid currency-pairs can be fetched using \code{\link{public_info}}.
#'
#' @return  Dataframe with fills for all products or for the provided products. The volume is quoted in USD.
#'
#' @examples
#' \dontrun{
#' fills(api.key = your_key,
#' secret = your_api_secret,
#' passphrase = your_api_pass,
#' product_id = "BTC-USD")
#' }
#'
#' @export

# output tested on WIN. Macos pending
fills <-
  function(api.key,
           secret,
           passphrase,
           product_id=NULL) {
    #get url extension----
    if (is.null(product_id)) {
      req.url = "/fills"
    } else {
      product_id <- toupper(product_id)
      req.url = paste0("/fills?product_id=", product_id)
    }


    #get method----
    method <- "GET"

    #fetch response----
    fills <- auth(
      method = method,
      req.url = req.url,
      api.key = api.key,
      secret = secret,
      passphrase = passphrase
    )

    #transform----
    fills <- ldply(fills, data.frame)

    #return----
    return(fills)
  }

Try the rgdax package in your browser

Any scripts or data that you put into this service are public.

rgdax documentation built on Aug. 3, 2021, 9:06 a.m.