Learn R Programming

quantmod (version 0.4.20)

getQuote: Download Current Stock Quote

Description

Fetch current stock quote(s) from specified source. At present this only handles sourcing quotes from Yahoo Finance and Alpha Vantage, but it can be extended to additional sources.

Usage

getQuote(Symbols, src = "yahoo", what, ...)

standardQuote(src="yahoo") yahooQF(names) yahooQuote.EOD

Value

The number of symbols per request is limited to 200 for Yahoo! and 100 for Alpha Vantage. getQuote will make multiple requests if more than the maximum number of symbols are requested. It will then combine the results of all the requests and return one data frame. The data frame will contain a column for each requested data field, and the requested symbols will be stored in the row names.

In order to import quotes from Alpha Vantage, you must obtain an API key by completing a free, one-time registration at their website: https://www.alphavantage.co/. Then you can call getQuote with src = "av" and api.key = "[your key]".

The what argument allows for specific data to be requested. For getQuote.yahoo, the value of what should be a quoteFormat

object like that returned by standardQuote. The yahooQF function will create an interactive selection tool if the what argument is missing. The what argument is currently ignored for Alpha Vantage data because only a few fields are available.

standardQuote currently only applies to the Yahoo! data source. It returns a quoteFormat object to use with the getQuote function.

yahooQuote.EOD is a constant quoteFormat object for OHLCV data.

Arguments

Symbols

character string of symbols, separated by semi-colons

src

source of data ("yahoo" and "av" are currently implemented)

what

what should be retrieved

names

which data should be retrieved

...

currently unused

Author

Jeffrey A. Ryan (Yahoo) Ethan B. Smith (Alpha Vantage)

References

Yahoo! Finance https://finance.yahoo.com Alpha Vantage https://www.alphavantage.co

See Also

getSymbols, getSymbols.av

Examples

Run this code
yahooQuote.EOD
if (FALSE) {
getQuote("AAPL")
getQuote("QQQQ;SPY;^VXN",what=yahooQF(c("Bid","Ask")))
standardQuote()
yahooQF()
}

Run the code above in your browser using DataLab