Tuesday, April 28, 2009

R/Finance 2009 Overview

The first international R/Finance 2009 conference in Chicago, IL was a huge success! David Smith from REvolution Computing has written a great summary of the entire event. I'll take the lazy route and point you to his blog post. :)
The first international conference dedicated to the use of R in the finance industry, R/Finance 2009, was a great success. With over 150 attendees (my poor estimation skills notwithstanding), sold-out tutorials, and an outstanding lineup of invited and contributing speakers from around the world, this event really demonstrated the importance of R in the world of financial analysis.

Source:
R/Finance 2009 roundup
David Smith
Revolutions, 4/27/2009

Friday, April 17, 2009

opentick is no more

After a year of "we plan to accept new subscribers shortly", opentick has shut its doors completely. As of March 20th, the opentick service is no longer available.

From opentick.com:

3/16/2009

To opentick subscribers, friends, supporters, contributors and the rest of the community...

It has been quite a journey for opentick, and for those of you who have been with us for the ride we cannot thank you enough for the support, contributions and guidance you have given us over the course of the last 5 years. We could not have come as far as we have without you.

However, we are sad to say that the time has come for us to close the doors for opentick. However, this isn't goodbye. In fact, it's a new beginning. We will be introducing a fresh service with all the bells and whistles we've been slaving on over the course of the last year under a new name, a new website and a new level of service. Check back here in the near future for more information about the forthcoming new company and service. Of course amongst all these changes, there are some things that will remain the same - we still aim to provide a reliable free market data service, with an open architecture for a wide range of software platform support.

If you are a current paying subscriber, this March billing cycle will be your final billing cycle; at your next billing date service will be terminated. If you are a delayed or historical data user not currently paying for service, your account will be deactivated as of Friday, March 20th.

Sincerely,
opentick Staff

One day, we shall come back. Yes, we shall come back. Until then, there must be no regrets, no tears, no anxieties. Just go forward in all your beliefs, and prove to us we are not mistaken in ours.

I'm not optimistic their new offering (most likely their sister company, Xasax) will be available anytime soon. The managers of the two companies sub-optimally managed expectations with opentick and potential Xasax customers are sure to keep that in mind.

At least I learned quite a bit creating the 'opentick' package, since it is now useless... perhaps Xasax will have a similar API, but I won't get my hopes up.

Related Posts:
Xasax closes shop
opentick alternatives

Monday, April 13, 2009

Testing RSI(2) with R, First Steps

This is the first of a series of posts that will demonstrate how to build, test, and implement a trading strategy using my favorite FOSS, R. I chose the RSI(2) strategy because it has gotten considerable attention on trading blogs over the past 6 months.

In particular, I will be replicating and extending some of the results from Michael Stokes' excellent MarketSci Blog. This post will focus on replicating this simple RSI(2) strategy.

Without further ado, let's get to some code...
# We will need the quantmod package for charting and pulling
# data and the TTR package to calculate RSI(2).
# You can install packages via: install.packages("packageName")
# install.packages(c("quantmod","TTR"))
library(quantmod)
library(TTR)

# Pull S&P500 index data from Yahoo! Finance
getSymbols("^GSPC", from="2000-01-01", to="2008-12-07")

# Calculate the RSI indicator
rsi <- RSI(Cl(GSPC),2)

# Create the long (up) and short (dn) signals
sigup <- ifelse(rsi < 10, 1, 0)
sigdn <- ifelse(rsi > 90, -1, 0)

# Lag signals to align with days in market,
# not days signals were generated
#sigup <- Lag(sigup,1) # Use lag() to avoid Toby's error
#sigdn <- Lag(sigdn,1) # Use lag() to avoid Toby's error
sigup <- lag(sigup,1) # Note k=1 implies a move *forward*
sigdn <- lag(sigdn,1) # Note k=1 implies a move *forward*

# Replace missing signals with no position
# (generally just at beginning of series)
sigup[is.na(sigup)] <- 0
sigdn[is.na(sigdn)] <- 0

# Combine both signals into one vector
sig <- sigup + sigdn

# Calculate Close-to-Close returns
ret <- ROC(Cl(GSPC))
ret[1] <- 0

# Calculate equity curves
eq_up <- exp(cumsum(ret*sigup))
eq_dn <-
exp(cumsum(ret*sigdn*-1))
eq_all <-
exp(cumsum(ret*sig))

# Replicate Michael's nice chart
plot.zoo( cbind(eq_up, eq_dn),
ylab=c("Long","Short"), col=c("green","red"),
main="Simple RSI(2) Strategy: 2000-01-02 through 2008-12-07" )

# Wait a few seconds before making next chart...
#Sys.sleep(5)

# Create a chart showing the S&P500
#chartSeries(GSPC, type="line")

# Add the total equity line
#addTA(eq_all)
My version of Michael's chart is below. Up next, scaling in/out of positions with RSI(2).


Now, let's look at RSI(2) with position sizing.