The Average Investor's Blog

A software developer view on the markets

Archive for February, 2011

The Weekly Update

Posted by The Average Investor on Feb 27, 2011

There was a pullback in all markets last week. Of course, on a grand scale, this pullback is nothing more than a blip. The different indexes continue to be heavily over-bought, just a tad lower than the record levels the market posted last week.

Asset Symbol Position Date In Gain
Nasdaq 100 ^NDX Long 2010-09-03 25.45%
US REIT VNQ Long 2010-07-23 16.96%
S&P 500 ^GSPC Long 2010-09-30 15.66%

With the pull back, the fresh position in the Emerging Markets, turned into another whip saw. The loss incurred is 1.7%. The Emerging Markets index has been a good leading indicator for the US indexes over the past few years, so it’s direction is not something that could be lightly ignored.

Emerging Markets (EEM)

Emerging Markets (EEM)


The above chart only emphasizes the point – if EEM breaks the resistant red line for good, the floor is far away. Certainly a chart where a speculative position with a tight stop loss can be taken either way.

Posted in Trades | Leave a Comment »

The Weekly Update

Posted by The Average Investor on Feb 21, 2011

Looking at the market as of late, I can’t help but wonder what is it trying to tell us. Most likely (tongue in chick) it’s seeing some prosperous times at the horizon. Following the market, the gains in the long-term trend-following positions have increased yet again.

Asset Symbol Position Date In Gain
Nasdaq 100 ^NDX Long 2010-09-03 27.92%
US REIT VNQ Long 2010-07-23 17.60%
S&P 500 ^GSPC Long 2010-09-30 17.68%
Emerging Markets EEM Long 2011-02-18 0%

The Emerging Markets gave another buy signal on Friday. Let’s see whether it will be another short term whipsaw like the previous one.

One more thing, the S&P 500 is 14.71% above its 10-month moving average. According to my R code (which is not necessarily correct;)) this index is in the 98th quantile with respect to it’s 10-month moving average and in 97th quantile with respect to it’s 20-week moving average. In other words, for the past 60 years, the situation foreseen by the market was better than what it’s seeing right now in only two percent of the cases!

Don’t get excited yet, this is not such a rare event – it has happened on 397 days in the past since 1950 (15,383 days of history). 🙂 The last time it happened was on several occasions (on 106 days in total to be precise) between November 1996 and April 1999. Here is the month list:

1951: Jan, Feb
1954: Sep-Dec
1955: Jan-Feb, Jun-Dec
1958: Dec
1961: Apr
1971: Apr
1975: Jun
1976: Jan
1980: Sep-Nov
1982: Oct-Dec
1983: Jan-Jun
1986: Feb-May
1987: Jan-Apr, Jun-Aug
1989: Jul, Aug
1996: Nov
1997: Feb, May-Oct
1998: Feb-Apr, Jul, Dec
1999: Jan, Apr

Some of the months on the list are just before some really scaring events (Aug 1987, Apr 1999, etc). Keep the printing press, oops the economy, rolling and let’s be optimists – this time it’s going to be all different.

Posted in Uncategorized | 1 Comment »

Open-sourcing some of my automation code

Posted by The Average Investor on Feb 20, 2011

To automate my trading I use a mix of scripts. Everything goes – R, Python, shell, C++, etc. For some time now I have been satisfied with the tools I have created. They run once a day, gather data from EODDATA, update the database, run some R magic to decide what needs to be done for trading and finally, I get an email with the report. Good enough for me!

All the tools are available from the quantscript project at Google code. Be aware that this is work in very early progress, and be aware that this is not for mass use – you need to know what you are doing. 😉 In any case, I hope these scripts prove useful in your trading!

Posted in coding, eoddata, R | Leave a Comment »

RSI(2) and the pre 80s Market

Posted by The Average Investor on Feb 17, 2011

In his detailed research on RSI(2) indicator, MarketSci emphasized several times that the contrarian strategies based on the RSI(2) indicator didn’t start working until the 80s. I remembered this observation recently when I observed another interesting anomaly …

In statistics, an important initial step in studying time series data is to consider the auto correlation of the series. In R, the simplest way to accomplish this is to use the acf function (for more details see Introductory Time Series with R). The R code to visualize the auto correlations is:

library(quantmod)
getSymbols("^GSPC", from="1900-01-01")
acf(diff(Cl(GSPC["2009"])), na.action=na.pass, main="S&P 500 - Correlation between Lags in 2009")

The result looks exactly “as expected”. There is no statistically significant correlation (the dotted lines) at any of the lags.

S&P 500 - Correlation between Lags in 2009

S&P 500 - Correlation between Lags in 2009

Imagine my surprise when I run the same command for the 1965:

S&P 500 - Correlations between Lags in 1965

S&P 500 - Correlations between Lags in 1965

Now there is a statistically significant correlation at lag 1! At this point I remembered MarketSci statement and decided to dig further. To make the long story short, for the most of the 60s and 70s, this correlation existed. I can hear some of you saying so what?

Here is what, a strong correlation in lag 1 means that the returns of the previous day are very predictable of the returns of the next day. In other words, I would expect a very simple strategy as take a long position at the close if market is up or take a short position at the close if the market is down, to perform quite well. This is like taking a heavily biased bet with the odds on the better’s side! Using some R code I quickly tested it and lo and behold, it seemed to work quite well! The detailed results would have to wait a next posting though …

Posted in Market Timing, R, Strategies | 3 Comments »

The Weekly Update

Posted by The Average Investor on Feb 13, 2011

Asset Symbol Position Date In Gain
Nasdaq 100 ^NDX Long 2010-09-03 27.21%
US REIT VNQ Long 2010-07-23 17.19%
S&P 500 ^GSPC Long 2010-09-30 16.47%

Another whipsaw in the Emerging Markets position, the 20-week MA is again out of this trade. This cost us 1.87% loss. Doesn’t look too much, however, these whipsaws can be pretty devastating.

If one took a long position in EET, the double leveraged cousin of EEM based on the same underlying index, the loss would have been 3.79%.

Posted in Uncategorized | Leave a Comment »

The Weekly Update

Posted by The Average Investor on Feb 7, 2011

Monday was the end of January. At the end of January, the (only) long position based on a monthly MA, S&P 500, is still open with a healthy gain. At the Friday close, there was a signal to go long on the Emerging markets (EEM). So far, it looks like we got “whipsawed” over the last two weeks.

Asset Symbol Position Date In Gain
Nasdaq 100 ^NDX Long 2010-09-03 25.02%
S&P 500 ^GSPC Long 2010-09-30 14.87%
US REIT VNQ Long 2010-07-23 14.24%
Emerging Markets EEM Long 2011-02-04 0%

Posted in Trades | Leave a Comment »

 
%d bloggers like this: