R/temp_roxygen.R

Defines functions rh_getInstrumentInfo rh_getInstrumentURL rh_getFundamentals

Documented in rh_getFundamentals rh_getInstrumentInfo rh_getInstrumentURL

#' Get instrument info.
#'
#' Return list with symbol and name for instrument url
#' @param  instrumentURL instrument url returned by rh_getInstrumentURL.
rh_getInstrumentInfo <- function(instrumentURL) {
  res <- httr::GET(instrumentURL)
  instrumentTicker <- httr::content(res)$symbol
  instrumentName <- httr::content(res)$name
  instrumentInfo <- list()
  instrumentInfo$ticker <- instrumentTicker
  instrumentInfo$name <- instrumentName
  return(instrumentInfo)
}

rh_getInstrumentURL <- function(ticker,account) {
  header <- account$user$authHeader
  res <- httr::GET(paste("https://api.robinhood.com/fundamentals/", ticker, "/",sep = ""), httr::add_headers(.headers=header))
  instrumentURL <- httr::content(res)$instrument
  return(instrumentURL)
}

#' Get fundamentals
#'
#' Get summary fundamentals data on company ticker.
#' @param ticker  Equity ticker symbol. All caps string.
#' @param account Initialized instance of the R6 Account class. Generated by Account$new(login).
rh_getFundamentals<-function(ticker,account){
  ticker<-toupper(ticker)
  header<-account$user$authHeader
  res<-httr::GET(paste("https://api.robinhood.com/fundamentals/",ticker,"/",sep=""), httr::add_headers(.headers=header))
  fundamentals_list<-httr::content(res)
  fundamentals_list<-as.data.frame(fundamentals_list)
  return(fundamentals_list)
}

#' Get current balances.
#' Retrieve current portfolio market value and positions.
#' @param account Initialized instance of the R6 Account class. Generated by Account$new(login).
## Order<-Orders$new(robinhoodUser$account)
## orders<-Order$orders
## current_positions<-orders$Current_Positions
QuantumFuse/robinhoodQF documentation built on Sept. 27, 2019, 1:57 p.m.