[R-SIG-Finance] Finding price difference of a time series

veepsirtt veepsirtt at gmail.com
Tue Jul 23 08:31:13 CEST 2013


Hi R users,

#  How to find price difference of a-b and c-d ?.


require(quantmod)

require_symbol <- function(symbol, envir = parent.frame()) {
  if (is.null(envir[[symbol]])) {
    envir[[symbol]] <- getSymbols(symbol, auto.assign = FALSE)
  }
  
  envir[[symbol]]
}



# Create an environment for storing data
symbol_env <- new.env()

s1="SPY"
s2="GOOG"

A<- require_symbol(s1, symbol_env)              
B<- require_symbol(s2, symbol_env)

x1=A[,6]
x2=B[,6]

a=head(x1,1)
b=tail(x1,1)
c=head(x2,1)
d=tail(x2,1)

J=a-b

I got the following messages.

> J
Data:
  numeric(0)

Index:
  numeric(0)
> str(J)
An 'xts' object of zero-width

with regards.
veepsirtt



--
View this message in context: http://r.789695.n4.nabble.com/Finding-price-difference-of-a-time-series-tp4672099.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list