quantmod

Pulling Intraday Minute Bar Data with Quantmod in R

别等时光非礼了梦想. 提交于 2019-12-05 16:51:27
I expect this is a fairly simple answer (and I will be embarrassed when I see how easy the solution is), but I am having a lot of trouble pulling intraday stock data by minute using the getSymbols() function under the quantmod package. I try to pull data using getSymbols("F") and end up with the following output: > F[1:10] F.Open F.High F.Low F.Close F.Volume F.Adjusted 2007-01-03 7.56 7.67 7.44 7.51 78652200 7.22 2007-01-04 7.56 7.72 7.43 7.70 63454900 7.41 2007-01-05 7.72 7.75 7.57 7.62 40562100 7.33 2007-01-08 7.63 7.75 7.62 7.73 48938500 7.43 2007-01-09 7.75 7.86 7.73 7.79 56732200 7.49

How to show gaps in R/quantmod's chartSeries/candleChart plots

怎甘沉沦 提交于 2019-12-05 06:59:13
I am trying to show "gaps" in financial data using the plotting functions in the excellent quantmod package for R. Normally R allows you to show gaps in plots using NA values, as with: x<-1:10 y<-2*x y[4:7]<-NA plot(x,y,type="l") I would like to do something similar with R/quantmod's candleChart plots. However, rows of data containing NA's are removed before plotting (there is a na.omit command in the chartSeries code that does this) so I cannot see how to do this. An example is: require(quantmod) #Make some pretend data x<-0:30 y<-100+20*sin(x) y.open<-y[-length(y)] y.close<-y[-1] val<-as.xts

Python rpy2 and quantmod examples

孤者浪人 提交于 2019-12-05 05:01:59
问题 Python programming language has helped me a lot in developing financial data analysis applications. Alternatively, there is the R for data analysis too, which has dedicated financial data analysis packages, for example: quantmod. Now, that there is rpy2 to interface between both these languages(i.e. Python & R). I would like to prototype some financial data analysis applications using the power of python with the quantmod package. By now, I have spent several hours searching the internet for

How to plot S&P 500 and Sotheby's Time Series in one ggplot?

南楼画角 提交于 2019-12-05 03:49:27
问题 I am downloading with the quantmod package the S&P 500 time series and the Sotheby's stock: library(zoo) library(tseries) library(quantmod) library(ggplot2) env1 = new.env() getSymbols("^GSPC", env = env1, src ="yahoo", from = as.Date("1988-06-01"),to = as.Date("2013-05-29")) GSPC = env1$GSPC gspc.df = data.frame(date=time(GSPC), coredata(GSPC)) env2 = new.env() getSymbols("BID", env = env2, src ="yahoo", from = as.Date("1988-06-01"),to = as.Date("2013-05-29")) BID = env2$BID sothebys.df =

Optimize moving averages calculation - is it possible?

廉价感情. 提交于 2019-12-05 03:48:41
问题 Is it possible to optimize (make it much faster) this piece of code: out <- do.call(rbind, lapply(split(Cl(cumulativeBars), "days"), function(x) { previousFullBars <- barsEndptCl[as.Date(index(barsEndptCl), tz=indexTZ(barsEndptCl)) < as.Date(last(index(x)), tz=indexTZ(x)), ] if (NROW(previousFullBars) >= 4) { last(SMA(last(rbind(previousFullBars, x), n=6), n=5)) } else { xts(NA, order.by=index(x)) } })) Below you can find my original question with all the code example that runs but a bit to

QuantMod getOptionChain “subscript out of bounds” error

我怕爱的太早我们不能终老 提交于 2019-12-05 02:12:47
问题 I am trying to use the function getOptionChain() from the QuantMod library to download option chains for VIX, SP500 and Eurostoxx 50 but the following doesn't work: library(quantmod) VIX.OPT <- getOptionChain("^VIX") I'm getting this error: Error in lapply(strsplit(opt, "<tr>"), function(.) gsub(",", "", gsub("N/A", : subscript out of bounds In addition: Warning message: In readLines(paste(paste("http://finance.yahoo.com/q/op?s", Symbols, : incomplete final line found on 'http://finance.yahoo

Adding Multiple Chart Series in Quantmod R

时光总嘲笑我的痴心妄想 提交于 2019-12-05 00:55:28
问题 I am trying to plot two charts on one chartSeries in quantmod in R. I am having some difficulty doing this. library(quantmod) tickers <- c('GLD', 'GDX') data <- new.env() getSymbols(tickers, src = 'yahoo', from = '1980-01-01', env = data) chartSeries(Cl(data$GLD), TA="addTA(Cl(data$GDX), on=1)") addRSI() 回答1: You could use chart_Series instead of chartSeries . chart_Series(Cl(data$GLD)) add_TA(Cl(data$GDX), on = 1) And then if you want RSI below in a sub panel, just add add_RSI() . Another

Error in getSymbols function usage in R(https) [closed]

二次信任 提交于 2019-12-04 19:30:42
Running library(quantmod) getSymbols("^BSESN",src="yahoo") produces the following error message: Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'https://ichart.finance.yahoo.com/table.csv?s=F&a=0&b=01&c=2007&d=4&e=17&f=2017&g=d&q=q&y=0&z=F&x=.csv' In addition: Warning message: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'https://ichart.finance.yahoo.com/table.csv?s=F&a=0&b=01&c=2007&d=4&e=17&f=2017&g=d&q=q&y=0&z=F&x=.csv': HTTP status was '502 Connection refused' This occurs due to the usage of https in

Simple function of quantmod not working anymore

孤人 提交于 2019-12-04 18:17:17
问题 I am turning in my thesis tomorow and I'm getting a very bizzare error message with quantmod which I never had during the last weeks while working with this package. I can't manage to import data specificly of Dow Jones index (^DJI). I get the following error message: getSymbols("^DJI",src="yahoo", from='2005-6-01', to='2012-6-21') Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : impossible to open the URL 'http://chart.yahoo.com/table.csv?s=^DJI&a=5&b=01&c=2005&d

R quantmod::getFinancials

╄→гoц情女王★ 提交于 2019-12-04 12:37:18
I'm using the quantmod package. I've got a vector of tickers like this : c("AAPL","GOOG","IBM","GS","AMZN","GE") and I want to create a function to calculate the EBIT margin of a stock (= operating income / total revenue). So for a given stock, I use the following piece of code which only works for GE (provided a ".f" is added a the end of the ticker) : require(quantmod) getFinancials("GE",period="A") ebit.margin <- function(stock.ticker.f){ return(stock.ticker$IS$A["Operating Income",]/stock.ticker$IS$A["Total Revenue",]) } ebit.margin("GE") I would like to generalize this function in order