search for: gspc

Displaying 20 results from an estimated 23 matches for "gspc".

Did you mean: gsoc
2011 May 05
1
quantmod's addTA plotting functions
...I'm having trouble with quantmod's addTA plotting functions. They seem to work fine when run from the command line. But when run inside a function, only the last one run is visible. Here's an example. test.addTA <- function(from = "2010-06-01") { getSymbols("^GSPC", from = from) GSPC.close <- GSPC[,"GSPC.Close"] GSPC.EMA.3 <- EMA(GSPC.close, n=3, ratio=NULL) GSPC.EMA.10 <- EMA(GSPC.close, n=10, ratio=NULL) chartSeries(GSPC.close, theme=chartTheme('white'), up.col="black", dn.col="black&quo...
2010 Mar 16
1
Simple for-loop runs out of memory
I have the following simple for-loop, which makes R crash every time. The length of the vectors is about 1200 rows, 1 column. n = max(length(GSPC),length(FTSE)) for(i in 1:1000) { if (row.names(GSPC)[i]==row.names(FTSE)[i]){ } else { if (row.names(GSPC)[i]>row.names(FTSE)[i]){ GSPC<-rbind(GSPC[1:(i-1),],GSPC[(i-1):length(GSPC),]) row.names(GSPC)[i]=row.names(FTSE)[i] } else { FTSE<-rbind(FTSE[1:(i-1),],FTSE[(i-1):lengt...
2012 Dec 06
1
Fuction Error
I'm calling a list of symbols and then using a function to build a data frame from that symbol list. It works great until I introduce this index symbol from yahoo '^GSPC'. When and index symbol is introduced I get and error which is below. > Data <- symbolFrame(symbols) Error in get(S) : object '^GSPC' not found Since R does not like the ^ in front of a name it would seem that my function needs away around the ^ in the symbol list. When...
2009 Aug 03
3
Help with data type
Hi there, Using a quantmod function, I calculate the daily change between two points in a time series. However, I don't think I am using the data correctly. Code: getSymbols("^GSPC", src="yahoo") CloseData <- Cl(GSPC) Delta <- diff(CloseData, lag=1) for (i in 3:length(Delta)) { if (Delta[i]>Delta[i-1]) sum <- sum + Delta } I can't seem to use the Delta variable. Can anyone point me in the right direction to transform the variable into a usab...
2011 May 07
2
Convenience-at-the-expense-of-clarity (was: quantmod's addTA plotting functions)
...more time than it should to find errors of that sort. The convenience wasn't worth the wasted time. That's my rant for today. *-- Russ * On Thu, May 5, 2011 at 10:13 AM, P Ehlers <ehlers@ucalgary.ca> wrote: > Russ, > > All you have to do is replace > > > addTA(GSPC.EMA.3, on = 1, col = "#0000ff") > > with > > plot(addTA(GSPC.EMA.3, on = 1, col = "#0000ff")) > > etc. > > I can sympathize with the documentation frustration, but I think > that much of the documentation in R and in many R packages is > actual...
2011 Apr 29
3
why doesn't ifelse work ?
I have the following lines of code: ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 I never get a value of -1 for signal even though I know diff(ind , 5) is less than zero frequently. It looks like when diff(ind , 5) is less than zero, signal gets set to 0 instead of - 1. Any ideas why ?...
2010 Aug 15
2
Adding colored background area to a time series plot
...9;m trying to do is very similar to the question and example given here: http://www.mail-archive.com/r-help at stat.math.ethz.ch/msg73948.html http://www.mayin.org/ajayshah/KB/R/html/g5.html My problem/difference is that my time series looks like so: > library(quantmod) > getSymbols("^GSPC", from="2008-01-01") > xtsPR <- diff(log(Ad(GSPC))) > head(xtsPR) GSPC.Adjusted 2008-01-02 NA 2008-01-03 0.000000000 2008-01-04 -0.024857950 2008-01-07 0.003218041 2008-01-08 -0.018522677 2008-01-09 0.013532064 So my dates along the x...
2011 Jun 03
2
tkrplot Newbie
...I am trying to write a tcltk based program that plots/manipulates xts/xoo time series objects. I have the code I used from ## http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/tkrplot.html : ## require(quantmod) require(tcltk) library(tkrplot) Sys.setenv(TZ="GMT") getSymbols("^GSPC", from = "1960-01-01") Myhscale <- 2.5 # Horizontal scaling Myvscale <- 1.25 # Vertical scaling plotFunction <- function(x) { params <- par(bg="white") plot(x,main="A time series") par(params) } tt <- tktoplevel() tkwm.title(...
2011 Nov 10
2
Error in axis ????
...rdatamarket > rm(list=ls()) > g > <-dmlist("http://datamarket.com/data/set/1jz5/st-louis-financial-stress-index#display=line&ds=1jz5") > g$Date <-as.Date(g[,1], "%Y-%m-%d") > h <-as.xts(g, order.by=g[,1]) > j <-h[,2] > s <-getSymbols('^GSPC', from="1990-01-01", to=Sys.Date()) > s <-to.weekly(GSPC) > s <-s[,6] > x <-na.omit(merge(s,j)) ; names(x) <-c("sp","stress") > print(head(x)) sp stress 1993-12-31 466.45 -0.453 1994-01-07 469.90 -0.442 1994-01-14 474.91 -0.43...
2011 Oct 22
1
Help w/an old R program I've rediscovered and want to make work
...icient way of writing what is probably cumbersome and spagetti-ish would be helpful. pce369 ## code begins below ## # simulation parameters LoopsNumber <- 10000 # number of iterations WindowPeriod <- 20 # 20 unit returns # data input area data <- read.table("gspc.txt",header=T) #gspc.txt is a column of returns under gspc header # main PeriodsNumber <- trunc(length(data$gspc)/WindowPeriod) # above will lead to losing last few elements, but makes life easier for (i in 1:LoopsNumber) { MCP <- sample(data$gspc, replace = FALSE) # resampling he...
2010 Dec 02
1
Downloading quote data from yahoo finance
...le downloading quote data from yahoo finance.   The example code is below (taken from tseries help):   library(tseries)   con <- url("http://quote.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(instrume...
2007 Oct 15
0
oanda and yahoo get.hist.quote
Hello Alexander I doubt that such an analyis is very useful as the data is not sampled synchronously (equity close in the US for ^gspc and even that is not always at the same time, some average price from Oanda data). Also fx data from others sources as suggested in another mail on this list would not really help with this unless it is really sampled at exactly the same times as the equity close of ^gspc. The only way to get c...
2012 Mar 10
1
Generating abnormal returns in R
Hello This is my first post on this forum and I hope someone can help me out. I have a datafile (weeklyR) with returns of +- 100 companies. I acquired this computing the following code: library("tseries"); tickers = c("GSPC" , "BP" , "TOT" , "ENI.MI" , "VOW.BE" , "CS.PA" , "DAI.DE" , "ALV.DE" , "EOAN.DE" , "CA.PA" , "G.MI" , "DE" , "EXR.MI" , "MUV2.BE" , "UG.PA" , "PRU.L...
2017 Jul 30
4
Kalman filter for a time series
...uot;) ssFit = fitSSM(inits=c(0.5*log(var(t)), 0.5*log(var(t))), model = ssModel ) kfs = KFS( ssFit$model, smoothing="state", nsim=length(t)) vals = kfs$a lastVal = vals[ length(vals)] return(lastVal) } Start = "2011-01-01" End = "2012-12-31" SandP = "^GSPC" windowWidth = 20 tsLength = 100 SAndP.ts = getDailyPrices( SandP, Start, End ) SAndP.ts = SAndP.ts[1:tsLength] SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter) par(mfrow=c(1,1)) prices = coredata( SAndP.ts[windowWidth:length(SAndP.ts)]) plot(prices, col=&quot...
2011 May 15
4
DCC-GARCH model
...questions concerning the DCC-GARCH model and its programming in R. So here is what I want to do: I take quotes of two indices - S&P500 and DJ. And the aim is to estimate coefficients of the DCC-GARCH model for them. This is how I do it: library(tseries) p1 = get.hist.quote(instrument = "^gspc",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose") p2 = get.hist.quote(instrument = "^dji",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose") p = cbind...
2008 Jun 19
1
How can I shade the background area of a zoo time series object between specific dates?
Dear list members, How can I shade the background area of a zoo time series object between specific dates? eg. library(tseries) library(zoo) SP500<-get.hist.quote("^GSPC", start = "1990-01-01", quote = "Close") plot(SP500) How can I produce the same plot but with a (say) red background between 2007-04-12 and 2008-05-14 ? Many thanks in advance... Costas P Think before you print. Disclaimer: This e-mail is con...
2012 Feb 11
1
object not found - Can not figure out why I get this error: Error in NROW(yCoordinatesOfLines) : object 'low' not found
...test function that uses add_HorizontalLine test<-function(series, low=20, high=80) { chart_Series(SPX, subset="2012") add_TA(RSI(Cl(SPX))) plot(add_HorizontalLine(c(low, high), on=2, col=c('green', 'red'), lwd=2)) } # Actual test SPX <- getSymbols("^GSPC", from="2000-01-01", auto.assign=FALSE) dev.new() test(SPX) This gives me the following error: > test(SPX) Error in NROW(yCoordinatesOfLines) : object 'low' not found What am I doing wrong here? Any hints highly appreciated. The funniest thing is that this was working a...
2017 Jul 30
0
Kalman filter for a time series
...r(t)), 0.5*log(var(t))), model = ssModel ) > kfs = KFS( ssFit$model, smoothing="state", nsim=length(t)) > vals = kfs$a > lastVal = vals[ length(vals)] > return(lastVal) > } > > Start = "2011-01-01" > End = "2012-12-31" > SandP = "^GSPC" > > windowWidth = 20 > tsLength = 100 > > SAndP.ts = getDailyPrices( SandP, Start, End ) > SAndP.ts = SAndP.ts[1:tsLength] > SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter) > > par(mfrow=c(1,1)) > prices = coredata( SAndP.ts[win...
2011 May 12
2
DCC-GARCH model and AR(1)-GARCH(1,1) regression model
...ecause I cannot solve it by myself...i just ran out of ideas. So here is what I want to do: I take quotes of two indices - S&P500 and DJ. And my first aim is to estimate coefficients of the DCC-GARCH model for them. This is how I do it: library(tseries) p1 = get.hist.quote(instrument = "^gspc",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose") p2 = get.hist.quote(instrument = "^dji",start = "2005-01-07",end = "2009-09-04",compression = "w", quote="AdjClose") p = cbind...
2007 Sep 01
1
Problem in downloading Yahoo Finance data from R
Hi R users, I have a problem in downloading Yahoo Finance data from R. I have tried an example given in R, to download. The error is given below: >library(fCalendar) > yahooImport("s=IBM&a=11&b=1&c=1999&d=0&q=31&f=2000&z=IBM&x=.csv ", file = "D:\\ Downlaod",source = "http://ichart.yahoo.com/table.csv?", save = FALSE,