Saturday, May 31, 2014

Head First C++ code for Duck Simulator : A Strategy Pattern

The very first chapter in the awesome Head First Design Patterns book explains 3 fundamental design principle that forms the basis of Strategy design pattern. These principles are

  1. Identify the aspect of your application that vary and separate them from what stays the same.
  2. Program to an interface, not an implementation.
  3. Favor composition over inheritance.
The example code in Chapter 1 Intro to Design Patterns provide Java Implementation of Duck Simulator. I tried to write similar code in C++ that explains the Strategy Pattern used in the program. The behaviors of a duck that can vary (  Fly Behavior, Quack Behavior ) are encapsulated as family of classes and the non varying part ie Duck Class is base class for different types of ducks ( principle 1). Duck acts as client and make use of encapsulated family of behaviors/algorithms. This particular design is Strategy pattern and it defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that uses it.

Here is the class diagram of SimUDuck simulator

The c++ code is build using VS2010 IDE. You can download code from here.


Thursday, May 15, 2014

Tax Saving Mutual Fund Risk Measures

ELSS (Equity Linked Saving Scheme) Risk assessment

It’s quite a daunting task to select best performing mutual fund that can provide handsome returns and tax benefits too. One thing I want to make clear that I am only providing a way to understand the risk measurements and it does not guarantee that a given scheme will definitely provide best results or gains. Since these saving schemes are equity or market related so nothing is guaranteed but it is also a fact that equity linked scheme has always outperformed the sure shot saving schemes. There is inherent risk involved but if you can understand and measure those, you will be able to make informed decision.
So let us understand how to read factsheets of different mutual fund houses and make informed decisions.
Rsquare:  Measures the percentage of an investment's movement that are attributable to movements in its benchmark index. A mutual fund should have a balance in R-square and ideally it should not be more than 90 and less than 80
Beta Ratio:  where the alpha looks at excess returns over the index, the beta looks at excess risk over the index. If you have a beta of 1, it is said that you have the same risk as the market. If you have a beta of 0.61, it is said that you have experienced about 61% of the risk of the market.
Alpha Ratio: If you are trying to see if a mutual fund has beat the performance of it’s relative index, you should take a look at the alpha ratio. Measures risk relative to the market or benchmark index. For investors, the more positive an alpha is, the better it is. The greater is the number, the greater the out performance.
Sharpe Ratio:  An indicator of whether an investment's return is due to smart investing decisions or a result of excess risk. Higher Sharpe Ratio is better. The range of Sharpe Ratios for global equity funds went from as low a -1.11 to a high of 0.94. A positive Sharpe ratio means the fund did better on a risk adjusted basis. In other words, the higher the Sharpe ratio, the better. The Sharpe ratio tells you about history but it does not tell you anything about the future. Just because a fund has a positive Sharpe ratio for the last 5 years does not mean it will outperform the index for the next 5 years.
Treynor Ratio: Unlike Sharpe Ratio, Treynor Ratio utilizes "market" risk (beta) instead of total risk (standard deviation). It is measure of returns earned in excess of that which could have been earned on a riskless investment.
Expense Ratio:  Denotes the annual expenses of the funds, including the management fee, and administrative cost. Lower expense ratio is better.
Standard deviation: SD is applied to the annual rate of return of an investment to measure its volatility or risk. A volatile stock would have a high standard deviation. With mutual funds, the standard deviation tells us how much the return on a fund is deviating from the expected returns based on its historical performance.

Scheme/Time period
R Square
Beta
Alpha
Treynor Ratio
Sharpe ratio
Standard deviation
Canara Robeco Equity Taxsaver






3-Year
83.61
0.83
1.85
2.36
0.19
17.01
5-year
92.56
0.92
5.60
2.29
0.21
29.10
10 –year
85.53
0.90
4.72
20.97
0.74
27.51
Religare Tax Plan (Growth)






3-Year
92.95
0.78
4.42
6.42
0.38
15.14
5-year
93.83
0.81
3.54
0.91
0.15
25.33
Reliance Tax Saver Gr






3-Year
88.68
0.99
4.78
5.07
0.33
19.60
5-Year
93.45
0.85
4.67
1.96
0.19
26.73







Overall Category: ELSS Risk






3-Year
92.97
0.88
1.33
2.08
0.18
17.13
5-year
95.29
0.89
0.18
-3.56
0.02
27.62
10 –year
89.17
0.91
4.03
20.30
0.73
27.12

From above figures Religare Tax plan looks less risky but other two funds have outperformed it with extra risk. Another important factor is fund size. By fund size we mean total asset value that is managed by fund manager of respective fund.  Canara Robeco Equity Taxsaver have AUM ( asset under management ) of Rs 506.77 crore, Religare tax plan has 129.26 cr and Reliance tax saver 2104.51 cr. Sometimes as size of fund become too large, fund manager find it difficult to invest. Again what is too large is based on perspective.
Source: Jago Invester, Moneycontrol, Investopedia, MorningStar  and internet.