Questions tagged [xts]

xts is an R package that contains an eXtensible Time Series class and methods. xts extends and behaves like zoo.

xts is an package for analysis. It provides uniform handling of R's different time-based data classes by extending the package.

Repositories

Vignettes

Other resources

Related tags

1987 questions
1
vote
1 answer

Why xts::apply.daily fails with cummin or cummax?

I am trying to do a very simple thing: transform OHLC currency data in such a way that I replace Hi with biggest value of high until that moment of time in a given day and replace Lo with smallest value of low until that moment of time in a given…
Samo
  • 2,065
  • 20
  • 41
1
vote
1 answer

Find what will be the working X years from a given date

Suppose that I buy a at the money European Call on the EuroSTOXX 5O on the 1990/01/10 with maturity of 9 years. I would like to know what will be the maturity date. Any idea? I can start with the quantmod…
marino89
  • 899
  • 1
  • 10
  • 16
1
vote
3 answers

Trying to understand how to calculate lagging in an xts object

Currently I have the following xts table. AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted 2013-09-09 505.00 507.92 503.48 506.17 12116200 506.17 2013-09-10 506.20 507.45 489.50 494.64 …
Ahdee
  • 4,679
  • 4
  • 34
  • 58
1
vote
2 answers

R xts how to add calculated column

I have two series that I have joined in a single xts object using merge(foo, footoo, all = FALSE). Now I need to take a new vector = foo/footoo : either as a new column in the existing xts object or as a new xts object with the same index. I'm…
opt
  • 45
  • 1
  • 4
1
vote
0 answers

How to print the change in last 2 daily opening prices in R

So far my code is as follows: companyList <- read.csv("~/Downloads/companylist.csv") ticker <- as.vector(as.character(companyList[1:10, 'Symbol'])) stockData <- new.env() x <- 1 while(x<11){ getSymbols(ticker[x], auto.assign = TRUE, env =…
Brandon Williams
  • 103
  • 1
  • 1
  • 9
1
vote
2 answers

Iterate over a list containing xts objects of unequal length

I have a list containing time series data stored in xts format. The lists are of unequal lengths, and only a subset of the dates / rows intersect. I wish to iterate over combinations of the lists with various functions -- for the case in point,…
ricardo
  • 8,195
  • 7
  • 47
  • 69
1
vote
1 answer

error in row name conversion in R for a data frame

I'm using R 3.0.2 and I loaded a csv into a dataframe that I want to convert to xts format. my data looks something like this head(data) V1 V2 V3 V4 V5 V6 V7 V8 V9 1 1999-01-04 1.1812 1.18120 1.18120…
pyCthon
  • 11,746
  • 20
  • 73
  • 135
1
vote
1 answer

plot.xts + abline not quite accurate?

I am using xtsExtra to plot some scatter graphs of xts objects and wanted to draw a horizontal line through zero but it looks like its in the wrong place...please see the code below? is this a bug? set.seed(123) require(xts) f <-…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
1
vote
1 answer

Removing rows according to duplicated index

Please, put in R this xts object: afspline <- structure(c(0, -1.60475876973764e-09, 0.00359139378023358, 0.00858791466940025, 0.00965799381183328, 0.010535272095448, 0.00353659588787858, 0.00979116750570292, 0.011240852699161, 0.0104516005116994,…
Lisa Ann
  • 3,345
  • 6
  • 31
  • 42
1
vote
1 answer

Plotting xts objects works with points but not with lines

I have merged two xts objects and want to plot them in a single display. This works fine when I use points (type="p"). However, when I use lines (type="l") a problem occurs: the first series is shown only in the index region that is not covered by…
Tungurahua
  • 489
  • 7
  • 21
1
vote
2 answers

XTS conditional sum

In the sample xts data below, I show a small subset of intra-day data. my.temp <- structure(c(1134.65, 45665.2, 63639.8, 262817.8, 71898.4, 128737, 641741.8, 6090, 7561.5, 3954.73, 15733.2, 274.88, 824.64, 1099.52, 1924.16, 348715, 196425,…
E.D.
  • 319
  • 1
  • 5
  • 15
1
vote
1 answer

Is it possible to build a quantmod chart incrementally and export the final result as a single-page pdf?

I would like to produce a pdf of a chart produced with quantmod. For example, library(quantmod) data(sample_matrix) d <- as.xts(sample_matrix) pdf("chart1.pdf") chartSeries(d$Open,TA=c(addTA(d$Close,on=1),addTA(d$High))) dev.off() The question…
Rahul Savani
  • 872
  • 1
  • 10
  • 24
1
vote
1 answer

Buy Low Sell High

I've a data like this: library("xts") close <- c(0, -0.5, -0.75, -1, -0.75, -1.5, -2, -2.5, -3, -3.5, -3, -2.5, -2, -1, 0, 1, 1.5, 2, 2.5, 3, 2.5, 2, 0) data <- xts(close, Sys.Date()-23:1) colnames(data) <- "close" I'd like to generate another…
Ashish Jalan
  • 181
  • 8
1
vote
1 answer

apply.quarterly(): Error in coredata.xts(x) : currently unsupported data type

Reproducible code: #install.packages('quantmod') require(quantmod) # Downloading data and merging them getSymbols(c('^GSPC', '^GDAXI'), from = '1900-01-01') X <- na.omit(merge(GSPC, GDAXI)) SP500 <- X[,substr(colnames(X), 1, 4) == 'GSPC'] DAX <-…
Lisa Ann
  • 3,345
  • 6
  • 31
  • 42
1
vote
1 answer

Vectorization of values based upon values of contiguous rows

Consider the following (example) zoo object: The data frame is sorted in ascending order on the date index. The ma3 field provides the 3-day moving average value of the duration field. The comparison field compares the value of the duration value…
Jubbles
  • 4,450
  • 8
  • 35
  • 47