Author: shyam

S&P 500 SMA Regimes

In the post Mixture model over S&P 500 returns, we looked at how mixture models can be used to classify returns as belonging to “bull” or “bear” regimes. Unfortunately, we found that using it to trade the index itself was a losing proposition. This lead us to ask ourselves whether a mixture model was any better than a simple moving average based classifier.

Daily returns

If we split returns that occur over different moving averages (50-, 100-, 200-days) and plot their densities, we can see how losses are more frequent when the index is trading below some moving average:
S&P 500 simple moving average returns density plot

Avoiding being long the index when it is trading below a moving average seems to be a good idea. And a quick back-test shows the 200-day average is the one to watch:
S&P 500 long-only SMA returns

All the moving-average “systems” above out-performed the mixture-model based system.

Take-away

Simple beats complex, most of the time.

Code and charts are on github.

Mixture model over S&P 500 returns

Market returns have different characteristics depending on whether they are in a “bull” phase or a “bear” phase. Daily returns can be labeled as either belonging to the “bull” camp or the “bear” camp using mixture models. This post extends Eran Raviv’s idea described here.

Rolling vs. whole period analysis

The density plot of daily returns of the distributions fit by the mixture model using the entire data-set of daily returns looked promising. There was a very visible difference in the way returns behaved under the two regimes. However, rolling period analysis hews closer to the real world. And the densities don’t look as pretty:
density plot of returns in stable and unstable regimes

Sure, “unstable” or “bear” regimes have slightly fatter tails but the densities are not as different as they appeared to be in the whole-period analysis.

Another gotcha is that when the regimes are superimposed on the S&P 500 price index, it looks like it could be good idea to use this system to trade it:
S&P 500 regimes
1 (blue) => stable

Timing signal?

It looks like the model helped escape most of the 2008 carnage and the “stable” regime looks to be long most of the up-trends. However, the overall return profile is sub-par when used in a systematic trading strategy:
S&P 500 cumulative returns

Take-away

Mixture models are an interesting tool in the quant tool-box. However, like how using skew as a timing signal appeared to be a good idea on the face of it, it turns out that using mixture models to time trades in a linear fashion is not such a good idea.

Code and charts on github.

Momentum, Growth and Market-cap Weighted

Momentum and growth investing are not the same and investing in a market-cap weighted index is not the same as momentum investing.

Momentum Investing

One-liner: A portfolio that is long the stocks that have gone up in price over the last one year will out-perform the market.

There are a number of ways to measure price appreciation. Mainly:

  1. Relative: Compare how price has appreciated in comparison to the market. Rank from largest to smallest.
  2. Absolute: Rank returns from largest to smallest.
  3. Acceleration: Compare how price has appreciated in the last 6-months vs. how price appreciated in the prior 6-month period. Rank from largest to smallest.

The one-year formation period is by no means carved in stone. Some portfolios measure momentum over different time-periods and blend them together.

Additionally, the following preference overlays can be applied:

  1. Stocks with lesser volatility.
  2. Stocks that rise up in price gradually (linear) over ones that have gone up like a hokey stick (parabolic.)
  3. Liquid stocks over illiquid ones to reduce trading frictions.
  4. A trailing stop-loss over strict scheduled rebalancing to manage stock-specific risk.

Growth Investing

One-liner: A portfolio that is long the stocks whose earnings have grown at an above-average rate relative to the market will out-perform the market.

There are number of ways to measure earnings growth. Mainly:

  1. Total sales: Compare this year’s revenue over previous years’.
  2. EBITDA: Compare this year’s operating performance over previous years’.
  3. EPS: Compare this year’s earnings per share over previous years’.

All these measures involve gotchas. For example, any of the following actions taken by the company will boost revenue:

  1. Increase the asset base – setup a new factory.
  2. Increase leverage – take on more debt/buy-back stock.
  3. Compromise on margins – lower prices.

Also, there could be temporary structural shocks – natural disasters/policy shifts – that takes out supply/boosts short-term demand for a company’s/sector’s products.

Market-cap Weighted

One-liner: A committee meets every six months and creates a basket of stocks primarily based on their market cap (number of shares outstanding x price.) This basket defines the market.

Passive investors invest in such a basket through index funds or ETFs and get on with their lives.

The long-arch

All investment strategies have their day/year/decade under the sun and neither are necessarily “better” than the other. It depends on the investor’s task at hand. As an analogy, whether you use a flat-head or a Phillips screw is all nuance when compared to task at hand: screwing. But it is important to know the difference between these investing approaches and not get confused between them.

Nifty Gaps

There is always a time alignment problem when working with global data. For example, Nifty closes a day ahead of the S&P for the same closing date. There are two ways to get around this “rolling close” problem:

  1. Shift up the the lagging data to align the times zones.
  2. Instead of using close-to-close, use open-to-close on the data that is ahead.

But how big a problem is this? If the model uses a weekly time-series, how much of a difference would trading on Friday close vs. Monday open make?

Gap Opens

Unfortunately, for the NIFTY, we can only use data from 2011 to analyze opening gaps (Why?) Be that as it may, are Monday opening gaps different from other trading-day gaps?

NIFTY gaps

NIFTY gaps table

MONDAY: gap on a regular Monday after a two-day weekend.
HOLIDAY: gap on a weekday that is not a Monday, but one that opens after a holiday.
DAY_1: gap on a regular day that is not a MONDAY and not a HOLIDAY.

What this tells us is that there is nothing special about a Monday open. On, average, it is just like any other day.

Close-to-Close vs. Open-to-Close returns

The next question is how much of a difference would it make if we traded at the close and held our position over the weekend vs. buying at the open on Monday?

Comparing Close-to-Close (c2c) vs. Open-to-Close (o2c) is tricky because the holding period of the latter is considerably shorter than the former. Nevertheless, here are cumulative returns of buying on Friday close and selling on Monday close vs. buying on Monday open and selling on Monday close:
Buying NIFTY on Friday close and selling on Monday close vs. buying on Monday open and selling on Monday close

What about holding over a holiday?
holding NIFTY over a holiday

And, lastly, holding overnight vs. over a single trading day:
holding NIFTY overnight vs. over a single trading day

The above charts indicate that there is a big difference in holding positions overnight vs. buying at the open.

Volatility at Open vs. Close

The opening and closing prices are computed prices. Actual traded prices could vary based on market conditions. The last question that needs to be answered before choosing between trading at the open vs. the close is how different is the market at the open vs. the close?

To answer this question, lets take the on-the-run NIFTY futures and plot the summary metrics of its returns over the first half-hour and the last half-hour of trading:
NIFTY first 30 minutes
NIFTY last 30 minutes

There seems to be no glaring difference. The drift between traded prices and the published open/close should be about the same whether you trade at the open or at the close.

Take-away

All things considered, there is a net benefit in not carrying over positions over the weekend. So, in theory, a global macro model using weekly time-series could be run over the weekend – positions opened on Monday at the open and closed on Friday at the close – and the “rolling close” problem can be ignored when trading the NIFTY.

Related: Trading turnover throughout the day
Code is on github.

Macro: Is there a relationship between US Treasury and NIFTY 50 returns?

We often hear pundits talk about moves in US treasuries when discussing the NIFTY. Is there a connection? And more importantly, is there a connection that can be exploited?

Two-year US Treasury weekly returns vs. subsequent NIFTY 50 returns

Two-year US Treasury weekly returns vs. subsequent NIFTY 50 returns

Ten-year US Treasury weekly returns vs. subsequent NIFTY 50 returns

Ten-year US Treasury weekly returns vs. subsequent NIFTY 50 returns

It doesn’t look like there is a link between the two on a weekly basis. Maybe it works in subtler ways (“sentiment”) but it doesn’t look like moves in US Treasuries can be used to trade the NIFTY 50.