Publications by The Average Investor
ARMA Models for Trading, Part VI
All posts in this series were combined into a single, extended tutorial and posted on my new blog. In the fourth posting in this series, we saw the performance comparison between the ARMA strategy and buy-and-hold over the last approximately 10 years. Over the last few weeks (it does take time, believe me) I back-tested the ARMA strategy over th...
2913 sym R (654 sym/3 pcs) 8 img
Yet another reason to avoid loops in R
In some previous posts I have mentioned my struggles with the performance of the computations needed to implement the ARMA strategies in practice. Finally I have found a worthy solution, and as usual, there is a programming pattern to learn from it – avoid loops in R. My first approach was to optimize the algorithms. Willing to trade some qual...
3341 sym R (258 sym/3 pcs) 6 img
Summarizing Returns with R
Often I like to see the performance of a trading strategy summarized annually, quarterly or by month. In R, we start off with the summary function: aggregateReturns = function( xx, leverage=1 ) { return( tail( cumprod( 1 + xx*leverage ), 1 ) ) } Given a series xx, usually a chunk of the original, this function returns the accumulative returns...
1081 sym R (1685 sym/3 pcs) 6 img
R. I. P. EMA
That’s right, I am moving away from exponential moving averages. Originally, I decided to use them somewhat arbitrary, probably because they tend to swing faster. Last night, after spending two and half hours debugging an issue which yet again turned out to be a particular property of these averages, I made my mind. I am back to simple moving a...
1223 sym R (252 sym/2 pcs) 4 img
Covered Call ETF Performance
Covered call ETFs have become quite popular lately. Living in Canada, I have been holding a couple Canadian members of this family for the last few months. When I purchased them, I liked the benefits and since I wasn’t expecting any bull markets on the horizon, I bought some. These were new products back them, so I promised myself to do some mo...
2391 sym R (878 sym/1 pcs) 6 img
Pre-computing a trading plan in parallel
R version 2.14 introduced a new package, called parallel. This new package combines the functionality from two previous packages: snow and multicore. Since I was using multicore to parallelise my computations, I had to migrate to the new package and decided to publish some code. Often trading strategies are tested using the daily closing price bo...
1627 sym R (2597 sym/3 pcs) 4 img
More orthodox ARMA/GARCH trading
The system described in the earlier series for ARMA trading was in fact an “extreme” version of the more common, orthodox approach prevailing in the literature. Recently I tried using R to reproduce the results of a particular paper, and that lead to a lot of new developments … How is typically ARMA trading simulated? The data is split into...
2999 sym R (789 sym/1 pcs) 4 img
Were markets exceptionally volatile in 2011?
2011 was a volatile year, no doubt about that, but was it exceptionally so from a historic point of view? To quantify the volatility, I used the Dow Jones Industrial average, which goes back to 1928 on Yahoo Finance: library(quantmod) getSymbols("^DJI", from="1900-01-01") dji = Cl(DJI["/2011"]) djiVol = aggregate( dji, ...
1243 sym R (892 sym/2 pcs) 6 img