R/sandboxDeletePositions.R

Defines functions sandboxDeletePositions

Documented in sandboxDeletePositions

#' @title Working with sandbox. Delete positions
#'
#' @description Delete sandbox positions (all positions: stocks, etfs,bonds and money)
#'
#' @param token token from Tinkoff account (only sandbox token)
#' @details  If you need to create few money position, use this function for each position
#' @return returns a list object containing the information about state of operation.
#' @note Not for the faint of heart. All profits and losses related are yours and yours alone. If you don't like it, write it yourself.
#' @author Vyacheslav Arbuzov
#' @seealso \code{\link{sandboxPositions}}
#' @examples
#' token = 'your_token_from_tcs_account'
#' sandboxDeletePositions(token)
#' @export

sandboxDeletePositions = function(token = '')
{
  headers = add_headers("accept" = "application/json","Authorization" = paste("Bearer",token))
  url = paste0('https://api-invest.tinkoff.ru/openapi/sandbox/sandbox/clear')
  raw_data = POST(url, headers)
  if(raw_data$status_code==200)
  {
    data_tmp = content(raw_data, as = "parsed")
    return(data_tmp)
  }
  if(raw_data$status_code!=200)
    return(content(raw_data, as = "text"))
}

Try the tcsinvest package in your browser

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

tcsinvest documentation built on Aug. 17, 2021, 9:08 a.m.