xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.

https://github.com/joshuaulrich/xts

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 28 committers (7.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.3%) to scientific vocabulary

Keywords

c r time-series

Keywords from Contributors

rcpp algorithmic-trading technical-analysis devtools rmarkdown quantitative-finance hash-digest xlsx literate-programming pandoc
Last synced: 6 months ago · JSON representation

Repository

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.

Basic Info
Statistics
  • Stars: 220
  • Watchers: 21
  • Forks: 70
  • Open Issues: 67
  • Releases: 10
Topics
c r time-series
Created almost 11 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Funding License

README.md

About

xts is an R package that provides an extension of the zoo class. zoo's strength comes from its simplicity of use (it's very similar to base R functions), and its overall flexibility (you can use anything as an index). The xts extension was motivated by the ability to improve performance by imposing reasonable constraints, while providing a truly time-based structure.

xts for enterprise

Available as part of the Tidelift Subscription.

The maintainers of xts and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Supporting xts development

If you are interested in supporting the ongoing development and maintenance of xts, please consider becoming a sponsor.

Installation

The current release is available on CRAN, which you can install via:

r install.packages("xts")

To install the development version, you need to clone the repository and build from source, or run one of:

```r

lightweight

remotes::install_github("joshuaulrich/xts")

or

devtools::install_github("joshuaulrich/xts") ```

You will need tools to compile C, C++, and Fortran code. See the relevant appendix in the R Installation and Administration manual for your operating system:

Getting Started

You can create xts objects using xts() and as.xts().

Note that as.xts() currently expects the date/times to be in the row names for matrix and data.frame objects, or in the names for vector. You can also use the dateFormat argument to control whether the names should be converted to Date or POSIXct. See help(as.xts.methods) for details.

```r n <- 10 series <- rnorm(n)

POSIXct (date/time) index

datetimes <- seq(as.POSIXct("2017-03-27"), length.out = n, by = "days") library(xts) x <- xts(series, datetimes) ```

In addition to the usual ways you can subset matrix and zoo objects, you can also subset xts objects using character strings that adhere to the ISO-8601 standard, which is the internationally recognized and accepted way to represent dates and times. Using the data from the prior code block, here are some examples:

```r

March, 2017

x["2017-03"]

[,1]

2017-03-27 0.25155453

2017-03-28 -0.09379529

2017-03-29 0.44600926

2017-03-30 0.18095782

2017-03-31 -1.45539421

March 30th through April 2nd

x["2017-03-30/2017-04-02"]

[,1]

2017-03-30 0.1809578

2017-03-31 -1.4553942

2017-04-01 -0.4012951

2017-04-02 -0.5331497

Beginning of the series to April 1st

x["/2017-04-01"]

[,1]

2017-03-27 0.25155453

2017-03-28 -0.09379529

2017-03-29 0.44600926

2017-03-30 0.18095782

2017-03-31 -1.45539421

2017-04-01 -0.40129513

```

You can aggregate a univariate series, or open-high-low-close (OHLC) data, into a lower frequency OHLC series with the to.period() function. There are also convenience functions for some frequencies (e.g. to.minutes(), to.daily(), to.yearly(), etc).

```r data(samplematrix) x <- as.xts(samplematrix) to.period(x, "months")

x.Open x.High x.Low x.Close

2007-01-31 50.03978 50.77336 49.76308 50.22578

2007-02-28 50.22448 51.32342 50.19101 50.77091

2007-03-31 50.81620 50.81620 48.23648 48.97490

2007-04-30 48.94407 50.33781 48.80962 49.33974

2007-05-31 49.34572 49.69097 47.51796 47.73780

2007-06-30 47.74432 47.94127 47.09144 47.76719

to.monthly(x) # result has a 'yearmon' index

x.Open x.High x.Low x.Close

Jan 2007 50.03978 50.77336 49.76308 50.22578

Feb 2007 50.22448 51.32342 50.19101 50.77091

Mar 2007 50.81620 50.81620 48.23648 48.97490

Apr 2007 48.94407 50.33781 48.80962 49.33974

May 2007 49.34572 49.69097 47.51796 47.73780

Jun 2007 47.74432 47.94127 47.09144 47.76719

```

The period.apply() function allows you apply a custom function to non- overlapping intervals. You specify the intervals using a vector similar to the output of endpoints(). Like to.period() there are convenience functions, like apply.daily(), apply.quarterly(), etc.

```r

Average monthly value for each column

period.apply(x, endpoints(x, "months"), colMeans)

Open High Low Close

2007-01-31 50.21140 50.31528 50.12072 50.22791

2007-02-28 50.78427 50.88091 50.69639 50.79533

2007-03-31 49.53185 49.61232 49.40435 49.48246

2007-04-30 49.62687 49.71287 49.53189 49.62978

2007-05-31 48.31942 48.41694 48.18960 48.26699

2007-06-30 47.47717 47.57592 47.38255 47.46899

Open High Low Close

2007-01-31 50.21140 50.31528 50.12072 50.22791

2007-02-28 50.78427 50.88091 50.69639 50.79533

2007-03-31 49.53185 49.61232 49.40435 49.48246

2007-04-30 49.62687 49.71287 49.53189 49.62978

2007-05-31 48.31942 48.41694 48.18960 48.26699

2007-06-30 47.47717 47.57592 47.38255 47.46899

```

Have a question?

Ask your question on Stack Overflow or the R-SIG-Finance mailing list (you must subscribe to post).

Want hands-on experience?

Contributing

Please see the Contributing Guide.

See Also

  • quantmod: quantitative financial modeling framework
  • TTR: functions for technical trading rules
  • zoo: class for regular and irregular time series

Author

Jeffrey Ryan, Joshua Ulrich

Owner

  • Name: Joshua Ulrich
  • Login: joshuaulrich
  • Kind: user
  • Location: Saint Louis, Missouri, USA

GitHub Events

Total
  • Issues event: 9
  • Watch event: 4
  • Issue comment event: 25
  • Push event: 6
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 7
  • Fork event: 2
  • Create event: 3
Last Year
  • Issues event: 9
  • Watch event: 4
  • Issue comment event: 25
  • Push event: 6
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 7
  • Fork event: 2
  • Create event: 3

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,383
  • Total Committers: 28
  • Avg Commits per committer: 49.393
  • Development Distribution Score (DDS): 0.506
Past Year
  • Commits: 13
  • Committers: 3
  • Avg Commits per committer: 4.333
  • Development Distribution Score (DDS): 0.231
Top Committers
Name Email Commits
Joshua Ulrich j****h@g****m 683
Jeffrey A. Ryan j****n@g****m 594
Dirk Eddelbuettel e****d@d****g 25
Ross Bennett r****4@u****u 23
Ross Bennett r****4@g****m 14
corwinjoy c****y@g****m 12
Tom Andrews t****a@w****m 7
Ethan Smith 2****h 3
cjm c****l@g****m 2
olivroy 5****y 2
pverspeelt p****4@g****m 1
harvey131 2****1 1
Corwin Joy c****y@o****m 1
Jasper Schelfhout j****t@o****u 1
Michael Beigelmacher m****r@g****m 1
Stefan Theussl s****l@w****t 1
evelynmitchell e****b@l****m 1
cloudcell e****f@o****m 1
bollard r****d@g****m 1
Pierre Lamarche l****p@g****m 1
Panagiotis Cheilaris p****s@c****r 1
Michael Chirico m****4@g****m 1
Jasen Mackie j****3@g****m 1
HughParsonage h****e@g****m 1
Henri Yandell h****l@a****m 1
Anders Ellern Bilgrau a****u@g****m 1
Brian G. Peterson b****n@b****m 1
CGiachalis 2****s 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 123
  • Total pull requests: 15
  • Average time to close issues: about 2 years
  • Average time to close pull requests: 4 months
  • Total issue authors: 54
  • Total pull request authors: 10
  • Average comments per issue: 3.04
  • Average comments per pull request: 3.07
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 5
  • Average time to close issues: 1 day
  • Average time to close pull requests: 2 days
  • Issue authors: 6
  • Pull request authors: 2
  • Average comments per issue: 1.67
  • Average comments per pull request: 1.8
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • joshuaulrich (50)
  • ethanbsmith (11)
  • ggrothendieck (4)
  • harvey131 (2)
  • ckatsulis (2)
  • AndreMikulec (2)
  • minimenchmuncher (2)
  • cgiachalis (2)
  • rossb34 (2)
  • linc0380 (2)
  • cactus74 (1)
  • bollard (1)
  • interzonez (1)
  • vspinu (1)
  • avrenli2 (1)
Pull Request Authors
  • ethanbsmith (6)
  • MichaelChirico (4)
  • cgiachalis (2)
  • olivroy (2)
  • bollard (1)
  • pierre-lamarche (1)
  • hasandiwan (1)
  • ReesaJohn (1)
  • harvey131 (1)
  • JasperSch (1)
Top Labels
Issue Labels
bug (39) plot (18) enhancement (14) feature request (13) question (9) duplicate (7) help wanted (1)
Pull Request Labels
bug (1)

Packages

  • Total packages: 3
  • Total downloads:
    • cran 284,574 last-month
  • Total docker downloads: 34,779,309
  • Total dependent packages: 245
    (may contain duplicates)
  • Total dependent repositories: 1,273
    (may contain duplicates)
  • Total versions: 59
  • Total maintainers: 1
cran.r-project.org: xts

eXtensible Time Series

  • Versions: 44
  • Dependent Packages: 224
  • Dependent Repositories: 1,249
  • Downloads: 284,574 Last month
  • Docker Downloads: 34,779,309
Rankings
Dependent repos count: 0.4%
Dependent packages count: 0.5%
Downloads: 0.6%
Forks count: 1.0%
Stargazers count: 2.0%
Average: 3.6%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/joshuaulrich/xts
  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: r-xts
  • Versions: 8
  • Dependent Packages: 21
  • Dependent Repositories: 24
Rankings
Dependent packages count: 3.1%
Dependent repos count: 7.4%
Average: 14.5%
Forks count: 21.6%
Stargazers count: 25.9%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • zoo >= 1.7 depends
  • methods * imports
  • RUnit * suggests
  • chron * suggests
  • fts * suggests
  • timeDate * suggests
  • timeSeries * suggests
  • tis * suggests
  • tseries * suggests
inst/api_example/DESCRIPTION cran
  • xts * depends
.github/workflows/ci.yaml actions
  • actions/checkout v2 composite