Monday, January 30, 2012

Calendar effects in USD-INR exchange rate

In a previous post, i looked at calendar effects in Indian markets using Nifty index data and concluded that end-of-month effect is very much alive in Indian markets.

The beauty of doing this analysis in a higher level language like R is that the work becomes easily reusable. Let's see if we can find some other nails to hit using this hammer. Such as - currencies.


The reference exchange rates between INR and  USD, Euro and JPY are available on RBI site. As of late 2008, retail investors can trade currencies on NSE and MCX-SX through their regular brokerage accounts.

Before we look at the data, let's look at conventional wisdom. Here is a newfeed from last week (26 January 2012) by Reuters which was picked up by ET, Mint and Moneycontrol.  Quoting:

The rupee fell on Wednesday as dollar demand from oil importers for month-end payments offset a rise in the local share market, ...
...
Oil is India's largest import item and oil refiners, the largest buyers of dollar in the local market, step up demand towards the end of every month to meet payment requirements.

Going by this, we would expect that rupee would depreciate toward the end of the month. Time for the evidence.

Let's first look at last 3 years when the currency markets were opened up for retail participation.

The chart below is that of  long Rupee trade i.e. what return you would have made by going long rupee (which is equivalent to short USD) on various calendar dates. Such a strategy would have lost money when rupee depreciated - remember, we are long rupee - and made money when rupee appreciated against dollar.

So, going by conventional wisdom, one would expect this strategy to lose money toward end of the month.




Wow. We find that rupee actually appreciates toward the end of the month.

Maybe market anticipates the oil dollar buying and moves ahead of it.
Or, maybe, this effect is related to end-of-month effect in Nifty i.e. FIIs bring in the money toward the end of the month lifting both the index and the rupee.
Or, maybe there is some other reason. All that is fodder for next few posts.

In any case, let's explore what happened in 2011 when rupee fell all the way from 45 level to 53 level? A long rupee strategy would have killed you, right? Right. Except, if you did it only during the last 3 days of the month and first 3 days of month. These turn-of-month days were still good in such a horrendous year.


Just in case you are interested, here is data for all of last 10 years: from 2002 to 2011.


Long live the calendar effects!

Wednesday, January 25, 2012

(OT) Tools of the trade

I posted on my other blog about the free online valuation courses being offered by Prof. Ashwath Damodaran.

Prof Damodaran is using an online system (again, free) called coursekit and i decided to give it a go for the 'introduction to R' course i am conducting. 

Coursekit has facebook like look and feel. Students love it.  The interaction among them has gone up by a magnitude compared to the old system of using google-groups - which was mainly email oriented. 

I am totally impressed with coursekit. 




Tuesday, January 17, 2012

A technical market timing method for Nifty

Technical investor wants to be in sync with the market. Go with the flow is their motto.

On the other hand, fundamental investor wants to zag when the market zigs. Be Fearful when others are greedy and be greedy when others are fearful, says Warren Buffett. Invest when there is blood in the streets, says Sir Templeton.

Who is right? I have a hunch that maybe both are right - at different time scales. Anyhow, in the spirit of this blog, let's test the hunches with the data. Let's see what data has to say.

In this post, i will look at  one of the most common technical method for market timing viz. moving average method. (Fundamental based market timing methods are a topic for another post)

A Moving average is commonly used with time series data to smooth out short-term fluctuations and highlight longer-term trends. Traders most commonly use moving averages of 50-period, 100-period and 200-period.

The strategy is very simple:
i) If today's closing price for Nifty is above N days moving average, then stay in the market.
ii) If today's closing price falls below N days moving average, sell out and stay out of the market till condition i signals you to get back in again.

How did this strategy do in Indian markets over last 10 years? The chart below shows the results of 100 Rupees invested according to 50 day / 100 day and 200 day simple moving average (SMA) strategy. The start date is 1st January 2002 and end date is 31 Dec 2011.

The benchmark is the buy-and-hold strategy i.e. you just invested 100 Rupees in an index fund and stayed invested through thick and thin. This is shown by the third line from the top in the graph.


Click on the graph to see bigger picture.

Both 50 and 100 day SMA strategies did better than buy and hold. They did this primarily by stepping out of the market for a time in 2008. However, the really good part about them is that they allowed one to participate fully during the bull markets. Participate in the upside, minimize damage during downside ... what more can one ask for ;)

Several caveats are in order:
i) Look at 200 day SMA. That strategy didn't work in Indian markets in last 10 years. You left way too much money on the table during bull runs. You were better off just buying and holding through thick and thin.

Note that 200 day strategy is most well known. See Mebane Faber's paper on SSRN where he sings eulogies of 10-month moving average (essentially 200 day). This paper is the 2nd most downloaded paper on SSRN.

With the benefit of hindsight, one can come up with arguments such as 200-day is too slow for today's markets and 50 or 100 days is better. But you didn't know that back then.

ii) Even with a 100 day SMA strategy, there were 6 signals on average per year. That means you had to switch in and out of the markets 6 times a year. Imagine churning your entire portfolio that many times. (There is a workaround which will get you most of the benefits without churning your portfolio - see post on my other blog)

iii) It wasn't very effective in 2011. By the way, i consider that as good news.

So there it is.

As usual, all the nifty index data is from NSE and i have posted the code to github. I have also posted an Excel file so that people who are not familiar with R could replicate my work in Excel and come up with even better timing models.

Tuesday, January 10, 2012

Looking at calendar effects in Indian Markets


What is 'too good to be true' is generally so - especially so, in stock markets.

You come across something like Calendar Effects and your first reaction is: nice try. Maybe it used to work but cannot work anymore. After all, markets are efficient and if everybody knows something to work, lo and behold, it will stop working.

In this post, let's look at the so called 'turn of the month effect'. For an accessible commentary, see Larry Connors 'Do Stocks show a bullish bias at month end'? Larry concludes: 'We show that over the past 11 3/4 years, stocks have been much stronger near months-end than they have been any other time of the month ... The fund managers like to buy near months-end, ...'.

So here we have:
a) an effect which has been documented in other markets &
b) there is a plausible reason why it works and might continue to work

Let's test it in Indian markets.

I split the data into 10 groups so that group 1 contains dates 1st - 3rd, group 2 contains dates 4th - 6th and so on.

If there is any turn of the month effect, we should be able to see it when we plot average returns for each group. If there is turn of month effect then the group 10 (dates 28 to 31 of month) should have higher average returns. See the graphs for yourself.

Conclusion: Yes Virginia, there is a turn of the month effect in Indian equity markets. Last 3 days of month have been unusually good historically.


This is the graph for last 11 years: 2001 to 2011


Does it still work? Maybe the average is driven by earlier period?
Let's plot data for last 3 years i.e. 2009, 2010 and 2011.



It continued to work in last 3 years.
How about the really bad 2008 - when nothing worked?


Cool. Even in the horrendous 2008, you actually made money if you were in the market only for last calendar week.

Notes:
(1) Data: S&P Nifty index data for last 11 years viz. from 1st January 2001 to 31 Dec 2011. You can download it from NSE. The data is already clean and in CSV format.
(2)  For the geek reader, the code in R is hosted here

Sunday, January 8, 2012

Welcome guest

In this blog, I want to look at  publicly available datasets to verify the "conventional wisdom" or, maybe, refute it. If the data refutes conventional wisdom, that should be fun.

Typically I will look at equity market data as a) it is readily available in abundance and b) there is a lot of conventional wisdom i.e. folklore around how to make money in the markets.

I am looking for occasional profit in addition to regular fun. Wait a minute, maybe i should reverse it - that sounds better - I am looking for regular profit and occasional fun.