<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/an-out-of-sample-update-on-ddns-volatility-momentum-trading-strategy-and-beta-convexity/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://quantstrattrader.wordpress.com/2017/06/20/an-out-of-sample-update-on-ddns-volatility-momentum-trading-strategy-and-beta-convexity/"> R – QuantStrat TradeR</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The first part of this post is a quick update on Tony Cooper’s of Double Digit Numerics’s volatility <a rel="nofollow" href="http://volatilitymadesimple.com/a-momentum-rotation-strategy-for-trading-vix-etps/" target="_blank">ETN momentum strategy</a> from the volatility made simple blog (which has stopped updating as of a year and a half ago). The second part will cover Dr. Jonathan Kinlay’s <a rel="nofollow" href="http://jonathankinlay.com/2017/05/beta-convexity/" target="_blank">Beta Convexity concept</a>.</p>
<p>So, now that I have the ability to generate a <a rel="nofollow" href="https://quantstrattrader.wordpress.com/2017/04/27/creating-a-vix-futures-term-structure-in-r-from-official-cboe-settlement-data/" target="_blank">term structure</a> and <a rel="nofollow" href="https://quantstrattrader.wordpress.com/2017/05/18/constant-expiry-vix-futures-using-public-data/" target="_blank">constant expiry contracts</a>, I decided to revisit some of the strategies on Volatility Made Simple and see if any of them are any good (long story short: all of the publicly detailed ones aren’t so hot besides mine–they either have a massive drawdown in-sample around the time of the crisis, or a massive drawdown out-of-sample).</p>
<p>Why this strategy? Because it seemed different from most of the usual term structure ratio trades (of which mine is an example), so I thought I’d check out how it did since its first publishing date, and because it’s rather easy to understand.</p>
<p>Here’s the strategy:</p>
<p>Take XIV, VXX, ZIV, VXZ, and SHY (this last one as the “risk free” asset), and at the close, invest in whichever has had the highest 83 day momentum (this was the result of optimization done on volatilityMadeSimple).</p>
<p>Here’s the code to do this in R, using the Quandl EOD database. There are two variants tested–observe the close, buy the close (AKA magical thinking), and observe the close, buy tomorrow’s close.</p>
<pre>
require(quantmod)
require(PerformanceAnalytics)
require(TTR)
require(Quandl)

Quandl.api_key(&quot;yourKeyHere&quot;)

symbols &lt;- c(&quot;XIV&quot;, &quot;VXX&quot;, &quot;ZIV&quot;, &quot;VXZ&quot;, &quot;SHY&quot;)

prices &lt;- list()
for(i in 1:length(symbols)) {
  price &lt;- Quandl(paste0(&quot;EOD/&quot;, symbols[i]), start_date=&quot;1990-12-31&quot;, type = &quot;xts&quot;)$Adj_Close
  colnames(price) &lt;- symbols[i]
  prices[[i]] &lt;- price
}
prices &lt;- na.omit(do.call(cbind, prices))
returns &lt;- na.omit(Return.calculate(prices))

# find highest asset, assign column names
topAsset &lt;- function(row, assetNames) {
  out &lt;- row==max(row, na.rm = TRUE)
  names(out) &lt;- assetNames
  out &lt;- data.frame(out)
  return(out)
}

# compute momentum
momentums &lt;- na.omit(xts(apply(prices, 2, ROC, n = 83), order.by=index(prices)))

# find highest asset each day, turn it into an xts
highestMom &lt;- apply(momentums, 1, topAsset, assetNames = colnames(momentums))
highestMom &lt;- xts(t(do.call(cbind, highestMom)), order.by=index(momentums))

# observe today's close, buy tomorrow's close
buyTomorrow &lt;- na.omit(xts(rowSums(returns * lag(highestMom, 2)), order.by=index(highestMom)))

# observe today's close, buy today's close (aka magic thinking)
magicThinking &lt;- na.omit(xts(rowSums(returns * lag(highestMom)), order.by=index(highestMom)))

out &lt;- na.omit(cbind(buyTomorrow, magicThinking))
colnames(out) &lt;- c(&quot;buyTomorrow&quot;, &quot;magicalThinking&quot;)

# results
charts.PerformanceSummary(out['2014-04-11::'], legend.loc = 'top')
rbind(table.AnnualizedReturns(out['2014-04-11::']), maxDrawdown(out['2014-04-11::']))
</pre>
<p>Pretty simple.</p>
<p>Here are the results.</p>
<p><img data-orig-file="https://quantstrattrader.files.wordpress.com/2017/06/capture.png?w=456" data-orig-size="661,606" data-medium-file="https://quantstrattrader.files.wordpress.com/2017/06/capture.png?w=456?w=300" data-attachment-id="1042" data-image-meta="{" data-image-description="" src="https://quantstrattrader.files.wordpress.com/2017/06/capture.png?w=456" data-permalink="https://quantstrattrader.wordpress.com/2017/06/20/an-out-of-sample-update-on-ddns-volatility-momentum-trading-strategy-and-beta-convexity/capture-2/#main" data-large-file="https://quantstrattrader.files.wordpress.com/2017/06/capture.png?w=456?w=640" alt="capture" data-image-title="capture" sizes="(max-width: 640px) 100vw, 640px" data-comments-opened="1" class="wp-image-1042" data-recalc-dims="1"></p>
<pre>
> rbind(table.AnnualizedReturns(out['2014-04-11::']), maxDrawdown(out['2014-04-11::']))
                          buyTomorrow magicalThinking
Annualized Return          -0.0320000       0.0378000
Annualized Std Dev          0.5853000       0.5854000
Annualized Sharpe (Rf=0%)  -0.0547000       0.0646000
Worst Drawdown              0.8166912       0.7761655
</pre>
<p>Looks like this strategy didn’t pan out too well. Just a daily reminder that if you’re using fine grid-search to select a particularly good parameter (EG n = 83 days? Maybe 4 21-day trading months, but even that would have been n = 82), you’re asking for a visit from, in the words of Mr. Tony Cooper, a visit from the grim reaper.</p>
<p>****</p>
<p>Moving onto another topic, whenever Dr. Jonathan Kinlay posts something that I think I can replicate that I’d be very wise to do so, as he is a very skilled and experienced practitioner (and also includes me on his blogroll).</p>
<p>A topic that Dr. Kinlay covered is the idea of beta convexity–namely, that an asset’s beta to a benchmark may be different when the benchmark is up as compared to when it’s down. Essentially, it’s the idea that we want to weed out firms that are what I’d deem as “losers in disguise”–I.E. those that act fine when times are good (which is when we really don’t care about diversification, since everything is going up anyway), but do nothing during bad times. </p>
<p>The beta convexity is calculated quite simply: it’s the beta of an asset to a benchmark when the benchmark has a positive return, minus the beta of an asset to a benchmark when the benchmark has a negative return, then squaring the difference. That is, (beta_bench_positive – beta_bench_negative) ^ 2.</p>
<p>Here’s some R code to demonstrate this, using IBM vs. the S&amp;P 500 since 1995.</p>
<pre>
ibm &lt;- Quandl(&quot;EOD/IBM&quot;, start_date=&quot;1995-01-01&quot;, type = &quot;xts&quot;)
ibmRets &lt;- Return.calculate(ibm$Adj_Close)

spy &lt;- Quandl(&quot;EOD/SPY&quot;, start_date=&quot;1995-01-01&quot;, type = &quot;xts&quot;)
spyRets &lt;- Return.calculate(spy$Adj_Close)

rets &lt;- na.omit(cbind(ibmRets, spyRets))
colnames(rets) &lt;- c(&quot;IBM&quot;, &quot;SPY&quot;)

betaConvexity &lt;- function(Ra, Rb) {
  positiveBench &lt;- Rb[Rb > 0]
  assetPositiveBench &lt;- Ra[index(positiveBench)]
  positiveBeta &lt;- CAPM.beta(Ra = assetPositiveBench, Rb = positiveBench)
  
  negativeBench &lt;- Rb[Rb &lt; 0]
  assetNegativeBench &lt;- Ra[index(negativeBench)]
  negativeBeta &lt;- CAPM.beta(Ra = assetNegativeBench, Rb = negativeBench)
  
  out &lt;- (positiveBeta - negativeBeta) ^ 2
  return(out)
}

betaConvexity(rets$IBM, rets$SPY)
</pre>
<p>For the result:</p>
<pre>
> betaConvexity(rets$IBM, rets$SPY)
[1] 0.004136034
</pre>
<p>Thanks for reading.</p>
<p>NOTE: I am always looking to network, and am currently actively looking for full-time opportunities which may benefit from my skill set. If you have a position which may benefit from my skills, do not hesitate to reach out to me. My LinkedIn profile can be found <a rel="nofollow" href="https://www.linkedin.com/in/ilyakipnis/" target="_blank">here</a>.</p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quantstrattrader.wordpress.com/990/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/quantstrattrader.wordpress.com/990/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://quantstrattrader.wordpress.com/2017/06/20/an-out-of-sample-update-on-ddns-volatility-momentum-trading-strategy-and-beta-convexity/"> R – QuantStrat TradeR</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/DQWFJPQr5Qw" height="1"></a></div>