Author: shyam

Bank Nifty vs. HDFC Bank and ICICI Bank

We recently discussed linear regression by using it to inspect the relationship between two banking stocks. Lets try and extend that treatment to an index and its predominant constituents.

Bank Nifty

The Bank Nifty is composed of 12 bank stocks with ICICIBANK and HDFCBANK making up 29.27% and 28.26% of the index, respectively. Lets start with the scatterplot of daily log returns of the nearest to expiration futures.

bank-futures

Notice the strong relationship between the index and the banks?

Q-Q Plots

ICICIBANK~HDFCBANK-q-q-plot

BANKNIFTY~ICICIBANK-q-q-plot

BANKNIFTY~HDFCBANK-q-q-plot

Index vs. Banks have a predominantly Gaussian distribution. HDFC vs. ICICI – not so much.

Pairs trading

With this knowledge in hand, can we trade pairs made out of these three? The rules for pairs trading is fairly straightforward:

  1. find stocks that move together
  2. take a long–short position when they diverge and unwind on convergence

The execution of a pairs trading strategy involves answering these questions:

  1. How do you identify “stocks that move together?”
  2. Should they be in the same industry?
  3. How far should they have to diverge before you enter the trade?
  4. When is a position unwound?

Bank Nifty, HDFC Bank and ICICI Bank certainly fit the criteria.

Co-integrated prices

If the long and short components fluctuate due to common factors, then the prices of the component portfolios would be co-integrated and the pairs trading strategy should work.

If we have two non-stationary time series X and Y that become stationary when differenced (these are called integrated of order one series, or I(1) series) such that some linear combination of X and Y is stationary (aka, I(0)), then we say that X and Y are cointegrated. In other words, while neither X nor Y alone hovers around a constant value, some combination of them does, so we can think of cointegration as describing a particular kind of long-run equilibrium relationship.

For a light introduction to co-integration, read this post on Quora.

To be continued…

Weekly Recap: Complex Adaptive

Equities

world equity markets 2014-04-17.2014-04-25

Another flat week for the Nifty (-1.15% in USD terms.)

Major
DAX(DEU) -0.09%
CAC(FRA) +0.27%
UKX(GBR) +0.91%
NKY(JPN) -1.22%
SPX(USA) -0.08%
MINTs
JCI(IDN) -0.26%
INMEX(MEX) -1.97%
NGSEINDX(NGA) -1.09%
XU030(TUR) -3.25%
BRICS
IBOV(BRA) -1.37%
SHCOMP(CHN) -2.60%
NIFTY(IND) +0.05%
INDEXCF(RUS) -5.63%
TOP40(ZAF) +0.93%

Commodities

Energy
Brent Crude Oil +0.13%
Ethanol +2.92%
Heating Oil -0.56%
Natural Gas -2.07%
RBOB Gasoline +0.79%
WTI Crude Oil -3.36%
Metals
Copper +1.63%
Gold 100oz +0.52%
Palladium +1.30%
Platinum +0.27%
Silver 5000oz +1.02%

Currencies

USDEUR:-0.18% USDJPY:-0.43%

MINTs
USDIDR(IDN) +1.16%
USDMXN(MEX) +0.61%
USDNGN(NGA) -1.20%
USDTRY(TUR) +0.15%
BRICS
USDBRL(BRA) +0.31%
USDCNY(CHN) +0.45%
USDINR(IND) +0.50%
USDRUB(RUS) +1.31%
USDZAR(ZAF) +1.56%
Agricultural
Cattle +0.59%
Cocoa -1.98%
Coffee (Arabica) +1.20%
Coffee (Robusta) +0.76%
Corn +1.92%
Cotton +3.23%
Feeder Cattle +0.88%
Lean Hogs -2.19%
Lumber +2.60%
Orange Juice -2.05%
Soybean Meal +0.41%
Soybeans -1.09%
Sugar #11 +2.94%
Wheat +1.38%
White Sugar +2.87%

Nifty Heatmap

CNX NIFTY heatmap 2014-04-17.2014-04-25

Index returns

index performance 2014-04-17.2014-04-25

Top winners and losers

CONCOR +10.64%
M&MFIN +10.65%
YESBANK +12.30%
WIPRO -11.37%
CAIRN -9.18%
CROMPGREAV -6.88%
Wipro tanked on muted outlook. L&T Finance and YES Bank and exploring a merger…

ETFs

PSUBNKBEES +6.75%
JUNIORBEES +2.30%
GOLDBEES +2.14%
BANKBEES +1.94%
NIFTYBEES +0.37%
INFRABEES -9.69%
PSU banks continued to tick up…

Investment Theme Performance

Nice to see all investment strategies end in green this week!

Sector performance

sector performance 2014-04-17.2014-04-25

Yield Curve

What is going on in the short end of the curve?

yield Curve 2014-04-17.2014-04-25

Weekend Reading

Weather is a complex system. The act of predicting does not influence the outcome. Although near-term weather is extremely complex, with many interacting parts leading to higher order outcomes, it does have an element of predictability.

The stock-market is a complex adaptive system. Traders and investors in the market are interacting with one another constantly and adapting their behavior to what they know about others’ behavior. The key element of a complex adaptive system is the social element.

Source: Musings on stock-market forecasts

Relationship between a pair of stocks

Linear Regression

The easiest relationship to examine between a pair of stocks is linearity. You can try and fit a linear model through their daily log returns first and then decide further course of action.

Here’s a scatter-plot that shows how Bank of India and Canara Bank could be related to each other.

BANKINDIA-CANBK

Results of linear regression:

Residuals:
      Min        1Q    Median        3Q       Max 
-0.055050 -0.009995  0.000331  0.009440  0.063258 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.0002843  0.0006817  -0.417    0.677    
BANKINDIA    0.7451950  0.0232860  32.002   <2e-16 ***
---
Residual standard error: 0.01638 on 575 degrees of freedom
Multiple R-squared:  0.6404,    Adjusted R-squared:  0.6398 
F-statistic:  1024 on 1 and 575 DF,  p-value: < 2.2e-16

After fitting a regression model it is important to determine whether all the necessary model assumptions are valid before performing inference. If there are any violations, subsequent inferential procedures may be invalid resulting in faulty conclusions. Therefore, it is crucial to perform appropriate model diagnostics.

Residuals vs. Fitted

Residuals are estimates of experimental error obtained by subtracting the observed responses from the predicted responses. The predicted response is calculated from the model after all the unknown model parameters have been estimated from the data. Ideally, we should not see any pattern here.

BANKINDIA-CANBK-1

BANKINDIA-CANBK-3

Q-Q Plot of Residuals

The QQ Plot shows fat tails.

QQ plot BANKINDIA-CANBK-2

Residuals vs. Leverage

The leverage of an observation measures its ability to move the regression model all by itself by simply moving in the y-direction. The leverage measures the amount by which the predicted value would change if the observation was shifted one unit in the y-direction. The leverage always takes values between 0 and 1. A point with zero leverage has no effect on the regression model. If a point has leverage equal to 1 the line must follow the point perfectly.

Labeled points on this plot represent cases we may want to investigate as possibly having undue influence on the regression relationship.

BANKINDIA-CANBK-4

Conclusion

A linear model on daily log returns may not be the best way to understand the relationship between the two stocks. We can either change the model (linear) or change the attribute (daily log returns) that we are using.

To be continued…

Source: Model Diagnostics for Regression

Nifty Statistical Study

Returns vs. Log Returns

We had discussed how the most important assumption in finance is that returns are normally distributed. Also, the benefit of using returns, versus prices, is normalization. All your variables are now on the same scale and can be compared easily. But if you pick up any book on financial statistical modelling, you’ll run into log returns more often.

nifty-daily-returns

nifty-daily-log-returns

As you can see from the charts above, visually, they don’t make a difference. However, taking the log of returns makes the math easier:

  1. If we assume that prices are distributed log normally, then log(1+ri), where ri is the ith period return, is normally distributed. And we know how to work with normal distributions.
  2. When returns are very small, log(1+ri) ≈ r
  3. Calculating compounding return goes from series multiplication (∏) to series summation (∑).

nifty-histogram

nifty-log-histogram

Quantiles

The easiest way to summarize a frequency distribution is through quantiles. Quantiles are values which divide the distribution such that there is a given proportion of observations below the quantile. For example, the median is a quantile such that half the points are less than or equal to it and half are greater than or equal to it.

Raw-returns (%):

1% 5% 25% 50% 75% 95% 99%
-4.1986 -2.4994 -0.6992 0.0967 0.8585 2.4387 4.4465

Log-returns:

1% 5% 25% 50% 75% 95% 99%
-0.04289 -0.0253 -0.0070 0.0009 0.0085 0.0240 0.0435

Q-Q Plot

Once we know the qunatiles of our log returns, we can compare it to that of a normal distribution. When you plot the quantiles of the sample (Nifty daily log returns) to the quantiles of a theoretical normal distribution, you get a visual feel for the outliers – the fat tails.

nifty-log-returns-normal-qq-plot

This plot shows that both tails are heavier than the tails of the normal distribution. So, although using log returns and assuming that prices are distributed log normally makes the math easier, we should always be aware that it is a sleight of hand.

To be continued…

Sources:

Markets 24.04.2014

Indian markets are closed due to elections in Mumbai. Here’s a roundup of world markets and the latest flash PMI numbers.

Your world at 9am

world equity markets 2014-04-24

Equities

Major
DAX(DEU) -0.58%
CAC(FRA) -0.74%
UKX(GBR) -0.11%
NKY(JPN) -0.44%
SPX(USA) -0.22%
MINTs
JCI(IDN) +0.18%
INMEX(MEX) -0.62%
NGSEINDX(NGA) -0.54%
XU030(TUR) -0.51%
BRICS
IBOV(BRA) -0.78%
SHCOMP(CHN) -0.11%
NIFTY(IND) +0.37%
INDEXCF(RUS) -0.49%
TOP40(ZAF) -0.14%

Commodities

Energy
Brent Crude Oil +0.17%
Ethanol +0.00%
Heating Oil +0.09%
Natural Gas +1.01%
RBOB Gasoline +0.16%
WTI Crude Oil +0.23%
Metals
Copper +0.26%
Gold 100oz +0.16%
Palladium -0.03%
Platinum +0.13%
Silver 5000oz +0.00%

Currencies

USDEUR:+0.00% USDJPY:-0.10%

MINTs
USDIDR(IDN) -0.04%
USDMXN(MEX) +0.06%
USDNGN(NGA) +0.24%
USDTRY(TUR) -0.00%
BRICS
USDBRL(BRA) -0.71%
USDCNY(CHN) +0.06%
USDINR(IND) +0.52%
USDRUB(RUS) -0.04%
USDZAR(ZAF) -0.06%
Agricultural
Cattle -0.02%
Cocoa +0.48%
Coffee (Arabica) -0.33%
Coffee (Robusta) +0.37%
Corn -0.30%
Cotton +0.10%
Feeder Cattle +0.10%
Lean Hogs -0.30%
Lumber -0.12%
Orange Juice +0.97%
Soybean Meal +0.08%
Soybeans -0.09%
Sugar #11 +2.06%
Wheat -0.59%
White Sugar +1.44%

PMI Roundup

China

Still below 50, but green shoots.

China PMI April 2014

US

Production rises at fastest pace for over three years.

US PMI April 2014

Eurozone

Business activity expansion nears three-year peak.

Eurozone PMI April 2014

Germany

Flash Germany Composite Output Index at 2 month high.

Germany PMI April 2014

France

Flash France Composite Output Index falls to 2-month low.

France PMI April 2014

Source: Markit