R/gettdays.R

#
#   extraTechInds: extra Technical Indicators of TTR and quantmod
#
#   Copyright (C) 2016  Chen Chaozong
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#' Retrieve valid days between two days.
#'
#' @aliases gettdays
#' @param starttime starttime in w.tdays
#' @param endtime endtime in w.tdays
#' @param options options in w.tdays, use w.menu to get more help
#' @export

gettdays <- function(starttime, endtime = Sys.time(), options = ""){
  if(checkwindr()!=0) return(NULL)
  tmpdata <- w.tdays(starttime,endtime,options)
  if(!tmpdata$ErrorCode==0) {
    message(paste("Can not get wind data, error code:",tmpdata$ErrorCode))
    return(NULL)
  }
  out <- tmpdata$Data[,"DATETIME"]
  return(out)
}

#' Retrieve duration between two days.
#'
#' @aliases gettdayscount
#' @param starttime starttime in w.tdayscount
#' @param endtime endtime in w.tdayscount
#' @param options options in w.tdayscount, use w.menu to get more help
#' @export

gettdayscount <- function(starttime, endtime = Sys.time(), options = ""){
  if(checkwindr()!=0) return(NULL)
  tmpdata <- w.tdayscount(starttime,endtime,options)
  if(!tmpdata$ErrorCode==0) {
    message(paste("Can not get wind data, error code:",tmpdata$ErrorCode))
    return(NULL)
  }
  out <- tmpdata$Data[,2]
  return(out)
}

#' Retrieve a day based on the input day
#'
#' @aliases gettdaysoffset
#' @param offset wind offset in w.tdaysoffset
#' @param starttime starttime in w.tdaysoffset
#' @param options options in w.tdaysoffset, use w.menu to get more help
#' @export

gettdaysoffset <- function(offset,starttime=Sys.time(), options = ""){
  if(checkwindr()!=0) return(NULL)
  tmpdata <- w.tdaysoffset(offset,starttime,options)
  if(!tmpdata$ErrorCode==0) {
    message(paste("Can not get wind data, error code:",tmpdata$ErrorCode))
    return(NULL)
  }
  out <- tmpdata$Data[,"DATETIME"]
  return(out)
}
Chen-Chaozong/getwinddata documentation built on May 6, 2019, 10:10 a.m.