Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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

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.

Author(s)

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

References

See Also

Examples

yahooQuote.EOD
## Not run: 
getQuote("AAPL")
getQuote("QQQQ;SPY;^VXN",what=yahooQF(c("Bid","Ask")))
standardQuote()
yahooQF()

## End(Not run)

quantmod

Quantitative Financial Modelling Framework

v0.4.18
GPL-3
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Wouter Thielen [ctb], Paul Teetor [ctb], Steve Bronder [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.