Wednesday, January 4, 2017

R/Finance 2017: Call for Papers

R/Finance 2017: Applied Finance with R
May 19 and 20, 2017
University of Illinois at Chicago

The ninth annual R/Finance conference for applied finance using R will be held on May 19 and 20, 2017 in Chicago, IL, USA at the University of Illinois at Chicago.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics.  All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.

Over the past eight years, R/Finance has included attendees from around the world.  It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2017.

We invite you to submit complete papers in pdf format for consideration.  We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated "lightning talks." Both academic and practitioner proposals related to R are encouraged.

All slides will be made publicly available at conference time.  Presenters are strongly encouraged to provide working R code to accompany the slides.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors).  Preference may be given to presenters who have released R packages.

Financial assistance for travel and accommodation may be available to presenters, however requests must be made at the time of submission.  Assistance will be granted at the discretion of the conference committee.

Please submit proposals online at  Submissions will be reviewed and accepted on a rolling basis with a final deadline of February 28, 2017.  Submitters will be notified via email by March 31, 2017 of acceptance, presentation length, and financial assistance (if requested).

Additional details will be announced via the conference website as they become available.  Information on previous years' presenters and their presentations are also at the conference website.  We will make a separate announcement when registration opens.

For the program committee:
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich

Monday, August 29, 2016

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 (#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  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.

I added documentation for getPrice (#77), and removed the unused unsetSymbolLookup function and corresponding documentation (#115).

Friday, June 17, 2016

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.
I'm excited to announce that I'm working on a course for this new series! It will provide an introduction to importing and managing financial data.

If you've ever done anything with financial or economic time series, you know the data come in various shapes, sizes, and periodicities. Getting the data into R can be stressful and time-consuming, especially when you need to merge data from several different sources into one data set. This course will cover importing data from local files as well as from internet sources.

The tentative course outline is below. I'd really appreciate your feedback on what should be included in this introductory course! So let me know if I've omitted something, or if you think any of the topics are too advanced.

Introduction to importing and managing financial data
  1. Introduction and downloading data
    1. getSymbols design overview, Quandl
    2. Finding and downloading data from internet sources
      1. E.g., getSymbols.FRED, Quandl
    3. Loading and transforming multiple instruments
    4. Checking for errors (i.e. summary stats, visualizing)
  2. Managing data from multiple sources
    1. Setting per-instrument sources and default arguments
      1. setSymbolLookupsaveSymbolLookuploadSymbolLookup, setDefaults
    2. Handling instruments names that clash or are not valid R object names
  3. Aligning data with different periodicities
    1. Making irregular data regular
    2. Aggregating to lowest frequency
    3. Combining monthly with daily
    4. Combining daily with intraday
  4. Storing and updating data
    1. Creating an initial RData-backed storage
    2. Adjusting financial time-series
    3. Handling errors during update process

Monday, April 11, 2016

Registration for R/Finance 2016 is open!

You can find registration information and agenda details on the conference website.  Or you can go directly to the Cvent registration page.

Note that registration fees will increase by 50% at the end of early registration on May 6, 2016.

The conference will take place on May 20 and 21, at UIC in Chicago.  Building on the success of the previous conferences in 2009-2015, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 50 presenters covering all areas of finance with R.

We are very excited about the four keynote presentations given by Patrick Burns, Frank Diebold, Tarek Eldin, and Rishi Narang.  The conference agenda (currently) includes 17 full presentations and 33 shorter "lightning talks".  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.

There is also an (optional) conference dinner at The Riverside Room and Gallery at Trump.  Situated directly on the hotel's new River Walk, it is a perfect venue to continue conversations while dining and drinking.

We would to thank our 2016 Sponsors for the continued support enabling us to host such an exciting conference:

  UIC Liautaud Master of Science in Finance

  MS-Computational Finance and Risk Management at University of Washington

  Charles Schwab
  Hull Investments
  Interactive Brokers

On behalf of the committee and sponsors, we look forward to seeing you in Chicago!

  Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich

Monday, November 16, 2015

Comment on Overnight SPY Anomaly

This post is in response to Michael Harris' Price Action Lab post, where he uses some simple R code to evaluate the asymmetry of returns from the day's close to the following day's open.  I'd like to respond to his 3 notes, which I've included below.
  1. The R backtest assumes fractional shares. This means that equity is fully invested at each new position. This is important because it affects drawdown calculations.
  2. When calculating the Sharpe ratio, the “geometric = FALSE” option must be used otherwise the result may not be correct. It took some time to figure that out.
  3. The profit factor result in R does not reconcile with results from other platforms or even from excel. PF in R is shown as 1.23 but the correct value is 1.17. Actually, the profit factor is calculated on a per share basis in R, although returns are geometric.
I completely agree with the first point.  I'm not sure Mike considers the output of  SharpeRatio.annualized with geometric=TRUE to be suspect (he doesn't elaborate).  The overnightRets are calculated as arithmetic returns, so it's proper to aggregate them using geometric chaining (i.e. multiplication).

I also agree with the third point, because the R code used to calculate profit factor is wrong.  My main impetus to write this post was to provide a corrected profit factor calculation.  The calculation (with slightly modified syntax) in Mike's post is:

getSymbols('SPY', from = '1900-01-01')
SPY <- adjustOHLC(SPY, use.Adjusted=TRUE)
overnightRets <- na.omit(Op(SPY)/lag(Cl(SPY)) - 1)
posRet <- overnightRets > 0
profitFactor <- -sum(overnightRets[posRet])/sum(overnightRets[!posRet])

Note that profit factor in the code above is calculated by summing positive and negative returns, when it should be calculated using positive and negative P&L.  In order to do that, we need to calculate the equity curve and then take its first difference to get P&L.  The corrected calculation is below, and it provides the correct result Mike expected.

grossEquity <- cumprod(overnightRets+1)
grossPnL <- diff(grossEquity)
grossProfit <- sum(grossPnL[grossPnL > 0])
grossLoss <- sum(grossPnL[grossPnL < 0])
profitFactor <- grossProfit / abs(grossLoss)

I'd also like to respond to Mike's comment:
Since in the past I have identified serious flaws in commercially available backtesting platforms, I would not be surprised if some of the R libraries have some flaws.
I'm certain all of the backtesting R packages have flaws/bugs.  All software has bugs because all software is written by fallible humans.  One nice thing about (most) R packages is that they're open source, which means anyone/everyone can check the code for bugs, and fix any bugs that are found.  With closed-source software, commercial or not, you depend on the vendor to deliver a patched version at their discretion and in their timing.

Now, I'm not making an argument that open source software is inherently better. I simply wanted to point out this one difference.  As much as I love open source software, there are times where commercial vendor-supported software presents a more appealing set of tradeoffs than using open source software.  Each situation is different.

Friday, July 24, 2015

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).

The biggest changes in quantmod were to fix getSymbols.MySQL to use the correct dbConnect call based on changes made in RMySQL_0.10 and to fix getSymbols.FRED to use https:// instead of http:// when downloading FRED data. getSymbols.csv also got some much-needed love.

I'd also like to mention that development has moved to GitHub for both TTR and quantmod.

Monday, April 20, 2015

plot.xts RFC

We have been working on a new charting engine for xts::plot.xts for the past couple years. It started with Michael Weylandt's work during the 2012 Google Summer of Code, and Ross Bennett took up the torch during the 2014 GSoC.

This new engine improves the functionality, modularity, and flexibility of plot.xts by building off the framework Jeff Ryan began with quantmod::chart_Series.  The modular framework allows users to plot an xts object and incrementally build custom charts by adding panels of new data (including transformations of the original xts object).

The main objective was to provide functionality similar to chartSeries and addTA for xts objects. The current code includes support for:
  • Basic time series plots with sensible defaults
  • Plotting xts objects by column "automagically" as separate panels
  • Small multiples with multiple pages
  • "Layout-safe" so multiple specifications/panels can be charted in a single device
  • Easily add data to an existing plot or add panels similar to quantmod::add*
  • Event lines
The xts team would greatly appreciate any comments, feedback, and bug reports before the upcoming CRAN release at the end of April.

The new version of plot.xts is in the main xts development code base, which is available on GitHub in the develop branch.  GitHub is also the place to submit bug reports and feature requests.

Note that the new plot.xts includes breaking changes to the original (and rather limited) plot.xts.  However, we believe the new functionality more than compensates for the potential one-time inconvenience.