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
7
votes
1 answer

Load multiple symbols using csv with quantmod

I am trying to load multiple symbols using a csv file rather than downloading from Yahoo. The original code works great and uses load.packages('quantmod') tickers = spl('TLT,IWM,GLD') data <- new.env() getSymbols(tickers, src = 'yahoo', from =…
AdmiralF
  • 113
  • 2
  • 8
7
votes
1 answer

time zones in POSIXct and xts, converting from GMT in R

I have a bunch of 1 minute returns in an xts object with the index being POSIXct and time zone being GMT. The returns are on NYSE so I would like to convert to the eastern time zone but I would like to take care of the daylight savings time…
Alex
  • 19,533
  • 37
  • 126
  • 195
6
votes
2 answers

What is the best method to bin intraday volume figures from a stock price timeseries using XTS / ZOO etc in R?

For instance, let's say you have ~10 years of daily 1 min data for the volume of instrument x as follows (in xts format) from 9:30am to 4:30pm : Date.Time Volume 2001-01-01 09:30:00 1200 2001-01-01 09:31:00 …
n.e.w
  • 1,128
  • 10
  • 23
6
votes
2 answers

Get time from xts index

I have an xts object, x. I want to run a for loop until a certain time, based on the time stamp in the index. > index(x) [1] "2011-10-12 16:44:00 SAST" Lets say I want to run my loop as long as the time in the index is less than say 16:40:00. How…
E.D.
  • 319
  • 1
  • 5
  • 15
6
votes
2 answers

Moving from a normal bar chart to a stacked bar on dygraphs

I've got an xts df of the following format: structure(c("May 2022", "Jun 2022", "Jul 2022", "Aug 2022", "Sep 2022", "Oct 2022", "Nov 2022", "Dec 2022", " 3035.199", " 5500.000", "11568.750", " 2510.000", " 6999.999", "21792.149", " 9750.000", "…
alec22
  • 735
  • 2
  • 12
6
votes
1 answer

Adding Points, Legends and Text to plots using xts objects

I am starting on a bit of analysis on pairs of stocks (pairs trading) and here is the function I wrote for producing a graph (pairs.report - listed below). I need to plot three different lines in a single plot. The function I have listed does what I…
Soumendra
  • 1,174
  • 1
  • 15
  • 28
6
votes
2 answers

R: Error in xts - order.by

I am trying to (re)build a basic prediction model of the S&P 500 INDEX (data orignates from Yahoo finance) I ran into some difficulties with the "ordering" of my data set. During the build of data.model the following error occurs Error in xts(new.x,…
Val
  • 163
  • 1
  • 1
  • 4
6
votes
1 answer

Improving a function to get stock news data from google in R

I've written a function to grab and parse news data from Google for a given stock symbol, but I'm sure there are ways it could be improved. For starters, my function returns an object in the GMT timezone, rather than the user's current timezone,…
Zach
  • 29,791
  • 35
  • 142
  • 201
6
votes
5 answers

Efficient coding to make time increments 'finer' from minutes to seconds

I have a time series data with 1 minute increments. I have written a code but with the large amount of data I have (over 1M rows), looping through each line is taking way too long. The data looks something like the below: t0 = as.POSIXlt("2018-12-23…
jay2020
  • 451
  • 1
  • 3
  • 12
6
votes
2 answers

dealing with NA in seasonal cycle analysis R

I have a timeseries of monthly data with lots of missing datapoints, set to NA. I want to simply subtract the annual cycle from the data, ignoring the missing entries. It seems that the decompose function can't handle missing data points, but I…
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
6
votes
1 answer

sparseIndexTracking 0.1.0 failure in if(): missing value where TRUE/FALSE needed

I have two datasets. Both are xts objects. > dput(head(all_data[,2:3])) structure(c(0.00108166576527857, 0.00324149108589955, 0, 0, 0.00484652665589658, 0.00267952840300101, 0.00606980273141122, 0.00301659125188536, …
Alex Bădoi
  • 830
  • 2
  • 9
  • 24
6
votes
3 answers

Setting an xts Index

Build an xts object with two rows. library(xts) junk<-xts(c(1,2),as.Date(c("2010-01-01","2010-05-01"))) junk > [,1] > 2010-01-01 1 > 2010-05-01 2 Why doesn't the following change the index for the first row? …
Bill S
  • 61
  • 1
  • 2
6
votes
1 answer

Differentiate missing values from main data in a plot using R

I create a dummy timeseries xts object with missing data on date 2-09-2015 as: library(xts) library(ggplot2) library(scales) set.seed(123) seq <- seq(as.POSIXct("2015-09-01"),as.POSIXct("2015-09-02"), by = "1 hour") ob1 <-…
Haroon Lone
  • 2,837
  • 5
  • 29
  • 65
6
votes
1 answer

Split xts object by specified irregular intervals in R

I want to split a daily xts object into 4 separate weeks which correspond to the following days in the month: 1st-7th, 8th-14th, 15th-21st, and 22nd to the end of the month, where the last week will generally be longer (but that's okay!). Here's…
6
votes
3 answers

How to do cumulative logical operations on mutliple columns

I've a number of columns in an xts object, and I want to find the percentage in the first column above a certain number, the percentage in either first or second column above a certain number, the percentage in any of the first three columns above a…
Darren Cook
  • 27,837
  • 13
  • 117
  • 217