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

Merge output from quantmod::getSymbols

I looked many entries on merging R data frames, however they are not clear to me, they talk about merging/joining using a common column, but in my case its missed or may I don't know how to extract. Here is what I am…
1
vote
2 answers

Subtract every column from each other in an xts object

I am a newbie learning to code and have an xts object of 1000 rows and 10 columns. I need to subtract every column from each other creating a new xts object keeping the date column. I've tried to use combn but could not get it to create B-A result…
doug
  • 13
  • 2
1
vote
2 answers

How to merge a daily xts into a sparse time-indexed xts?

I have a multi-column xts object, which goes to second accuracy. I then have another xts object which contains one value for each day. I'd like to add that daily value as a column in the main xts object. Here is an example: Sys.setenv(TZ = "UTC")…
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
1
vote
0 answers

Creating XTS with correct time values

I'm trying to create a new XTS object for a set of intraday FX data. The initial dataframe is called "one_day_series" and looks like this: pair id date_time bid ask mid_price 1 USDCAD 485194239 …
AVSG
  • 23
  • 2
1
vote
1 answer

Editing Index After Aggregation Using XTS in R

I'm using the xts package to create a sample time series in R. I've created a range of dates, separated by the minute, created sample data for each of those dates, and then finally aggregating on the hour, summing the data. This works, except for…
giraffehere
  • 1,118
  • 7
  • 18
1
vote
2 answers

Average xts object with missing values to hourly endpoints

I am using xts to convert to hourly average data. I am starting with a year's worth of 10-minute data. Some hours have one 10-minute period (such as 'UTSP' in row 229) that is NA (missing). For such hours, I would still like the average of the data…
lost in R
  • 55
  • 11
1
vote
1 answer

Iteratively change the names (column names) of xts timeseries objects

I want to iteratively assign a vector of strings to the names (as in column names of a matrix) of the objects they represent. Example: > Names [1] "gs2" "gs3" "gs5" "gs7" "gs10" The objects are xts timeseries of interest rates, for example: >…
eigenvalet
  • 33
  • 5
1
vote
1 answer

Trying to understand blotter account Unrealized.PL and End.Eq calculation

While programming a strategy in blotter, I came across the problem that the End.Eq after my trades did not match my expected results from manual calculation. So I have written some simple R code to better understand how blotter works. Also here the…
JBlohm
  • 13
  • 3
1
vote
1 answer

As.XTS from Matrix - Error - Adds time and timezone info

For some reason I do not understand, when I run as.xts to convert from a matrix with a date in rownames, this operation will generate a Date Time in the end. Since this is different from the start indexes merge/cbinds will not work. Can someone…
husvar
  • 373
  • 1
  • 3
  • 13
1
vote
1 answer

Change xts object date indexing

I have two data files with stock returns. I'm trying to apply the same function to both but I get an error for one of them. I wanted to find out what's causing the error, so I compared the output of str for both xts objects and the only line that…
user1984076
  • 777
  • 1
  • 8
  • 16
1
vote
3 answers

How change dimname in R

I have in my program one class table "xts" and "zoo" which is as follows > head(BRA$Adj.Close) Adj.Close 2005-01-03 25722 2005-01-04 24848 2005-01-05 24692 2005-01-06 24367 2005-01-07 24747 2005-01-10 24292 I…
1
vote
1 answer

Date issues with quantmod getSymbols.csv?

Im uploading files to R using the quantmod function getSymbols.csv. however, once i have uploaded the files, the dates seem to get lost and all the dates are the same. I use the following code to upload the 100 stock symbols: getSymbols.csv(symbols,…
NMRQL
  • 65
  • 1
  • 6
1
vote
1 answer

Group by time AND another dimension in R (xts matrix)?

I am trying to use the apply.daily/weekly/monthly functions with xts in R, but I need to have the apply function work on subsets at a time. For example, x=xts(data.frame(value=1:100,code=rep(1:5,20)), …
Karthik
  • 31
  • 3
1
vote
1 answer

R, lag( ) has inconsistent behavior for xts and ts objects

I would like to take a lag of an xts variable, and the lag() function returns a lag. However, if I use it on a ts variable, it gives a lead. Is this a bug, or working as intended? library('xts') a = as.xts(ts(c(5,3,7,2,4,8,3), start=c(1980,1),…
HRC
  • 107
  • 7
1
vote
1 answer

Using highfrequency::spotvol(), how to set k parameter in my aggregate?

I would like to use the spotvol() function from the highfrequency package on 30 second log returns for 5 hours of trading. I have a 665x1 matrix of 30-second log returns i.e. diff(log(prices) logRet<- as.matrix(diff(log(r$PRICE))) logRet<-…
user3022875
  • 8,598
  • 26
  • 103
  • 167