This post started as a replication of an article that used machine learning to predict financial time series. The article used python and I thought it would be fun to replicate in R. But I found a lot of problems with the analysis as I worked through the replication. I don’t want to publicly tear down another person’s work, so this post will generally focus on common errors I see when people do analysis–specifically machine learning–on time series.
I follow Quantocracy on Twitter, and I found Rolling mean correlation in the tidyverse by Robot Wealth. They say to let them know if you’d approach it differently. I would, so I thought it would be interesting to replicate the analysis using tools I’m familiar with: xts and TTR. The xts package is an extension of the very excellent zoo package. zoo objects are for ordered observations. Underneath, they are a matrix that can be ordered by anything: numbers, letters, dates, times, and more.
This is a long-overdue post. I’m trying to get int the habit of posting and announcing each of my package releases. So I’m writing posts this morning for the most recent release of the most popular packages I maintain. I released an updated version of xts to CRAN on 2020-09-09. I’m also going to include some notes from the prior release (0.12-0), since I didn’t post about that. It has some nifty changes in it too.
This is another one of my long-overdue posts. I’m trying to get int the habit of posting and announcing each of my package releases. So I’m writing posts this morning for the most recent release of the most popular packages I maintain. I released an updated version of TTR to CRAN on 2020-09-01. This is mainly a bug-fix release. There were several issues in the underlying C code that caused various issues.
A new version of quantmod is on CRAN! One really cool thing about this release is that almost all the changes are contributions from the community. Ethan Smith made more excellent contributions to getQuote() in this release. It no longer throws an error if one or more symbols are missing. And it handles multiple symbols in a semicolon-delimted string, just like getSymbols(). For example, you can get quotes for multiple symbols by calling getQuote("SPY;AAPL").
I pushed an updated microbenchmark to CRAN a couple weeks ago. There were two noteworthy changes, thanks to great contributions from @MichaelChirico and @harvey131. Michael fixed a bug in the check for whether the unit argument was a character string (#9, #10). The prior behavior was an uninformative error. Harvey added a feature to allow you to use a string for common checks: “equal”, “identical”, and “equivalent” (#16). So you don’t need to create a custom function to use all.
I just pushed a new release of quantmod to CRAN! I’m most excited about the update to getSymbols() so it doesn’t throw an error and stop processing if there’s a problem with one ticker symbol. Now getSymbols() will import all the data it can, and provide an informative error message for any ticker symbols it could not import. Another cool feature is that getQuote() can now import quotes from Tiingo. But don’t thank me; thank Ethan Smith for the feature request [#247] and pull request [#250].
xts version 0.11-2 was published to CRAN yesterday. xts provides data structure and functions to work with time-indexed data. This is a bug-fix release, with notable changes below: The xts method for shift.time() is now registered. Thanks to Philippe Verspeelt for the report and PR (#268, #273). An if-statement in the xts constructor will no longer try to use a logical vector with length > 1. Code like if (c(TRUE, TRUE)) will throw a warning in an upcoming R release, and this patch will prevent that warning.
xts version 0.11-1 was published to CRAN this morning. xts provides data structure and functions to work with time-indexed data. This release contains some awesome features that will transparently make your xts code even faster! There’s a new window.xts() method, thanks to Corwin Joy (#100, #240). Corwin also refactored and improved the performance of the binary search algorithm used to subset xts objects. Tom Andrews reported and fixed a few related regressions (#251, #263, #264).
Someone recently shared this great talk by Chris Allen from lambda conf 2017. The title of the talk is “Why Johnny Can’t Code Good,” but the content is more about how to grow as a programmer. His points are true whether you’re just starting out, or have been coding for years. My notes from Chris’ talk are below, in the order they appear in the presentation. My thoughts are in parentheses.