get_quote.yahoo: Download current instrument quote from yahoo...

Description Usage Arguments Details Value References See Also Examples

View source: R/get_quote.R

Description

Download current instrument quote from yahoo

Usage

1
get_quote.yahoo(Symbols, what = standardQuote(), waitTime = 30, ...)

Arguments

Symbols

Can be a vector of instrument names, or a character string of symbols, separated by semi-colons.

what

what should be retrieved

waitTime

time in seconds that is the longest you're willing to wait to get back a quote with a valid timestamp.

...

args to pass to getSymbols.FI

Details

This get_quote.yahoo method is the same as Jeff Ryan's code for getQuote.yahoo (see also) except for two differences. First, the quote requests are wrapped in a while loop. If the timestamp of the receied quote has a year that is different than the current year (as reported by Sys.time()), it will keep trying until either the year in the quote is the same as the current year, or waitTime has passed. Thanks to Zachary Mayar for suggesting the change, and Samo Pahor for providing the specific patch for this code. Second, if the Symbols are defined instruments that have a ‘yahoo’ identifier.

Value

a data frame with rows matching the number of Symbols requested, and the columns matching the requested columns.

References

http://r.789695.n4.nabble.com/getQuote-problem-tt3689746.html

See Also

getQuote, get_quote.IB

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
#backup instruments
ibak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
rm_instruments()
# create some instruments and give them 'yahoo' identifiers
synthetic("SPX", currency("USD"), identifiers=list(yahoo="^GSPC"))
future("ES", currency("USD"), multiplier=50, underlying_id="SPX")
## figure out front month contract for ES
(fid <- future_id("ES", format(Sys.Date(), "%b"), format(Sys.Date(), "%y")))
(yahooid <- paste(format_id(fid, sep=""), "CME", sep="."))
## define future_series, adding yahoo identifier
future_series(fid, identifiers=list(yahoo=yahooid))
s <- c("SPX", "SPY", "ES_M12")
get_quote.yahoo(s)
get_quote(s, src='yahoo') #same
## restore previous instrument environment
reloadInstruments(ibak)

## End(Not run)

twsInstrument documentation built on May 2, 2019, 5:24 p.m.