Long Verses Long Short

It has been documented in academic white papers and other websites that bear market volatility is always greater than the bull market volatility. Is this one of the reasons why it has always been better to stick to a long only strategy for stocks?

For a given interval of time and with the right environmental variables, we usually don’t see panic buying. On the other hand, all else equal, there are myriads of examples where panic selling occurs. One such example of the modern creation is the flash crash of May 9th 2010. This is true for the equities market.

Can we extend our rationale to futures? How has a long only strategy performed compared to long short? Does this apply to a variety of trend following systems? In this little study I set upon with an hypothesis that shorting brings forth volatility to a trading strategy due to the fundamental idea in buying and selling. I will be coming from a trend following perspective with 3 sample systems and compare their performance across parameters and time to ensure validity of my findings.

For the entire set of simulation I will be using ratio adjusted futures contracts. Test range will be from first trading day of 1980 to 5 months in to 2011. 56 markets will cover all sectors to ensure diversification and robustness of results. No commission is used.

For the first system I will be testing a Donchian N-Day breakout. It will take on one parameter, the breakout day. The exit day will be the same as entry. Sizing is Fixed fractional 1%.

In the above chart, I’ve parameter stepped the system from 20 days to 300 days in increments of 10. This is to ensure that conclusions can be drawn for breakout systems in general rather than just 1 parameter. I’ve recorded the annual Sharpe ratio of both the Long only strategy and Long/Short version of it. As you can see form the results, short to intermediate term breakout days show (40 to 180) consistently higher Sharpe.

Here is another view, showing the excess Sharpe generated for Long only compared to Long/Short. Does this simple test show that long only breakout strategy of intermediate term is better and less volatile compared to Long/Short? If so how come?

To ensure that the period between 40-180 is no fluke, I used a random number generator (numbers generated from atmospheric noises) and picked 10 integers between 40-180 and tested it Long vs Long/Short. The results..

In this, I also incorporated the daily Sharpe ratio (second graph) to show if its consistent with my earlier findings in a different time frame. The excess Sharpe for both graphs were all above zero.

In this simple test, evidence suggest breakout strategies do seem to consistently performance better when they are traded long only rather then long short. I’ve also tested the breakout strategy trading the short side, the results show that it had higher volatility, DD, and lower return.

In the next post, I will attempt answer and analyze…

1. Is Long only better for trend following in general?

2. If so, what may be the causal factor?

Good trading.

Core System Robustness

Along the the way of my research I was doing sensitivity tests on two system’s parameters. I thought I’d post the graphs to share. The two systems are dual moving average and donchian breakout.

Dual Moving average: Horizontal Axis is the stepped parameter for the long term MA while the vertical  axis represents annualized sharpe. 21 years of ratio adjusted data with 56 futures instruments. (1980-2011) System parameters also include a 2 ATR stop with 1 % volatility sizing. First graph represents starting cash of 1 Million with the following graphs 5.5 Million and 10 Million respectively.

 

Donchian: Horizontal Axis represents breakout days while the vertical axis represents annualized sharpe. It has no other parameters but entry and exit each set to the same days. 1% sizing with same portfolio and time tested.

Note that I also varied the starting cash for both tests.

IMO, it is these basic tests that gives you confidence in the underlying nature of the strategy and trend following. In all the tests above, all parameter selection had double digit returns. Nevertheless, each case was paired with a higher DD.

Rolling Metrics + Python Code for TBlox Integration

I’ve always been fascinated coming up with a good idea and testing it. But the goodness of the idea must go through enough stages of evaluation before I know that it isn’t a fluke. A lot of performance measures that gets calculated after a test in the summary page is static in nature. They only give you a number that represents a segment of time that you specified for the simulation. As traders, we don’t operate in the same way. By that I mean we don’t usually develop a system and them follow it blindly for a specified period of time in to the future and look back. Instead we take all the signals the system generates, bad or good ones, and live through all the draw-downs. Therefore it is usually useful to take apart the performance and view it over time to see ‘consistency.’  Below is a simply python code that I wrote that integrates with TBlox. It takes the monthly equity log from TBlox and generates a rolling ‘n’ month return.

The above chart was generated for a simple TB supplied trading system called “Triple Move Average System” The chart is a rolling 12 month percentage return.

Python Code:

#Author: Michael Guan / freely distribute

 import xlrd #package for reading excel file
 import matplotlib.pyplot as plt #package for plot in python

 #note that this package only takes on a .xls excel extension
 #TB's Monthly Equity log is .csv; change the extension before
 #using

 def main():
  list = []
  filename = raw_input('Please enter a file name: ')
  months = input('Please specify the rolling months (integer): ')
  totalmonths = input('Please specify total months of test (integer): ')
  metric = input('Please Enter one of the following (4-Close Equity | 5-Total Equity | 9-Total Risk): ')
  wb = xlrd.open_workbook(filename)
  sheet1 = wb.sheet_by_index(0)

  for x in range(1,totalmonths-(months-2)): #loop to loop over excel spread sheet
   initial = sheet1.cell(x,metric).value
   final = sheet1.cell(x+(months-1),metric).value
   temp = (final - initial)/initial
   result = round(temp, 6)
   list.append(result)

  plt.plot(list)
  plt.axhline(y=0,color='r')
  plt.show()

 if __name__ == '__main__':
  main()

 [/sourcecode]

NDX-100 Constituents

Couple of months ago I mentioned the importance of survivor-ship bias when testing strategies that trade on equities. I thought it will help traders to achieve better testing results if they could build them themselves. I got from my university a list of NDX100 constituents all the way back to 1995. Those of you interested can email me if you want a copy of it. I would of upload it but I cant with my current wordpress account.

email: [email protected]

 

On the Theory of Asset Allocation

It has been drilled in my head for the past year that the finance theories and their underlying premise are wrong.  I nevertheless agree with the previous statement given the questionable assumptions with which the theories are based on; but where would we be if Markovitzs and Sharpe were never born or sadly if they majored in arts..?

Modern portfolio theory (MPT) rests on the idea that you can maximize an individuals expected return given a targeted risk profile (standard deviations of return). In constructing an allocation mix, the financial analyst must determine the historic return on each potential asset that may enter into the portfolio. The return of the entire portfolio with only 2 assets will be simply the weighted average of the expected returns of the two asset classes.

The standard deviation of this entire portfolio would be..

And since…

 

Then…

If we vary the correlation variable in the equation and plot it on a expected return – standard deviation plane, we will see something like this.

 

From standard theory, the idea is that if an asset class is negatively correlated to the existing asset in a portfolio, combining them will yield a reduced overall risk preserving the return.

Ok, I have just regurgitated what I’ve learned in my financial theory class for the past three weeks.

The idea of mixing uncorrelated assets together intuitively makes sense. If one asset is going down, then a negatively correlated asset class will up, cancelling out the risk. This view to asset allocation seems alright only when you assume the correlation between the asset class hold in the future. This usually isn’t the case due to globalization of the entire financial markets (ie 2008).  Moreover, the expected value of the long run asset return is assumed to converge to a value(historic expected return). The reliance on this is arbitrary; a recent unexpected evidence of this is in a 30 year stretch, bonds have beaten stocks.

Can we adopt any of the ideas from MPT to systems development? One idea that I came across earlier and posted quite a bit on is system diversification. Instead of selecting the optimal assets to combine together, we can instead select combinations of “systems” to form different optimal portfolios. There are a lot of capabilities to this idea as from a systems point of view, we can create strategies for different time frames, anomalies (momentum, trend following, value, or mean reversion), or ideas limited to your imagination only. Given each systems statistics, achieved from robust backtest procedures, we can optimally combine them together to form portfolio of strategies engineered to a set of parameters.

The ideas above are just me day dreaming after class, they are just my by-products of when (if ever  : D) my creative juices are at work…

Source: Investments 7th Edition, Bodie

 

 

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.

Implied Volatility as an Asset Class

When M.Faber published a model for asset allocation, there has been significant increase in interest in the area on the internet.

With this post, I hope I can add value to the existing allocation framework by introducing another asset class into the mix which I believe can help improve existing TAA models.

In one of the previous posts, I made the point that the VIX timed the market pretty well in the sense that it spiked whenever the S&P declined. Although it is fundamentally created to measured the implied market volatility, I believe it can be used to improved TAA models in time of stress.

A few ETF products has sprang up lately which offers investors the tool to take advantage of the movements in the VIX. They are…

VXX- iPath S&P 500 VIX Short-Term Futures ETN

VXZ- iPath S&P 500 VIX Mid-Term Futures ETN

Playing around with concepts in my head, I hypothesized that given its inverse relationship with the S&P, it may be a good candidate to incorporate in a momentum based TAA model.  The idea is summarized in the following short picture.

The picture is my way of visualizing the past 6 month return on the S&P 500(SPY, Red), Bonds (SHY, Orange), Gold(GLD, Green) and Implied Volatility (VXX, Blue). You can see that in the recent European crisis, we will mostly be in Gold and VXZ if assuming we are holding the top two funds.

In the following simple backtest, I attempt to quantify this with some evidence. In both backtests, I am allocating funds to the top 2 performing assets (50% capital for each). I am rebalancing weekly and I am using 6 Month ROC to calculate the return.  (Please go to bottom to see assumptions)

Notes: The test was done on the less than 9 years of data. The VXX history started in late 2009 so conclusions should be drawn carefully as past performance is not indicative of future returns.

Amibroker Code:

#include <kpi.afl>;
Filter =1;
SetOption("PortfolioReportMode",0);
SetOption("CommissionAmount",0.0);
SetOption("InitialEquity", 100000);
Maxposition = 2;
SetOption("MaxOpenPositions",Maxposition);
SetPositionSize( 100/Maxposition, spsPercentOfEquity);
SetOption("UsePrevBarEquityForPosSizing", True);
SetBacktestMode(backtestRotational);
SetOption("WorstRankHeld",Maxposition);
EnableRotationalTrading();
BuyPrice = C; 

/////////////////////////////////////////////////

rs3                     = ROC(Close,120); 

/////////////////////////////////////////////////
averagescore		= 1000+rs3;
PositionScore		= IIf(Year()>=2003 AND DayOfWeek()==5,averagescore, scoreNoRotate); //DayOfWeek()==5

Cross-Sectional and Time-Series Momentum

A lot of white papers explain momentum as a cross-sectional result. What this means is that future outperformance of a stock is predicated by its outperformance relative to its peers. (MCD vs GE) This is the standard way of doing it, ranking a universe of stocks based on ROC or some other measure.

The other one is time series momentum. This is not a new concept. The idea is that a securities past performance predicts its own future return. From this, auto-correlation is used. The main advantage is that time series momentum can measure and analyze all asset classes because it relies only on its own past price.

The reason I introduced these two different explanation for momentum is that both offer promising fundamental concepts that can be used to build robust strategies. I leave it to the reader to explore further.

Futher Reading:

http://pages.stern.nyu.edu/~lpederse/papers/TimeSeriesMomentum.pdf

http://www.eurojournals.com/irjfe_50_14.pdf

http://web.mit.edu/lewellen/www/Documents/Momentum.pdf

http://pages.stern.nyu.edu/~lpederse/papers/TSMOM_Slides.pdf

SE

Monthly Sector Rotation Part 3

Consistency is really important in trading. For this post, I finally was able to construct the rolling risk adjusted return of the strategy through excel. This may not mean a lot to you but for a backtest that stretched more 20 years, the equity curve really doesn’t reveal much. The graph below plots the rolling 1 year risk adjusted return of the strategy which was calculated by dividing rolling 1 yr return by the standard deviation of those return.

As you can see the strategy is pretty stable in its return during bull markets. During the crash/bear period of 87’, 90’, 00’ and 08’, the strategy performed well compared to the market index in the sense that it was able to get the investor to stay in cash preventing from large drawdowns. This is one of the most important aspect of the system as with the implementation of the moving average, anything that dips below it moves the investor back into cash until otherwise.

This strategy is by no way tradable. It is merely displayed to proof a point that relative strength rotational models works.

SE

Monthly Sector Rotation Part 2

I posted a sector rotation system a couple of days ago. In this post I would like to check the parameter stability of the system just to see if the performance was due to “luck”.

 

From the above, I did a 3d optimization in Amibroker. I varied the top held rank and the cut of off rank from 1 to 9 to see visually the parameter performance of each combination. As you can see, anything to the left of the red lines are better. When we hold more than top 5 positions, we will no longer get the advantages of better performance through investing in high momentum sectors. On the other hand, if our entry and exit were the same (ie enter top 5 rank; exit when fund drops below top 5), there are going to be whipsaws as funds may change rank monthly. Therefore it smoothly return when they are different.

In a later post, I hope to display parameter consistency through displaying rolling performance metrics for this model. I believe that its pointless if we just use the above optimization technique to choose the parameter to trade. Rather I think its better to find a parameter set which offers consistency in return.

SE