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 = "LTC-USD")
#' }
#'
#' @export


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$price <- as.numeric(fills$price)
    fills$size <- as.numeric(fills$size)
    fills$fee <- as.numeric(fills$fee)
    fills$usd_volume <- as.numeric(fills$usd_volume)
    fills$created_at <- strptime(fills$created_at, "%Y-%m-%dT%H:%M:%OS")

    #return----
    return(fills)
  }
JARVIS001011/rgdax documentation built on May 6, 2019, 12:06 p.m.