Quantmod

Stack Financials: Analyze Financial Statement Data

A quantmod user asked an interesting question on StackOverflow: Looping viewFinancials from quantmod. Basically, they wanted to create a data.frame that contained financial statement data for several companies for several years. I answered their question, and thought others might find the function I wrote useful… hence, this post!

I called the function stackFinancials() because it would use getFinancials() and viewFinancials() to pull financial statement data for multiple symbols, and stack them together in long form. I chose a long data format because I don’t know whether the output of viewFinancials() always has the same number of rows and columns for a given type and period. The long format makes it easy to put all the data in one object.

quantmod 0.4-6 on CRAN

CRAN just accepted a bugfix release of quantmod.  The most pertinent changes were to fix getSymbols.oanda (#36) and getOptionChain.yahoo (#92).  It also includes a fix to addTRIX (#72).

Oanda changed their URL format from http to https, and getSymbols.oanda did not follow the redirect.  Yahoo Finance changed the HTML for displaying options data, which broke getOptionChain.yahoo.  The fix downloads JSON instead of scraping HTML, so hopefully it will be less likely to break.  For more information, see the links to the GitHub issues above.

DataCamp course: Importing and managing financial data

The team at DataCamp announced a new R/Finance course series in a recent email:

Subject: Data Mining Tutorial, R/Finance course series, and more!

R/Finance - A new course series in the works
We are working on a whole new course series on applied finance using R. This new series will cover topics such as time series (David S. Matteson), portfolio analysis (Kris Boudt), the xts and zoo packages (Jeffrey Ryan), and much more. Start our first course Intro to Credit Risk Modeling in R today.

New quantmod and TTR on CRAN

I just sent quantmod_0.4-5 to CRAN, and TTR_0.23-0 has been there for a couple weeks. I’d like to thank Ivan Popivanov for many useful reports and patches to TTR. He provided patches to add HMA() (Hull MA), ALMA(), and ultimateOscillator() functions.

James Toll provided a patch to the volatility() function that uses a zero mean (instead of the sample mean) in close-to-close volatility. The other big change is that moving average functions no longer return objects with column names based on the input object column names. There are many other bug fixes (see the CHANGES file in the package).

Import Japanese equity data into R with quantmod 0.4-4

I pushed quantmod 0.4-4 to CRAN this weekend.  It adds a getSymbols.yahooj function to pull stock data from Yahoo Finance Japan, and fixes issues in getOptionChain.yahoo and getSymbols.oanda.

Changes to the Yahoo Finance and Oanda websites broke the getOptionChain.yahoo and getSymbols.oanda functions, respectively.  I didn’t use getOptionChain.yahoo much, so I’m not certain I restored all the prior functionality.  Let me know if there’s something I missed. I’d be glad to add a test case for that, or to add a test you’ve written.

Updated quantmod on CRAN

An updated version of quantmod has just been released on CRAN.  This is my first submission as the new maintainer.  The major change was removing the dependency on the now-archived Defaults package.  End-users shouldn’t notice a difference, since I basically copied the necessary functionality from Defaults and added it to quantmod.

There are also several bug fixes. A few worth noting are:

Packages featured with Inference for R

quantmod, TTR, and xts were (not so) recently featured on the Inference for R Blog. Inference for R is a Integrated Development Environment (IDE) designed specifically for R.

The post gives an example of how to easily perform advanced financial stock analysis using Inference in Excel.

I appreciate how they’re making R more accessible to a general audience, even though I like a command line interface and my preferred development environment is vim. :-)