Category Archives: strategy

VIX vs Italy: Rules vs Opinion

I am faced with the following dilemma:

1. I believe in rules and strategy-based trading. I believe one must not deviate from the “rules”.
2. I can “see” risks that are not incorporated into my model(s).
Let me put this in context.
From a quant point of view (at least a simple, price-based quant model) a jump in VIX of 30%+ does signify an event. Some strategies will enter a mean reverting mode, some will sell-off to avoid a volatile environment, some will jump in and double down, some will sell options, etc.
Quantitatively speaking, one may start by looking at other instances where the VIX jumped more than X% and see what happened in the next few days (here, here , here and here).
From a fundamental (and common sense) point of view, the event that caused the VIX to jump was the outcome of the Italian elections. This is by no means a minor event. It is the first time the south European public votes against German imposed austerity, something that surprisingly  has not yet happened even in Greece (@34% unemployment… how long can that last?), Spain (@20%+ unemployment) or more recently, Cyprus.  This could cause fundamental long term changes to Europe and affect the U.S. market as well.
For illustrative purposes only, I created a simplistic diagram of outcomes following the Italian Elections:
No-matter what the final outcome, halfway through the diagram, there is a lose-lose situation. In other words, one can argue that until the Italian Elections are conclusive, it is not in the interest of the ECB or Germany to stabilize the markets, especially the Italian sovereign spreads.  So if we were to accept the logic of this diagram, even the market-positive outcome assumes a bearish transitory period.
So how does one incorporate this theoretical “belief” without diverging from the systems in place?
One solution is to do nothing and stick to your guns.
Another solution is to get out of the market and stay cash. 
But when do you come back in? How do you decide when the danger is over. When the market has already advanced another 15% while sitting in cash?
A third solution is to turn-on alternative strategies. These could be tail-protection* strategies.
There are many ways to protect from tail risk. Some are better than others. Most cost money in a bullish environment. An obvious example is buying puts. That could protect your positions but if the crash never materializes, the cost of the puts would eat into the returns.
Well, nowadays a retail investor has access to other protection than just buying puts. 
One way to find such a strategy is to split existing strategies into their short and their long components and trade just the short one as a hedge to existing positions.
Take MarketSci’s proposed strategy as an example. As of yesterday the VIX futures are barely in contago, which means that the strategy is ready to go long the VXX.  
Here’s another strategy that it’s short side may work in a bearish environment.
Conclusion:
One way to solve the subjective opinion vs objective model dilemma is to create a strategy that is both agreeable to your subjective opinion and has done ok historically. Then instead of trading the subjective belief you trade the model that incorporates it.
If you cannot find a good model that incorporates it, chances are you shouldn’t trade those beliefs in the first place.
*Tail protection is a fancy way of saying protection from abnormal events such as sudden market crashes. 

** This information is not to be construed as financial or investment advice. No information herein should be taken as a recommendation buy, hold or sell any investment or to use a specific investment strategy

Raging Bull

It seems that most of the strategies that are in the public sphere, are consciously or unconsciously trying to prevent the large 2007-2009 draw-down. From simple to complex Tactical Allocation Systems, to mean-reverting strategies, to volatility based strategies, pairs strategies, etc. They all avoid (in hindsight) the biggest market crash that most of us have experienced.

But what happens in a Bull market? Most of these strategies will under-perform.

I will make an assumption, here:
Whatever strategy exists, if it is ‘well performing’ and is ‘known’ it will be imitated by more and more and eventually the ‘market’ will change in such a way as to make the strategy not work anymore. The market (or rather, the participants) will ‘adapt’ to the strategy.

Sample Tactical Allocation strategy: Immune to the 2008 drop but less so to the 2011 drop and 2012 bull run.

And let’s just say I was to join ranks with those ‘market paranoids’ and look at ways on how the market is out to “outsmart’ me. How could the market do that. What strategy would it employ?
Well, it would do what it has recently done:

Go up. Just up.

Most strategies I deal with have some kind of neutral outlook. I am fine with the market going no-where. I also like downside protection strategies that stand to benefit on a large downturn, either by shorting, hedging or playing the rise in volatility. What about raging Bull market? Where’s the 2004-2007 index-beating straight-up bull strategy?

So here’s one.

So yes, this has been a great bull market strategy. But during 2009-2012, when the SP500 did exceptionally well (and ’emerging’ equity did less so) this remained fairly flat.

 I will not tell how it trades since I am sure you can build a better one. I will tell you that it trades country indices (data)*. You can get started by thinking of momentum vs value strategies.  I will also tell you what the current positions are:

See the catch?
How do you trade the Ukraine Index? Or the Lebanese?
So maybe Institutional investors are not ‘smarter’. Maybe they just have more access to data and instruments.

If you know how to trade these indexes, or you live in these countries, drop me a line and tell me what you think, either here or via e-mail.

So far I only found etfs for Greece: GREK and GRE.PA

*Data used from MSCI Indexes.

Mon AMMI

No, it’s not french and it’s not the movie.
It’s a fast-N-rough “Adaptive Multi strategy Multi Instrument” model.

Let’s assume we want to trade mean-reversion: If price moves down we buy, if it moves up we sell.

Possible Indicators from the blog-o-sphere:
RSI(2),RSI(3),RSI(4)
DV2 here and here
BSI here or here
BoilingerBands
CRSI here
TD9 here

Question 1: Which Indicator to use?

One way to choose an indicator is to run backtests for each one (and each one’s parameters) and pick the one that has performed the best in the recent past. “Performance” can be pure profit or it can be any other metric we choose:  CAR/MDD (annual return/MaxDrawdown), Profit Factor, Expectancy or your very own “Bliss function“.
So if DV2 has performed best in the past 6 months, maybe we should use that to trade for the next few weeks.

Question 2: What should we trade? 

Just one instrument?
Why not backtest all indicators on all instrument and let the data tell us which instrument behaves best with which indicator? We can then trade that one. Did someone say “overfit”?.
Why not a bunch of instruments? A portfolio! Yes and we ‘ll throw some weights in there, too:
30% SPY 10% AAPL 10% XLU 20% IBM 30% GLD  … wightN*InstrumentN

I guess now we have to backtest the different indicators with these different weights on our instruments, too. What are we doing here? Let’s step back.

Question 3: What are we doing here?

We start with a set of selected assets (StockA, StockB,… StockN).
We bring in a  set of selected indicators (ind1, Ind2, …IndN).
We then build an “ammi” that picks and chooses from these two universes.
We optimize that “ammi” using some type of non-exhaustive optimization technique.

In other words we are creating a portfolio and trading each instrument inside the portfolio with each own indicator/strategy. So what’s the catch? There’s nothing new here. We could just trade SPY with DV2 and AAPL with RSI(3). Allocate 30% of capital to strategy “SPY” and 10% to strategy “AAPL”. Is there an advantage in mixing it all up?

For the purposes of this post we will assume:
1. Our optimizing target  is % profit.
2. We are investing a fixed percentage of current equity on each trade (i.e., 10% of Equity). In other words we are compounding.

By optimizing one instrument and one strategy, the optimizer will look for the most consistent “timing” to enter and exit trades.

By optimizing the whole AMMI, the optimizer is handed one more tool. Since it wants to maximize compound profit it can do so by minimizing max drawdown which in turn gets accomplished by minimizing correlations between the “weighted and traded” equity curves. So, in theory, the optimizer should not necessarily choose the best timing of each instrument/indicator but rather the best combination of instruments/strategies that are somewhat profitable and least correlated*. We hope that this criterion is more robust criterion than just timing.

Almost forgot! We also want to be able to change both the “instrument” and the “strategy” as time passes. That means we re-optimize every x days and trade with the fresh settings. Hence, the “Adaptive Multi strategy Multi Instrument” , a.k.a, AMMI, nick-name.

For the sake of simplicity, we will consider indicators RSI(2), RSI(3) and RSI(4). Possible thresholds are 0–>50 for a Buy signal and 50–>100 for a Sell signal. We will use 10 instruments that can have weights ranging from 5% –> 100%. We assume the standard 2x leverage can be used.

Let’s run an Out Of Sample test. In_Sample (IS) Optimization period is 2 years, Out_Of_Sample trading period (OOS) is 3 months.**
Optimization is done using Amibroker’s non-exhaustive CMAE plug-in set to run very few “runs” so as not to overfit (and not wait too long…). Target for the optimization is pure % Profit (hence the huge draw-downs).

Here’s the  result trading a few instruments and using RSI(2), RSI(3) and RSI(4) as possible indicators with varied thresholds. This is an OOS (out of sample, i.e., realistic) equity. At 40%+ (in the “good” version) draw-downs, it’s not something I would trade***. It’s just for illustration purposes.

Again. this is a rough “model”. It is best used as a starting point to get ideas going. It might also help to get a sense of how different data groups react to different indicators.  Instead of mean reverting indicators you could have trend following , or pattern based indicators. And instead of optimizing precise values you could fuzzify them.

———————————————————————————
* Adding a losing strategy to a profitable strategy may increased the Sharpe Ratio of the system.

**The In-Sample optimization will gives us the weights on the instruments as well as the indicator and the thresholds that were used to produce the best performance. An example would be 5% InstrA, 0% InstrB, 0%InsrC,70% InstrD,100% InstrE, 25% InstrF, etc. Indicator would be RSI(4) and lower and upper thresholds would be 30 and 70. Those set of parameters whould then be used to trade “live” (Out-Of-Sample) for the next three months. After that we would re-optimize (inclusive of the 3 months that were traded) and change param for the next 3 months.

***Unless you know what you are doing, optimizing a system for Max Profit, is a fairly bad idea. It will tend to pick few winners and not diversify (i.e., in hindsight it will tend to pick 100% APPLE). 

———————————————————————————

The code in Amibroker:

 
//----Code by Sanz P.-----------------------------------------------------//
//----Place the instruments on a watchlist and select it under Parameters
//----Optimize/Walk Forward on that watchlist
//------------------------------------------------------------------------//
function Set2D( tablename, x, y, value )
{VarSet( tablename + StrFormat("%03.0f%03.0f", x, y ), value );}
function Get2D( tablename, x, y )
{return VarGet( tablename + StrFormat("%03.0f%03.0f", x, y ) );}
OptimizerSetEngine("cmae");
OptimizerSetOption("Runs", 3 );
OptimizerSetOption("MaxEval", 300 );
WatchlistNumber =Param("Choose Watchlist with Tickers",12,0,30,1);
TickerList= CategoryGetSymbols( categoryWatchlist , WatchlistNumber ) ;
tablename="a";
//init
for( n=0; (instrument=StrExtract( TickerList, n)) != ""; n++)
set2d( tablename, n, 0, n );
Buy=Sell=0;
for( n=0; (instrument=StrExtract( TickerList, n)) != ""; n++)
{
set2d( tablename, n, 1 , Optimize("Ticker"+n+ "Position",20,0,50,5) ); //pos
set2d( tablename, n, 2 , Optimize("Ind"+n,2,0,2,1) ); //ind
set2d( tablename, n, 3 , Optimize("Thrsh"+n,20,0,100,5) ); //thr
}
for( n=0; (instrument=StrExtract( TickerList, n)) != ""; n++)
{
if (Name()== instrument)
{
indicator=0;//init
indicatorcode=get2d( tablename, n, 2 );
switch(indicatorcode)
{
case 0:
indicator=RSI(2);
break;
case 1:
indicator=RSI(3);
break;
case 2:
indicator=RSI(4);
break;
}
PositionSize= - get2d( tablename, n, 1 );
thresh=get2d( tablename, n, 3 );
Buy=Cross(thresh,indicator);
Sell=Cross(indicator,thresh);
}
}
SetTradeDelays(1,1,1,1);
BuyPrice=SellPrice=ShortPrice=CoverPrice=O;
SetOption("MaxOpenPositions",10);

Seasonals – SP500, Euro

Here’s the strategy:
Each month we buy at the Open of the first day of the month and sell at the close of the last day of the month.

Here’s the average profit loss for the S&P500 Etfs, SPY  (yahoo:SPY). Data from 1993.

This chart shows that for example if we bought every December @ the open and sold at the end of the month @the Close, we would average a 1.97% profit.
But is average profit, alone, a good indication of profit loss potential?

One way to look at this is his:
Mr. X., a french expat and a bon viveur, wakes up and just feels like gambling. He takes a trip to the nearby casino. We ‘ll call it the Casino “Royale”. He enters the lobby and is presented with 12 different slot machines.



Mr. Francois is the oldest employee of the Royale and has been there since the very beginning. His job is to record the history of those machines. How many times each paid off and how much. 
Mr. X and Francois are buddies. So Mr. X has access to Francois’ notes. 
Francois keeps telling Mr. X, that past does not guarantee the future: If machine #3 paid off 100% of the times it was played, does not mean that it will pay off the next one.
But if it did, if the winning rates and payoffs were “stable”, ie, we expected future statistics to be similar to past statistics, which machine should Mr. X choose and how much should he bet?
The answer to both is the Kelly criterion: f=(bp-q)/b

where:
f* is the fraction of the current bankroll to wager;
b is the net odds received on the wager (“b to 1”); i.e., if you play $1, how much do I win/loose.
p is the probability of winning;
q is the probability of losing, which is 1 − p.

The bigger the probability of winning and the bigger the money paid per $1 bet, the bigger Kelly becomes. . Which only makes sense since we want to play games with big winning percentages and large payoffs. So we can use Kelly as an “indicator” to tell us what would be our “best” bet.

So again, here’s the SPY chart using Kelly instead of Average Profit.



For December here are the stats:

NumOfwins[12]: 14     – i.e., 14 Decembers were wins
NumOfloss[12]: 6        – i.e., 6 Decembers were losers
AvgWin[12]: 2.6075
AvgLoss[12]: -2.02946
Certainty[12]: 70             – i.e. 14 winning Dec’s out of 20 = 70% winning prob.
EXPECT[12]: 1.21641
KELLY[12]: 0.466505

So now that we got all that out of the way, here’s a longer term chart for the SP500 (^GSPC) with data since 1960:
Here you can visually see where the “sell in May and go away” saying comes from. Again, this is historical stats. Doesn’t mean they predict the future.
Probably all this is known to you: The best months to have invested on the SPY are November and December and the worst are May to October. 
And why am I posting this now? It’s already the end of December…
So here’s another seasonal for my European friends that have lost much of their purchasing power over the last 2 years.
This is the Euro (using the Futures prices, since 1995). Keep in mind that the Euro has had a bullish bias through most of it’s history. But look at January:

Approximate continuous “averaged” EURO graph Jan. to Dec

Past returns may not be indicative of  future returns.

Quiz System

Here’s the  Equity curve:

And here’s the code:

Buy=Sell=Short=Cover=0;
if (StrFind(“WOODGDXEPUIDXPALLJJG”, Name()))
Buy=Sell=1;
qty=6;
SetOption(“MaxOpenPositions”,qty);;
PositionSize=-98/qty;
SetTradeDelays(0,1,1,1);
BuyPrice=C;
SellPrice=O;
ShortPrice=O;
CoverPrice=C;

What’s happening here?

This is a variation of Jay Kaeppel’s post at optionetics but using some extra ETFs that have exhibited the same kind of behavior. Original article: http://www.optionetics.com/market/articles/2012/11/28/kaeppels-corner-the-greatest-gold-stock-system-youll-probably-never-use

It buys equal amounts of each of these 6 etfs: WOOD,GDX,EPU,IDX,PALL,JJG.
It buys on the close of the U.S.session, holds overnight and sells on the open the next day.

That’s it.

Would you invest in this strategy
?