{"id":40883513,"date":"2021-11-19T12:32:53","date_gmt":"2021-11-19T07:02:53","guid":{"rendered":"https:\/\/stockviz.biz\/index.php\/?p=40883513"},"modified":"2021-11-19T12:32:59","modified_gmt":"2021-11-19T07:02:59","slug":"direction-vs-magnitude","status":"publish","type":"post","link":"https:\/\/stockviz.biz\/index.php\/2021\/11\/19\/direction-vs-magnitude\/","title":{"rendered":"Direction vs. Magnitude"},"content":{"rendered":"\n<p>Sometimes, it is useful to remove information from the data that you have. <\/p>\n\n\n\n<p>Lets say, you have a time-series of returns: +0.001,  +0.001,  +0.001,  <strong>+0.1<\/strong>,  -0.01,  -0.01. What if, you removed <em>magnitude<\/em> information and kept only the <em>direction<\/em>? You end up with: UP, UP, UP, UP, DN, DN. Now, you can analyze this transformed dataset using a whole bunch of algorithms designed to work on binary sequences.<\/p>\n\n\n\n<p>Run Length Encoding (<a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Run-length_encoding\" target=\"_blank\">rle<\/a>) is one such algo. We used it while looking for streaks (<a rel=\"noreferrer noopener\" href=\"https:\/\/stockviz.biz\/2019\/01\/02\/streaks-part-i\/\" target=\"_blank\">Part I<\/a>, <a rel=\"noreferrer noopener\" href=\"https:\/\/stockviz.biz\/2019\/01\/03\/streaks-part-ii-backtest\/\" target=\"_blank\">Part II<\/a>.) We dismissed the backtest as a datamining artefact. Which it might very well be. However, if you believe that a timeseries can exhibit both trend and mean-reversion, then looking at it through this lens can be useful.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/stockviz\/blog\/master\/technical\/streaks\/NIFTY%2050.streak.facets.png\" alt=\"\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/stockviz\/blog\/master\/technical\/streaks\/NIFTY%20MIDCAP%20150.streak.facets.png\" alt=\"\" \/><figcaption>Knowing the &#8220;average&#8221; length of streaks can also help in position sizing in a trend-following system and regime classification. <\/figcaption><\/figure>\n\n\n\n<p>Stay tuned.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, it is useful to remove information from the data that you have. Lets say, you have a time-series of returns: +0.001, +0.001, +0.001, +0.1, -0.01, -0.01. What if, you removed magnitude information and kept only the direction? You end up with: UP, UP, UP, UP, DN, DN. Now, you can analyze this transformed dataset &hellip; <\/p>\n","protected":false},"author":2,"featured_media":2089693,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3471],"tags":[2761],"class_list":["post-40883513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-investing-insight","tag-quant","entry"],"_links":{"self":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/40883513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/comments?post=40883513"}],"version-history":[{"count":0,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/40883513\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media\/2089693"}],"wp:attachment":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media?parent=40883513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/categories?post=40883513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/tags?post=40883513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}