Category: Investing Insight

Investing insight to make you a better investor.

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.

Macro: Computing DTWEXM before the FRED

In our posts on using currency indices published by the FRED to predict the NIFTY (collection), we assumed that the currency indices will be available to us on Friday before NIFTY closes. This is problematic on two counts:

  1. The FRED publishes the currency indices only on Monday afternoons, or the next business day if they were closed.
  2. The dataset uses Friday index values which is Friday New York time. NIFTY would have closed for the weekend a good 24 hours before that.

In this post, we will get around the #1 problem by computing the currency index we are interested in (DTWEXM) by using the underlying the currencies themselves and the weights used by the FRED. Here are the results:

computing DTWEXM

Apart from a few outliers, the approach looks to be good enough.

For those who are curious about how this was done, the code is on github.

SIP: Expected Returns

“A monthly Rs. 5,000/- SIP will make you a crore-pathi!” Screamed a Facebook ad. Really? Is it that simple? Lets break it apart and find out the assumptions baked into that bold assertion.

Historical annualized mid-cap returns

annualized historical midcap 100 returns

The NIFTY MIDCAP 100 index has given an annualized return of ~21% between 2002 and 2016. If you assume a 20% return over the next 20 years, then a monthly SIP of Rs. 5,000 will indeed result in a Rs. 1,21,94,282/- corpus, making you are crore-pathi.

But what happens if you were 100% invested in Midcaps (20% returns!) and retired in 2007? All your crore-pathi dreams would have gone poof (Midcaps crashed 60% in 2008.)

Static Asset allocation

One way to mitigate blow-up risk is to diversify away from equities into bonds. A popular allocation scheme is the 60/40 equity/bond allocation. So how much should you expect a 20 year, Rs. 5,000/- monthly SIP to return under this scheme?

SIP returns

It is a range of returns because it looks at a 10,000 random samples of 20×12 monthly (historical) returns to reflect the path-dependency of SIPs.

Now, what about the size of the final corpus under this scheme?

SIP returns

On average, you should not expect more then Rs. 60 lakhs as the final corpus under a static 60/40 allocation scheme. You could get unlucky and end up with Rs. 30 lakhs or get very lucky and end up with Rs. 1 crore. But this is the expected range of returns.

If you still want to get to the magic one-crore mark, you will have to “step-up” the SIP contributions.

The final corpus if the SIP is Rs. 5k a month for the first 5 years and 10k, 15k and 20k for the next 5 year blocks, under a static 60/40 allocation:
SIP returns

Glide-path Asset allocation

The 60/40 split would still leave you exposed to market downturns towards the end. One way to eliminate most equity market risks is to adopt an asset allocation scheme that starts with 100% equity, 0% bonds and “glides” to 5% equity and 95% bonds over a period of 20 years. This way, you will have progressively less exposure to equity as you near the end. Under a fixed Rs. 5,000/- a month SIP, your final corpus is likely to be:

SIP returns

And what if you stepped it up?
SIP returns

Take-away

The kind of “straight-line” thinking that the ad propagates will set you up for disappointment if you don’t understand the underlying assumptions that went into it. Prudent asset allocation is much more than raw performance. It is making sure that you will have the money when you need it. And it inevitably compresses returns, so it requires you to save more.

Next time you see such an ad, you can respond by saying “Give me one crore now and I will give you 5k every month for the next 20 yrs.”


Notes:
Rebalanced once a year.
Allows the allocation to drift by 5% before triggering a rebalance.
Assumes a 10% tax on returns at every rebalance.
“0_5” is the total return index of the 0-5 year government bond.

Code and additional charts (with returns using the NIFTY 50 index) are on github.

Macro: Using Currencies to Predict NIFTY, Part V

Please read Part I and Part II for an introduction. Part III extends the treatment to other dollar indices. Part IV looked at an ensemble model from our learnings from Part III.

In this final part of our series on training a simple Support Vector Machine on currency indices to predict the NIFTY, we will incorporate a Simple Moving Average into our decision matrix. While our model in Part IV would go long/long-short based purely on the predictions of the SVM, the model we use here will go long only if both the prediction is positive and the NIFTY is above a 50-day SMA and go short only if both the prediction is negative and the NIFTY is below its 50-day SMA. Think of the SMA as a regime signifier.

Results

Cumulative returns:
DTWEXB%2BDTWEXM.NIFTY with SMA SVM

DTWEXB%2BDTWEXM.NIFTY cumulative returns

BH: buy & hold
L0: Long-only using SMA 50 alone
LS0: Long-short using SMA 50 alone

L1: Long-only using DTWEXB SVM and SMA 50
LS1: Long-short using DTWEXB SVM SMA 50

L2: Long-only using DTWEXM SVM and SMA 50
LS2: Long-short using DTWEXM SVM SMA 50

L: Long-only using ensemble SVM and SMA 50
LS: Long-short using ensemble SVM SMA 50

The SVM that is only based on DTWEXM (LS2) give better returns than the one based on the ensemble model (LS.) However, the ensemble model had a slightly lower drawdown of the two. Also, when compared to the earlier version that did not use the SMA, LS2 under-performs by about 10%. However, the key difference is in the drawdowns. Using the SMA filter reduced drawdowns significantly, especially the one occurring in 2018.

Without SMA filter:
no SMA drawdowns
With SMA filter:
SMA drawdowns

Conclusion

An SVM with a 4th degree polynomial over the DTWEXM currency index in conjunction with a 50-day SMA seems to be the winning combination.

Code and charts are on github.