Tag: quant

USDINR and Dollar Indices, Part I

The St. Louis Fed publishes a number of economic and financial series on its Federal Reserve Economic Data (FRED) database. It is a treasure trove of information for quants. There are a number of currency related time-series in the database. In this post, we will plot the USDINR exchange rate with the trade-weighted indices available on FRED to explore any relationships that there might be between them.

Trade-weighted indices

A trade-weighted dollar index is simply the weighted average of the foreign exchange value of the U.S. dollar against the currencies of a group of U.S. trading partners. The FRED publishes the following such indices:

  1. DTWEXB: Includes the Euro Area, Canada, Japan, Mexico, China, United Kingdom, Taiwan, Korea, Singapore, Hong Kong, Malaysia, Brazil, Switzerland, Thailand, Philippines, Australia, Indonesia, India, Israel, Saudi Arabia, Russia, Sweden, Argentina, Venezuela, Chile and Colombia.
  2. DTWEXM: Includes the Euro Area, Canada, Japan, United Kingdom, Switzerland, Australia, and Sweden.
  3. DTWEXO: Includes Mexico, China, Taiwan, Korea, Singapore, Hong Kong, Malaysia, Brazil, Thailand, Philippines, Indonesia, India, Israel, Saudi Arabia, Russia, Argentina, Venezuela, Chile and Colombia.

Additionally, they also publish the DEXINUS series that is the USDINR exchange rate.

These series go back to the mid-70’s and mid-90’s. However, India was a closed economy with a managed currency for the most parts. So for the rest of this post, we will consider data only from 2005 onward.

Here is how the time-series looks:
FRED DEXINUS-DTWEXB-DTWEXM-DTWEXO indices

Beta between USDINR and the rest

What we are interested in is the relationship between USDINR and the rest of the trade-weighted averages. DTWEXB and DTWEXO have India exposure with the latter made up predominantly of emerging markets. So we should expect a high beta between USDINR and those.

To calculate the beta, we will fit a linear model through USDINR and each of the trade-weighted indices in turn. Also, we will force the intercept to be zero to force the fit.

Here are the betas with a 20-day look-back:
20-day beta between USDINR and trade-weighted indices

Here are the betas with a 50-day look-back:
50-day beta between USDINR and trade-weighted indices

The 20-day chart shows that the beta oscillates within a tight band for the most part. This insight can be used to build a mean-reversion model for USDINR.

In Part II, we will explore the spread between USDINR and all three of the indices. Stay tuned!

Code and charts are on github.

Minimizing the role of luck in systematic trading

The following post is a replication of the Newfound Research article When Simplicity Met Fragility (pdf)

Thesis

Returns are function of both luck and skill. Even while applying systematic strategies like trend-following, momentum or value, there is always negative beta that sometimes overwhelms positive alpha. The article shows that “simple” strategies are often “fragile” because of the role of randomness (luck.) So it makes sense to combine different strategies within the same umbrella to make the investment process more robust. For example, there are more than a few dozen ways to implement a momentum strategy. Combining a few of them will result in a portfolio that is less exposed to luck.

Replication results

We used R to replicate the process described in the article on the S&P 500 index. We downloaded index values from Yahoo Finance and put through the same steps. Here is the single-strategy spread chart that uses 12-1 month momentum:

And this is the multi-strategy spread chart that combines three trend-following strategies including the one above:

As you can see, the multi-strategy chart is a lot less choppy that the single-strategy one. We will chalk this up as a successful replication of the original article.

The NIFTY 50 experience

Would the thesis hold when applied to the NIFTY 50 index?
Here is the single-strategy spread:

And here is the multi-strategy spread:

As you can see, the multi-strategy chart is a lot less choppy that the single-strategy one on the NIFTY 50 index as well.

Take-away

By combining different approaches under the same systematic strategy umbrella, investors can reduce the fragility of their overall portfolio and the influence of luck over the investment outcome.

This is something that we have been doing with our Themes right from the beginning. It just felt like common-sense back then. It is nice to see it in numbers.

Code and charts are on github.

Is Skewness a Timing Signal?

We recently came across a post titled “IMPROVING THE ODDS OF VALUE” (link,) where the author uses the skewness of one-year daily returns to time the value factor. Here, we try to replicate/extend the original backtest.

Key differences

We had to make some tweaks to simplify the task:

  1. The original uses a one-year lookback period, we use a 220-day (trading days) lookback. [minor]
  2. The original uses the S&P 500 index, we use the SPY ETF. Our prices are adjusted for dividends. [minor]
  3. The original constructs a long-short value portfolio. i.e., an academic alpha portfolio. We use it to time the IVE ETF which tracks the S&P 500 Value Index. [major]

We expected the major premise of the original post – that you can go long value during periods of positive skewness and go into cash otherwise – to hold. And perhaps provide some marginal advantage while using it to time a long-only value ETF.

Results

We observed the exact opposite result. Going long IVE during periods of positive skewness under-performed going long IVE during periods of negative skewness. In the cumulative returns chart below:

  • the black and red lines are buy&hold IVE and SPY,
  • the green and blue lines are IVE returns when being long during periods of positive and negative skewness, respectively,
  • the cyan and purple lines are SPY returns when being long during periods of positive and negative skewness, respectively,

cumulative returns using skewness for timing (IVE/SPY)
Note how buy&hold vastly out-performs the timing portfolio.

Further, if you rotate into a liquid fund (earning risk-free returns) instead of going into cash (earning zero), the SPY returns being long during periods of negative skewness beat buy&hold SPY returns:
cumulative returns using skewness for timing with risk-free rate (IVE/SPY)

Perhaps, we are seeing these totally different results because we are long-only and the original back-test was long-short? We are not entirely sure.
Also, the out-performance we observed on SPY failed to replicate on the NIFTY 50 and NIFTY MIDCAP 100 indices.

Code, charts and backtest results for NIFTY 50 and NIFTY MIDCAP 100 indices are on github.

Principal Component Analysis, Part II

This post is an update to Part I of applying PCA to NASDAQOMX India TR indices.

Daily returns tends to be noisy. One way to smooth things out is to use rolling returns over a certain period of days. Rolling returns also allows a bit of slack in terms of variable response times. We wanted to check if using rolling returns would help shake out any obvious regime shifts that daily returns could not.

To recap, we split the NASDAQOMX India TR Index (NQINT) into two regimes. One above SMA-200 (A SMA_200) and the other below (B SMA_200.) The idea was to use PCA on the component indices to see if we could develop a “good times” and “bad times” portfolio based on the regime we are in.

NQINT 200-day SMA chart:
NQINT SMA 200

Factor loadings of indices when NQINT is above its 200-day SMA:
loadings above 200-day SMA

Factor loadings of indices when NQINT is below its 200-day SMA:
factor loadings below 200-day SMA

And finally, factor loadings through out:
factor loadings

Unfortunately, neither using daily returns nor lagged rolling returns resulted in PCA being useful in chalking out a regime specific portfolio.

Code and more charts are on github.

Principal Component Analysis, Part I

Introduction

Principal Component Analysis (PCA) is a way of summarizing data. For example, if you take financial services, there are quite a few sector indices that cover it: Bank, Pvt. Bank, Public Bank, Financial Services, etc… There will be overlap between all these indices, so the question is, in what proportion should one invest in these individual indices in order to get the most optimal exposure to financial services? PCA is one way to answer this question. To get a better understanding of what it is, see: stats.stackexchange.

NASDAQ OMX India TR Indices

To start this series on PCA, we will first look at the USD denominated Total Return indices published by NASDAQ-OMX. Choosing these indices helps us avoid a lot of data pre-processing steps. First, they are Total Return, so they incorporate dividends, etc. Second, they are US dollar denominated, so we don’t have to worry about being long USDINR while looking at tech stocks. And third, they start from 2001, which goes way farther than the TR indices published by the NSE.

We use the following sector indices:
NASDAQ India Basic Matls TR Index (NQIN1000T),
NASDAQ India Cnsmr Goods TR Index (NQIN3000T),
NASDAQ India Financials TR Index (NQIN8000T),
NASDAQ India Health Care TR Index (NQIN4000T),
NASDAQ India Inds TR Index (NQIN2000T),
NASDAQ India Tech TR Index (NQIN9000T),
and the NASDAQ India TR Index (NQINT) to further divide time periods when it is above and below 50-, 100- and 200-day SMA.

The question we are trying to answer is that are the factor loadings stable? If they are not, then how do they change over time and across different market regimes. To answer this, we setup a sliding window of 5-year daily returns that is incremented by one year at a time. That gives us 11 datasets, starting from 2002-2007 through to 2013-2017. We run PCA on the daily returns of the sector indices listed above. We then plot the loadings of the first principal component.

NASDAQOMX India Sector Index PCA

A few things stand out:

  1. Dominated by Basic Materials, Financials and Industrials.
  2. Relative importance of IT has dropped.
  3. Financials dominate the below-SMA200 market regime implying that most of the time, the market is below 200-SMA because of financials.

What we had hoped to find was some sort of stability in the loadings either in the entire dataset or in specific SMA regimes. We could have then constructed a “good times” and “bad times” portfolio and switched between them based on SMA. But it looks like it is not possible with these indices.

Code and more charts are on github.