get.hist.quote

0th

Percentile

Download Historical Finance Data

Download historical financial data from a given data provider over the WWW.

Keywords
ts
Usage
get.hist.quote(instrument = "^gdax", start, end,
               quote = c("Open", "High", "Low", "Close"),
               provider = c("yahoo"), method = NULL,
               origin = "1899-12-30", compression = "d",
	       retclass = c("zoo", "ts"), quiet = FALSE, drop = FALSE)
Arguments
instrument

a character string giving the name of the quote symbol to download. See the web page of the data provider for information about the available quote symbols.

start

an R object specifying the date of the start of the period to download. This must be in a form which is recognized by as.POSIXct, which includes R POSIX date/time objects, objects of class "date" (from package date) and "chron" and "dates" (from package chron), and character strings representing dates in ISO 8601 format. Defaults to 1992-01-02.

end

an R object specifying the end of the download period, see above. Defaults to yesterday.

quote

a character string or vector indicating whether to download opening, high, low, or closing quotes, or volume. For the default provider, this can be specified as "Open", "High", "Low", "Close", "Adjusted", and "Volume", respectively. Abbreviations are allowed.

provider

a character string with the name of the data provider. Currently, only "yahoo" is supported via getSymbols from package quantmod for the Yahoo Finance source. Provider "oanda" is no longer available.

method

No longer used.

origin

an R object specifying the origin of the Julian dates, see above. Defaults to 1899-12-30 (Popular spreadsheet programs internally also use Julian dates with this origin).

compression

Governs the granularity of the retrieved data; "d" for daily, "w" for weekly or "m" for monthly. Defaults to "d". For the provider "oanda", this argument is ignored.

retclass

character specifying which class the return value should have: can be either "zoo" (with "Date" index), or "ts" (with numeric index corresponding to days since origin).

quiet

logical. Should status messages (if any) be suppressed?

drop

logical. If TRUE the result is coerced to the lowest possible dimension. Default is FALSE.

Value

A time series containing the data either as a "zoo" series (default) or a "ts" series. The "zoo" series is created with zoo and has an index of class "Date". If a "ts" series is returned, the index is in physical time, i.e., weekends, holidays, and missing days are filled with NAs if not available. The time scale is given in Julian dates (days since the origin).

See Also

getSymbols for downloads from various providers; zoo, ts, as.Date, as.POSIXct,

Aliases
  • get.hist.quote
Examples
# NOT RUN {
con <- url("https://finance.yahoo.com")
if(!inherits(try(open(con), silent = TRUE), "try-error")) {
  close(con)
  x <- get.hist.quote(instrument = "^gspc", start = "1998-01-01",
                      quote = "Close")
  plot(x)

  x <- get.hist.quote(instrument = "ibm", quote = c("Cl", "Vol"))
  plot(x, main = "International Business Machines Corp")

  spc <- get.hist.quote(instrument = "^gspc", start = "1998-01-01",
         quote = "Close")
  ibm <- get.hist.quote(instrument = "ibm",  start = "1998-01-01",
         quote = "Adj")
  require("zoo")		# For merge() method.
  x <- merge(spc, ibm)
  plot(x, main = "IBM vs S&P 500")
}
# }
Documentation reproduced from package tseries, version 0.10-47, License: GPL-2

Community examples

Looks like there are no examples yet.