<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/the-bear-is-here/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.quintuitive.com/2018/12/22/the-bear-is-here/"> R – Quintuitive</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>October and December have been devastating for stocks. It wasn’t until Friday though that we officially reached the depths of a bear market.</p>
<p><span></span></p>
<p>There are different theories, the most common is 20% pullback in an index. As <a rel="nofollow" href="http://www.quintuitive.com/2018/03/24/the-bull-barely-survived-on-friday/" target="_blank">readers of this blog are aware</a>, I follow a slightly different definition, based on <a rel="nofollow" href="https://thedowtheory.com/" target="_blank">Jack Schannep’s work</a>. Based on this definition, a bear market is official when two of the three major indexes (Dow Jones Industrial, S&amp;P 500 and Dow Jones Transportation) reach a 16% decline of the most recent high. For the mathematically inclined, the 16% is not random – simply it takes about 19% gain off the bottom of a 16% decline to reach the same level. Thus, a bear market is official at 16%, and a bull market – at 19%.</p>
<p>Friday was significant on these metrics. Here is the situation on the S&amp;P 500:</p>
<pre>
require(quantmod)
require(PerformanceAnalytics)

sp = getSymbols(&quot;^GSPC&quot;, from=&quot;1900-01-01&quot;, auto.assign=F)
sp.ret = ROC(Cl(sp), type=&quot;discrete&quot;)
table.Drawdowns(sp.ret[&quot;2008/&quot;], top=5)
</pre>
<p>This has the following output:</p>
<div align="center">
<a rel="nofollow" href="https://i1.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/spbear.png" target="_blank"><img sizes="(max-width: 631px) 100vw, 631px" src="https://i1.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/spbear.png?w=450" alt="" class="wp-image-3369" data-recalc-dims="1"></a>
</div>
<p>The current pullback is the first 16+% correction since 2008. The story is the same on the Dow Jones Industrial:</p>
<div align="center">
<a rel="nofollow" href="https://i2.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/djibear.png" target="_blank"><img sizes="(max-width: 623px) 100vw, 623px" src="https://i2.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/djibear.png?w=450" alt="" class="wp-image-3370" data-recalc-dims="1"></a>
</div>
<p>And slightly different on the Down Jones Transportation:</p>
<div align="center">
<a rel="nofollow" href="https://i1.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/djtbear.png" target="_blank"><img sizes="(max-width: 631px) 100vw, 631px" src="https://i1.wp.com/www.quintuitive.com/wp-content/uploads/2018/12/djtbear.png?w=450" alt="" class="wp-image-3371" data-recalc-dims="1"></a>
</div>
<p>This is certainly the most cherished bear market in US history, but that won’t make it less painful or less damaging. A recession does not always follow a bear market, but does quite often. How often – check Jack Schannep’s book. There are a few interesting statistics, like the average bear market decline and duration. Let’s take the S&amp;P 500 (history from 1950) and do the math:</p>
<pre>
dd = table.Drawdowns(sp.ret, top=20)
print(dd)
# A visual inspection shows that we
# 11 previous bear markets 
mean(head(dd, 11)[,'Depth'])
# [1] -0.3288091 - 33%
median(head(dd, 11)[,'Depth'])
# [1] -0.2797 - 28%
max(head(dd, 11)[,'Depth'])
# [1] -0.1934 - 19%
</pre>
<p>A gloomy picture. The average bear market is 33%, the median bear market – 28% and the smallest – 19%. In other words, if history repeats itself, there is more pain to come. Significantly more on average.</p>
<p>The last piece of the puzzle (mine puzzle, Jack Schannep has a lot more), is to check the market for oversold signs. For this, Schannep has proposed a simple, yet powerful, indicator to forecast market bottoms. <a rel="nofollow" href="https://theaverageinvestor.wordpress.com/2011/08/" target="_blank">It was extremely precise</a> in the 2011 pullback. Here is the code:</p>
<pre>
capitulation = function(spx=NULL, dji=NULL, nyse=NULL)
{
  require(quantmod)

  spx = if(is.null(spx)) na.fill(Ad(getSymbols(&quot;^GSPC&quot;, from=&quot;1900-01-01&quot;, auto.assign=F)), &quot;extend&quot;)  else spx
  dji = if(is.null(dji)) na.fill(Ad(getSymbols(&quot;^DJI&quot;, from=&quot;1900-01-01&quot;, auto.assign=F)), &quot;extend&quot;) else dji
  nyse = if(is.null(nyse)) na.fill(Ad(getSymbols(&quot;^NYA&quot;, from=&quot;1900-01-01&quot;, auto.assign=F)), &quot;extend&quot;) else nyse
  
  spx.macd = MACD(spx, nFast=1, nSlow=50, maType=EMA)
  dji.macd = MACD(dji, nFast=1, nSlow=50, maType=EMA)
  nyse.macd = MACD(nyse, nFast=1, nSlow=50, maType=EMA)
  
  merged = merge(spx.macd[,1], dji.macd[,1], nyse.macd[,1], spx, dji, nyse, all=FALSE)
  merged = cbind(ifelse(merged[,1] &lt;= -10 &amp; merged[,2] &lt;= -10 &amp; merged[,3] &lt;= -10, 1, 0), merged)
  colnames(merged) = c(&quot;ind&quot;, &quot;spx.ind&quot;, &quot;dji.ind&quot;, &quot;nyse.ind&quot;, &quot;spx.close&quot;, &quot;dji.close&quot;, &quot;nyse.close&quot;)
  
  capitulation = merged[merged[,1] == 1,2:NCOL(merged)]
  
  return(list(capitulation=capitulation, details=merged))
}
cap = capitulation()
tail(cap$capitulation)
#              spx.ind   dji.ind  nyse.ind spx.close dji.close nyse.close
# 2009-03-05 -16.48942 -16.15225 -16.95556    682.55   6594.44    4267.60
# 2009-03-06 -15.84705 -15.21571 -16.07971    683.38   6626.94    4284.49
# 2009-03-09 -16.14169 -15.70102 -16.65649    676.53   6547.05    4226.31
# 2009-03-10 -10.42353 -10.43552 -10.87757    719.60   6926.49    4499.38
# 2011-08-08 -13.47900 -11.42400 -14.88095   1119.46  10809.85    6895.97
# 2011-08-10 -12.61128 -11.47501 -11.57217   1120.76  10719.94    7101.24
</pre>
<p>The above table shows that there is no extreme selling in the current recess. All in all – more troubles ahead.</p>
<p>The post <a rel="nofollow" href="http://www.quintuitive.com/2018/12/22/the-bear-is-here/" target="_blank">The Bear is Here</a> appeared first on <a rel="nofollow" href="http://www.quintuitive.com/" target="_blank">Quintuitive</a>.</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="http://www.quintuitive.com/2018/12/22/the-bear-is-here/"> R – Quintuitive</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 width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/6sozHtobrBc" height="1"></a></div>