Friday, October 28, 2016

Macro: The Quiet Riot - Continental Version

For the past few weeks, the fixed income market has seen a significant change in moods.

The earliest trigger was in the JGBs market in late July, then it was the Gilts in late September following a pause from BoE. This week it definitely felt like the Bunds. Treasuries are down too from July highs, but in a much gradual fashion compared to the rest.

Now while we do have individual explanation (with the 20/20 hindsight) for all these (BoJ steepening chatter, Brexit, ECB QE rumors and, of course, Fed hike expectation), these moves signals some fundamental changes common across the markets as well. For one, this sell-off in rates is markedly different that recent large moves or the 2013 taper tantrum in terms of the accompanying movement of the inflation expectation. This is the first large sell-off in rates where the real rates (I used 10y yield less the 5y swap breakeven rate) were stable. Clearly the common thread has been inflation expectation - led by the Sterling inflation market, in response to a weakening currencies. But this was not limited only to GBP. Backed by the strong recovery of the commodity prices and oil, inflation markets across regions rallied, recovering from the bottom in Q1 this year. Even the Euro inflation is  flat on YTD basis after this recent move.
However, it is still too early to say if this points to an inflation scare. We are far off from seeing the white of the eyes of inflation. Large part of the recovery in inflation is driven by commodity prices which just came off multi-year lows. With over-capacity in many sectors, and a new cost/ supply equation for oil (see here too), there is no strong case for the commodity rally to overshoot substantially from here. On the demand side, apart from the healthy wage growth in the US, things are not significantly better. UK is still trying to figure out the consequences of Brexit. The collapse of the credit impulse in the Euro area late last year is yet to recover and Japan seems increasingly stuck.

The suddenness of the move suggests a large driver of the sell-off may be positioning, especially in Euro and GBP. Bunds open interest on Eurex were near historical high since 2008 before the selloff. This was definitely not helped by a rather tight-lipped Draghi on the last ECB. ICE Gilt positioning also indicated asymmetry with position build-up after Brexit. For core rates, this means the recent sell-off will stabilize as the pressure from positioning is diffused eventually. However, it is clear that we are approaching near the end of the era of quantitative easing. The next big move in rates will not be triggered by Fed. It will be the policy announcement from BoJ in Nov, followed by ECB's decision on QE in Q1 next year. Fed is priced in, and with all probabilities, will carry out a measured hike in December. It will be mostly a non-event.

What is rather interesting is how the current monetary policy plays out for the curve. It is clear we are increasingly approaching the end of QE-topia, with some central banks moving to normalize, and some still leaving considerable liquidity in the system and trying to lean on the next lever. This apparent divergence in the first order (the level of rates) is leading a convergence drive in the second order (the yield curve slope). BoJ is actively seeking to steepen the curve to alleviate concerns of the banking sectors, among other things. ECB will be glad to have the Euro area curve steepen back. The Fed is allegedly getting in the same business. The latest round of rates sell-off, unlike most before in recent time, was mostly a bear steepening move. Unfortunately, steepeners are not as juicy as they used to be in terms of carry a couple of years back, but still this is the trade to be in for the medium term - either in absolute term or cross-markets.

On the equity side, contrary to general view, this is not at all negative. Inflation recovering from current levels shows strength of the macro drivers. In fact in recent years, S&P 500 has shown more asymmetric correlation to inflation expectation than outright rates itself (see chart below). The thick tail on the right hand side has been dominated by inflation downside (i.e. correlated sell-off in equities with collapse in inflation expectation). A recovery in inflation expectation should be positive, at least initially, and ultimately uncorrelated to equity performance (runaway inflation is still a distance myth). This is especially true given the strong commitment from the Fed on its intention of slow paced hikes.
The S&P appears to be in a consolidation state - in a typical triangle formation, before the next leg (usually up from here).


The downside for equities from here is in fact event risks, and not macro. The US presidential election is one -although apparently the market does not care. Italian referendum is another - and again the history does not make a strong case for it either, if you go by the off-hand manner in which market digested the outcome of recent southern European election outcome.

Saturday, October 22, 2016

Systematic Trading | An R Package for Automated Technical Analysis

This is an R package for automated technical analysis and some ground stuff for some pattern matching algorithm I plan to build. This is available at github - you can directly install it from github or you can fork or download. Currently it has three functionalities - 1) perceptually important points 2) change points for time series with linear deterministic trends and 3) automated technical support/ resistance/ price envelope identification (useful for back-test, but I have not found the time yet). It has also an undocumented module for technical pattern identification, which is in fluid state. Please note the is in early version and features/ data structures may undergo substantial changes in later version. I copy paste the R vignette below.


Techchart: Technical Feature Extraction of Time Series Data The R package techchart is a collection of tools to extract features from time series data for technical analysis and related quantitative applications. While R is not the most suitable platform for carrying out technical analysis with human inputs, this package makes it possible to extract and match technical features and patterns and use them to back-test trading ideas. At present, the package covers four major areas:
  • Perceptually Important Points (PIPs) identification
  • Supports/resistance identification (either based on PIPs or the old-fashioned Fibonacci method)
  • Change point analysis of trends and segmentation of time series based on underlying trend
  • Identification of technical envelopes (like trend channels or triangles) of a time series

Perceptually Important Points

PIPs are an effort to algorithmically derive a set of important points as perceived by a human to describe a time series. This typically can be a set of minima or maxima points or a set of turning points which are important from a feature extraction perspective. Traditional technical analysis - like technical pattern identification - relies heavily on PIPs. In addition, a set of PIPs can be used to compress a time series in a very useful way. This compressed representation then can be used for comparing segments of time series (match finding) or other purposes. In this package, we have implemented the approach detailed here.
spx <- quantmod::getSymbols("^GSPC", auto.assign = FALSE)
spx <- spx["2014::2015"]
imppts <- techchart::find.imppoints(spx,2)
head(imppts)
##            pos sign   value
## 2014-02-03  22   -1 1741.89
## 2014-03-07  45    1 1878.52
## 2014-03-14  50   -1 1841.13
## 2014-04-03  64    1 1891.43
quantmod::chart_Series(spx)
points(as.numeric(imppts$maxima$pos),as.numeric(imppts$maxima$value),bg="green",pch=24,cex=1.25)
points(as.numeric(imppts$minima$pos),as.numeric(imppts$minima$value),bg="red",pch=25,cex=1.25)

The function takes in a time series object (in xts format), and a tolerance level for extreme points identification (can be either a percentage or a multiple of standard deviation). It returns an object which has the list of all PIPs identified, marked by either a -1 (minima) or 1 (maxima), as well as the maxima and minima points separately as xts objects

Supports/ Resistance

Supports and resistance levels are very popular tools for technical analysis. The function find.pivots implements a couple of ways to identify supports and resistance levels for a price series. Using the option FIB will produce a set of Fibonacci levels around the most recent price point. The option SR will run an algorithm to find co-linear points along x-axis (horizontal line) to find levels most tested in recent times. A set of levels as well as xts representation of the lines defined by them are returned
spx <- quantmod::getSymbols("^GSPC", auto.assign = FALSE)
spx <- spx["2014::2015"]
sups <- techchart::find.pivots(spx, type = "FIB")
summary(sups)
## supports and resistance:
## next 3 supports:1982.249 1936.355 1890.461
## next 3 resistance:2130.82
sups <- techchart::find.pivots(spx, type = "SR", strength = 5)
summary(sups)
## supports and resistance:
## next 3 supports:2043.688 1992.551 1895.028
## next 3 resistance:2070.407 2111.588

Price Envelop Identification

Price envelopes features are an integral part of technical analysis. For example technical analysts look for features like trending channel, or ascending triangles etc to identify continuation or breakout from current price actions. The function find.tchannel identifies the most recent such envelopes using an implementation of the popular Hough transform algorithm in image processing, along with some heuristics.
spx <- quantmod::getSymbols("^GSPC", auto.assign = FALSE)
spx <- spx["2016-01-01::2016-09-30"]
tchannel <- techchart::find.tchannel(spx,1.25)
tchannel
## name: channel
## type: neutral
## direction: 0
## threshold: NA
quantmod::chart_Series(spx)

quantmod::add_TA(tchannel$xlines$maxlines[[1]],on=1, lty=3, col="brown")

quantmod::add_TA(tchannel$xlines$minlines[[1]],on=1, lty=3, col="brown")

The function returns an object with parameters of the envelopes found (if any), as well as the xts representation of the envelopes lines

Saturday, October 15, 2016

Central Bank Watch: FOMC Minutes (and RBI)

It is highly interesting to see the views and counter-views on the impact of  low rates on the DCF industry. I think both miss the subtle point here . All these DCFs and PVs and pretty much everything else depends on an assumption of properly functioning lending and borrowing market. The question is: if negative rate does persist for long, will that assumption breakdown, or will adapt.

Speaking of rates, the FOMC minutes released this week was very informative. It was a much ambivalent FOMC than we have seen earlier. It appears the September hold decision was a close call. So it is safe to assume it will be so in November and December (if no hike in Nov) as well.

On the major points that drives the"data dependent" FOMC, it seems the consensus is on the labor markets. Since the last meetings, we had more or less similar or slightly improved wage data. However, this week's job opening (JOLT) was a bit disappointing. On economic growth expectation, retails sales data from Friday was more or less on the mark, matching street expectation, and capital goods from earlier has shown improvement as well. Even the much discussed negative influence of foreign GDP has subsided. Eurozone forecast edged up to 1.3% from 1.2%, and UK forecasts from 0.50% to 0.70% (since Sep FOMC). 

However, surprisingly, on both of these parameters, Fed's own measure is going the other way. The Labor Market Condition Index and the Atlanta Fed's GDP now-casting have both nose-dived in recent readings.


On the inflation front, the both the CPI and PCE edged up since. The CPI is still suffering from energy prices drag. Given the recent moves in oil prices, this should have a positive impact on data before the next meeting. 


Overall, I expect the data to be neutral for both employment and growth and marginally hawkish for inflation for the November meeting. The possibility of a November hike is still lower. Partly, that will be a surprise for the markets - which currently prices in a 17% chance of a hike at November FOMC and a 64% at the Dec meeting. As I discussed before, Fed has never hiked before without a substantial chance priced in by the markets.

That said, one particular line of arguments stands out from the released minutes:
 A few participants referred to historical episodes when the unemployment rate appeared to have fallen well below its estimated longer-run normal level. They observed that monetary tightening in those episodes typically had been followed by recession and a large increase in the unemployment rate. Several participants viewed this historical experience as relevant for the Committee's current decisionmaking and saw it as providing evidence that waiting too long to resume the process of policy firming could pose risks to the economic expansion, or noted that a significant increase in unemployment would have disproportionate effects on low-skilled workers and minority groups.
There were only two major hike cycles not followed by a rise in unemployment in recent history. One was following the early 80s recession, and the other following the early 90s recession. 


This points towards a strong commitment of FOMC towards a gradual rate hike, even if the initial hike has to be brought forward in time. It will be very surprising if we do not have another hike by the end of the year. But this, along with the now-lower long term equilibrium rates, also means it will NOT be particularly threatening to US equities or rates in general (both slopes and levels). Fade the move if any respond violently to FOMC one way or the other.. Both equities and rates should depend less on FOMC and more on intrinsic and unexpected events.

Talking of unexpected evens, the one is of course the US presidential election. The general expectation is a sell-off if Mr Trump wins. Although I fail to see a rally even if it is Mrs Clinton. And of course market expectation can be wrong. In 2012, it was widely expected that a Obama win will be bad for equities, and indeed there was minor sell-off leading up to the election day. However the results marked the start of a long stretch of bull run.

October was also a historic moment for Reserve bank of India. It was a new Governor (following the exit of Raghuram Rajan) and its first ever Monetary Policy Committee decision. And it was a decision quite difficult to understand - an (mostly) unexpected 25 bps cut. RBI revised GDP higher, and both real rate and inflation lower. A lower real rate expectation usually means a lower potential GDP. That means a higher GDP will lead to a potential overheating. A lower inflation rate is not consistent with this, unless RBI is expecting substantial imported disinflation.


India's decreasing credit growth is a worry, but it is not clear higher rates are the culprit here. The decline is driven mostly by the industrial sector - which presumably has more on its plate than to worry about higher rates. And in any case the pass through of RBI rate cuts by the banking sector has not been exemplary in recent time -which has been mired in its own significant bad loan problems. It was appeasing to the markets (and politics perhaps), but hard to imagine how much, if at all, it will help the economy forward.