Code

Introduction to PortfolioAnalytics

PortfolioAnalytics Basics body, td { font-family: sans-serif; background-color: white; font-size: 12px; margin: 8px; } tt, code, pre { font-family: ‘DejaVu Sans Mono’, ‘Droid Sans Mono’, ‘Lucida Console’, Consolas, Monaco, monospace; } h1 { font-size:2.2em; } h2 { font-size:1.8em; } h3 { font-size:1.4em; } h4 { font-size:1.0em; } h5 { font-size:0.9em; } h6 { font-size:0.8em; } a:visited { color: rgb(50%, 0%, 50%); } pre { margin-top: 0; max-width: 95%; border: 1px solid #ccc; white-space: pre-wrap; } pre code { display: block; padding: 0.

quantstrat is slow

The complaint I hear most frequently about quantstrat is that it’s slow, especially for large data. Some of this slow performance is due to quantstrat treating all strategies as path-dependent by default. Path dependence requires rules to be re-evaluated for each timestamp with a signal. More signals equates to longer run-times. If your strategy is not path-dependent, you can get a fairly substantial performance improvement by turning path-dependence off. If your strategy truly is path-dependent, keep reading…

A New plot.xts

Wow!!!! Great work RMW. jryan - Aug 3, 2012Wow!!!! Great work RMW.

A New plot.xts

The Google Summer of Code (2012) project to extend xts has produced a very promising new plot.xts function. Michael Weylandt, the project’s student, wrote R-SIG-Finance to request impressions, feedback, and bug reports. The function is housed in the xtsExtra package of the xts project on R-Forge. Please try xtsExtra::plot.xts and let us know what you think. A sample of the eye-candy produced by the code in Michael’s email is below. Granted, this isn’t a one-liner, but it’s certainly impressive!

R in Google Summer of Code 2012

This post is a slightly revised (and “blogified”) version of the message Brian Peterson has sent to various R mailing lists. Once again, R has been accepted as a mentoring organization for the Google Summer of Code (2012). We invite students interested in this program to learn more about it. A good starting point is the R GSoC wiki. Students participating in the program receive US$5,000 for successful completion of a GSoC project, a great resume item, and an opportunity to work with R package authors.

Tactical asset allocation using quantstrat

I am trying to run this script in R-Studio on OSX … Lemao - Aug 2, 2011I am trying to run this script in R-Studio on OSX but I am getting the following error: > currency(“USD”) Error in assign(primary_id, currency_temp, envir = as.environment(.instrument)) : object ‘.instrument’ not found I have installed the dependencies: zoo, xts, TTR, RTAQ, quantstrat, quantmod, Performanceanalytics, FInancialInstrument, Defaults and blotter. Any ideas of what is going wrong here?

Tactical asset allocation using quantstrat

As promised in the introduction to quantstrat, here is an example strategy. I thought I’d start with the obligatory tactial asset allocation (TAA) strategy. This post will replicate the strategy in the post, tactical asset allocation using blotter. The “faber” demo in the quanstrat package contains a TAA strategy but it uses a slightly different approach than the code we’re trying to replicate. There are two major differences: The blotter TAA code initiates a position at the first observation where the close is above the SMA.

Historical / Future Volatility Correlation Stability

I’ve noticed odd behaviour like this before in… Unknown - May 0, 2010I’ve noticed odd behaviour like this before in correlations (the swings in the 252 day vols from -1/+1); in this case the effect probably due to the lack of independence of the variables in use. that is, your bottom plot for 1 year historical/future really only has 40 independent points, the rest are (auto)correlated. likewise, when computing the correlation of two rolling series with high degrees of autocorrelation, the correlations get screwy.

Historical / Future Volatility Correlation Stability

Michael Stokes, author of the MarketSci blog recently published a thought-provoking post about the correlation between historical and future volatility (measured as the standard deviation of daily close price percentage changes). This post is intended as an extension of his “unfinished thought”, not a critique. He suggests using his table of volatility correlations as a back-of-the-envelope approach to estimate future volatility, which led me to question the stability of the correlations in his table.

Tactical asset allocation using blotter

Hi, If I change to.monthly() to to.weekly() it se… Unknown - Nov 4, 2009Hi, If I change to.monthly() to to.weekly() it seems to die strangely. Any ideas? Cheers, -——- Error in if (!all(i <= 0)) stop(“only zeros may be mixed with negative subscripts”) : missing value where TRUE/FALSE needed Calls: updateAcct -> calcPortfSummary -> time -> [ -> [.xts Thanks Josh for providing this nice example of the use of blotter.