Risk Control

Engineering Risks and Returns

In this post, I want to present a framework for formulating portfolio with targeted risk or return. The basic idea was inspired by controlling risk from a different point of view. The traditional way of controlling for portfolio risk was to apply a given set of weights to historical data to calculate historical risk. If estimated portfolio risk exceeds a threshold, we peel off allocation percentages for each asset. In this framework, I focus on constructing portfolios that target a given risk or return on a efficient risk return frontier.

First lets get some data to so we can visualize traditional portfolio optimization’s risk return characteristics. I will be using a 8 asset ETF universe.

rm(list=ls())
setInternet2(TRUE)
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb'))
source(con)
close(con)
tickers = spl('EEM,EFA,GLD,IWM,IYR,QQQ,SPY,TLT')
data <- new.env()
getSymbols(tickers, src = 'yahoo', from = '1980-01-01', env = data, auto.assign = T)
for(i in ls(data)) data[[i]] = adjustOHLC(data[[i]], use.Adjusted=T)
bt.prep(data, align='keep.all', dates='2000:12::')

Here are the return streams we are working with

Rplot

The optimization algorithms I will employ are the following:

  • Minimum Variance Portfolio
  • Risk Parity Portfolio
  • Equal Risk Contribution Portfolio
  • Maximum Diversification Portfolio
  • Max Sharpe Portfolio

To construct the risk return plane, I will put together the necessary input assumptions (correlation, return, covariance, etc). This can be done with create.historical.ia function in the SIT tool box.

#input Assumptions
prices = data$prices
n=ncol(prices)
ret = prices/mlag(prices)-1
ia = create.historical.ia(ret,252)
# 0 <= x.i <= 1
constraints = new.constraints(n, lb = 0, ub = 1)
constraints = add.constraints(diag(n), type='>=', b=0, constraints)
constraints = add.constraints(diag(n), type='<=', b=1, constraints)

# SUM x.i = 1
constraints = add.constraints(rep(1, n), 1, type = '=', constraints)

With the above we can go ahead and input both ‘ia’ and ‘constraints’ in to the above optimization algorithms to get weights. With the weights, we can derive the portfolio risk and portfolio return. These then can be plotted on a risk return plain visually.

# create efficient frontier
ef = portopt(ia, constraints, 50, 'Efficient Frontier')
plot.ef(ia, list(ef), transition.map=F)

Rplot01

The risk return plain in the above image shows all the possible space to which a portfolio’s risk and return characteristic can reside. Anything that is beyond to the left side of the frontier do not exist (unless leverage, to which the EF will also shift leftward too). Since I am more of a visual guy, I tend to construct this risk return plain whenever I am working on new allocation algorithms. This allows me to compare with other portfolio the expected risk and return.

As you can see, each portfolio algorithm has their own set of characteristics. Note that these characteristics fluctuate across the frontier were we to frame this rolling through time. A logical extension to these risk return concepts is to construct a portfolio that aims to target ether a given risk or a given return on the frontier. To formulate this problem in SIT for the return component, simply modify the constraints as follows:

constraints = add.constraints(ia$expected.return,type='>=', b=target.return, constraints)

Note that the target.return variable is simply a variable storing the desired target return. After adding the constraint, simply run a minimum variance portfolio and you will get a target return portfolio. On the other hand, targeting risk is a bit more complicated. If you look at the efficient frontier, you will find that for a given level of risk there is two portfolios that line on it.  (The sub-optimal portion of the efficient frontier is hidden). I solved for the weights using a multi optimization framework which employed both linear and quadratic (dual) optimization.

target.risk.obj<-function(ia,constraints,target.risk){

 max.w = max.return.portfolio(ia, constraints)
 min.w = min.var.portfolio(ia, constraints)
 max.r = sum(max.w * ia$expected.return)
 min.r = sum(min.w * ia$expected.return)
 max.risk = portfolio.risk(max.w,ia)
 min.risk = portfolio.risk(min.w,ia)

 # If target risk exists as an efficient portfolio else
 # return weights of 0
 if(target.risk >= min.risk | target.risk <= max.risk){
 out <-optimize(f =target.return.risk.helper,
 interval = c(0,max.r),
 target.risk = target.risk,
 ia = ia,
 constraints = constraints)$minimum
 weight=target.return.portfolio(out)(ia,constraints)
 }else{
 weight=rep(0,ia$n)
 }

 return(weight)
}

Below is a simple backtest that takes the above assets and optimizes for the target return or target risk component. Each will run with a target of 8%.

Backtest1Now the model itself requires us to specify a return or risk component. What if instead we make that a dynamic component such that we extract ether the risk or return component of a alternative sizing algorithm. Below are the performance of the dynamic risk or return component extracted from naive risk parity.

Backtest2

 

Not surprisingly, whenever we target risk, the strategy tends to become more risky. This confirms confirms risk based allocations are superior if investors are aiming to achieve low long term volatility.

 

Thanks for reading,

Mike

Advertisements

Equity Bond Exposure Management

I did a post last October (here) looking at varying allocation between stocks/bonds and at the end I hinted towards a tactical overly between the two asset classes. Six months later, I finally found a decent overlay I feel may hold value.

In a paper called “Principal Components as a Measure of Systemic Risk” (SSRN), Kritzman Et al. presented a method for identifying “fragile” market states. To do this, he constructed the Absorption Ratio. Here is the equation:

The numerator sigma represents the variance of the ith eigenvector, while the denominator one equals the variance of the jth asset. In the paper, n = 1/5 the total number of assets (N). The interpretation is simple, the higher the ratio, the more “fragile” the market state. The intuition behind this ratio is that when its high, it implies that risk is very concentrated. On the other hand, when it is low, risk is dispersed and spread out. Think weak and strong. Following is the raw AR through time of the DJ 30 Components. 

ar

As you can see, the ratio spikes during the tech bubble and the recent financial crisis. How would it look like when used as a filter? Below are two pictures comparing the signals generated by 200 day sma and standardized AR.

SMA ARatio

Pretty good at the timing in my opinion. In line with the paper, I reconstructed the strategy that switches between stocks(DIA) and bonds (VBMFX). When the AR is between 1 and -1, we will split 50/50. When its above 1, we are in love with bonds and when its below -1, we are  in love with stocks. Simple. Results:

EQPerf
Table

And here is the code: (I know its messy, didn’t have a lot of time! :)

Note: There is survivorship bias. I used the current day DJ30.

Thanks for reading

Diversification through Equity Blending

In a sound asset allocation framework, it is never a good idea to over weight the risky portion of the portfolio. One example would be the traditional 60/40 portfolio whereby an investor allocates 60% to equities and 40% to bonds. Such allocation may intuitively makes sense as you “feel” diversified but when extraordinary events happen, you will be less protected. Below is the performance of the 60/40 allocation rebalanced monthly since 2003. Note I used SPY and IEF for the mix.

In this post, I would like to show some ideas that will reduce risk and increase return by bringing in a different type of return stream. Traditional asset allocation focuses mainly on optimal diversification of assets, here I will focus on allocation to strategies. From my own research, there are only so many asset classes the individual can choose to mix to form portfolios, not to mention the less than reliable cross correlation between assets classes in market turmoil (2008). To bring stability for the core portfolio, I will incorporate Harry Browne’s Permanent Portfolio. This return stream is composed of equal weight allocation to equities, gold, bonds. and liquid cash. For the more aggressive part, I will use daily equity mean reversion (RSI2). Note that a basic strategy overlay on an asset can produce a return stream that can have diversification benefits. Below are three different equity curves. Black, green and red represents, mean reversion, 60/40 equal weight allocation of both strategies, and permanent portfolio respectively.  

To summarize, I have taken two return streams derived from strategies traded over assets and combined them to form a portfolio. The allocation percentage is 40% to the risk asset (mean reversion/MR) and 60% to the conservative asset (Permanent Portfolio/PP). And here are the performance metrics.

Traditional represents the traditional 60/40 allocation to equity and bonds while B-H represents buy and hold for the SP500. This superficial analysis is only meant to prove the powerful idea of equity blending of assets and trading strategies. When traditional search for diversification becomes fruitless, this idea of incorporating different strategies can have a huge impact on your underlying performance.

I will come back later for the R code as its pretty late and I have class tomorrow!

Volatility Parity

When I first started out in system research a year ago, I was told that in this business, if you can achieve return with lower volatility, you will definitely attract a lot of people’s attention. Since then, I’ve found myself to leaning towards strategies with lower volatility, usually achieved through proper volatility management.

In this post, I’d like to take a look at portfolio volatility by using some tools from portfolio theory. I’d like to show that through peeling into volatility one can better manage their portfolio.

There exists a fine line between academic finance and practitioners of finance. The opposing ideas are  whether the markets are efficient or not. I am not going to dive in to the discussion of this, but I stand to reason that there are no rules or equation to the markets. They are ever changing, therefore, I believe that one should treat every concept as tools.

A bit of equations…portfolio variance is defined by the following equation. I am only going to use a two asset class example to avoid bringing in the use of covariance matrix.

        

    

 

The variance contribution of each asset is thus…

In my opinion, the above equations capture a lot of information that can be used to manage volatility. At any given time multi market strategies will have more than one position. If you are able to position size each position so that each one contributes equally to overall portfolio volatility, you will have much smoother balanced and diversified portfolio.

In the following graphs, I calculated according to the above equations how Bonds and Stock contribute to aggregate portfolio variance. For stocks, I used SPY and for bonds, I used IEF, both are exchange traded funds. This is a rolling 252 day graph with traditional 60/40 allocation.

 From the above graph one can infer that the volatility contribution is not equal and at times, you will see that stocks will contribution more than 100% while bonds contributed negatively.

The above graph also gives a pretty good market timing signal. When bonds contributed negatively, it seems that the market is in turmoil and vice versa for stocks when it contributed more than 100%.

I hope through this, the reader will be able to understand volatility more and look and just how it affects your portfolio.

A Few Words on Risk

The measurement of risk is a lot of models in finance is inappropriate to some extent. And in my own arsenal of tools, I have continually tried to err away from using traditional assumptions. These assumptions were made popular from the titans of portfolio theory. (I am not going to give a bash on the MPT and how it’s a minority view that EMH is wrong, as it isn’t a minority view…)

In the convenient and accepted norm, risk = whether you can sleep at night or put another way the “volatility” of your portfolio. With such objective and quantitative measure came a whole sort of metrics, (Sharpe ratio, black Scholes formula, etc). Does it do a good job intuitively to model the real world? If you look at the equation for standard deviation, you will see that it doesn’t differentiate between upside and downside volatility. Further on, ask yourself if you care about upside volatility? Evidence from multiple bull market shows the euphoria that takes place when the stock market goes up as a whole. I am not afraid to deduce that people treat upside volatility with a welcome.

Then it must be I intuitive to accept that downside volatility is a better measure of risk. What metric can one use to measure such things? Below are a few of my favorites.

Sortino Ratio

 Where r is return, r(f) is risk free rate, and the denominator is the downside standard deviation

Ulcer Performance Index (UPI)

Where p(i) is price, p(max) is the max price during period

Where r is return, and r(f) is risk free rate

MAR Ratio

The above ratio are modified versions which I use a lot in strategy testing as a measure of goodness. I once only concentrated on the MAR but then found other measures to add value. I personally use the above and a few others.

*A note on the Sortino Ratio: There are variations to calculations to this ratio. Some calcualtions take into account the zeros which are days with upside return. There are disagreements with to whether this is correct. Readers should be aware and know which one you are using.

Dynamic Portfolio Selection

When I first started to get in to systematic trading, I never sat easy on the fact that after the entire system was built based on objective sounds principles, the selection of portfolio to trade was subjective. How can the most important part of the whole process be left to discretion? Just like our stock forecasts never seem to pan out the way we want, I don’t think the selection of the portfolio based on our assumption that individual markets will continue to behave the same way will lead to anything accurate.

I went to look at Markovitz’s stuff and found it to be fundamentally thought provoking but technically counter-productive. I cant really say its a waste of time when millions (billions?) are managed this way. Lets just say their measure of risk is inherently flawed and keep it at that.

The Markovitz stuff lead to me to think further on minimizing correlation on the assets that I propose to trade. This made a lot of sense to me as if my system gave a signal on DJIA futures and S&P futures on the same day, it is unwise to take both. But the thing is correlation is ever-changing due to the fact that it is computed based on historical data and the results are not very reliable. (How many of you thought you were diversified enough during 2008..?)

Over at TB forum the other day, I landed on a idea that seems to be quite promising. It also took into consideration of many traders that have little capital. It conveyed the idea that a starting trader who has little capital to risk would inherently accumulate greater risk than starting traders who started out with a couple of million dollars in the futures market. This is caused by the fact that the small trader cannot use diversification to his/her advantage.

Solution: Predetermine the number of slots/positions (fixed) you would like to have. The number of slots is directly proportional to the amount of portfolio heat you can have if you have positions open representing each market in each slot. The only thing that can change is the markets that are in each slot. They can be replaced by new markets based on different criteria like liquidity, relative strength, trend strength, etc. This way you will only take the gist of markets based on your criteria for selection. Now instead of monitor your static bunch of markets you can monitor as many markets you want and only take signals from the ones that your criteria deems best.

Systematic Edge

Position Sizing Filters

These days, almost all trading systems have entry filters that hope to reduce sour trades and whipsaws. They enhance performance. Most entry filters for TF systems these days require that the signal be in line with the long term trend.

Today, i tried searching up on the subject of position sizing filters but found nothing. Not only do i think there is a limited research on position sizing, but there is little to no research on position sizing filters.

Position sizing filters are different from position sizing models. Position sizing models tells you how “much” you should buy or sell (ie number of contracts). These can range from martingale models to anti-martingale models. On the other hand, position sizing filters takes a step further to increase or decrease leverage based on some other external factors. These factors can include volatility, overbought/oversold conditions, or any other criteria in your imagination. Will they improve results? Well, thats where you should do more testing.

M