<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.feedblitz.com/feedblitz_rss.xslt"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"  version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><channel><title>FOSS Trading</title><link>https://blog.fosstrading.com/post/</link><description>Recent content in Posts on FOSS Trading</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 22 Jan 2024 12:41:00 -0500</lastBuildDate><atom:link href="https://blog.fosstrading.com/post/index.xml" rel="self" type="application/rss+xml"/>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<item>
<feedburner:origLink>https://blog.fosstrading.com/2024/01/xts-0-13-2-on-cran/</feedburner:origLink><title>xts_0.13.2 on CRAN</title><link>https://feeds.feedblitz.com/~/864760196/0/fosstrading/</link><pubDate>Mon, 22 Jan 2024 12:41:00 -0500</pubDate><guid>https://blog.fosstrading.com/2024/01/xts-0-13-2-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=xts">xts</a> is now on <a href="http://cran.r-project.org/">CRAN</a>. The most notable change is that <code>plot.xts()</code> now supports a log scale y-axis. This involved a significant refactor of the <code>plot.xts()</code> internals, so it&rsquo;s possible to have introduced some bugs.</p>
<h3 id="features">Features</h3>
<ul>
<li>
<p>Add ability to log scale the y-axis in <code>plot.xts()</code>. (<a href="https://github.com/joshuaulrich/xts/issues/103">#103</a>)</p>
</li>
<li>
<p>Significantly refactor the internals of <code>plot.xts()</code>. This made it a lot easier to add the y-axis log scale. (<a href="https://github.com/joshuaulrich/xts/issues/408">#408</a>)</p>
</li>
</ul>
<h3 id="enhancements">Enhancements</h3>
<ul>
<li>
<p>Print a message when <code>period.apply()</code> is called with <code>FUN = mean</code> because it calculates the mean for each column, not all the data in the subset like it does for all other functions. The message says to use <code>FUN = colMeans</code> for current behavior and <code>FUN = function(x) mean(x)</code> to calculate the mean for all the data. This information is also included in the help files. The option <code>xts.message.period.apply.mean = FALSE</code> suppresses the message. (<a href="https://github.com/joshuaulrich/xts/issues/124">#124</a>)</p>
</li>
<li>
<p>Actually change the underlying index values when &rsquo;tclass&rsquo; is changed from a class with a timezone (e.g. POSIXct) to one without a timezone (e.g. Date). Add a warning when this happens, with a global option to always suppress the warning. Thanks to <a href="https://github.com/dppalomar">Daniel Palomar</a> for the report and suggestion! (<a href="https://github.com/joshuaulrich/xts/issues/311">#311</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fix error when <code>print.xts()</code> is called &lsquo;quote&rsquo; or &lsquo;right&rsquo; arguments. Thanks to <a href="https://github.com/WillemMaetens">Willem Maetens</a> for the report and patch! (<a href="https://github.com/joshuaulrich/xts/issues/401">#401</a>)</p>
</li>
<li>
<p>Fix <code>addPolygon()</code> so it renders when <code>observation.based = TRUE</code>. (<a href="https://github.com/joshuaulrich/xts/issues/403">#403</a>)</p>
</li>
<li>
<p>Print trailing zeros for index value with fractional seconds, so every index value has the same number of characters. (<a href="https://github.com/joshuaulrich/xts/issues/404">#404</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176036" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176036" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176037" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176038" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176039" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176039" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176040" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176040" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>. The most notable change is that <code>plot.xts()</code> now supports a log scale y-axis. This involved a significant refactor of the <code>plot.xts()</code> internals, so it&rsquo;s possible to have introduced some bugs.</p>
<h3 id="features">Features</h3>
<ul>
<li>
<p>Add ability to log scale the y-axis in <code>plot.xts()</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/103">#103</a>)</p>
</li>
<li>
<p>Significantly refactor the internals of <code>plot.xts()</code>. This made it a lot easier to add the y-axis log scale. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/408">#408</a>)</p>
</li>
</ul>
<h3 id="enhancements">Enhancements</h3>
<ul>
<li>
<p>Print a message when <code>period.apply()</code> is called with <code>FUN = mean</code> because it calculates the mean for each column, not all the data in the subset like it does for all other functions. The message says to use <code>FUN = colMeans</code> for current behavior and <code>FUN = function(x) mean(x)</code> to calculate the mean for all the data. This information is also included in the help files. The option <code>xts.message.period.apply.mean = FALSE</code> suppresses the message. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/124">#124</a>)</p>
</li>
<li>
<p>Actually change the underlying index values when &rsquo;tclass&rsquo; is changed from a class with a timezone (e.g. POSIXct) to one without a timezone (e.g. Date). Add a warning when this happens, with a global option to always suppress the warning. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/dppalomar">Daniel Palomar</a> for the report and suggestion! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/311">#311</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fix error when <code>print.xts()</code> is called &lsquo;quote&rsquo; or &lsquo;right&rsquo; arguments. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/WillemMaetens">Willem Maetens</a> for the report and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/401">#401</a>)</p>
</li>
<li>
<p>Fix <code>addPolygon()</code> so it renders when <code>observation.based = TRUE</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/403">#403</a>)</p>
</li>
<li>
<p>Print trailing zeros for index value with fractional seconds, so every index value has the same number of characters. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/404">#404</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/864760196/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/864760196/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176036" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176036" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176037" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176038" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176039" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176039" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176040" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176040" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/</feedburner:origLink><title>Adaptive Asset Allocation Extended</title><link>https://feeds.feedblitz.com/~/862590650/0/fosstrading/</link><pubDate>Wed, 17 Jan 2024 13:02:00 -0500</pubDate><guid>https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/</guid><description><![CDATA[<p>This post extends the replication from the <a href="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/">Adaptive Asset Allocation Replication</a> post by running the analysis on OOS (out-of-sample) data from 2015 through 2023. Thanks to <a href="https://www.q36llc.com/">Dale Rosenthal</a> for helpful comments.</p>
<p>The paper uses the 5 portfolios below. Each section of this post will give a short description of the portfolio construction and then focus on comparing the OOS results with the replicated and original results. See the other post for details on the data and portfolio construction methodologies.</p>
<ol>
<li>Equal weight of all asset classes</li>
<li>Equal risk contribution of all asset classes</li>
<li>Equal weight of highest momentum asset classes</li>
<li>Equal risk contribution of highest momentum asset classes</li>
<li>Minimum variance of highest momentum asset classes</li>
</ol>
<p>The table below summarizes the date ranges for each sample period in this post.</p>
<table>
<thead>
<tr>
<th style="text-align: left">Period</th>
<th style="text-align: left">Date Range</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Replication</td>
<td style="text-align: left">Feb 1996 - Dec 2014</td>
</tr>
<tr>
<td style="text-align: left">OOS</td>
<td style="text-align: left">Jan 2015 - Dec 2023</td>
</tr>
<tr>
<td style="text-align: left">2015-2021</td>
<td style="text-align: left">Jan 2015 - Dec 2021</td>
</tr>
<tr>
<td style="text-align: left">Full</td>
<td style="text-align: left">Feb 1996 - Dec 2023</td>
</tr>
</tbody>
</table>
<p>This post uses the <a href="https://github.com/joshuaulrich/ftblog">ftblog</a> package. You can install it using the <code>remotes::install_github()</code> function in the code block below. First we need to setup our environment with the necessary packages, data, and functions.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># remotes::install_github(&#34;joshuaulrich/ftblog&#34;)</span>
</span></span><span class="line"><span class="cl"><span class="nf">suppressPackageStartupMessages</span><span class="p">({</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">ftblog</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">PerformanceAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">aaa_returns</span><span class="p">,</span> <span class="n">package</span> <span class="o">=</span> <span class="s">&#34;ftblog&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">aaa_returns[</span><span class="p">,</span> <span class="m">-1</span><span class="n">]</span> <span class="c1"># no cash</span>
</span></span><span class="line"><span class="cl"><span class="n">r_rep</span> <span class="o">&lt;-</span> <span class="n">returns[</span><span class="s">&#34;/2014&#34;</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="n">r_oos</span> <span class="o">&lt;-</span> <span class="n">returns[</span><span class="s">&#34;2014-07/&#34;</span><span class="n">]</span> <span class="c1"># need 6 months for 120-day lags (this is 128 days)</span>
</span></span><span class="line"><span class="cl"><span class="n">r_full</span> <span class="o">&lt;-</span> <span class="n">returns</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate strategy statistics</span>
</span></span><span class="line"><span class="cl"><span class="n">strat_summary</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="kc">NULL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">table.AnnualizedReturns</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">rbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;Worst Drawdown&#34;</span> <span class="o">=</span> <span class="o">-</span><span class="nf">maxDrawdown</span><span class="p">(</span><span class="n">returns</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="o">!</span><span class="nf">is.null</span><span class="p">(</span><span class="n">original_results</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">cbind</span><span class="p">(</span><span class="n">original_results</span><span class="p">,</span> <span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span><span class="n">[1]</span> <span class="o">&lt;-</span> <span class="s">&#34;Original&#34;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">round</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">return</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">chart_performance</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">R</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">title</span> <span class="o">=</span> <span class="s">&#34;Performance&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">stopifnot</span><span class="p">(</span><span class="nf">all</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">)</span> <span class="o">%in%</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">R</span><span class="p">)))</span>
</span></span><span class="line"><span class="cl"> <span class="n">r</span> <span class="o">&lt;-</span> <span class="n">R[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">)</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">chart.CumReturns</span><span class="p">(</span><span class="n">r</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main.timespan</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">yaxis.right</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addLegend</span><span class="p">(</span><span class="s">&#34;topleft&#34;</span><span class="p">,</span> <span class="n">lty</span> <span class="o">=</span> <span class="m">1</span><span class="p">,</span> <span class="n">lwd</span> <span class="o">=</span> <span class="m">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="n">r[</span><span class="p">,</span><span class="m">1</span><span class="n">]</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Return&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="n">r[</span><span class="p">,</span><span class="m">2</span><span class="n">]</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="n">on</span> <span class="o">=</span> <span class="m">0</span><span class="p">,</span> <span class="n">col</span> <span class="o">=</span> <span class="s">&#34;red&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="nf">Drawdowns</span><span class="p">(</span><span class="n">r</span><span class="p">),</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Drawdown&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><h3 id="1-equal-weight-portfolio-of-all-asset-classes">1. Equal weight portfolio of all asset classes</h3>
<p>This portfolio assumes no knowledge of expected relative asset class performance, risk, or correlation. It holds each asset class in equal weight and is rebalanced monthly.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns[</span><span class="s">&#34;/2014&#34;</span><span class="n">]</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="n">Replication</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">OOS</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;2015-2021&#34;</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_weight[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">Full</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">check.names</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;All Assets - Equal Weight&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/862590650/0/fosstrading/equal_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.049</td>
<td style="text-align: right">0.072</td>
<td style="text-align: right">0.069</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.107</td>
<td style="text-align: right">0.091</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">0.456</td>
<td style="text-align: right">0.794</td>
<td style="text-align: right">0.614</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.210</td>
<td style="text-align: right">-0.136</td>
<td style="text-align: right">-0.377</td>
</tr>
</tbody>
</table>
<p>The OOS annualized return is significantly less than the prior results. This is largely due to the -21.0% drawdown that started in 2022 and is still ongoing. Note that the full-period results are very similar to the replication results, though the 2022 drawdown did decrease the annualized return by ~1%.</p>
<p>Note that this portfolio&rsquo;s results from 2015-2021 are very similar to the replication results through the end of 2014. That suggests the 2022 bear market is the main cause for the lower return in the OOS results.</p>
<h3 id="2-equal-risk-contribution-using-all-asset-classes">2. Equal risk contribution using all asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s risk, but still no knowledge of relative performance or correlations. So each asset in this portfolio is given a weight proportional to its historical relative risk, with the hope that each asset will contribute the same amount of risk to the overall portfolio in the future.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_equal_risk</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_risk[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_risk[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_equal_risk</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;All Assets - Equal Risk&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/862590650/0/fosstrading/equal_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.034</td>
<td style="text-align: right">0.056</td>
<td style="text-align: right">0.069</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.061</td>
<td style="text-align: right">0.076</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">0.411</td>
<td style="text-align: right">0.908</td>
<td style="text-align: right">0.903</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.194</td>
<td style="text-align: right">-0.071</td>
<td style="text-align: right">-0.194</td>
</tr>
</tbody>
</table>
<p>Like the equal weight portfolio, this portfolio&rsquo;s OOS annualized return is significantly lower than the replication results. This methodology only slightly reduced the 2022 drawdown to -19.4% from -21.0%. The maximum drawdown is now in 2022 instead of during the 2008 financial crisis.</p>
<p>In the replication, the equal risk contribution portfolio results are better than the equal weight portfolio, but the OOS equal risk portfolio did not show similar improvement. Even when 2022 is excluded, the OOS equal risk portfolio didn&rsquo;t show improvement over the equal weight portfolio.</p>
<h3 id="3-equal-weight-portfolio-of-highest-momentum-asset-classes">3. Equal weight portfolio of highest momentum asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s returns, but still no knowledge of risk or correlations. Asset returns are based on 6-month momentum (approximately 120 days). Momentum is re-estimated every month and only the top 5 assets are included in the portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_eq_wt</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_wt[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_wt[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_eq_wt</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Top 5 Momentum Assets - Equal Weight&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/862590650/0/fosstrading/top5_momo_eq_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.051</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.104</td>
<td style="text-align: right">0.092</td>
<td style="text-align: right">0.111</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">0.488</td>
<td style="text-align: right">0.884</td>
<td style="text-align: right">1.001</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.213</td>
<td style="text-align: right">-0.114</td>
<td style="text-align: right">-0.213</td>
</tr>
</tbody>
</table>
<p>Again, the OOS annualized return is significantly worse than the replicated results. The OOS results for this portfolio show improvement in the Sharpe Ratio versus the equal risk contribution portfolio (2). The replicated results for this portfolio showed similar improvements versus portfolio (2).</p>
<p>In the replication, equal weight momentum results are better than the equal risk portfolio. But the OOS equal weight momentum portfolio did not show significant improvement versus the equal risk portfolio (2), and is roughly the same as the equal weight portfolio (1).</p>
<h3 id="4-equal-risk-contribution-portfolio-of-highest-momentum-asset-classes">4. Equal risk contribution portfolio of highest momentum asset classes</h3>
<p>The previous two portfolios estimated asset weights using either risk-based or momentum-based weights. This next portfolio combines estimates of momentum-based performance and accounts for asset class risk differences. It includes the top 5 asset classes based on 6-month returns and weights them using the same equal risk contribution method as portfolio (2).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_eq_risk</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_risk[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_risk[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_eq_risk</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Top 5 Momentum Assets - Equal Risk&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/862590650/0/fosstrading/top_momo_eq_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.050</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.108</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.100</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">0.528</td>
<td style="text-align: right">0.991</td>
<td style="text-align: right">1.076</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.204</td>
<td style="text-align: right">-0.086</td>
<td style="text-align: right">-0.204</td>
</tr>
</tbody>
</table>
<p>It&rsquo;s clear that the major cause of the poorer OOS performance of this portfolio is due to how it handled the 2022 bear market. This portfolio handled the 2008 financial crisis very well, but it offered almost no protection in 2022. This indicates there was a fundamental difference in 2008 versus 2022 in the asset classes held by this portfolio.</p>
<p>Similar to the replicated results, the reduction in risk is the main benefit of this portfolio versus the equal weight momentum portfolio (3). That said, the OOS performance of this portfolio only showed marginal improvement versus portfolio (3). Even more notable, this portfolio didn&rsquo;t improve returns versus the simple equal weight portfolio (1) during the OOS period like it did for the replication period.</p>
<h3 id="5-minimum-variance-portfolio-of-highest-momentum-asset-classes">5. Minimum variance portfolio of highest momentum asset classes</h3>
<p>The final portfolio takes the above concepts and adds correlation estimates to the portfolio optimization. The previous portfolios only accounted for the relative risk between the asset classes, but not the correlation between the assets&rsquo; returns. This portfolio accounts for the correlations between asset classes by finding the minimum variance portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_min_var</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_min_var[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_min_var[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_min_var</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Above Average 6mo Momentum - Min Var&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/862590650/0/fosstrading/top_momo_min_var-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.130</td>
<td style="text-align: right">0.058</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.106</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.099</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.098</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.315</td>
<td style="text-align: right">0.612</td>
<td style="text-align: right">1.008</td>
<td style="text-align: right">1.086</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.112</td>
<td style="text-align: right">-0.162</td>
<td style="text-align: right">-0.083</td>
<td style="text-align: right">-0.162</td>
</tr>
</tbody>
</table>
<p>Recall that the original results for portfolio (5) showed improved return and lower maximum drawdown versus portfolio (4), while the replicated results were almost the same for both portfolios. The OOS results for these two portfolios are also very similar. In the 2015-2021 period, portfolio (5) has a slightly higher return and Sharpe ratio and lower max drawdown than portfolio (4).</p>
<h2 id="conclusion">Conclusion</h2>
<p>For all 5 portfolios, the OOS results are not as good as the replicated results. This is largely due to the 2022 bear market, but the 2015-2021 results still aren&rsquo;t as good as the replicated results.</p>
<p><a href="https://allocatesmartly.com/tactical-asset-allocation-performance-during-the-2022-bear-market/">Allocate Smartly</a> has a great post about 2022 bear market performance of tactical asset allocation (TAA) strategies like this one. They find that TAA strategies did poorly in the 2022 bear market if they assumed intermediate and long-term bonds provide diversification from risky assets. Both risk assets and longer duration bonds performed poorly in 2022, and the correlation between bonds and equities was positive instead of negative like they have been historically.</p>
<p>In a future post, I may investigate how these portfolios would have performed if they were allowed to allocate to short-term Treasuries.</p>
<h3 id="portfolio-results-by-sample-period">Portfolio Results by Sample Period</h3>
<p>This section contains tables with results for all portfolios in a particular sample period.</p>
<h5 id="replication-period">Replication Period</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.130</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.099</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">1.315</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.112</td>
</tr>
</tbody>
</table>
<h5 id="out-of-sample-2015-2023">Out-of-Sample: 2015-2023</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.049</td>
<td style="text-align: right">0.034</td>
<td style="text-align: right">0.051</td>
<td style="text-align: right">0.050</td>
<td style="text-align: right">0.058</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.107</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.104</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.095</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.456</td>
<td style="text-align: right">0.411</td>
<td style="text-align: right">0.488</td>
<td style="text-align: right">0.528</td>
<td style="text-align: right">0.612</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.210</td>
<td style="text-align: right">-0.194</td>
<td style="text-align: right">-0.213</td>
<td style="text-align: right">-0.204</td>
<td style="text-align: right">-0.162</td>
</tr>
</tbody>
</table>
<h5 id="out-of-sample-2015-2021">Out-of-Sample: 2015-2021</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.072</td>
<td style="text-align: right">0.056</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.082</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.091</td>
<td style="text-align: right">0.061</td>
<td style="text-align: right">0.092</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.081</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.794</td>
<td style="text-align: right">0.908</td>
<td style="text-align: right">0.884</td>
<td style="text-align: right">0.991</td>
<td style="text-align: right">1.008</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.136</td>
<td style="text-align: right">-0.071</td>
<td style="text-align: right">-0.114</td>
<td style="text-align: right">-0.086</td>
<td style="text-align: right">-0.083</td>
</tr>
</tbody>
</table><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176041" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176041" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176042" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176043" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176044" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176044" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176045" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176045" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This post extends the replication from the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/">Adaptive Asset Allocation Replication</a> post by running the analysis on OOS (out-of-sample) data from 2015 through 2023. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.q36llc.com/">Dale Rosenthal</a> for helpful comments.</p>
<p>The paper uses the 5 portfolios below. Each section of this post will give a short description of the portfolio construction and then focus on comparing the OOS results with the replicated and original results. See the other post for details on the data and portfolio construction methodologies.</p>
<ol>
<li>Equal weight of all asset classes</li>
<li>Equal risk contribution of all asset classes</li>
<li>Equal weight of highest momentum asset classes</li>
<li>Equal risk contribution of highest momentum asset classes</li>
<li>Minimum variance of highest momentum asset classes</li>
</ol>
<p>The table below summarizes the date ranges for each sample period in this post.</p>
<table>
<thead>
<tr>
<th style="text-align: left">Period</th>
<th style="text-align: left">Date Range</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Replication</td>
<td style="text-align: left">Feb 1996 - Dec 2014</td>
</tr>
<tr>
<td style="text-align: left">OOS</td>
<td style="text-align: left">Jan 2015 - Dec 2023</td>
</tr>
<tr>
<td style="text-align: left">2015-2021</td>
<td style="text-align: left">Jan 2015 - Dec 2021</td>
</tr>
<tr>
<td style="text-align: left">Full</td>
<td style="text-align: left">Feb 1996 - Dec 2023</td>
</tr>
</tbody>
</table>
<p>This post uses the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/ftblog">ftblog</a> package. You can install it using the <code>remotes::install_github()</code> function in the code block below. First we need to setup our environment with the necessary packages, data, and functions.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># remotes::install_github(&#34;joshuaulrich/ftblog&#34;)</span>
</span></span><span class="line"><span class="cl"><span class="nf">suppressPackageStartupMessages</span><span class="p">({</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">ftblog</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">PerformanceAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">aaa_returns</span><span class="p">,</span> <span class="n">package</span> <span class="o">=</span> <span class="s">&#34;ftblog&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">aaa_returns[</span><span class="p">,</span> <span class="m">-1</span><span class="n">]</span> <span class="c1"># no cash</span>
</span></span><span class="line"><span class="cl"><span class="n">r_rep</span> <span class="o">&lt;-</span> <span class="n">returns[</span><span class="s">&#34;/2014&#34;</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="n">r_oos</span> <span class="o">&lt;-</span> <span class="n">returns[</span><span class="s">&#34;2014-07/&#34;</span><span class="n">]</span> <span class="c1"># need 6 months for 120-day lags (this is 128 days)</span>
</span></span><span class="line"><span class="cl"><span class="n">r_full</span> <span class="o">&lt;-</span> <span class="n">returns</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate strategy statistics</span>
</span></span><span class="line"><span class="cl"><span class="n">strat_summary</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="kc">NULL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">table.AnnualizedReturns</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">rbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;Worst Drawdown&#34;</span> <span class="o">=</span> <span class="o">-</span><span class="nf">maxDrawdown</span><span class="p">(</span><span class="n">returns</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="o">!</span><span class="nf">is.null</span><span class="p">(</span><span class="n">original_results</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">cbind</span><span class="p">(</span><span class="n">original_results</span><span class="p">,</span> <span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span><span class="n">[1]</span> <span class="o">&lt;-</span> <span class="s">&#34;Original&#34;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">round</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">return</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">chart_performance</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">R</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">title</span> <span class="o">=</span> <span class="s">&#34;Performance&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">stopifnot</span><span class="p">(</span><span class="nf">all</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">)</span> <span class="o">%in%</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">R</span><span class="p">)))</span>
</span></span><span class="line"><span class="cl"> <span class="n">r</span> <span class="o">&lt;-</span> <span class="n">R[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">)</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">chart.CumReturns</span><span class="p">(</span><span class="n">r</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main.timespan</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">yaxis.right</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addLegend</span><span class="p">(</span><span class="s">&#34;topleft&#34;</span><span class="p">,</span> <span class="n">lty</span> <span class="o">=</span> <span class="m">1</span><span class="p">,</span> <span class="n">lwd</span> <span class="o">=</span> <span class="m">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="n">r[</span><span class="p">,</span><span class="m">1</span><span class="n">]</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Return&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="n">r[</span><span class="p">,</span><span class="m">2</span><span class="n">]</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;h&#34;</span><span class="p">,</span> <span class="n">on</span> <span class="o">=</span> <span class="m">0</span><span class="p">,</span> <span class="n">col</span> <span class="o">=</span> <span class="s">&#34;red&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span> <span class="o">&lt;-</span> <span class="nf">addSeries</span><span class="p">(</span><span class="nf">Drawdowns</span><span class="p">(</span><span class="n">r</span><span class="p">),</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Drawdown&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">p</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><h3 id="1-equal-weight-portfolio-of-all-asset-classes">1. Equal weight portfolio of all asset classes</h3>
<p>This portfolio assumes no knowledge of expected relative asset class performance, risk, or correlation. It holds each asset class in equal weight and is rebalanced monthly.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns[</span><span class="s">&#34;/2014&#34;</span><span class="n">]</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_equal_weight</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="n">Replication</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">OOS</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;2015-2021&#34;</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_weight[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">Full</span> <span class="o">=</span> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_equal_weight</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">check.names</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;All Assets - Equal Weight&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/equal_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.049</td>
<td style="text-align: right">0.072</td>
<td style="text-align: right">0.069</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.107</td>
<td style="text-align: right">0.091</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">0.456</td>
<td style="text-align: right">0.794</td>
<td style="text-align: right">0.614</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.210</td>
<td style="text-align: right">-0.136</td>
<td style="text-align: right">-0.377</td>
</tr>
</tbody>
</table>
<p>The OOS annualized return is significantly less than the prior results. This is largely due to the -21.0% drawdown that started in 2022 and is still ongoing. Note that the full-period results are very similar to the replication results, though the 2022 drawdown did decrease the annualized return by ~1%.</p>
<p>Note that this portfolio&rsquo;s results from 2015-2021 are very similar to the replication results through the end of 2014. That suggests the 2022 bear market is the main cause for the lower return in the OOS results.</p>
<h3 id="2-equal-risk-contribution-using-all-asset-classes">2. Equal risk contribution using all asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s risk, but still no knowledge of relative performance or correlations. So each asset in this portfolio is given a weight proportional to its historical relative risk, with the hope that each asset will contribute the same amount of risk to the overall portfolio in the future.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_equal_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_equal_risk</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_risk[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_equal_risk[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_equal_risk</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;All Assets - Equal Risk&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/equal_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.034</td>
<td style="text-align: right">0.056</td>
<td style="text-align: right">0.069</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.061</td>
<td style="text-align: right">0.076</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">0.411</td>
<td style="text-align: right">0.908</td>
<td style="text-align: right">0.903</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.194</td>
<td style="text-align: right">-0.071</td>
<td style="text-align: right">-0.194</td>
</tr>
</tbody>
</table>
<p>Like the equal weight portfolio, this portfolio&rsquo;s OOS annualized return is significantly lower than the replication results. This methodology only slightly reduced the 2022 drawdown to -19.4% from -21.0%. The maximum drawdown is now in 2022 instead of during the 2008 financial crisis.</p>
<p>In the replication, the equal risk contribution portfolio results are better than the equal weight portfolio, but the OOS equal risk portfolio did not show similar improvement. Even when 2022 is excluded, the OOS equal risk portfolio didn&rsquo;t show improvement over the equal weight portfolio.</p>
<h3 id="3-equal-weight-portfolio-of-highest-momentum-asset-classes">3. Equal weight portfolio of highest momentum asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s returns, but still no knowledge of risk or correlations. Asset returns are based on 6-month momentum (approximately 120 days). Momentum is re-estimated every month and only the top 5 assets are included in the portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_eq_wt</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_eq_wt</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_wt[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_wt[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_eq_wt</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Top 5 Momentum Assets - Equal Weight&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/top5_momo_eq_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.051</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.104</td>
<td style="text-align: right">0.092</td>
<td style="text-align: right">0.111</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">0.488</td>
<td style="text-align: right">0.884</td>
<td style="text-align: right">1.001</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.213</td>
<td style="text-align: right">-0.114</td>
<td style="text-align: right">-0.213</td>
</tr>
</tbody>
</table>
<p>Again, the OOS annualized return is significantly worse than the replicated results. The OOS results for this portfolio show improvement in the Sharpe Ratio versus the equal risk contribution portfolio (2). The replicated results for this portfolio showed similar improvements versus portfolio (2).</p>
<p>In the replication, equal weight momentum results are better than the equal risk portfolio. But the OOS equal weight momentum portfolio did not show significant improvement versus the equal risk portfolio (2), and is roughly the same as the equal weight portfolio (1).</p>
<h3 id="4-equal-risk-contribution-portfolio-of-highest-momentum-asset-classes">4. Equal risk contribution portfolio of highest momentum asset classes</h3>
<p>The previous two portfolios estimated asset weights using either risk-based or momentum-based weights. This next portfolio combines estimates of momentum-based performance and accounts for asset class risk differences. It includes the top 5 asset classes based on 6-month returns and weights them using the same equal risk contribution method as portfolio (2).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_eq_risk</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_eq_risk</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_risk[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_eq_risk[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_eq_risk</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Top 5 Momentum Assets - Equal Risk&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/top_momo_eq_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.050</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.108</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.100</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">0.528</td>
<td style="text-align: right">0.991</td>
<td style="text-align: right">1.076</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.204</td>
<td style="text-align: right">-0.086</td>
<td style="text-align: right">-0.204</td>
</tr>
</tbody>
</table>
<p>It&rsquo;s clear that the major cause of the poorer OOS performance of this portfolio is due to how it handled the 2022 bear market. This portfolio handled the 2008 financial crisis very well, but it offered almost no protection in 2022. This indicates there was a fundamental difference in 2008 versus 2022 in the asset classes held by this portfolio.</p>
<p>Similar to the replicated results, the reduction in risk is the main benefit of this portfolio versus the equal weight momentum portfolio (3). That said, the OOS performance of this portfolio only showed marginal improvement versus portfolio (3). Even more notable, this portfolio didn&rsquo;t improve returns versus the simple equal weight portfolio (1) during the OOS period like it did for the replication period.</p>
<h3 id="5-minimum-variance-portfolio-of-highest-momentum-asset-classes">5. Minimum variance portfolio of highest momentum asset classes</h3>
<p>The final portfolio takes the above concepts and adds correlation estimates to the portfolio optimization. The previous portfolios only accounted for the relative risk between the asset classes, but not the correlation between the assets&rsquo; returns. This portfolio accounts for the correlations between asset classes by finding the minimum variance portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rr_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_rep</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">ro_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_oos</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rf_momo_min_var</span> <span class="o">&lt;-</span> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">r_full</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">monthly_returns</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">merge</span><span class="p">(</span><span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rr_momo_min_var</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_min_var[</span><span class="s">&#34;2015/&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">ro_momo_min_var[</span><span class="s">&#34;2015/2021&#34;</span><span class="n">]</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">(</span><span class="n">rf_momo_min_var</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;Replication&#34;</span><span class="p">,</span> <span class="s">&#34;OOS&#34;</span><span class="p">,</span> <span class="s">&#34;2015-2021&#34;</span><span class="p">,</span> <span class="s">&#34;Full&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">chart_performance</span><span class="p">(</span><span class="n">monthly_returns</span><span class="p">,</span> <span class="s">&#34;Above Average 6mo Momentum - Min Var&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/top_momo_min_var-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">OOS</th>
<th style="text-align: right">2015-2021</th>
<th style="text-align: right">Full</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.130</td>
<td style="text-align: right">0.058</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.106</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.099</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.098</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.315</td>
<td style="text-align: right">0.612</td>
<td style="text-align: right">1.008</td>
<td style="text-align: right">1.086</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.112</td>
<td style="text-align: right">-0.162</td>
<td style="text-align: right">-0.083</td>
<td style="text-align: right">-0.162</td>
</tr>
</tbody>
</table>
<p>Recall that the original results for portfolio (5) showed improved return and lower maximum drawdown versus portfolio (4), while the replicated results were almost the same for both portfolios. The OOS results for these two portfolios are also very similar. In the 2015-2021 period, portfolio (5) has a slightly higher return and Sharpe ratio and lower max drawdown than portfolio (4).</p>
<h2 id="conclusion">Conclusion</h2>
<p>For all 5 portfolios, the OOS results are not as good as the replicated results. This is largely due to the 2022 bear market, but the 2015-2021 results still aren&rsquo;t as good as the replicated results.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://allocatesmartly.com/tactical-asset-allocation-performance-during-the-2022-bear-market/">Allocate Smartly</a> has a great post about 2022 bear market performance of tactical asset allocation (TAA) strategies like this one. They find that TAA strategies did poorly in the 2022 bear market if they assumed intermediate and long-term bonds provide diversification from risky assets. Both risk assets and longer duration bonds performed poorly in 2022, and the correlation between bonds and equities was positive instead of negative like they have been historically.</p>
<p>In a future post, I may investigate how these portfolios would have performed if they were allowed to allocate to short-term Treasuries.</p>
<h3 id="portfolio-results-by-sample-period">Portfolio Results by Sample Period</h3>
<p>This section contains tables with results for all portfolios in a particular sample period.</p>
<h5 id="replication-period">Replication Period</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.130</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.099</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">1.315</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.112</td>
</tr>
</tbody>
</table>
<h5 id="out-of-sample-2015-2023">Out-of-Sample: 2015-2023</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.049</td>
<td style="text-align: right">0.034</td>
<td style="text-align: right">0.051</td>
<td style="text-align: right">0.050</td>
<td style="text-align: right">0.058</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.107</td>
<td style="text-align: right">0.082</td>
<td style="text-align: right">0.104</td>
<td style="text-align: right">0.095</td>
<td style="text-align: right">0.095</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.456</td>
<td style="text-align: right">0.411</td>
<td style="text-align: right">0.488</td>
<td style="text-align: right">0.528</td>
<td style="text-align: right">0.612</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.210</td>
<td style="text-align: right">-0.194</td>
<td style="text-align: right">-0.213</td>
<td style="text-align: right">-0.204</td>
<td style="text-align: right">-0.162</td>
</tr>
</tbody>
</table>
<h5 id="out-of-sample-2015-2021">Out-of-Sample: 2015-2021</h5>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Equal Weight</th>
<th style="text-align: right">Equal Risk</th>
<th style="text-align: right">Momo Eq Weight</th>
<th style="text-align: right">Momo Eq Risk</th>
<th style="text-align: right">Momo Min Var</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Ann. Return</td>
<td style="text-align: right">0.072</td>
<td style="text-align: right">0.056</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.082</td>
</tr>
<tr>
<td style="text-align: left">Ann. Std Dev</td>
<td style="text-align: right">0.091</td>
<td style="text-align: right">0.061</td>
<td style="text-align: right">0.092</td>
<td style="text-align: right">0.081</td>
<td style="text-align: right">0.081</td>
</tr>
<tr>
<td style="text-align: left">Ann. Sharpe</td>
<td style="text-align: right">0.794</td>
<td style="text-align: right">0.908</td>
<td style="text-align: right">0.884</td>
<td style="text-align: right">0.991</td>
<td style="text-align: right">1.008</td>
</tr>
<tr>
<td style="text-align: left">Max Drawdown</td>
<td style="text-align: right">-0.136</td>
<td style="text-align: right">-0.071</td>
<td style="text-align: right">-0.114</td>
<td style="text-align: right">-0.086</td>
<td style="text-align: right">-0.083</td>
</tr>
</tbody>
</table><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/862590650/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/862590650/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176041" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176041" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176042" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176043" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176044" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176044" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176045" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176045" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/</feedburner:origLink><title>Adaptive Asset Allocation Replication</title><link>https://feeds.feedblitz.com/~/848510933/0/fosstrading/</link><pubDate>Fri, 08 Dec 2023 13:00:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/</guid><description><![CDATA[<p>The paper, <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2328254">&ldquo;Adaptive Asset Allocation: A Primer&rdquo;</a> by Adam Butler, Mike Philbrick, Rodrigo Gordillo, and David Varadi addresses flaws in the traditional application of Modern Portfolio Theory related to Strategic Asset Allocation. It shows that estimating return and (co)variance parameters over shorter time horizons are superior to estimates over long-term horizons because parameter estimates vary substantially over time. Longer-term estimates do not account for this variability in the short-term. They propose an Adaptive Asset Allocation portfolio construction methodology that uses the new parameter estimates to substantially improve performance relative to Strategic Asset Allocation.</p>
<h1 id="data">Data</h1>
<p>The original paper creates portfolios from 10 major global asset classes using data between 1995 and 2014. It uses ETFs when possible, and uses passive no-load mutual funds, underlying indexes, and no-load active mutual funds as proxies for asset class returns prior to ETF inception. The paper doesn&rsquo;t list the actual instruments used at each point in time, so this post attempts to replicate their described methodology using publicly available data.</p>
<p>The table below shows the asset class, instruments, and time horizons used for each asset class in this replication. The data start in late 1997 instead of 1995 as in the original paper. Returns in this analysis are adjusted for splits and dividends.</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: left">ETF</th>
<th style="text-align: left">ETF Start</th>
<th style="text-align: left">Fund</th>
<th style="text-align: left">Fund Start</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">US Equity</td>
<td style="text-align: left">VTI</td>
<td style="text-align: left">2001-05</td>
<td style="text-align: left">VTSMX</td>
<td style="text-align: left">1992-04</td>
</tr>
<tr>
<td style="text-align: left">European Equity</td>
<td style="text-align: left">VGK</td>
<td style="text-align: left">2005-03</td>
<td style="text-align: left">VEURX</td>
<td style="text-align: left">1990-06</td>
</tr>
<tr>
<td style="text-align: left">Japanese Equity</td>
<td style="text-align: left">EWJ</td>
<td style="text-align: left">1996-03</td>
<td style="text-align: left">FJPNX</td>
<td style="text-align: left">1992-12</td>
</tr>
<tr>
<td style="text-align: left">Emerging Market Equity</td>
<td style="text-align: left">EEM</td>
<td style="text-align: left">2003-04</td>
<td style="text-align: left">VEIEX</td>
<td style="text-align: left">1994-12</td>
</tr>
<tr>
<td style="text-align: left">US Real Estate</td>
<td style="text-align: left">ICF</td>
<td style="text-align: left">2001-02</td>
<td style="text-align: left">VGSIX</td>
<td style="text-align: left">1996-05</td>
</tr>
<tr>
<td style="text-align: left">International Real Estate</td>
<td style="text-align: left">RWX</td>
<td style="text-align: left">2006-12</td>
<td style="text-align: left">XRFIX</td>
<td style="text-align: left">1997-09</td>
</tr>
<tr>
<td style="text-align: left">Intermediate Term Treasury</td>
<td style="text-align: left">IEF</td>
<td style="text-align: left">2002-07</td>
<td style="text-align: left">VFITX</td>
<td style="text-align: left">1991-12</td>
</tr>
<tr>
<td style="text-align: left">Long Term Treasury</td>
<td style="text-align: left">TLT</td>
<td style="text-align: left">2002-07</td>
<td style="text-align: left">VUSTX</td>
<td style="text-align: left">1986-12</td>
</tr>
<tr>
<td style="text-align: left">Commodities</td>
<td style="text-align: left">DBC</td>
<td style="text-align: left">2006-02</td>
<td style="text-align: left">QRACX</td>
<td style="text-align: left">1997-03</td>
</tr>
<tr>
<td style="text-align: left">Gold</td>
<td style="text-align: left">GLD</td>
<td style="text-align: left">2004-11</td>
<td style="text-align: left">SGGDX</td>
<td style="text-align: left">1993-08</td>
</tr>
</tbody>
</table>
<p>This post uses the <a href="https://github.com/joshuaulrich/ftblog">ftblog</a> package. You can install it using the <code>remotes::install_github()</code> function in the code block below. First we need to setup our environment with the necessary packages, data, and functions.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># remotes::install_github(&#34;joshuaulrich/ftblog&#34;)</span>
</span></span><span class="line"><span class="cl"><span class="nf">suppressPackageStartupMessages</span><span class="p">({</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">ftblog</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">PerformanceAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">aaa_returns</span><span class="p">,</span> <span class="n">package</span> <span class="o">=</span> <span class="s">&#34;ftblog&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># Only use data through the end of 2014, and no cash</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">aaa_returns[</span><span class="s">&#34;/2014&#34;</span><span class="p">,</span> <span class="m">-1</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate strategy statistics</span>
</span></span><span class="line"><span class="cl"><span class="n">strat_summary</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="kc">NULL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">table.AnnualizedReturns</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">rbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;Worst Drawdown&#34;</span> <span class="o">=</span> <span class="o">-</span><span class="nf">maxDrawdown</span><span class="p">(</span><span class="n">returns</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="s">&#34;Replication&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="o">!</span><span class="nf">is.null</span><span class="p">(</span><span class="n">original_results</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">cbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="n">original_results</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span><span class="n">[2]</span> <span class="o">&lt;-</span> <span class="s">&#34;Original&#34;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">round</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">return</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><h1 id="replication">Replication</h1>
<p>This analysis attempts to replicate all 5 portfolios in the original paper.</p>
<ol>
<li>Equal weight of all asset classes</li>
<li>Equal risk contribution of all asset classes</li>
<li>Equal weight of highest momentum asset classes</li>
<li>Equal risk contribution of highest momentum asset classes</li>
<li>Minimum variance of highest momentum asset classes</li>
</ol>
<p>The original paper showed results as a monthly series. The <code>to_monthly_returns()</code> function converts the strategy returns from daily to monthly. The <code>strat_summary()</code> function uses the <a href="https://cran.r-project.org/package=PerformanceAnalytics">PerformanceAnalytics</a> package to calculate summary statistics to compare with the original paper. The file <a href="https://feeds.feedblitz.com/~/848510933/0/fosstrading/adaptive-asset-allocation-replication.R">adaptive-asset-allocation-replication.R</a> contains all the code used in this analysis, and the <a href="https://feeds.feedblitz.com/~/848510933/0/fosstrading/returns.rds">returns.rds</a> function contains the data.</p>
<h3 id="1-equal-weight-portfolio-of-all-asset-classes">1. Equal weight portfolio of all asset classes</h3>
<p>The baseline example assumes no knowledge of expected relative asset class performance, risk, or correlation. The results below are based on a portfolio that holds each asset class in equal weight and is rebalanced monthly. The table compares the results of this replication with the original results. Some of the difference in results are due to the different instruments and time frames used for the analysis. Despite the differences in the data between the two approaches, the results are very similar.</p>
<p>The <code>returns_equal_weight</code> object contains the portfolio returns for each day. Then we convert those returns to monthly and evaluate the portfolio results.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_equal_weight</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;All Assets - Equal Weight&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_equal_weight</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.081</span><span class="p">,</span> <span class="m">0.112</span><span class="p">,</span> <span class="m">0.72</span><span class="p">,</span> <span class="m">-0.392</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_equal_weight</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/848510933/0/fosstrading/equal_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.081</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">0.720</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.392</td>
</tr>
</tbody>
</table>
<h3 id="2-equal-risk-contribution-using-all-asset-classes">2. Equal risk contribution using all asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s risk, but still no knowledge of relative performance or correlations. So each asset in this portfolio is given a weight proportional to its relative risk, and each asset contributes the same amount of risk to the overall portfolio. That way no asset&rsquo;s risk will dominate the risk of the overall portfolio.</p>
<p>The <code>portf_return_equal_risk()</code> estimates the equal risk contribution portfolio using the <code>PERC()</code> function from the <a href="https://cran.r-project.org/package=FRAPO">FRAPO</a> package. It calculates the portfolio weights at the end of month using estimated portfolio risk from the returns over the last 60 days. Then those weights are used to calculate the portfolio returns for the following month.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_equal_risk</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;All Assets - Equal Risk Contribution&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_equal_risk</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.085</span><span class="p">,</span> <span class="m">0.086</span><span class="p">,</span> <span class="m">0.99</span><span class="p">,</span> <span class="m">-0.242</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_equal_risk</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/848510933/0/fosstrading/equal_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.085</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.086</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">0.990</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.242</td>
</tr>
</tbody>
</table>
<p>In this case, the replicated results are better than the original results. The data differences and the method used to estimate the equal risk contribution portfolio weights are the most likely explanation for the differences in the replicated results.</p>
<h3 id="3-equal-weight-portfolio-of-highest-momentum-asset-classes">3. Equal weight portfolio of highest momentum asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s returns, but still no knowledge of risk or correlations. The original paper uses momentum to estimate each asset&rsquo;s returns because momentum (also known as long-term memory) is a well-known property of financial market returns. Assets that have increased (decreased) in price are likely to continue increasing (decreasing) in price in the next period. Academic research shows that instruments with higher (lower) momentum over the past 1-12 months exhibits better (worse) performance over short-term future periods. See the original paper for a description of some reasons why momentum exists in financial markets.</p>
<p>The estimates of each asset&rsquo;s returns are based on 6-month momentum (approximately 120 days). Momentum is re-estimated every month and only the top 5 assets are included in the portfolio, rather than including every asset in the portfolio. Note that this doesn&rsquo;t mean every asset included in the portfolio has a positive return over the 6-month period. All of them could have negative returns over the period, in which case the 5 assets with the smallest losses would be included in the portfolio. Each of the top 5 assets included in the portfolio are held with equal weight.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_equal_weight</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Top 5 Assets by 6-month Momentum - Equal Weight&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_equal_weight</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.130</span><span class="p">,</span> <span class="m">0.110</span><span class="p">,</span> <span class="m">1.17</span><span class="p">,</span> <span class="m">-0.217</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_equal_weight</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/848510933/0/fosstrading/top5_momo_eq_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.130</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.110</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">1.170</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.217</td>
</tr>
</tbody>
</table>
<p>The replicated results have slightly better returns and maximum drawdown, but similar standard deviation. That said, the results are similar enough to suggest this analysis replicates the approach accurately.</p>
<h3 id="4-equal-risk-contribution-portfolio-of-highest-momentum-asset-classes">4. Equal risk contribution portfolio of highest momentum asset classes</h3>
<p>The previous two portfolios estimated asset weights using either risk-based or momentum-based weights. This next portfolio combines estimates of momentum-based performance and accounts for asset class risk differences. It includes the top 5 asset classes based on 6-month returns and weights them using the <code>estimate_equal_risk_portf()</code> function defined earlier. Recall that the function weights each asset class so they each contribute the same amount of risk to the portfolio. Note that the asset volatilities are calculated on 60 days (approximately 3 months) of returns while the momentum is based on 120 days (approximately 6 months).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_equal_risk</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Top 5 Assets by 6-month Momentum - Equal Risk Contribution&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_equal_risk</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.140</span><span class="p">,</span> <span class="m">0.099</span><span class="p">,</span> <span class="m">1.41</span><span class="p">,</span> <span class="m">-0.148</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_equal_risk</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/848510933/0/fosstrading/top_momo_eq_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.140</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.099</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">1.410</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.148</td>
</tr>
</tbody>
</table>
<p>The original and replicated results for this portfolio are very similar. Note that in the original paper this portfolio&rsquo;s overall return increased to 14.0% versus 13.0% for the momentum-based equal weight portfolio, but the replicated results were more similar (14.2% versus 13.7%). Again, the data differences and portfolio weight estimation differences likely cause differences in the results. Also, an un-scientific comparison of the two cumulative return graphs suggests some difference may be due to performance in 2012, when the replicated results have a significant drawdown while the original results showed positive performance.</p>
<h3 id="5-minimum-variance-portfolio-of-highest-momentum-asset-classes">5. Minimum variance portfolio of highest momentum asset classes</h3>
<p>The final portfolio takes the above concepts and adds correlation estimates to the portfolio optimization. The previous portfolios only accounted for the relative risk between the asset classes, but not the correlation between the assets&rsquo; returns. This portfolio accounts for the correlations between asset classes by finding the minimum variance portfolio using <a href="https://en.wikipedia.org/wiki/Modern_portfolio_theory">modern portfolio theory</a>. The asset selection for these portfolios in the original paper differ slightly from the previous portfolios. Instead of taking the top 5 assets with the highest momentum, the original paper selects &ldquo;assets with above average 6-month momentum&rdquo;. So it&rsquo;s not clear how many assets are held in the portfolio each month.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_min_var</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Assets With Above Average 6-month Momentum - Minimum Variance&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_min_var</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.150</span><span class="p">,</span> <span class="m">0.094</span><span class="p">,</span> <span class="m">1.60</span><span class="p">,</span> <span class="m">-0.088</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_min_var</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://feeds.feedblitz.com/~/848510933/0/fosstrading/top_momo_min_var-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.130</td>
<td style="text-align: right">0.150</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.099</td>
<td style="text-align: right">0.094</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.315</td>
<td style="text-align: right">1.600</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.112</td>
<td style="text-align: right">-0.088</td>
</tr>
</tbody>
</table>
<p>The replicated results still show worse performance than the original results, which also seems to be related to performance during 2012. The replicated results also do not show significant improvement relative to the top 5 momentum equal risk portfolio like the original paper shows.</p>
<h1 id="conclusion">Conclusion</h1>
<p>Despite using returns from different instruments in the same asset classes, over a slightly different time period, this analysis closely replicates the results from <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2328254">Adaptive Asset Allocation: A Primer</a>. The differences in the data sets seem to create a significant difference in performance during 2012, but otherwise produce similar results on monthly data.</p>
<p>See <a href="https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/">Adaptive Asset Allocation Extended</a> for an analysis of the out-of-sample performance of these portfolios. Thanks for reading!</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176046" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176046" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176047" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176048" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176049" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176049" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176050" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176050" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>The paper, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2328254">&ldquo;Adaptive Asset Allocation: A Primer&rdquo;</a> by Adam Butler, Mike Philbrick, Rodrigo Gordillo, and David Varadi addresses flaws in the traditional application of Modern Portfolio Theory related to Strategic Asset Allocation. It shows that estimating return and (co)variance parameters over shorter time horizons are superior to estimates over long-term horizons because parameter estimates vary substantially over time. Longer-term estimates do not account for this variability in the short-term. They propose an Adaptive Asset Allocation portfolio construction methodology that uses the new parameter estimates to substantially improve performance relative to Strategic Asset Allocation.</p>
<h1 id="data">Data</h1>
<p>The original paper creates portfolios from 10 major global asset classes using data between 1995 and 2014. It uses ETFs when possible, and uses passive no-load mutual funds, underlying indexes, and no-load active mutual funds as proxies for asset class returns prior to ETF inception. The paper doesn&rsquo;t list the actual instruments used at each point in time, so this post attempts to replicate their described methodology using publicly available data.</p>
<p>The table below shows the asset class, instruments, and time horizons used for each asset class in this replication. The data start in late 1997 instead of 1995 as in the original paper. Returns in this analysis are adjusted for splits and dividends.</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: left">ETF</th>
<th style="text-align: left">ETF Start</th>
<th style="text-align: left">Fund</th>
<th style="text-align: left">Fund Start</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">US Equity</td>
<td style="text-align: left">VTI</td>
<td style="text-align: left">2001-05</td>
<td style="text-align: left">VTSMX</td>
<td style="text-align: left">1992-04</td>
</tr>
<tr>
<td style="text-align: left">European Equity</td>
<td style="text-align: left">VGK</td>
<td style="text-align: left">2005-03</td>
<td style="text-align: left">VEURX</td>
<td style="text-align: left">1990-06</td>
</tr>
<tr>
<td style="text-align: left">Japanese Equity</td>
<td style="text-align: left">EWJ</td>
<td style="text-align: left">1996-03</td>
<td style="text-align: left">FJPNX</td>
<td style="text-align: left">1992-12</td>
</tr>
<tr>
<td style="text-align: left">Emerging Market Equity</td>
<td style="text-align: left">EEM</td>
<td style="text-align: left">2003-04</td>
<td style="text-align: left">VEIEX</td>
<td style="text-align: left">1994-12</td>
</tr>
<tr>
<td style="text-align: left">US Real Estate</td>
<td style="text-align: left">ICF</td>
<td style="text-align: left">2001-02</td>
<td style="text-align: left">VGSIX</td>
<td style="text-align: left">1996-05</td>
</tr>
<tr>
<td style="text-align: left">International Real Estate</td>
<td style="text-align: left">RWX</td>
<td style="text-align: left">2006-12</td>
<td style="text-align: left">XRFIX</td>
<td style="text-align: left">1997-09</td>
</tr>
<tr>
<td style="text-align: left">Intermediate Term Treasury</td>
<td style="text-align: left">IEF</td>
<td style="text-align: left">2002-07</td>
<td style="text-align: left">VFITX</td>
<td style="text-align: left">1991-12</td>
</tr>
<tr>
<td style="text-align: left">Long Term Treasury</td>
<td style="text-align: left">TLT</td>
<td style="text-align: left">2002-07</td>
<td style="text-align: left">VUSTX</td>
<td style="text-align: left">1986-12</td>
</tr>
<tr>
<td style="text-align: left">Commodities</td>
<td style="text-align: left">DBC</td>
<td style="text-align: left">2006-02</td>
<td style="text-align: left">QRACX</td>
<td style="text-align: left">1997-03</td>
</tr>
<tr>
<td style="text-align: left">Gold</td>
<td style="text-align: left">GLD</td>
<td style="text-align: left">2004-11</td>
<td style="text-align: left">SGGDX</td>
<td style="text-align: left">1993-08</td>
</tr>
</tbody>
</table>
<p>This post uses the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/ftblog">ftblog</a> package. You can install it using the <code>remotes::install_github()</code> function in the code block below. First we need to setup our environment with the necessary packages, data, and functions.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># remotes::install_github(&#34;joshuaulrich/ftblog&#34;)</span>
</span></span><span class="line"><span class="cl"><span class="nf">suppressPackageStartupMessages</span><span class="p">({</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">ftblog</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">library</span><span class="p">(</span><span class="n">PerformanceAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">aaa_returns</span><span class="p">,</span> <span class="n">package</span> <span class="o">=</span> <span class="s">&#34;ftblog&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># Only use data through the end of 2014, and no cash</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">aaa_returns[</span><span class="s">&#34;/2014&#34;</span><span class="p">,</span> <span class="m">-1</span><span class="n">]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate strategy statistics</span>
</span></span><span class="line"><span class="cl"><span class="n">strat_summary</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="kc">NULL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">table.AnnualizedReturns</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">rbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;Worst Drawdown&#34;</span> <span class="o">=</span> <span class="o">-</span><span class="nf">maxDrawdown</span><span class="p">(</span><span class="n">returns</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="s">&#34;Replication&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="o">!</span><span class="nf">is.null</span><span class="p">(</span><span class="n">original_results</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">cbind</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="n">original_results</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span><span class="n">[2]</span> <span class="o">&lt;-</span> <span class="s">&#34;Original&#34;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">round</span><span class="p">(</span><span class="n">stats</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kr">return</span><span class="p">(</span><span class="n">stats</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><h1 id="replication">Replication</h1>
<p>This analysis attempts to replicate all 5 portfolios in the original paper.</p>
<ol>
<li>Equal weight of all asset classes</li>
<li>Equal risk contribution of all asset classes</li>
<li>Equal weight of highest momentum asset classes</li>
<li>Equal risk contribution of highest momentum asset classes</li>
<li>Minimum variance of highest momentum asset classes</li>
</ol>
<p>The original paper showed results as a monthly series. The <code>to_monthly_returns()</code> function converts the strategy returns from daily to monthly. The <code>strat_summary()</code> function uses the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=PerformanceAnalytics">PerformanceAnalytics</a> package to calculate summary statistics to compare with the original paper. The file <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/adaptive-asset-allocation-replication.R">adaptive-asset-allocation-replication.R</a> contains all the code used in this analysis, and the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/returns.rds">returns.rds</a> function contains the data.</p>
<h3 id="1-equal-weight-portfolio-of-all-asset-classes">1. Equal weight portfolio of all asset classes</h3>
<p>The baseline example assumes no knowledge of expected relative asset class performance, risk, or correlation. The results below are based on a portfolio that holds each asset class in equal weight and is rebalanced monthly. The table compares the results of this replication with the original results. Some of the difference in results are due to the different instruments and time frames used for the analysis. Despite the differences in the data between the two approaches, the results are very similar.</p>
<p>The <code>returns_equal_weight</code> object contains the portfolio returns for each day. Then we convert those returns to monthly and evaluate the portfolio results.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_equal_weight</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">as.xts</span><span class="p">(</span><span class="nf">apply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="n">mean</span><span class="p">))</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;All Assets - Equal Weight&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_equal_weight</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.081</span><span class="p">,</span> <span class="m">0.112</span><span class="p">,</span> <span class="m">0.72</span><span class="p">,</span> <span class="m">-0.392</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_equal_weight</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/equal_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.079</td>
<td style="text-align: right">0.081</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.115</td>
<td style="text-align: right">0.112</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">0.684</td>
<td style="text-align: right">0.720</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.377</td>
<td style="text-align: right">-0.392</td>
</tr>
</tbody>
</table>
<h3 id="2-equal-risk-contribution-using-all-asset-classes">2. Equal risk contribution using all asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s risk, but still no knowledge of relative performance or correlations. So each asset in this portfolio is given a weight proportional to its relative risk, and each asset contributes the same amount of risk to the overall portfolio. That way no asset&rsquo;s risk will dominate the risk of the overall portfolio.</p>
<p>The <code>portf_return_equal_risk()</code> estimates the equal risk contribution portfolio using the <code>PERC()</code> function from the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=FRAPO">FRAPO</a> package. It calculates the portfolio weights at the end of month using estimated portfolio risk from the returns over the last 60 days. Then those weights are used to calculate the portfolio returns for the following month.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_equal_risk</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_equal_risk</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;All Assets - Equal Risk Contribution&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_equal_risk</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.085</span><span class="p">,</span> <span class="m">0.086</span><span class="p">,</span> <span class="m">0.99</span><span class="p">,</span> <span class="m">-0.242</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_equal_risk</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/equal_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.086</td>
<td style="text-align: right">0.085</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.073</td>
<td style="text-align: right">0.086</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.177</td>
<td style="text-align: right">0.990</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.142</td>
<td style="text-align: right">-0.242</td>
</tr>
</tbody>
</table>
<p>In this case, the replicated results are better than the original results. The data differences and the method used to estimate the equal risk contribution portfolio weights are the most likely explanation for the differences in the replicated results.</p>
<h3 id="3-equal-weight-portfolio-of-highest-momentum-asset-classes">3. Equal weight portfolio of highest momentum asset classes</h3>
<p>The next portfolio assumes the investor has some knowledge of each asset&rsquo;s returns, but still no knowledge of risk or correlations. The original paper uses momentum to estimate each asset&rsquo;s returns because momentum (also known as long-term memory) is a well-known property of financial market returns. Assets that have increased (decreased) in price are likely to continue increasing (decreasing) in price in the next period. Academic research shows that instruments with higher (lower) momentum over the past 1-12 months exhibits better (worse) performance over short-term future periods. See the original paper for a description of some reasons why momentum exists in financial markets.</p>
<p>The estimates of each asset&rsquo;s returns are based on 6-month momentum (approximately 120 days). Momentum is re-estimated every month and only the top 5 assets are included in the portfolio, rather than including every asset in the portfolio. Note that this doesn&rsquo;t mean every asset included in the portfolio has a positive return over the 6-month period. All of them could have negative returns over the period, in which case the 5 assets with the smallest losses would be included in the portfolio. Each of the top 5 assets included in the portfolio are held with equal weight.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_equal_weight</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Top 5 Assets by 6-month Momentum - Equal Weight&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_equal_weight</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.130</span><span class="p">,</span> <span class="m">0.110</span><span class="p">,</span> <span class="m">1.17</span><span class="p">,</span> <span class="m">-0.217</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_equal_weight</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/top5_momo_eq_weight-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.142</td>
<td style="text-align: right">0.130</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.114</td>
<td style="text-align: right">0.110</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.243</td>
<td style="text-align: right">1.170</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.199</td>
<td style="text-align: right">-0.217</td>
</tr>
</tbody>
</table>
<p>The replicated results have slightly better returns and maximum drawdown, but similar standard deviation. That said, the results are similar enough to suggest this analysis replicates the approach accurately.</p>
<h3 id="4-equal-risk-contribution-portfolio-of-highest-momentum-asset-classes">4. Equal risk contribution portfolio of highest momentum asset classes</h3>
<p>The previous two portfolios estimated asset weights using either risk-based or momentum-based weights. This next portfolio combines estimates of momentum-based performance and accounts for asset class risk differences. It includes the top 5 asset classes based on 6-month returns and weights them using the <code>estimate_equal_risk_portf()</code> function defined earlier. Recall that the function weights each asset class so they each contribute the same amount of risk to the portfolio. Note that the asset volatilities are calculated on 60 days (approximately 3 months) of returns while the momentum is based on 120 days (approximately 6 months).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_equal_risk</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo_equal_risk</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Top 5 Assets by 6-month Momentum - Equal Risk Contribution&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_equal_risk</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.140</span><span class="p">,</span> <span class="m">0.099</span><span class="p">,</span> <span class="m">1.41</span><span class="p">,</span> <span class="m">-0.148</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_equal_risk</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/top_momo_eq_risk-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.137</td>
<td style="text-align: right">0.140</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.102</td>
<td style="text-align: right">0.099</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.335</td>
<td style="text-align: right">1.410</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.119</td>
<td style="text-align: right">-0.148</td>
</tr>
</tbody>
</table>
<p>The original and replicated results for this portfolio are very similar. Note that in the original paper this portfolio&rsquo;s overall return increased to 14.0% versus 13.0% for the momentum-based equal weight portfolio, but the replicated results were more similar (14.2% versus 13.7%). Again, the data differences and portfolio weight estimation differences likely cause differences in the results. Also, an un-scientific comparison of the two cumulative return graphs suggests some difference may be due to performance in 2012, when the replicated results have a significant drawdown while the original results showed positive performance.</p>
<h3 id="5-minimum-variance-portfolio-of-highest-momentum-asset-classes">5. Minimum variance portfolio of highest momentum asset classes</h3>
<p>The final portfolio takes the above concepts and adds correlation estimates to the portfolio optimization. The previous portfolios only accounted for the relative risk between the asset classes, but not the correlation between the assets&rsquo; returns. This portfolio accounts for the correlations between asset classes by finding the minimum variance portfolio using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://en.wikipedia.org/wiki/Modern_portfolio_theory">modern portfolio theory</a>. The asset selection for these portfolios in the original paper differ slightly from the previous portfolios. Instead of taking the top 5 assets with the highest momentum, the original paper selects &ldquo;assets with above average 6-month momentum&rdquo;. So it&rsquo;s not clear how many assets are held in the portfolio each month.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">returns_momo_min_var</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">portf_return_momo_min_var</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">5</span><span class="p">,</span> <span class="m">120</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="s">&#34;above average&#34;</span><span class="p">)</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">to_monthly_returns</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">title</span> <span class="o">&lt;-</span> <span class="s">&#34;Assets With Above Average 6-month Momentum - Minimum Variance&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">stats</span> <span class="o">&lt;-</span> <span class="nf">strat_summary</span><span class="p">(</span><span class="n">returns_momo_min_var</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">original_results</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="m">0.150</span><span class="p">,</span> <span class="m">0.094</span><span class="p">,</span> <span class="m">1.60</span><span class="p">,</span> <span class="m">-0.088</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">charts.PerformanceSummary</span><span class="p">(</span><span class="n">returns_momo_min_var</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="n">title</span><span class="p">,</span> <span class="n">wealth.index</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/2023/12/adaptive-asset-allocation-replication/top_momo_min_var-1.png" alt="" >
</p>
<table>
<thead>
<tr>
<th style="text-align: left"></th>
<th style="text-align: right">Replication</th>
<th style="text-align: right">Original</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Annualized Return</td>
<td style="text-align: right">0.130</td>
<td style="text-align: right">0.150</td>
</tr>
<tr>
<td style="text-align: left">Annualized Std Dev</td>
<td style="text-align: right">0.099</td>
<td style="text-align: right">0.094</td>
</tr>
<tr>
<td style="text-align: left">Annualized Sharpe (Rf=0%)</td>
<td style="text-align: right">1.315</td>
<td style="text-align: right">1.600</td>
</tr>
<tr>
<td style="text-align: left">Worst Drawdown</td>
<td style="text-align: right">-0.112</td>
<td style="text-align: right">-0.088</td>
</tr>
</tbody>
</table>
<p>The replicated results still show worse performance than the original results, which also seems to be related to performance during 2012. The replicated results also do not show significant improvement relative to the top 5 momentum equal risk portfolio like the original paper shows.</p>
<h1 id="conclusion">Conclusion</h1>
<p>Despite using returns from different instruments in the same asset classes, over a slightly different time period, this analysis closely replicates the results from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2328254">Adaptive Asset Allocation: A Primer</a>. The differences in the data sets seem to create a significant difference in performance during 2012, but otherwise produce similar results on monthly data.</p>
<p>See <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2024/01/adaptive-asset-allocation-extended/">Adaptive Asset Allocation Extended</a> for an analysis of the out-of-sample performance of these portfolios. Thanks for reading!</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/848510933/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/848510933/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176046" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176046" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176047" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176048" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176049" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176049" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176050" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176050" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/08/quantmod-0-4-25-on-cran/</feedburner:origLink><title>quantmod_0.4.25 on CRAN</title><link>https://feeds.feedblitz.com/~/787844771/0/fosstrading/</link><pubDate>Tue, 22 Aug 2023 11:41:57 -0500</pubDate><guid>https://blog.fosstrading.com/2023/08/quantmod-0-4-25-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=quantmod">quantmod</a> is now on <a href="http://cran.r-project.org/">CRAN</a>.
It includes an awesome new feature that allows you to import up to 7 days of intraday data from Yahoo Finance!</p>
<h3 id="new-features">New Features</h3>
<ul>
<li>
<p><code>getSymbols.yahoo()</code> can import up to 7 days of intraday data! Thanks to <a href="https://github.com/kapsner">@kapsner</a> for the report and patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/351">#351</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/381">#381</a>) It will throw a warning if you try to request more than 7 days of intraday data, but you can suppress the warning (thanks to <a href="https://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a>). (<a href="https://github.com/joshuaulrich/quantmod/issues/399">#399</a>)</p>
</li>
<li>
<p>Add warning if <code>getSymbols()</code> is called with tickers that are reserved words because accessing them requires back-quotes (e.g. <code>NA</code>). (<a href="https://github.com/joshuaulrich/quantmod/issues/401">#401</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fix <code>getQuote.yahoo()</code> for API changes. Thanks to Ethan B. Smith for the report and patch! Also add error message for users in GDPR countries, since we cannot automatically consent to GDPR and the request fails without consent. (<a href="https://github.com/joshuaulrich/quantmod/issues/392">#392</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/393">#393</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/395">#395</a>)</p>
</li>
<li>
<p>Fix <code>getQuote.yahoo()</code> when the user only requested metrics that do not have have a value for &lsquo;regularMarketTime&rsquo;. Set the value to NA in these cases so the output remains the same regardless of whether the endpoint returns a &lsquo;regularMarketTime&rsquo; or not. Thanks to <a href="https://github.com/mehdiMBH">@mehdiMBH</a> for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/255">#255</a>)</p>
</li>
<li>
<p>Add fields to <code>getQuote.yahoo()</code> that are returned when no fields are explicitly requested. Thanks to <a href="https://github.com/Courvoisier13">@Courvoisier13</a> for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/335">#335</a>)</p>
</li>
<li>
<p>Fix <code>allReturns()</code> when &lsquo;subset&rsquo; is specified. Thanks to <a href="https://github.com/Panagis1980">@Panagis1980</a> for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/402">#402</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176051" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176051" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176052" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176053" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176054" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176054" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176055" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176055" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=quantmod">quantmod</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>.
It includes an awesome new feature that allows you to import up to 7 days of intraday data from Yahoo Finance!</p>
<h3 id="new-features">New Features</h3>
<ul>
<li>
<p><code>getSymbols.yahoo()</code> can import up to 7 days of intraday data! Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/kapsner">@kapsner</a> for the report and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/351">#351</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/381">#381</a>) It will throw a warning if you try to request more than 7 days of intraday data, but you can suppress the warning (thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a>). (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/399">#399</a>)</p>
</li>
<li>
<p>Add warning if <code>getSymbols()</code> is called with tickers that are reserved words because accessing them requires back-quotes (e.g. <code>NA</code>). (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/401">#401</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fix <code>getQuote.yahoo()</code> for API changes. Thanks to Ethan B. Smith for the report and patch! Also add error message for users in GDPR countries, since we cannot automatically consent to GDPR and the request fails without consent. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/392">#392</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/393">#393</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/395">#395</a>)</p>
</li>
<li>
<p>Fix <code>getQuote.yahoo()</code> when the user only requested metrics that do not have have a value for &lsquo;regularMarketTime&rsquo;. Set the value to NA in these cases so the output remains the same regardless of whether the endpoint returns a &lsquo;regularMarketTime&rsquo; or not. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/mehdiMBH">@mehdiMBH</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/255">#255</a>)</p>
</li>
<li>
<p>Add fields to <code>getQuote.yahoo()</code> that are returned when no fields are explicitly requested. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/Courvoisier13">@Courvoisier13</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/335">#335</a>)</p>
</li>
<li>
<p>Fix <code>allReturns()</code> when &lsquo;subset&rsquo; is specified. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/Panagis1980">@Panagis1980</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/402">#402</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/787844771/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/787844771/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176051" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176051" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176052" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176053" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176054" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176054" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176055" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176055" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/06/running-timebase-in-docker/</feedburner:origLink><title>Running TimeBase in Docker</title><link>https://feeds.feedblitz.com/~/748672280/0/fosstrading/</link><pubDate>Sat, 24 Jun 2023 10:21:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/06/running-timebase-in-docker/</guid><description><![CDATA[<p>This is the second post in the series on using <a href="https://timebase.info/">TimeBase</a> to stream real-time market data. This post covers using <a href="https://www.docker.com/">Docker</a> to run TimeBase and the <a href="https://kb.timebase.info/docs/development/tools/Web%20Admin/admin_about">TimeBase Web Administrator</a>.</p>
<h3 id="getting-started">Getting Started</h3>
<p>Docker installation and configuration is outside the scope of this post. Docker has a <a href="https://www.docker.com/get-started/">Get Started</a> page to help you get set up.</p>
<p>I&rsquo;ll be using Docker via Ubuntu and the command line interface. I know this approach is probably very advanced for most readers, but please bear with me. The concepts should be the same if you&rsquo;re using the <a href="https://docs.docker.com/desktop/">Docker Desktop</a> GUI instead.</p>
<p>If you&rsquo;re not familiar with Docker, an &ldquo;image&rdquo; contains all the necessary information to run an instance of the application. A &ldquo;container&rdquo; is a running instance of an image.</p>
<h3 id="running-the-docker-containers">Running the Docker Containers</h3>
<p>First we need to get the container images from <a href="https://hub.docker.com/">Docker Hub</a>. I will use the <code>docker pull</code> command.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># pull the TimeBase image</span>
</span></span><span class="line"><span class="cl">docker pull finos/timebase-ce-server:6.1.16
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># pull the Web Admin image</span>
</span></span><span class="line"><span class="cl">docker pull epam/timebase-ws-server:1.0
</span></span></code></pre></div><p>The TimeBase documentation has a page on <a href="https://kb.timebase.info/community/deployment/docker">deploying with Docker</a>. This post closely follows those examples.</p>
<p>One major difference is that TimeBase documentation uses the <code>--link</code> option to allow the containers to talk to each other, but the Docker documentation says that is a legacy feature that may be removed. The currently preferred method is to create a user-defined network.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># create a user-defined network so the containers to see each other</span>
</span></span><span class="line"><span class="cl">docker network create --driver bridge timebase-net
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># make sure the network was created</span>
</span></span><span class="line"><span class="cl">docker network ls
</span></span></code></pre></div><p>By default, the docker containers will write data to a disk that&rsquo;s only available to the container. You won&rsquo;t be able to access the data from your computer or if the container isn&rsquo;t running. There&rsquo;s a <code>--volume</code> option to specify a mapping between a directory in the container and a directory on your local machine. I&rsquo;m not going to use that here because you have to run the container as root in order for it to write to your local file system.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --rm --detach <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --publish 8011:8011 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --name timebase-server <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --user deltix:deltix <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --ulimit<span class="o">=</span><span class="nv">nofile</span><span class="o">=</span>65536:65536 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --network timebase-net <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> finos/timebase-ce-server:6.1.16
</span></span></code></pre></div><p>Here are the descriptions of the options used:</p>
<ul>
<li><code>--rm</code>: Automatically remove the container when it exits</li>
<li><code>--detach</code>: Run the container in the background</li>
<li><code>--publish</code>: Map the container&rsquo;s port 8011 to my computer&rsquo;s port 8011</li>
<li><code>--name</code>: Assign a name to the container</li>
<li><code>--user</code>: Run the container as the &lsquo;deltix&rsquo; user instead of &lsquo;root&rsquo;</li>
<li><code>--ulimit</code>: Set user process resource limits</li>
<li><code>--network</code>: Use the &rsquo;timebase-net&rsquo; network</li>
</ul>
<p>Now we can run the Web Admin container. Make sure to use the same network (<code>timebase-net</code>) and make sure the host name (<code>dxtick://timebase-server</code>) is the same as the name you used for the TimeBase container (i.e. &rsquo;timebase-server&rsquo; in this case). The <code>--env</code> option allows us to set environment variables. These are used to control various <a href="https://kb.timebase.info/community/development/tools/Web%20Admin/admin_config#deployment">configuration options</a> (note that these configuration options are for running a local instance, but they give you an idea of what you can change).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --rm --detach <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --publish 8099:8099 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --name timebase-admin <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --env <span class="s2">&#34;JAVA_OPTS=-Dtimebase.url=dxtick://timebase-server:8011&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --network timebase-net <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> epam/timebase-ws-server:1.0
</span></span></code></pre></div><p>We can use the Web Admin&rsquo;s interface once it&rsquo;s running. Open a browser and enter localhost:8099 in the address bar. That should take you to the login page. The default username/password is <code>admin/admin</code>. After you log in you should see a page like the image below. The only stream in the database is <code>events#</code>.</p>
<p><a href="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-initial-contents.png"><img src="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-initial-contents.png" alt="" >
</a></p>
<p>Although this post is about <em>running</em> TimeBase and the Web Admin, I&rsquo;m not going to end it without showing a little functionality.</p>
<h3 id="import-data">Import Data</h3>
<p>Let&rsquo;s import some data and take a quick look. Download this <a href="https://feeds.feedblitz.com/~/748672280/0/fosstrading/running-timebase-in-docker-bars.qsmsg.gz">data file</a>. Then click the &lsquo;Import from QSMSG&rsquo; button highlighted in red below.</p>
<p><a href="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-import-qsmsg-button.png"><img src="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-import-qsmsg-button.png" alt="" >
</a></p>
<p>Navigate to the file you just downloaded. Name the stream &lsquo;bars&rsquo;. You can leave the Description and Symbols fields blank, and leave Periodicity set to irregular.</p>
<p>Now click the &lsquo;bars&rsquo; stream in the navigation bar on the left. You should see the data you just imported. It looks like the image below.</p>
<p><a href="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-after-importing-bars.png"><img src="https://feeds.feedblitz.com/~/748672280/0/fosstrading/web-admin-after-importing-bars.png" alt="" >
</a></p>
<p>Okay, that&rsquo;s all for now. In the next post, we&rsquo;ll set up a data connector and watch some data stream into the database!</p>
<div class="container" role="main">
<div class="row">
<h3>Other Posts in this TimeBase Series</h3>
<ul>
<li><a href="https://blog.fosstrading.com/2023/06/streaming-data-with-timebase/">Streaming Market Data with TimeBase</a></li>
<li><a href="https://feeds.feedblitz.com/~/748672280/0/fosstrading/">Running TimeBase in Docker</a></li>
</ul>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176056" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176056" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176057" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176058" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176059" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176059" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176060" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176060" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This is the second post in the series on using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/">TimeBase</a> to stream real-time market data. This post covers using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.docker.com/">Docker</a> to run TimeBase and the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/docs/development/tools/Web%20Admin/admin_about">TimeBase Web Administrator</a>.</p>
<h3 id="getting-started">Getting Started</h3>
<p>Docker installation and configuration is outside the scope of this post. Docker has a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.docker.com/get-started/">Get Started</a> page to help you get set up.</p>
<p>I&rsquo;ll be using Docker via Ubuntu and the command line interface. I know this approach is probably very advanced for most readers, but please bear with me. The concepts should be the same if you&rsquo;re using the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://docs.docker.com/desktop/">Docker Desktop</a> GUI instead.</p>
<p>If you&rsquo;re not familiar with Docker, an &ldquo;image&rdquo; contains all the necessary information to run an instance of the application. A &ldquo;container&rdquo; is a running instance of an image.</p>
<h3 id="running-the-docker-containers">Running the Docker Containers</h3>
<p>First we need to get the container images from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://hub.docker.com/">Docker Hub</a>. I will use the <code>docker pull</code> command.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># pull the TimeBase image</span>
</span></span><span class="line"><span class="cl">docker pull finos/timebase-ce-server:6.1.16
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># pull the Web Admin image</span>
</span></span><span class="line"><span class="cl">docker pull epam/timebase-ws-server:1.0
</span></span></code></pre></div><p>The TimeBase documentation has a page on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/deployment/docker">deploying with Docker</a>. This post closely follows those examples.</p>
<p>One major difference is that TimeBase documentation uses the <code>--link</code> option to allow the containers to talk to each other, but the Docker documentation says that is a legacy feature that may be removed. The currently preferred method is to create a user-defined network.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># create a user-defined network so the containers to see each other</span>
</span></span><span class="line"><span class="cl">docker network create --driver bridge timebase-net
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># make sure the network was created</span>
</span></span><span class="line"><span class="cl">docker network ls
</span></span></code></pre></div><p>By default, the docker containers will write data to a disk that&rsquo;s only available to the container. You won&rsquo;t be able to access the data from your computer or if the container isn&rsquo;t running. There&rsquo;s a <code>--volume</code> option to specify a mapping between a directory in the container and a directory on your local machine. I&rsquo;m not going to use that here because you have to run the container as root in order for it to write to your local file system.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --rm --detach <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --publish 8011:8011 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --name timebase-server <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --user deltix:deltix <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --ulimit<span class="o">=</span><span class="nv">nofile</span><span class="o">=</span>65536:65536 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --network timebase-net <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> finos/timebase-ce-server:6.1.16
</span></span></code></pre></div><p>Here are the descriptions of the options used:</p>
<ul>
<li><code>--rm</code>: Automatically remove the container when it exits</li>
<li><code>--detach</code>: Run the container in the background</li>
<li><code>--publish</code>: Map the container&rsquo;s port 8011 to my computer&rsquo;s port 8011</li>
<li><code>--name</code>: Assign a name to the container</li>
<li><code>--user</code>: Run the container as the &lsquo;deltix&rsquo; user instead of &lsquo;root&rsquo;</li>
<li><code>--ulimit</code>: Set user process resource limits</li>
<li><code>--network</code>: Use the &rsquo;timebase-net&rsquo; network</li>
</ul>
<p>Now we can run the Web Admin container. Make sure to use the same network (<code>timebase-net</code>) and make sure the host name (<code>dxtick://timebase-server</code>) is the same as the name you used for the TimeBase container (i.e. &rsquo;timebase-server&rsquo; in this case). The <code>--env</code> option allows us to set environment variables. These are used to control various <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/development/tools/Web%20Admin/admin_config#deployment">configuration options</a> (note that these configuration options are for running a local instance, but they give you an idea of what you can change).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run --rm --detach <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --publish 8099:8099 <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --name timebase-admin <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --env <span class="s2">&#34;JAVA_OPTS=-Dtimebase.url=dxtick://timebase-server:8011&#34;</span> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --network timebase-net <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> epam/timebase-ws-server:1.0
</span></span></code></pre></div><p>We can use the Web Admin&rsquo;s interface once it&rsquo;s running. Open a browser and enter localhost:8099 in the address bar. That should take you to the login page. The default username/password is <code>admin/admin</code>. After you log in you should see a page like the image below. The only stream in the database is <code>events#</code>.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-initial-contents.png"><img src="https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-initial-contents.png" alt="" >
</a></p>
<p>Although this post is about <em>running</em> TimeBase and the Web Admin, I&rsquo;m not going to end it without showing a little functionality.</p>
<h3 id="import-data">Import Data</h3>
<p>Let&rsquo;s import some data and take a quick look. Download this <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/running-timebase-in-docker-bars.qsmsg.gz">data file</a>. Then click the &lsquo;Import from QSMSG&rsquo; button highlighted in red below.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-import-qsmsg-button.png"><img src="https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-import-qsmsg-button.png" alt="" >
</a></p>
<p>Navigate to the file you just downloaded. Name the stream &lsquo;bars&rsquo;. You can leave the Description and Symbols fields blank, and leave Periodicity set to irregular.</p>
<p>Now click the &lsquo;bars&rsquo; stream in the navigation bar on the left. You should see the data you just imported. It looks like the image below.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-after-importing-bars.png"><img src="https://blog.fosstrading.com/2023/06/running-timebase-in-docker/web-admin-after-importing-bars.png" alt="" >
</a></p>
<p>Okay, that&rsquo;s all for now. In the next post, we&rsquo;ll set up a data connector and watch some data stream into the database!</p>
<div class="container" role="main">
<div class="row">
<h3>Other Posts in this TimeBase Series</h3>
<ul>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/streaming-data-with-timebase/">Streaming Market Data with TimeBase</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/">Running TimeBase in Docker</a></li>
</ul>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672280/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672280/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176056" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176056" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176057" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176058" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176059" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176059" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176060" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176060" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/06/streaming-data-with-timebase/</feedburner:origLink><title>Streaming Market Data with TimeBase</title><link>https://feeds.feedblitz.com/~/748672283/0/fosstrading/</link><pubDate>Mon, 19 Jun 2023 12:14:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/06/streaming-data-with-timebase/</guid><description><![CDATA[<p>This is the first post of a series on using <a href="https://timebase.info/">TimeBase</a> to stream real-time market data. TimeBase is a high performance event-based time series database and message broker. I used it on a proprietary trading desk that made markets in futures, and currently use it to build and test equity trading strategies. It was <a href="https://github.com/finos/TimeBase-CE/">released as open-source</a> in February 2021.</p>
<h3 id="preface">Preface</h3>
<p>I am not affiliated with the company that created and maintains TimeBase (Deltix, now EPAM). I&rsquo;m not currently compensated by them in any way for promoting their product. I&rsquo;m merely a happy user who is excited that TimeBase is open source and I can show you how to do some cool stuff with it.</p>
<h3 id="whats-your-problem">What&rsquo;s Your Problem?</h3>
<p><a href="https://timebase.info/">TimeBase</a> addresses several key needs in automated trading. You need to process large amounts of real-time market data. This includes trades, best bid/offer, and/or the entire limit order book. You use this data to calculate indicators/features, determine when and where to place orders, monitoring unrealized P&amp;L, and monitoring/managing risk of your positions.</p>
<p>All data in the trading system needs to be processed quickly and absolutely must be processed in strict time order. This is not trivial when you need to interleave data from multiple sources (e.g. exchanges and the trading system itself).
The <a href="https://medium.com/prooftrading/proof-engineering-the-algorithmic-trading-platform-b9c2f195433d#d545">System Architecture</a> section of &ldquo;The Algorithmic Trading Platform&rdquo; by Prerak Sanghvi describes the benefits of using a strictly time-sequenced stream of events. To summarize:</p>
<ul>
<li>Synchronized: every system component always receives the same data in the same order.</li>
<li>Observable: the system is deterministic and can be debugged offline by replaying the data.</li>
<li>Auditable: You can re-create the state of the system at any point in time.</li>
<li>Streamlined: Tasks like logging and persisting to disk can be delegated to components that are off the critical path.</li>
</ul>
<p>The data also needs be stored for analysis and debugging. Analysis includes things like running backtests, post-trade evaluation, and investigating market behavior. <a href="https://medium.com/prooftrading/selecting-a-database-for-an-algorithmic-trading-system-2d25f9648d02">&ldquo;Selecting a Database for an Algorithmic Trading System&rdquo;
</a> by Prerak Sanghvi discusses the necessary components of a time-series database for algorithmic trading. To summarize:</p>
<ul>
<li>Fast data ingest: millions of records per second (quote data can be 100+ million records per day)</li>
<li>Ability to process large amounts of historical data for patterns and trends</li>
<li>Time series operations and real-time analytics (e.g. window functions, aggregations, as-of joins)</li>
<li>Expressive query language</li>
<li>Optimized on-disk layout</li>
</ul>
<h3 id="timebase-vs-alternatives">TimeBase vs Alternatives</h3>
<p>Why use TimeBase instead of other open-source projects like <a href="https://www.rabbitmq.com/">RabbitMQ</a>, <a href="https://kafka.apache.org/">Kafka</a>, <a href="https://www.influxdata.com/">InfluxDB</a>, <a href="https://www.timescale.com/">TimeScaleDB</a>, or <a href="https://clickhouse.com/">ClickHouse</a>? The main reason is that TimeBase is both a <a href="https://en.wikipedia.org/wiki/Message_broker">message broker</a> <em>and</em> a <a href="https://en.wikipedia.org/wiki/Time_series_database">time-series database</a>. The TimeBase website has its own <a href="https://timebase.info/why-timebase/">&ldquo;Why TimeBase&rdquo; page</a> and pages that compare popular <a href="https://timebase.info/why-timebase/tsdb-comparison.html">time-series databases</a> and <a href="https://timebase.info/why-timebase/message-brokers-comparison.html">message brokers</a>. Here&rsquo;s a summary of the benefits of TimeBase from those pages:</p>
<ul>
<li>Based on configuration, it supports microsecond latencies or the ability to handle millions of messages per second on commodity hardware.</li>
<li>Enforces stream schemas with heterogeneous and potentially complex <a href="https://kb.timebase.info/community/overview/messages">message structures</a>.</li>
<li>The same <a href="https://kb.timebase.info/community/development/libs">APIs</a> can be used to stream real-time data <em>and</em> replay historical data.</li>
<li>Able to <a href="https://kb.timebase.info/community/technology/replication/replication_intro">replicate data</a> to other TimeBase instances or applications.</li>
<li>The open-source community edition has multiple crypto exchange data connectors. The enterprise edition has 50+ built-in data connectors.</li>
</ul>
<h3 id="timebase-structure">TimeBase Structure</h3>
<p>This is a high-level summary of the <a href="https://timebase.info/architecture.html">TimeBase architecture page</a>.</p>
<p><strong>Data connectors</strong> handle connecting to external data sources and translating their data into the TimeBase format. There are many open source <a href="https://github.com/epam/TimebaseCryptoConnectors">crypto exchange data connectors</a>. The enterprise edition has another 50+ data connectors to all major exchanges and many data vendors.</p>
<p><strong>The message broker</strong> provides a <a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">publish/subscribe</a> pattern to write/read streaming data. The data is processed via readers and writers to <a href="https://kb.timebase.info/community/overview/streams">streams</a>.</p>
<p>Writers can only write to one stream. Readers can consume multiple streams simultaneously and the messages from every stream are interleaved so that every message consumed is always in guaranteed time order regardless of which stream they come from. It is extremely important that every consumer receives data strictly sequenced by time!</p>
<p>There are two types of streams, durable and transient. Durable streams are persisted to disk. Transient streams are only in memory and can be <em>lossy</em> or <em>lossless</em>.</p>
<ul>
<li>
<p>Writers to <em>lossy</em> streams are not blocked by slow readers, so slow readers may not receive every message but always receive the next available message once they finish processing a message.</p>
</li>
<li>
<p>Writers to <em>lossless</em> streams are blocked by slow readers, so every reader always receives every message and every reader can only process data as fast as the slowest reader.</p>
</li>
</ul>
<p><strong>The database</strong> handles reading/writing data from/to disk, importing and exporting data, replicating data to other applications, and can aggregate data to regular bars. It has a query language (<a href="https://kb.timebase.info/community/development/qql/QQL%205.5/qql-tut-intro">QQL</a>) you can use to extract, filter, aggregate, and transform data in streams.</p>
<p>There&rsquo;s also an open-source <a href="https://kb.timebase.info/community/development/tools/Web%20Admin/admin_config_ce">Web Administrator</a> you can use to manipulate streams (create, delete, edit, import/export). It also allows you to view data, including monitoring live data streaming in to the database.</p>
<h3 id="whats-next">What&rsquo;s Next?</h3>
<p>Later posts in this series will cover at least the topics below. Please leave a comment or contact me with any other things you would like to see!</p>
<ul>
<li>Building and running TimeBase from source/Docker</li>
<li>Building and running the Web Administrator from source/Docker</li>
<li>Setting up a data connector</li>
<li>Introduction to the Web Administrator (viewing/monitoring data, import/export)</li>
<li>Introduction to QQL, the quant query language</li>
</ul>
<p>Thanks to <a href="https://robotjames.com/">TheRobotJames</a> for helpful feedback, and to <a href="https://twitter.com/gestaltu">Adam Butler</a> for encouraging me to write more!</p>
<div class="container" role="main">
<div class="row">
<h3>Other Posts in this TimeBase Series</h3>
<ul>
<li><a href="https://feeds.feedblitz.com/~/748672283/0/fosstrading/">Streaming Market Data with TimeBase</a></li>
<li><a href="https://blog.fosstrading.com/2023/06/running-timebase-in-docker/">Running TimeBase in Docker</a></li>
</ul>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176067" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176067" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176068" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176069" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176070" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176070" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176071" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176071" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This is the first post of a series on using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/">TimeBase</a> to stream real-time market data. TimeBase is a high performance event-based time series database and message broker. I used it on a proprietary trading desk that made markets in futures, and currently use it to build and test equity trading strategies. It was <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/finos/TimeBase-CE/">released as open-source</a> in February 2021.</p>
<h3 id="preface">Preface</h3>
<p>I am not affiliated with the company that created and maintains TimeBase (Deltix, now EPAM). I&rsquo;m not currently compensated by them in any way for promoting their product. I&rsquo;m merely a happy user who is excited that TimeBase is open source and I can show you how to do some cool stuff with it.</p>
<h3 id="whats-your-problem">What&rsquo;s Your Problem?</h3>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/">TimeBase</a> addresses several key needs in automated trading. You need to process large amounts of real-time market data. This includes trades, best bid/offer, and/or the entire limit order book. You use this data to calculate indicators/features, determine when and where to place orders, monitoring unrealized P&amp;L, and monitoring/managing risk of your positions.</p>
<p>All data in the trading system needs to be processed quickly and absolutely must be processed in strict time order. This is not trivial when you need to interleave data from multiple sources (e.g. exchanges and the trading system itself).
The <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://medium.com/prooftrading/proof-engineering-the-algorithmic-trading-platform-b9c2f195433d#d545">System Architecture</a> section of &ldquo;The Algorithmic Trading Platform&rdquo; by Prerak Sanghvi describes the benefits of using a strictly time-sequenced stream of events. To summarize:</p>
<ul>
<li>Synchronized: every system component always receives the same data in the same order.</li>
<li>Observable: the system is deterministic and can be debugged offline by replaying the data.</li>
<li>Auditable: You can re-create the state of the system at any point in time.</li>
<li>Streamlined: Tasks like logging and persisting to disk can be delegated to components that are off the critical path.</li>
</ul>
<p>The data also needs be stored for analysis and debugging. Analysis includes things like running backtests, post-trade evaluation, and investigating market behavior. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://medium.com/prooftrading/selecting-a-database-for-an-algorithmic-trading-system-2d25f9648d02">&ldquo;Selecting a Database for an Algorithmic Trading System&rdquo;
</a> by Prerak Sanghvi discusses the necessary components of a time-series database for algorithmic trading. To summarize:</p>
<ul>
<li>Fast data ingest: millions of records per second (quote data can be 100+ million records per day)</li>
<li>Ability to process large amounts of historical data for patterns and trends</li>
<li>Time series operations and real-time analytics (e.g. window functions, aggregations, as-of joins)</li>
<li>Expressive query language</li>
<li>Optimized on-disk layout</li>
</ul>
<h3 id="timebase-vs-alternatives">TimeBase vs Alternatives</h3>
<p>Why use TimeBase instead of other open-source projects like <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.rabbitmq.com/">RabbitMQ</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kafka.apache.org/">Kafka</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.influxdata.com/">InfluxDB</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.timescale.com/">TimeScaleDB</a>, or <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://clickhouse.com/">ClickHouse</a>? The main reason is that TimeBase is both a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://en.wikipedia.org/wiki/Message_broker">message broker</a> <em>and</em> a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://en.wikipedia.org/wiki/Time_series_database">time-series database</a>. The TimeBase website has its own <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/why-timebase/">&ldquo;Why TimeBase&rdquo; page</a> and pages that compare popular <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/why-timebase/tsdb-comparison.html">time-series databases</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/why-timebase/message-brokers-comparison.html">message brokers</a>. Here&rsquo;s a summary of the benefits of TimeBase from those pages:</p>
<ul>
<li>Based on configuration, it supports microsecond latencies or the ability to handle millions of messages per second on commodity hardware.</li>
<li>Enforces stream schemas with heterogeneous and potentially complex <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/overview/messages">message structures</a>.</li>
<li>The same <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/development/libs">APIs</a> can be used to stream real-time data <em>and</em> replay historical data.</li>
<li>Able to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/technology/replication/replication_intro">replicate data</a> to other TimeBase instances or applications.</li>
<li>The open-source community edition has multiple crypto exchange data connectors. The enterprise edition has 50+ built-in data connectors.</li>
</ul>
<h3 id="timebase-structure">TimeBase Structure</h3>
<p>This is a high-level summary of the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://timebase.info/architecture.html">TimeBase architecture page</a>.</p>
<p><strong>Data connectors</strong> handle connecting to external data sources and translating their data into the TimeBase format. There are many open source <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/epam/TimebaseCryptoConnectors">crypto exchange data connectors</a>. The enterprise edition has another 50+ data connectors to all major exchanges and many data vendors.</p>
<p><strong>The message broker</strong> provides a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">publish/subscribe</a> pattern to write/read streaming data. The data is processed via readers and writers to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/overview/streams">streams</a>.</p>
<p>Writers can only write to one stream. Readers can consume multiple streams simultaneously and the messages from every stream are interleaved so that every message consumed is always in guaranteed time order regardless of which stream they come from. It is extremely important that every consumer receives data strictly sequenced by time!</p>
<p>There are two types of streams, durable and transient. Durable streams are persisted to disk. Transient streams are only in memory and can be <em>lossy</em> or <em>lossless</em>.</p>
<ul>
<li>
<p>Writers to <em>lossy</em> streams are not blocked by slow readers, so slow readers may not receive every message but always receive the next available message once they finish processing a message.</p>
</li>
<li>
<p>Writers to <em>lossless</em> streams are blocked by slow readers, so every reader always receives every message and every reader can only process data as fast as the slowest reader.</p>
</li>
</ul>
<p><strong>The database</strong> handles reading/writing data from/to disk, importing and exporting data, replicating data to other applications, and can aggregate data to regular bars. It has a query language (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/development/qql/QQL%205.5/qql-tut-intro">QQL</a>) you can use to extract, filter, aggregate, and transform data in streams.</p>
<p>There&rsquo;s also an open-source <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://kb.timebase.info/community/development/tools/Web%20Admin/admin_config_ce">Web Administrator</a> you can use to manipulate streams (create, delete, edit, import/export). It also allows you to view data, including monitoring live data streaming in to the database.</p>
<h3 id="whats-next">What&rsquo;s Next?</h3>
<p>Later posts in this series will cover at least the topics below. Please leave a comment or contact me with any other things you would like to see!</p>
<ul>
<li>Building and running TimeBase from source/Docker</li>
<li>Building and running the Web Administrator from source/Docker</li>
<li>Setting up a data connector</li>
<li>Introduction to the Web Administrator (viewing/monitoring data, import/export)</li>
<li>Introduction to QQL, the quant query language</li>
</ul>
<p>Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://robotjames.com/">TheRobotJames</a> for helpful feedback, and to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://twitter.com/gestaltu">Adam Butler</a> for encouraging me to write more!</p>
<div class="container" role="main">
<div class="row">
<h3>Other Posts in this TimeBase Series</h3>
<ul>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/streaming-data-with-timebase/">Streaming Market Data with TimeBase</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2023/06/running-timebase-in-docker/">Running TimeBase in Docker</a></li>
</ul>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672283/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672283/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176067" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176067" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176068" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176069" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176070" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176070" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176071" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176071" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/05/getsymbols-rebooted/</feedburner:origLink><title>getSymbols Rebooted</title><link>https://feeds.feedblitz.com/~/748672286/0/fosstrading/</link><pubDate>Mon, 22 May 2023 10:14:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/05/getsymbols-rebooted/</guid><description><![CDATA[<p>quantmod and <code>getSymbols()</code> have been a core part of the R/Finance ecosystem for over 15 years. We want to change some things, but they would break existing code. We can make these changes in the new <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> package instead.</p>
<h3 id="background">Background</h3>
<p>The quantmod package has been a core part of the R/Finance ecosystem for over 15 years. It&rsquo;s awesome that the package is so popular, but that also comes with responsibility to maintain backward compatibility. Breaking changes may break code used for making business decisions, research, production, blog posts, books, courses, answers on <a href="https://stackoverflow.com">stackoverflow</a>, and much more. We take this responsibility seriously, and do our best to keep functions backward compatible. Sometimes breaking changes are necessary (e.g. bug fixes, changes to external data sources, etc.), but we do our best to make them carefully, with plenty of warning and lead time for users to adjust their code.</p>
<h3 id="motivation">Motivation</h3>
<p>There are things in quantmod that we want to change, but they would certainly break existing code. No matter how much we&rsquo;d like to make those changes, we can&rsquo;t justify breaking a large portion of the code our community has written in the past 15+ years.</p>
<p>We can create a new package instead of making these changes in quantmod. <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> is where we will work on new implementations that improve on the pieces in <code>getSymbols()</code> that we would like to change. This code is <em>extremely alpha</em>. This is the time to provide feedback, suggestions, feature requests, etc. Know that we will break things, maybe without warning. You should consider the API unstable until the 1.0.0 release.</p>
<h3 id="refresher-on-how-getsymbols-works">Refresher on how <code>getSymbols()</code> works</h3>
<p>By default <code>getSymbols()</code> creates objects in the environment it&rsquo;s called from, and it returns the value of the <code>Symbols</code> argument. It&rsquo;s good practice for functions to avoid changing anything in the user&rsquo;s environment (this is called having side-effects). It&rsquo;s better for functions to only return a value, like <code>getSymbols(..., auto.assign = FALSE)</code> does. <code>getSymbols()</code> does not support <code>auto.assign = FALSE</code> for more than one symbol.</p>
<p><code>getSymbols()</code> also uses functionality that was formerly provided by the archived <a href="https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package. This functionality allows users to set default values for <code>getSymbols()</code> source method arguments (e.g. <code>return.class = &quot;data.frame&quot;</code>). This is also a side-effect because it makes <code>getSymbols()</code> depend on something other than argument values.</p>
<p><code>getSymbols()</code> specifies the data sources via its <code>src</code> argument, and uses the <code>src</code> argument to determine which source method to use (e.g. <code>getSymbols(&quot;SPY&quot;, src = &quot;yahoo&quot;)</code> will call <code>getSymbols.yahoo(&quot;SPY&quot;)</code> behind the scenes). This is essentially method dispatch, but done manually rather than using R&rsquo;s built-in S3 functionality.</p>
<h1 id="what-weve-learned">What we&rsquo;ve learned</h1>
<ol>
<li>We should avoid the side-effect of creating objects in the calling environment.</li>
<li>Data sources should use S3 method dispatch, and documentation needs to be easier to find.</li>
<li>Stock ticker symbology is a pain and we need a better way to handle it.</li>
<li>We need a way to provide functionality like the <a href="https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package did, but without side-effects.</li>
</ol>
<h3 id="1-automatically-creating-objects">1. Automatically creating objects</h3>
<p><code>getSymbols()</code> creates an object for every value in the <code>Symbols</code> argument. This isn&rsquo;t an issue for a few symbols, but it clutters the environment when there are several hundred symbols. You can load all the symbols into a separate environment, but that&rsquo;s not a pattern most users are familiar with.</p>
<p>We wanted to remove the ability to load objects into the calling environment, and even created a warning about changing <code>auto.assign = FALSE</code> as the default for <code>getSymbols()</code> and recommending users replace their <code>getSymbols()</code> call with the <code>loadSymbols()</code> function that already exists. But we ultimately decided breaking the community&rsquo;s code wasn&rsquo;t worth it.</p>
<p>Automatically creating objects makes it cumbersome to put prices for all symbols into one object. This is a common use case and there are several steps. It should be possible with one or two function calls. Here&rsquo;s an example.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">symbols</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">,</span> <span class="s">&#34;AAPL&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="n">symbols</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Put all the prices into one xts object,</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">get</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1"># or</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="n">symbols</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Extract only the Close prices</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices</span> <span class="o">&lt;-</span> <span class="nf">Cl</span><span class="p">(</span><span class="n">prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Remove &#34;.Close&#34; suffix so close_prices[, &#34;SPY&#34;] works</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">sub</span><span class="p">(</span><span class="s">&#34;.Close&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">))</span>
</span></span></code></pre></div><p>Automatically creating objects also makes passing all the data to another function awkward. It causes users to do things like:</p>
<ul>
<li>Call <code>getSymbols()</code> in any function that needs data, which may mean the same data is imported multiple times.</li>
<li>Pass the same <code>symbols</code> object to <code>getSymbols()</code> and the other function. Then the other function searches through environments to find the objects with named with those <code>symbols</code>.</li>
<li>Users could put all the data in an environment and use that as an argument to the function, but I haven&rsquo;t seen many people use this pattern.</li>
</ul>
<h3 id="2-data-source-methods">2. Data source methods</h3>
<p>Different <code>getSymbols()</code> source methods can (or may need to) have different arguments. Ideally the source methods wouldn&rsquo;t be exported because users shouldn&rsquo;t call them directly (users should call <code>getSymbols(&quot;SPY&quot;, src = &quot;yahoo&quot;)</code> instead of <code>getSymbols.yahoo(&quot;SPY&quot;)</code>). It&rsquo;s hard to find documentation for unexported functions, which means it&rsquo;s hard to know what arguments are available for each source method.</p>
<p>The source methods are named like S3 methods even though <code>getSymbols()</code> isn&rsquo;t a generic function and the source methods aren&rsquo;t actual S3 methods. This has the potential to create odd behavior that would confuse users.</p>
<h3 id="3-ticker-symbology">3. Ticker symbology</h3>
<p>There are two major issues with ticker symbols.</p>
<ol>
<li>Exchanges and data providers sometimes use different ticker symbols for the same security.</li>
<li>Some ticker symbols are not valid R object names.</li>
</ol>
<p>Another issue is when the ticker symbol is similar to the name of one of the price columns. This has come up several times with Lowe&rsquo;s (LOW). The <code>Lo()</code> and <code>OHLC()</code> functions think all of the columns with the ticker symbol in the column name are the low price for the period.</p>
<h4 id="same-security-different-ticker">Same security, different ticker</h4>
<p>This isn&rsquo;t <code>getSymbols()</code>&rsquo;s fault and it&rsquo;s out of our control, but it could be handled better. Exchange and data source symbology is awful. Identifiers for the same series are often different across exchanges and data providers. For example: the symbol for Berkshire Hathaway B-class shares is &ldquo;BRK-B&rdquo; for Yahoo Finance, &ldquo;BRK/B&rdquo; for the SIP (Securities Information Processor), &ldquo;BRK B&rdquo; for ICE, and probably &ldquo;BRK.B&rdquo; somewhere else.</p>
<p>This is a difficult problem and will likely take a lot of effort to get right. Therefore it won&rsquo;t be a high priority initially.</p>
<h4 id="invalid-r-object-names">Invalid R object names</h4>
<p><code>getSymbols()</code> tries to create objects with valid R names, but only does so for <em>some</em> symbols that aren&rsquo;t valid R object names. For example, <code>BRK-B</code>, <code>BRK B</code>, and <code>BRK/B</code> aren&rsquo;t valid R objects names because valid names start with a letter or a dot (<code>.</code>), and can only contain letters, numbers, a dot, or an underscore.</p>
<p>Here are some common examples of ticker symbology woes:</p>
<p><code>^DJI</code> isn&rsquo;t a valid R object name because it starts with <code>^</code>. So <code>getSymbols()</code> creates an object with the <code>^</code> removed. But then you can&rsquo;t use the code below to put all the prices into one object. Also notice that <code>getSymbols()</code> <em>returns</em> <code>&quot;^DJI&quot;</code> even though it creates an object with a different name.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">symbols</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;^DJI&#34;</span><span class="p">,</span> <span class="s">&#34;BRK-B&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="n">symbols</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;^DJI&#34; &#34;BRK-B&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="n">symbols</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error: value for &#39;^DJI&#39; not found</span>
</span></span></code></pre></div><p>You have to remove the leading <code>^</code> manually. And you have to set <code>fixed = TRUE</code> in the call to <code>sub()</code> because <code>^</code> is a special character in regular expressions. <em>Sigh</em>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="nf">sub</span><span class="p">(</span><span class="s">&#34;^&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">fixed</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)))</span>
</span></span></code></pre></div><p>Recall that <code>BRK-B</code> also isn&rsquo;t a valid R name because of the <code>-</code>. But it wasn&rsquo;t an issue in the code above because <code>getSymbols()</code> made an object named <code>BRK-B</code>, not an object with a valid R name. This is confusing for users because they can&rsquo;t easily access that object (i.e. <code>head(BRK-B)</code> is an error). This is a pervasive issue for several foreign exchanges with tickers that begin with numbers (e.g. <code>000001.SZ</code>).</p>
<p>Another issue with symbols that aren&rsquo;t valid R object names is that many R functions will convert column names into valid R object names, including <code>merge.xts()</code>. So you can&rsquo;t use the input symbol to subset the resulting xts object. Here&rsquo;s an example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Extract the close prices and remove &#34;.Close&#34; suffix</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices</span> <span class="o">&lt;-</span> <span class="nf">Cl</span><span class="p">(</span><span class="n">prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">sub</span><span class="p">(</span><span class="s">&#34;.Close&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Extract the close price for &#34;BRK-B&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices[</span><span class="p">,</span> <span class="s">&#34;BRK-B&#34;</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error in `[.xts`(close_prices, , &#34;BRK-B&#34;) : subscript out of bounds</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;DJI&#34; &#34;BRK.B&#34;</span>
</span></span></code></pre></div><p><code>setSymbolLookup()</code> exists to help with things like this, but it&rsquo;s another function users have to learn to use and my experience is that most users don&rsquo;t know about <code>setSymbolLookup()</code>. I just had to look at the source to figure out how to use it to make <code>getSymbols()</code> return a valid R object for <code>&quot;BRK-B&quot;</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setSymbolLookup</span><span class="p">(</span><span class="n">BRK.B</span> <span class="o">=</span> <span class="nf">list</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#34;BRK-B&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;yahoo&#34;</span><span class="p">))</span>
</span></span></code></pre></div><p>If I have to look at the source code to figure out how to do this, users don&rsquo;t have a chance. You may think, &ldquo;but you could document how to do this&rdquo;, but writing documentation isn&rsquo;t fun. And who reads the documentation anyway? ;-)</p>
<h3 id="4-defaults-functionality">4. &lsquo;Defaults&rsquo; functionality</h3>
<p>The &lsquo;Defaults&rsquo; functionality in quantmod comes from the archived <a href="https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package. This functionality allows users to set new default argument values to any <code>getSymbols()</code> source function. This is helpful because it makes importing easier. But it means <code>getSymbols()</code> relies on something other than its parameter values, and it&rsquo;s good practice to avoid side-effects like this.</p>
<p>This gave users the ability to set preferences like return class, periodicity (e.g. hourly, daily, monthly), connection settings (e.g. credentials, API keys).</p>
<h1 id="rfimport-design-and-features">&lsquo;rfimport&rsquo; design and features</h1>
<p>The design of <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> is influenced by the <a href="https://cran.r-project.org/web/packages/DBI/index.html"><code>DBI</code></a> package, which provides a set of generic &lsquo;database interface&rsquo; functions. Users create connection objects by creating a &lsquo;driver&rsquo; object for the specific database and passing that to <code>dbConnect()</code>. Then you pass that connection object to the other <code>DBI</code> functions. For example, to query an execute a statement for a PostgreSQL database:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">RPostgreSQL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">driver</span> <span class="o">&lt;-</span> <span class="nf">PostgreSQL</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="n">conn</span> <span class="o">&lt;-</span> <span class="n">DBI</span><span class="o">::</span><span class="nf">dbConnect</span><span class="p">(</span><span class="n">driver</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">student_count</span> <span class="o">&lt;-</span> <span class="n">DBI</span><span class="o">::</span><span class="nf">dbGetQuery</span><span class="p">(</span><span class="n">conn</span><span class="p">,</span> <span class="s">&#34;select count(*) from students&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> <code>sym_yahoo()</code> function corresponds to the <code>PostgreSQL()</code> function in the example above. And the <code>import_ohlc()</code> function pulls the data like <code>DBI::dbGetQuery()</code>. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">rfimport</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># The sym_* functions are a combination of the</span>
</span></span><span class="line"><span class="cl"><span class="c1"># driver, connection, and query in DBI</span>
</span></span><span class="line"><span class="cl"><span class="n">sym</span> <span class="o">&lt;-</span> <span class="nf">sym_yahoo</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Import some data from Yahoo Finance</span>
</span></span><span class="line"><span class="cl"><span class="n">spy</span> <span class="o">&lt;-</span> <span class="nf">import_ohlc</span><span class="p">(</span><span class="n">sym</span><span class="p">)</span>
</span></span></code></pre></div><h3 id="symbol-specification">Symbol specification</h3>
<p>The package introduces a new virtual S3 class <code>&quot;symbol_spec&quot;</code> as the basis for creating sub-classes that hold all necessary information to connect to a data source. This virtual class allows users to combine symbols from different data sources into a single vector. For example: <code>import_ohlc_collection(c(sym_yahoo(&quot;SPY&quot;), sym_tiingo(&quot;DIA&quot;)))</code> will import data for &ldquo;SPY&rdquo; from <a href="https://finance.yahoo.com/">Yahoo Finance</a> and data for &ldquo;DIA&rdquo; from <a href="https://www.tiingo.com/">Tiingo</a>.</p>
<p>Each data source will have its own <code>symbol_spec</code> constructor. The constructor will have an argument for the vector of symbols and other arguments for all the other data source connection settings. It will return an object that inherits from the new virtual <code>symbol_spec</code> For example <code>sym_yahoo()</code> will return a <code>c(&quot;yahoo&quot;, &quot;symbol_spec&quot;)</code> class vector.</p>
<p>The help page for the symbol spec constructors can also document the import methods that the data source supports. So <code>help(&quot;sym_yahoo&quot;)</code> would also contain information about <code>import_ohlc.yahoo()</code> and <code>import_ohlc_collection.yahoo()</code>. That way, users don&rsquo;t need to know the name of the data source method in order to find its documentation.</p>
<h3 id="ticker-symbology">Ticker symbology</h3>
<p>The package would standardize how index tickers are specified. One possibility is to prefix the ticker with an <code>i</code> or <code>i_</code> (e.g. <code>iDJI</code> or <code>i_DJI</code>).</p>
<p>It would also standardize how to specify share classes, warrants, preferred, etc. One possibility is to use an underscore to identify share classes, a lowercase &lsquo;w&rsquo; for warrants, and a lowercase &lsquo;p&rsquo; for preferred. For example, <code>BRK_B</code> for Berkshire Hathaway B shares, <code>FOOw</code> for warrants, <code>BARp</code> for preferred. We could also include a translation table and/or function. This would take a lot of effort to do correctly.</p>
<p>An easier alternative would be creating a way to map source symbols to user-defined values. It makes the most sense to do this is the <code>sym_&lt;source&gt;()</code> constructor. But how should the mapping be specified? Some possibilities:</p>
<ul>
<li><code>sym_yahoo(BRK.B = list(symbol = &quot;BRK-B&quot;))</code></li>
<li><code>sym_yahoo(c(BRK.B = &quot;BRK-B&quot;, &quot;DIA&quot;))</code></li>
<li><code>sym_yahoo(c(&quot;BRK.B&quot;, &quot;DIA&quot;), sym_db = list(BRK.B = &quot;BRK-B&quot;))</code></li>
</ul>
<h3 id="generic-import-functions">Generic import functions</h3>
<p>The package will have generic functions <code>import_ohlc()</code> and <code>import_ohlc_collection()</code> to dispatch on <code>symbol_spec</code> sub-classes. <code>import_ohlc()</code> only handles a single symbol and returns one xts object. <code>import_ohlc_collection()</code> will return a list of xts objects for one or more symbols.</p>
<p>Other generic import functions may be added in the future. It may make sense to include generic <code>import</code> functions that return specific types of data. For example: <code>import_statements()</code> for financial statements, and <code>import_bbo()</code> for best bid and offer.</p>
<p>The generics will have a <code>symbol_spec</code>, <code>dates</code>, <code>periodicity</code>, and <code>...</code> arguments.</p>
<p><code>dates</code> can be either an ISO 8601 date interval (e.g. <code>dates = &quot;2021-01-01/2021-12-31&quot;</code>) or a two-element vector with the start and end dates (e.g. <code>dates = c(&quot;2021-01-01&quot;, &quot;2021-12-31&quot;)</code>). The vector can be Date, POSIXct, or a character that is coercible to one of those two classes.</p>
<p>For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># one symbol returned as an xts object</span>
</span></span><span class="line"><span class="cl"><span class="n">spy</span> <span class="o">&lt;-</span> <span class="nf">import_ohlc</span><span class="p">(</span><span class="nf">sym_yahoo</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">),</span> <span class="n">dates</span> <span class="o">=</span> <span class="s">&#34;2021/2022&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># two symbols returned as a list of xts objects</span>
</span></span><span class="line"><span class="cl"><span class="n">stocks</span> <span class="o">&lt;-</span> <span class="nf">sym_tiingo</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;AAPL&#34;</span><span class="p">,</span> <span class="s">&#34;NFLX&#34;</span><span class="p">))</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">import_ohlc_collection</span><span class="p">(</span><span class="n">dates</span> <span class="o">=</span> <span class="s">&#34;2021-03-01/2022-11-31&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>periodicity</code> argument specifies the interval between data points (e.g. daily, monthly, 15-minute). The data source determines the possible periodicity values, so the data source method is responsible for ensuring the requested periodicity value is available from the data source. <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> will provide a standard way to specify the periodicity values. Then the source methods can translate those values into the value source needs. For example, one data source may use &ldquo;monthly&rdquo; for monthly data and another may use &ldquo;months&rdquo;. Users would set <code>periodicity = &quot;months&quot;</code> for either source and the source method would translate the value to &ldquo;monthly&rdquo;.</p>
<h3 id="data-source-methods">Data source methods</h3>
<p>Each data source will have a S3 method for the relevant import generics, rather than a <code>src</code> argument like <code>getSymbols()</code>. Calling <code>import_ohlc(sym_yahoo(&quot;SPY&quot;))</code> will call the corresponding <code>import_ohlc.yahoo()</code> method to import data from <a href="https://finance.yahoo.com">Yahoo Finance</a>. <code>import_ohlc(sym_tiingo(&quot;DIA&quot;))</code> will call <code>import_ohlc.tiingo()</code> to import data from <a href="https://api.tiingo.com/">Tiingo</a>.</p>
<h4 id="returned-data">Returned data</h4>
<p>The built-in data source methods will automatically include dividends and splits (when available) for daily OHLCV data. They will be included as attributes on the returned OHLCV object. This will allow users to switch between adjusted and unadjusted prices without having to re-download the data.</p>
<p>The built-in data sources methods also will not include the series symbol in the OHLCV column names like <code>getSymbols()</code> currently does. It may make sense to include an attribute with the &ldquo;source symbol&rdquo; and the &ldquo;R symbol&rdquo; on the returned xts object (e.g. <code>src_symbol = &quot;^DJI&quot;</code> and <code>r_symbol = &quot;iDJI&quot;)</code>. Then that attribute can be used later as part of the column names.</p>
<h3 id="providing-defaults-functionality">Providing &lsquo;Defaults&rsquo; functionality</h3>
<p>Though we want to avoid side-effects, we probably want to provide a way to set credentials so they do not have to be provided for every import call.</p>
<p>We could provide this functionality in a pure way by creating an <code>options</code> object that holds a list of values. Users would create this object once and pass it to the relevant <a href="https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> function (either <code>sym_&lt;source&gt;()</code> or <code>import_ohlc()</code>). The default options could be created by a function like <code>sym_&lt;source&gt;_options()</code>. This would be similar to the &lsquo;control&rsquo; arguments to many optimization routines (e.g. <code>DEoptim.control()</code>).</p>
<h1 id="open-questions-and-considerations">Open questions and considerations</h1>
<h3 id="how-should-we-specify-the-class-of-the-returned-object">How should we specify the class of the returned object?</h3>
<ul>
<li>
<p>Set it via a <code>return_class</code> argument in the <code>symbol_spec</code> constructor</p>
<ul>
<li>PRO: each source is likely to have a specific data structure, and it wouldn&rsquo;t require creating a generic <code>import</code> function for each return type.</li>
<li>CON: allows the potential for one call to an <code>import_*_collection()</code> function to return a list of heterogeneous objects.</li>
</ul>
</li>
<li>
<p>Set it via a <code>return_class</code> argument in the <code>import</code> method</p>
<ul>
<li>PRO: the method would return a list of objects that are all the same class.</li>
<li>CON: the generic and/or the default <code>import</code> method would need a <code>return_class</code> argument.</li>
</ul>
</li>
<li>
<p>Create a new generic <code>import</code> functions for each return class</p>
<ul>
<li>PRO: makes it clear what the <code>import</code> function returns.</li>
<li>CON: namespace clutter, don&rsquo;t want generics for <em>every</em> class. Possibly provide generics for most widely used non-xts classes: data.frame, data.table, tibble, tsibble.</li>
</ul>
</li>
<li>
<p>The symbol specification can store a function that controls what data is returned. This doesn&rsquo;t seem appealing because it adds complexity and the user could call that function after the data is returned. For example: <code>sym_yahoo(&quot;SPY&quot;, return_func = as.data.table)</code>.</p>
</li>
</ul>
<h3 id="how-can-we-make-it-easier-to-manipulate-results">How can we make it easier to manipulate results?</h3>
<p>The most common use case is making a wide xts object with close prices from a list of xts objects. This currently requires several steps that are likely unfamiliar to most users. It should be possible with one or two function calls. We can consider Garrett See&rsquo;s <a href="https://github.com/gsee/qmao">qmao</a> package for inspiration. For example, use &lsquo;price frames&rsquo; to replace <code>do.call(merge, list_of_xts_objects)</code>.</p>
<p>There are lots of other common manipulations, like aggregating to a higher periodicity or applying a function to many symbols&rsquo; data. The import functions will return something list-like, so users can use <code>lapply()</code> to apply any other function to each series.</p>
<h1 id="i-need-your-help">I need your help!</h1>
<p>I don&rsquo;t want to do this in a vacuum. Please try the new package, provide feedback, suggestions, feature requests, and help clarify documentation.</p>
<p>I need to know how you&rsquo;re using <code>getSymbols()</code> and how you would use the new package. I&rsquo;m not omniscient, so your feedback will be extremely valuable!</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176077" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176077" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176078" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176079" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176080" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176080" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176081" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176081" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>quantmod and <code>getSymbols()</code> have been a core part of the R/Finance ecosystem for over 15 years. We want to change some things, but they would break existing code. We can make these changes in the new <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> package instead.</p>
<h3 id="background">Background</h3>
<p>The quantmod package has been a core part of the R/Finance ecosystem for over 15 years. It&rsquo;s awesome that the package is so popular, but that also comes with responsibility to maintain backward compatibility. Breaking changes may break code used for making business decisions, research, production, blog posts, books, courses, answers on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com">stackoverflow</a>, and much more. We take this responsibility seriously, and do our best to keep functions backward compatible. Sometimes breaking changes are necessary (e.g. bug fixes, changes to external data sources, etc.), but we do our best to make them carefully, with plenty of warning and lead time for users to adjust their code.</p>
<h3 id="motivation">Motivation</h3>
<p>There are things in quantmod that we want to change, but they would certainly break existing code. No matter how much we&rsquo;d like to make those changes, we can&rsquo;t justify breaking a large portion of the code our community has written in the past 15+ years.</p>
<p>We can create a new package instead of making these changes in quantmod. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> is where we will work on new implementations that improve on the pieces in <code>getSymbols()</code> that we would like to change. This code is <em>extremely alpha</em>. This is the time to provide feedback, suggestions, feature requests, etc. Know that we will break things, maybe without warning. You should consider the API unstable until the 1.0.0 release.</p>
<h3 id="refresher-on-how-getsymbols-works">Refresher on how <code>getSymbols()</code> works</h3>
<p>By default <code>getSymbols()</code> creates objects in the environment it&rsquo;s called from, and it returns the value of the <code>Symbols</code> argument. It&rsquo;s good practice for functions to avoid changing anything in the user&rsquo;s environment (this is called having side-effects). It&rsquo;s better for functions to only return a value, like <code>getSymbols(..., auto.assign = FALSE)</code> does. <code>getSymbols()</code> does not support <code>auto.assign = FALSE</code> for more than one symbol.</p>
<p><code>getSymbols()</code> also uses functionality that was formerly provided by the archived <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package. This functionality allows users to set default values for <code>getSymbols()</code> source method arguments (e.g. <code>return.class = "data.frame"</code>). This is also a side-effect because it makes <code>getSymbols()</code> depend on something other than argument values.</p>
<p><code>getSymbols()</code> specifies the data sources via its <code>src</code> argument, and uses the <code>src</code> argument to determine which source method to use (e.g. <code>getSymbols("SPY", src= "yahoo")</code> will call <code>getSymbols.yahoo("SPY")</code> behind the scenes). This is essentially method dispatch, but done manually rather than using R&rsquo;s built-in S3 functionality.</p>
<h1 id="what-weve-learned">What we&rsquo;ve learned</h1>
<ol>
<li>We should avoid the side-effect of creating objects in the calling environment.</li>
<li>Data sources should use S3 method dispatch, and documentation needs to be easier to find.</li>
<li>Stock ticker symbology is a pain and we need a better way to handle it.</li>
<li>We need a way to provide functionality like the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package did, but without side-effects.</li>
</ol>
<h3 id="1-automatically-creating-objects">1. Automatically creating objects</h3>
<p><code>getSymbols()</code> creates an object for every value in the <code>Symbols</code> argument. This isn&rsquo;t an issue for a few symbols, but it clutters the environment when there are several hundred symbols. You can load all the symbols into a separate environment, but that&rsquo;s not a pattern most users are familiar with.</p>
<p>We wanted to remove the ability to load objects into the calling environment, and even created a warning about changing <code>auto.assign = FALSE</code> as the default for <code>getSymbols()</code> and recommending users replace their <code>getSymbols()</code> call with the <code>loadSymbols()</code> function that already exists. But we ultimately decided breaking the community&rsquo;s code wasn&rsquo;t worth it.</p>
<p>Automatically creating objects makes it cumbersome to put prices for all symbols into one object. This is a common use case and there are several steps. It should be possible with one or two function calls. Here&rsquo;s an example.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">symbols</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">,</span> <span class="s">&#34;AAPL&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="n">symbols</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Put all the prices into one xts object,</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">get</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1"># or</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="n">symbols</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Extract only the Close prices</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices</span> <span class="o">&lt;-</span> <span class="nf">Cl</span><span class="p">(</span><span class="n">prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Remove &#34;.Close&#34; suffix so close_prices[, &#34;SPY&#34;] works</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">sub</span><span class="p">(</span><span class="s">&#34;.Close&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">))</span>
</span></span></code></pre></div><p>Automatically creating objects also makes passing all the data to another function awkward. It causes users to do things like:</p>
<ul>
<li>Call <code>getSymbols()</code> in any function that needs data, which may mean the same data is imported multiple times.</li>
<li>Pass the same <code>symbols</code> object to <code>getSymbols()</code> and the other function. Then the other function searches through environments to find the objects with named with those <code>symbols</code>.</li>
<li>Users could put all the data in an environment and use that as an argument to the function, but I haven&rsquo;t seen many people use this pattern.</li>
</ul>
<h3 id="2-data-source-methods">2. Data source methods</h3>
<p>Different <code>getSymbols()</code> source methods can (or may need to) have different arguments. Ideally the source methods wouldn&rsquo;t be exported because users shouldn&rsquo;t call them directly (users should call <code>getSymbols("SPY", src= "yahoo")</code> instead of <code>getSymbols.yahoo("SPY")</code>). It&rsquo;s hard to find documentation for unexported functions, which means it&rsquo;s hard to know what arguments are available for each source method.</p>
<p>The source methods are named like S3 methods even though <code>getSymbols()</code> isn&rsquo;t a generic function and the source methods aren&rsquo;t actual S3 methods. This has the potential to create odd behavior that would confuse users.</p>
<h3 id="3-ticker-symbology">3. Ticker symbology</h3>
<p>There are two major issues with ticker symbols.</p>
<ol>
<li>Exchanges and data providers sometimes use different ticker symbols for the same security.</li>
<li>Some ticker symbols are not valid R object names.</li>
</ol>
<p>Another issue is when the ticker symbol is similar to the name of one of the price columns. This has come up several times with Lowe&rsquo;s (LOW). The <code>Lo()</code> and <code>OHLC()</code> functions think all of the columns with the ticker symbol in the column name are the low price for the period.</p>
<h4 id="same-security-different-ticker">Same security, different ticker</h4>
<p>This isn&rsquo;t <code>getSymbols()</code>&rsquo;s fault and it&rsquo;s out of our control, but it could be handled better. Exchange and data source symbology is awful. Identifiers for the same series are often different across exchanges and data providers. For example: the symbol for Berkshire Hathaway B-class shares is &ldquo;BRK-B&rdquo; for Yahoo Finance, &ldquo;BRK/B&rdquo; for the SIP (Securities Information Processor), &ldquo;BRK B&rdquo; for ICE, and probably &ldquo;BRK.B&rdquo; somewhere else.</p>
<p>This is a difficult problem and will likely take a lot of effort to get right. Therefore it won&rsquo;t be a high priority initially.</p>
<h4 id="invalid-r-object-names">Invalid R object names</h4>
<p><code>getSymbols()</code> tries to create objects with valid R names, but only does so for <em>some</em> symbols that aren&rsquo;t valid R object names. For example, <code>BRK-B</code>, <code>BRK B</code>, and <code>BRK/B</code> aren&rsquo;t valid R objects names because valid names start with a letter or a dot (<code>.</code>), and can only contain letters, numbers, a dot, or an underscore.</p>
<p>Here are some common examples of ticker symbology woes:</p>
<p><code>^DJI</code> isn&rsquo;t a valid R object name because it starts with <code>^</code>. So <code>getSymbols()</code> creates an object with the <code>^</code> removed. But then you can&rsquo;t use the code below to put all the prices into one object. Also notice that <code>getSymbols()</code> <em>returns</em> <code>"^DJI"</code> even though it creates an object with a different name.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">symbols</span> <span class="o">&lt;-</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;^DJI&#34;</span><span class="p">,</span> <span class="s">&#34;BRK-B&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="n">symbols</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;^DJI&#34; &#34;BRK-B&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="n">symbols</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error: value for &#39;^DJI&#39; not found</span>
</span></span></code></pre></div><p>You have to remove the leading <code>^</code> manually. And you have to set <code>fixed = TRUE</code> in the call to <code>sub()</code> because <code>^</code> is a special character in regular expressions. <em>Sigh</em>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">mget</span><span class="p">(</span><span class="nf">sub</span><span class="p">(</span><span class="s">&#34;^&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">fixed</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)))</span>
</span></span></code></pre></div><p>Recall that <code>BRK-B</code> also isn&rsquo;t a valid R name because of the <code>-</code>. But it wasn&rsquo;t an issue in the code above because <code>getSymbols()</code> made an object named <code>BRK-B</code>, not an object with a valid R name. This is confusing for users because they can&rsquo;t easily access that object (i.e. <code>head(BRK-B)</code> is an error). This is a pervasive issue for several foreign exchanges with tickers that begin with numbers (e.g. <code>000001.SZ</code>).</p>
<p>Another issue with symbols that aren&rsquo;t valid R object names is that many R functions will convert column names into valid R object names, including <code>merge.xts()</code>. So you can&rsquo;t use the input symbol to subset the resulting xts object. Here&rsquo;s an example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Extract the close prices and remove &#34;.Close&#34; suffix</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices</span> <span class="o">&lt;-</span> <span class="nf">Cl</span><span class="p">(</span><span class="n">prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">sub</span><span class="p">(</span><span class="s">&#34;.Close&#34;</span><span class="p">,</span> <span class="s">&#34;&#34;</span><span class="p">,</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Extract the close price for &#34;BRK-B&#34;</span>
</span></span><span class="line"><span class="cl"><span class="n">close_prices[</span><span class="p">,</span> <span class="s">&#34;BRK-B&#34;</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error in `[.xts`(close_prices, , &#34;BRK-B&#34;) : subscript out of bounds</span>
</span></span><span class="line"><span class="cl"><span class="nf">colnames</span><span class="p">(</span><span class="n">close_prices</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;DJI&#34; &#34;BRK.B&#34;</span>
</span></span></code></pre></div><p><code>setSymbolLookup()</code> exists to help with things like this, but it&rsquo;s another function users have to learn to use and my experience is that most users don&rsquo;t know about <code>setSymbolLookup()</code>. I just had to look at the source to figure out how to use it to make <code>getSymbols()</code> return a valid R object for <code>"BRK-B"</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setSymbolLookup</span><span class="p">(</span><span class="n">BRK.B</span> <span class="o">=</span> <span class="nf">list</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#34;BRK-B&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;yahoo&#34;</span><span class="p">))</span>
</span></span></code></pre></div><p>If I have to look at the source code to figure out how to do this, users don&rsquo;t have a chance. You may think, &ldquo;but you could document how to do this&rdquo;, but writing documentation isn&rsquo;t fun. And who reads the documentation anyway? ;-)</p>
<h3 id="4-defaults-functionality">4. &lsquo;Defaults&rsquo; functionality</h3>
<p>The &lsquo;Defaults&rsquo; functionality in quantmod comes from the archived <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=Defaults">&lsquo;Defaults&rsquo;</a> package. This functionality allows users to set new default argument values to any <code>getSymbols()</code> source function. This is helpful because it makes importing easier. But it means <code>getSymbols()</code> relies on something other than its parameter values, and it&rsquo;s good practice to avoid side-effects like this.</p>
<p>This gave users the ability to set preferences like return class, periodicity (e.g. hourly, daily, monthly), connection settings (e.g. credentials, API keys).</p>
<h1 id="rfimport-design-and-features">&lsquo;rfimport&rsquo; design and features</h1>
<p>The design of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> is influenced by the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/web/packages/DBI/index.html"><code>DBI</code></a> package, which provides a set of generic &lsquo;database interface&rsquo; functions. Users create connection objects by creating a &lsquo;driver&rsquo; object for the specific database and passing that to <code>dbConnect()</code>. Then you pass that connection object to the other <code>DBI</code> functions. For example, to query an execute a statement for a PostgreSQL database:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">RPostgreSQL</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">driver</span> <span class="o">&lt;-</span> <span class="nf">PostgreSQL</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="n">conn</span> <span class="o">&lt;-</span> <span class="n">DBI</span><span class="o">::</span><span class="nf">dbConnect</span><span class="p">(</span><span class="n">driver</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">student_count</span> <span class="o">&lt;-</span> <span class="n">DBI</span><span class="o">::</span><span class="nf">dbGetQuery</span><span class="p">(</span><span class="n">conn</span><span class="p">,</span> <span class="s">&#34;select count(*) from students&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> <code>sym_yahoo()</code> function corresponds to the <code>PostgreSQL()</code> function in the example above. And the <code>import_ohlc()</code> function pulls the data like <code>DBI::dbGetQuery()</code>. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">rfimport</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># The sym_* functions are a combination of the</span>
</span></span><span class="line"><span class="cl"><span class="c1"># driver, connection, and query in DBI</span>
</span></span><span class="line"><span class="cl"><span class="n">sym</span> <span class="o">&lt;-</span> <span class="nf">sym_yahoo</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Import some data from Yahoo Finance</span>
</span></span><span class="line"><span class="cl"><span class="n">spy</span> <span class="o">&lt;-</span> <span class="nf">import_ohlc</span><span class="p">(</span><span class="n">sym</span><span class="p">)</span>
</span></span></code></pre></div><h3 id="symbol-specification">Symbol specification</h3>
<p>The package introduces a new virtual S3 class <code>"symbol_spec"</code> as the basis for creating sub-classes that hold all necessary information to connect to a data source. This virtual class allows users to combine symbols from different data sources into a single vector. For example: <code>import_ohlc_collection(c(sym_yahoo("SPY"), sym_tiingo("DIA")))</code> will import data for &ldquo;SPY&rdquo; from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/">Yahoo Finance</a> and data for &ldquo;DIA&rdquo; from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tiingo.com/">Tiingo</a>.</p>
<p>Each data source will have its own <code>symbol_spec</code> constructor. The constructor will have an argument for the vector of symbols and other arguments for all the other data source connection settings. It will return an object that inherits from the new virtual <code>symbol_spec</code> For example <code>sym_yahoo()</code> will return a <code>c("yahoo", "symbol_spec")</code> class vector.</p>
<p>The help page for the symbol spec constructors can also document the import methods that the data source supports. So <code>help("sym_yahoo")</code> would also contain information about <code>import_ohlc.yahoo()</code> and <code>import_ohlc_collection.yahoo()</code>. That way, users don&rsquo;t need to know the name of the data source method in order to find its documentation.</p>
<h3 id="ticker-symbology">Ticker symbology</h3>
<p>The package would standardize how index tickers are specified. One possibility is to prefix the ticker with an <code>i</code> or <code>i_</code> (e.g. <code>iDJI</code> or <code>i_DJI</code>).</p>
<p>It would also standardize how to specify share classes, warrants, preferred, etc. One possibility is to use an underscore to identify share classes, a lowercase &lsquo;w&rsquo; for warrants, and a lowercase &lsquo;p&rsquo; for preferred. For example, <code>BRK_B</code> for Berkshire Hathaway B shares, <code>FOOw</code> for warrants, <code>BARp</code> for preferred. We could also include a translation table and/or function. This would take a lot of effort to do correctly.</p>
<p>An easier alternative would be creating a way to map source symbols to user-defined values. It makes the most sense to do this is the <code>sym_&lt;source&gt;()</code> constructor. But how should the mapping be specified? Some possibilities:</p>
<ul>
<li><code>sym_yahoo(BRK.B = list(symbol = "BRK-B"))</code></li>
<li><code>sym_yahoo(c(BRK.B = "BRK-B", "DIA"))</code></li>
<li><code>sym_yahoo(c("BRK.B", "DIA"), sym_db = list(BRK.B = "BRK-B"))</code></li>
</ul>
<h3 id="generic-import-functions">Generic import functions</h3>
<p>The package will have generic functions <code>import_ohlc()</code> and <code>import_ohlc_collection()</code> to dispatch on <code>symbol_spec</code> sub-classes. <code>import_ohlc()</code> only handles a single symbol and returns one xts object. <code>import_ohlc_collection()</code> will return a list of xts objects for one or more symbols.</p>
<p>Other generic import functions may be added in the future. It may make sense to include generic <code>import</code> functions that return specific types of data. For example: <code>import_statements()</code> for financial statements, and <code>import_bbo()</code> for best bid and offer.</p>
<p>The generics will have a <code>symbol_spec</code>, <code>dates</code>, <code>periodicity</code>, and <code>...</code> arguments.</p>
<p><code>dates</code> can be either an ISO 8601 date interval (e.g. <code>dates = "2021-01-01/2021-12-31"</code>) or a two-element vector with the start and end dates (e.g. <code>dates = c("2021-01-01", "2021-12-31")</code>). The vector can be Date, POSIXct, or a character that is coercible to one of those two classes.</p>
<p>For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># one symbol returned as an xts object</span>
</span></span><span class="line"><span class="cl"><span class="n">spy</span> <span class="o">&lt;-</span> <span class="nf">import_ohlc</span><span class="p">(</span><span class="nf">sym_yahoo</span><span class="p">(</span><span class="s">&#34;SPY&#34;</span><span class="p">),</span> <span class="n">dates</span> <span class="o">=</span> <span class="s">&#34;2021/2022&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># two symbols returned as a list of xts objects</span>
</span></span><span class="line"><span class="cl"><span class="n">stocks</span> <span class="o">&lt;-</span> <span class="nf">sym_tiingo</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;AAPL&#34;</span><span class="p">,</span> <span class="s">&#34;NFLX&#34;</span><span class="p">))</span> <span class="o">|&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nf">import_ohlc_collection</span><span class="p">(</span><span class="n">dates</span> <span class="o">=</span> <span class="s">&#34;2021-03-01/2022-11-31&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>periodicity</code> argument specifies the interval between data points (e.g. daily, monthly, 15-minute). The data source determines the possible periodicity values, so the data source method is responsible for ensuring the requested periodicity value is available from the data source. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> will provide a standard way to specify the periodicity values. Then the source methods can translate those values into the value source needs. For example, one data source may use &ldquo;monthly&rdquo; for monthly data and another may use &ldquo;months&rdquo;. Users would set <code>periodicity = "months"</code> for either source and the source method would translate the value to &ldquo;monthly&rdquo;.</p>
<h3 id="data-source-methods">Data source methods</h3>
<p>Each data source will have a S3 method for the relevant import generics, rather than a <code>src</code> argument like <code>getSymbols()</code>. Calling <code>import_ohlc(sym_yahoo("SPY"))</code> will call the corresponding <code>import_ohlc.yahoo()</code> method to import data from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com">Yahoo Finance</a>. <code>import_ohlc(sym_tiingo("DIA"))</code> will call <code>import_ohlc.tiingo()</code> to import data from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://api.tiingo.com/">Tiingo</a>.</p>
<h4 id="returned-data">Returned data</h4>
<p>The built-in data source methods will automatically include dividends and splits (when available) for daily OHLCV data. They will be included as attributes on the returned OHLCV object. This will allow users to switch between adjusted and unadjusted prices without having to re-download the data.</p>
<p>The built-in data sources methods also will not include the series symbol in the OHLCV column names like <code>getSymbols()</code> currently does. It may make sense to include an attribute with the &ldquo;source symbol&rdquo; and the &ldquo;R symbol&rdquo; on the returned xts object (e.g. <code>src_symbol = "^DJI"</code> and <code>r_symbol = "iDJI")</code>. Then that attribute can be used later as part of the column names.</p>
<h3 id="providing-defaults-functionality">Providing &lsquo;Defaults&rsquo; functionality</h3>
<p>Though we want to avoid side-effects, we probably want to provide a way to set credentials so they do not have to be provided for every import call.</p>
<p>We could provide this functionality in a pure way by creating an <code>options</code> object that holds a list of values. Users would create this object once and pass it to the relevant <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/rfimport/">&lsquo;rfimport&rsquo;</a> function (either <code>sym_&lt;source&gt;()</code> or <code>import_ohlc()</code>). The default options could be created by a function like <code>sym_&lt;source&gt;_options()</code>. This would be similar to the &lsquo;control&rsquo; arguments to many optimization routines (e.g. <code>DEoptim.control()</code>).</p>
<h1 id="open-questions-and-considerations">Open questions and considerations</h1>
<h3 id="how-should-we-specify-the-class-of-the-returned-object">How should we specify the class of the returned object?</h3>
<ul>
<li>
<p>Set it via a <code>return_class</code> argument in the <code>symbol_spec</code> constructor</p>
<ul>
<li>PRO: each source is likely to have a specific data structure, and it wouldn&rsquo;t require creating a generic <code>import</code> function for each return type.</li>
<li>CON: allows the potential for one call to an <code>import_*_collection()</code> function to return a list of heterogeneous objects.</li>
</ul>
</li>
<li>
<p>Set it via a <code>return_class</code> argument in the <code>import</code> method</p>
<ul>
<li>PRO: the method would return a list of objects that are all the same class.</li>
<li>CON: the generic and/or the default <code>import</code> method would need a <code>return_class</code> argument.</li>
</ul>
</li>
<li>
<p>Create a new generic <code>import</code> functions for each return class</p>
<ul>
<li>PRO: makes it clear what the <code>import</code> function returns.</li>
<li>CON: namespace clutter, don&rsquo;t want generics for <em>every</em> class. Possibly provide generics for most widely used non-xts classes: data.frame, data.table, tibble, tsibble.</li>
</ul>
</li>
<li>
<p>The symbol specification can store a function that controls what data is returned. This doesn&rsquo;t seem appealing because it adds complexity and the user could call that function after the data is returned. For example: <code>sym_yahoo("SPY", return_func = as.data.table)</code>.</p>
</li>
</ul>
<h3 id="how-can-we-make-it-easier-to-manipulate-results">How can we make it easier to manipulate results?</h3>
<p>The most common use case is making a wide xts object with close prices from a list of xts objects. This currently requires several steps that are likely unfamiliar to most users. It should be possible with one or two function calls. We can consider Garrett See&rsquo;s <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/gsee/qmao">qmao</a> package for inspiration. For example, use &lsquo;price frames&rsquo; to replace <code>do.call(merge, list_of_xts_objects)</code>.</p>
<p>There are lots of other common manipulations, like aggregating to a higher periodicity or applying a function to many symbols&rsquo; data. The import functions will return something list-like, so users can use <code>lapply()</code> to apply any other function to each series.</p>
<h1 id="i-need-your-help">I need your help!</h1>
<p>I don&rsquo;t want to do this in a vacuum. Please try the new package, provide feedback, suggestions, feature requests, and help clarify documentation.</p>
<p>I need to know how you&rsquo;re using <code>getSymbols()</code> and how you would use the new package. I&rsquo;m not omniscient, so your feedback will be extremely valuable!</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672286/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672286/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176077" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176077" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176078" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176079" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176080" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176080" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176081" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176081" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/04/xts-0-13-1-on-cran/</feedburner:origLink><title>xts_0.13.1 on CRAN</title><link>https://feeds.feedblitz.com/~/748672289/0/fosstrading/</link><pubDate>Mon, 24 Apr 2023 10:54:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/04/xts-0-13-1-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=xts">xts</a> is now on <a href="http://cran.r-project.org/">CRAN</a>. This release patches a few issues with the features added in version 0.13.0 and addresses a few maintenance issues that popped up recently.</p>
<h3 id="patches-for-features-added-in-0130">Patches for features added in 0.13.0</h3>
<ul>
<li>
<p>Format each column individually before printing. The top/bottom rows could have a different number of decimal places and there are often multiple varying spaces between columns. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"> <span class="n">close</span> <span class="n">volume</span> <span class="n">ma</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">31</span><span class="o">:</span><span class="m">00</span> <span class="m">476.470</span> <span class="m">803961.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">32</span><span class="o">:</span><span class="m">00</span> <span class="m">476.700</span> <span class="m">179476.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">33</span><span class="o">:</span><span class="m">00</span> <span class="m">476.540</span> <span class="m">197919.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"> <span class="kc">...</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">52</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6000</span> <span class="m">46728.0000</span> <span class="m">392.8636</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">53</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6500</span> <span class="m">64648.0000</span> <span class="m">392.8755</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">54</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6500</span> <span class="m">69900.0000</span> <span class="m">392.8873</span>
</span></span></code></pre></div><p>There are 4 spaces between the index and the &lsquo;close&rsquo; column, 2 between &lsquo;close&rsquo; and &lsquo;volume&rsquo;, and 4 between &lsquo;volume&rsquo; and &lsquo;ma&rsquo;. There should be a consistent number of spaces between the columns. Most other classes of objects print with 1 space between the columns. The top rows have 3 decimals and the bottom rows have 4. These should also be the same. (<a href="https://github.com/joshuaulrich/xts/issues/321">#321</a>)</p>
</li>
<li>
<p>Make column names based on number of columns. The original code was a lot more complicated because it tried to account for truncating the number of printed columns. That functionality was removed because of how complicated it was. So now we can simply create printed column names from the number of columns. (<a href="https://github.com/joshuaulrich/xts/issues/395">#395</a>)</p>
</li>
<li>
<p>Only convert printed index values to character. Converting the entire index to character is time-consuming for xts objects with many observations. It can take more than a second to print an xts object with 1 million observations.</p>
</li>
<li>
<p>Reduce instances when <code>dplyr::lag()</code> warning is shown. The warning was shown whenever it detected dplyr is installed, even if the user wasn&rsquo;t actively using dplyr. That caused an excessive amount of noise when other packages attached xts (e.g. quantmod). Thanks to Duncan Murdoch for the report and suggested fix! (<a href="https://github.com/joshuaulrich/xts/issues/393">#393</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Return &lsquo;POSIXct&rsquo; if object has no &rsquo;tclass&rsquo;. An empty string is not a valid &rsquo;tclass&rsquo;, so it can cause an error.</p>
</li>
<li>
<p>Fix <code>xts()</code> for zero-row data.frames. The <code>xts()</code> constructor would create an object with a list for coredata when <code>x</code> is a data.frame with no rows. xts objects can&rsquo;t have lists as coredata, so it should convert <code>x</code> to a matrix and throw an error if <code>x</code> is a list. (<a href="https://github.com/joshuaulrich/xts/issues/394">#394</a>)</p>
</li>
<li>
<p>Fix <code>as.data.frame()</code> when converting a data.frame with column names to xts when there&rsquo;s only one non-time-based column. Previously the xts object would not have the data.frame column name. (<a href="https://github.com/joshuaulrich/xts/issues/391">#391</a>)</p>
</li>
<li>
<p>Treat <code>NA</code> the same as <code>NULL</code> for &lsquo;start&rsquo; or &rsquo;end&rsquo; in <code>window.xts()</code>. <code>NULL</code> represents an undefined index value and <code>NA</code> represents an unknown or missing index value. xts does not allow <code>NA</code> as index values, so subsetting an xts or zoo object by <code>NA</code> returns a zero-length object. Therefore a <code>NA</code> (unknown) index value is essentially the same as an undefined index value. (<a href="https://github.com/joshuaulrich/xts/issues/383">#383</a>, <a href="https://github.com/joshuaulrich/xts/issues/345">#345</a>)</p>
</li>
<li>
<p>Warn and remove <code>NA</code> when <code>periodicity()</code> called on date-time vector with any <code>NA</code> values. Previously it threw the uninformative error below. (<a href="https://github.com/joshuaulrich/xts/issues/289">#289</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">Error</span> <span class="kr">in</span> <span class="nf">try.xts</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">error</span> <span class="o">=</span> <span class="s">&#34;&#39;x&#39; needs to be timeBased or xtsible&#34;</span><span class="p">)</span> <span class="o">:</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#39;x&#39;</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">be</span> <span class="n">timeBased</span> <span class="n">or</span> <span class="n">xtsible</span>
</span></span></code></pre></div></li>
<li>
<p>Account for timezones when making names for the list <code>split.xts()</code> creates. This was specifically a problem if the xts object&rsquo;s index was <code>yearmon</code> because <code>as.yearmon.POSIXct()</code> always sets <code>tz = &quot;GMT&quot;</code> when calling <code>as.POSIXlt()</code>, regardless of the xts&rsquo; index &rsquo;tzone&rsquo; attribute. That can cause the <code>as.yearmon()</code> results to be different days for GMT and the index&rsquo;s timezone. Use <code>format.POSIXct()</code> for &ldquo;months&rdquo; because it checks for a &rsquo;tzone&rsquo; attribute before converting to POSIXlt and calling <code>format.POSIXlt()</code>. The conversion to POSIXlt is important because it checks and uses the &rsquo;tzone&rsquo; attribute before considering the &rsquo;tz&rsquo; argument. So it effectively ignores the <code>tz = &quot;GMT&quot;</code> setting in <code>as.yearmon()</code>. This is also the reason for calling <code>as.POSIXlt()</code> before calling <code>as.yearqtr()</code>. (<a href="https://github.com/joshuaulrich/xts/issues/392">#392</a>)</p>
</li>
<li>
<p>Ignore attribute order in <code>all.equal()</code>. Attribute order shouldn&rsquo;t matter. That can be checked with <code>identical()</code>.</p>
</li>
</ul>
<h3 id="chores">Chores</h3>
<ul>
<li>
<p>Add notes on <code>plot.xts()</code> nomenclature and structure. Also add ASCII art to illustrate definitions and layout. (<a href="https://github.com/joshuaulrich/xts/issues/103">#103</a>)</p>
</li>
<li>
<p>Register missing S3 methods and update signatures. With R-devel (83995-ish), <code>R CMD check</code> notes these S3 methods are not registered. It also notes that the signatures for <code>as.POSIXct.tis()</code> and <code>str.replot_xts()</code> do not match the respective generics. <code>R CMD check</code> also thinks <code>time.frequency()</code> is a S3 method because <code>time()</code> is a generic. The function isn&rsquo;t exported, so renaming won&rsquo;t break any external code. Thanks to Kurt Hornik for the report. Issues with functionality for &rsquo;tis&rsquo; were also identified. I removed &rsquo;tis&rsquo; support entirely because the implementation was not even a bare minimum, and it&rsquo;s not clear it even worked correctly. (<a href="https://github.com/joshuaulrich/xts/issues/398">#398</a>)</p>
</li>
<li>
<p>Add instructions to update old objects. Old xts objects do not have &rsquo;tclass&rsquo; and &rsquo;tzone&rsquo; attributes on the index. Add a function to update the object attributes and add a note to the warning to show how to use it. Also, only call <code>tzone()</code> and <code>tclass()</code> once in <code>check.TZ()</code>. Calling these functions multiple times throws multiple warnings for xts objects created before the &rsquo;tclass&rsquo; and &rsquo;tzone&rsquo; were attached to the index instead of the xts object. (<a href="https://github.com/joshuaulrich/xts/issues/306">#306</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176082" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176082" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176083" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176084" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176085" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176085" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176086" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176086" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>. This release patches a few issues with the features added in version 0.13.0 and addresses a few maintenance issues that popped up recently.</p>
<h3 id="patches-for-features-added-in-0130">Patches for features added in 0.13.0</h3>
<ul>
<li>
<p>Format each column individually before printing. The top/bottom rows could have a different number of decimal places and there are often multiple varying spaces between columns. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"> <span class="n">close</span> <span class="n">volume</span> <span class="n">ma</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">31</span><span class="o">:</span><span class="m">00</span> <span class="m">476.470</span> <span class="m">803961.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">32</span><span class="o">:</span><span class="m">00</span> <span class="m">476.700</span> <span class="m">179476.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"><span class="m">2022-01-03</span> <span class="m">09</span><span class="o">:</span><span class="m">33</span><span class="o">:</span><span class="m">00</span> <span class="m">476.540</span> <span class="m">197919.000</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl"> <span class="kc">...</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">52</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6000</span> <span class="m">46728.0000</span> <span class="m">392.8636</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">53</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6500</span> <span class="m">64648.0000</span> <span class="m">392.8755</span>
</span></span><span class="line"><span class="cl"><span class="m">2023-03-16</span> <span class="m">14</span><span class="o">:</span><span class="m">54</span><span class="o">:</span><span class="m">00</span> <span class="m">394.6500</span> <span class="m">69900.0000</span> <span class="m">392.8873</span>
</span></span></code></pre></div><p>There are 4 spaces between the index and the &lsquo;close&rsquo; column, 2 between &lsquo;close&rsquo; and &lsquo;volume&rsquo;, and 4 between &lsquo;volume&rsquo; and &lsquo;ma&rsquo;. There should be a consistent number of spaces between the columns. Most other classes of objects print with 1 space between the columns. The top rows have 3 decimals and the bottom rows have 4. These should also be the same. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/321">#321</a>)</p>
</li>
<li>
<p>Make column names based on number of columns. The original code was a lot more complicated because it tried to account for truncating the number of printed columns. That functionality was removed because of how complicated it was. So now we can simply create printed column names from the number of columns. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/395">#395</a>)</p>
</li>
<li>
<p>Only convert printed index values to character. Converting the entire index to character is time-consuming for xts objects with many observations. It can take more than a second to print an xts object with 1 million observations.</p>
</li>
<li>
<p>Reduce instances when <code>dplyr::lag()</code> warning is shown. The warning was shown whenever it detected dplyr is installed, even if the user wasn&rsquo;t actively using dplyr. That caused an excessive amount of noise when other packages attached xts (e.g. quantmod). Thanks to Duncan Murdoch for the report and suggested fix! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/393">#393</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Return &lsquo;POSIXct&rsquo; if object has no &rsquo;tclass&rsquo;. An empty string is not a valid &rsquo;tclass&rsquo;, so it can cause an error.</p>
</li>
<li>
<p>Fix <code>xts()</code> for zero-row data.frames. The <code>xts()</code> constructor would create an object with a list for coredata when <code>x</code> is a data.frame with no rows. xts objects can&rsquo;t have lists as coredata, so it should convert <code>x</code> to a matrix and throw an error if <code>x</code> is a list. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/394">#394</a>)</p>
</li>
<li>
<p>Fix <code>as.data.frame()</code> when converting a data.frame with column names to xts when there&rsquo;s only one non-time-based column. Previously the xts object would not have the data.frame column name. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/391">#391</a>)</p>
</li>
<li>
<p>Treat <code>NA</code> the same as <code>NULL</code> for &lsquo;start&rsquo; or &rsquo;end&rsquo; in <code>window.xts()</code>. <code>NULL</code> represents an undefined index value and <code>NA</code> represents an unknown or missing index value. xts does not allow <code>NA</code> as index values, so subsetting an xts or zoo object by <code>NA</code> returns a zero-length object. Therefore a <code>NA</code> (unknown) index value is essentially the same as an undefined index value. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/383">#383</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/345">#345</a>)</p>
</li>
<li>
<p>Warn and remove <code>NA</code> when <code>periodicity()</code> called on date-time vector with any <code>NA</code> values. Previously it threw the uninformative error below. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/289">#289</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">Error</span> <span class="kr">in</span> <span class="nf">try.xts</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">error</span> <span class="o">=</span> <span class="s">&#34;&#39;x&#39; needs to be timeBased or xtsible&#34;</span><span class="p">)</span> <span class="o">:</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#39;x&#39;</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">be</span> <span class="n">timeBased</span> <span class="n">or</span> <span class="n">xtsible</span>
</span></span></code></pre></div></li>
<li>
<p>Account for timezones when making names for the list <code>split.xts()</code> creates. This was specifically a problem if the xts object&rsquo;s index was <code>yearmon</code> because <code>as.yearmon.POSIXct()</code> always sets <code>tz = "GMT"</code> when calling <code>as.POSIXlt()</code>, regardless of the xts&rsquo; index &rsquo;tzone&rsquo; attribute. That can cause the <code>as.yearmon()</code> results to be different days for GMT and the index&rsquo;s timezone. Use <code>format.POSIXct()</code> for &ldquo;months&rdquo; because it checks for a &rsquo;tzone&rsquo; attribute before converting to POSIXlt and calling <code>format.POSIXlt()</code>. The conversion to POSIXlt is important because it checks and uses the &rsquo;tzone&rsquo; attribute before considering the &rsquo;tz&rsquo; argument. So it effectively ignores the <code>tz = "GMT"</code> setting in <code>as.yearmon()</code>. This is also the reason for calling <code>as.POSIXlt()</code> before calling <code>as.yearqtr()</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/392">#392</a>)</p>
</li>
<li>
<p>Ignore attribute order in <code>all.equal()</code>. Attribute order shouldn&rsquo;t matter. That can be checked with <code>identical()</code>.</p>
</li>
</ul>
<h3 id="chores">Chores</h3>
<ul>
<li>
<p>Add notes on <code>plot.xts()</code> nomenclature and structure. Also add ASCII art to illustrate definitions and layout. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/103">#103</a>)</p>
</li>
<li>
<p>Register missing S3 methods and update signatures. With R-devel (83995-ish), <code>R CMD check</code> notes these S3 methods are not registered. It also notes that the signatures for <code>as.POSIXct.tis()</code> and <code>str.replot_xts()</code> do not match the respective generics. <code>R CMD check</code> also thinks <code>time.frequency()</code> is a S3 method because <code>time()</code> is a generic. The function isn&rsquo;t exported, so renaming won&rsquo;t break any external code. Thanks to Kurt Hornik for the report. Issues with functionality for &rsquo;tis&rsquo; were also identified. I removed &rsquo;tis&rsquo; support entirely because the implementation was not even a bare minimum, and it&rsquo;s not clear it even worked correctly. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/398">#398</a>)</p>
</li>
<li>
<p>Add instructions to update old objects. Old xts objects do not have &rsquo;tclass&rsquo; and &rsquo;tzone&rsquo; attributes on the index. Add a function to update the object attributes and add a note to the warning to show how to use it. Also, only call <code>tzone()</code> and <code>tclass()</code> once in <code>check.TZ()</code>. Calling these functions multiple times throws multiple warnings for xts objects created before the &rsquo;tclass&rsquo; and &rsquo;tzone&rsquo; were attached to the index instead of the xts object. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/306">#306</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672289/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672289/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176082" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176082" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176083" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176084" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176085" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176085" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176086" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176086" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/04/quantmod-0-4-22-on-cran/</feedburner:origLink><title>quantmod_0.4.22 on CRAN</title><link>https://feeds.feedblitz.com/~/748672292/0/fosstrading/</link><pubDate>Sun, 16 Apr 2023 03:41:57 -0500</pubDate><guid>https://blog.fosstrading.com/2023/04/quantmod-0-4-22-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=quantmod">quantmod</a> is now on <a href="http://cran.r-project.org/">CRAN</a>. It adds functions <code>HL()</code>, <code>is.HL()</code>, and <code>has.HL()</code> to check for &lsquo;high&rsquo; and &rsquo;low&rsquo; price columns. It also makes accessing Yahoo Finance price, dividend, and split data more robust. <code>getSymbols.FRED()</code> got <code>to</code> and <code>from</code> arguments, like other <code>getSymbols()</code> methods. The remaining changes are bug fixes and maintenace chores.</p>
<p>This was mainly a maintenance and bug fix release, but it does include a couple nice features. quantmod versions 0.4.17 through 0.4.21 included several relevant features that weren&rsquo;t highlighted in any previous posts. They&rsquo;re included in a separate section below.</p>
<h3 id="new-features">New Features</h3>
<ul>
<li>
<p>Exported <code>HL()</code>, <code>is.HL()</code>, and <code>has.HL()</code> functions and added documentation. These were added in 0.4.20 but not exported or included in the documentation.</p>
</li>
<li>
<p>Switched to the Yahoo Finance v8 JSON endpoint and removed the v7 CSV endpoint. There seems to be a rate limit for the number of tickers you can request via the CSV endpoint. The <a href="https://github.com/ranaroussi/yfinance">yfinance python library</a> uses the JSON endpoint and doesn&rsquo;t seem to have rate limit issues. (<a href="https://github.com/joshuaulrich/quantmod/issues/360">#360</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/362">#362</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/364">#364</a>)</p>
</li>
<li>
<p><code>getSymbols.FRED()</code> now supports <code>to</code> and <code>from</code> arguments. So users can set the &lsquo;from&rsquo; and &rsquo;to&rsquo; arguments for FRED data like they can for other data sources like Yahoo. Those values had been ignored and the entire series was always returned. (<a href="https://github.com/joshuaulrich/quantmod/issues/368">#368</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fixed <code>getDividends()</code> and <code>getSplits()</code> for stocks that issue monthly dividends. (<a href="https://github.com/joshuaulrich/quantmod/issues/372">#372</a>)</p>
</li>
<li>
<p>Added error handling to <code>getSplits()</code> and <code>getDividends()</code>. <code>getDividends()</code> didn&rsquo;t handle cases where the download failed, or when dividends needed to be split-adjusted but there were no splits. It also tried to set colnames on the empty xts object that&rsquo;s returned when there are no dividends. <code>getSplits()</code> had the same colnames issue. Thanks to Chris Cheung for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/366">#366</a>)</p>
</li>
<li>
<p>Remove &ldquo;^&rdquo; prefix from <code>getSymbols()</code> return value. The name of the object <code>getSymbols()</code> created and the symbol value it returned were inconsistent when the &lsquo;Symbols&rsquo; argument has a &ldquo;^&rdquo; prefix and <code>auto.assign = TRUE</code>:</p>
<ul>
<li><code>getSymbols()</code> removed the &ldquo;^&rdquo; from the object it creates, but</li>
<li>returned the &lsquo;Symbols&rsquo; argument unchanged, and</li>
<li>removed the &ldquo;^&rdquo; from the column names of the object it creates.</li>
</ul>
<p>The example below will create an object named <code>IXIC</code> but the value of <code>sym</code> will be &ldquo;^IXIC&rdquo;.</p>
<pre><code> sym &lt;- getSymbols(&quot;^IXIC&quot;)
</code></pre>
<p>That means <code>x &lt;- get(sym)</code> will not work because an object named <code>^IXIC</code> doesn&rsquo;t exist. (<a href="https://github.com/joshuaulrich/quantmod/issues/371">#371</a>)</p>
</li>
</ul>
<h3 id="chores">Chores</h3>
<ul>
<li>
<p>Moved <a href="http://cran.r-project.org/package=jsonlite">jsonlite</a> from Suggests to Imports so it doesn&rsquo;t cause a problem when a package that doesn&rsquo;t also Suggest jsonlite but uses <code>getSymbols()</code>. Thanks to Kurt Hornik for the report and fix! (<a href="https://github.com/joshuaulrich/quantmod/issues/380">#380</a>)</p>
</li>
<li>
<p>Fixed S3 method issues. R-devel (83995-ish) added a check that found methods that were not registered (<code>str.replot()</code>, <code>seriesHi.timeSeries()</code>, and <code>seriesLo.timeSeries()</code>). It was also confused by <code>range.bars()</code> and <code>unique.formula.names()</code> because they are named like S3 methods. Neither were exported so they didn&rsquo;t affect users. Thanks to Kurt Hornik for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/375">#375</a>)</p>
</li>
</ul>
<hr>
<h1 id="changes-in-prior-versions">Changes in Prior Versions</h1>
<h3 id="new-features-1">New Features</h3>
<ul>
<li>
<p>Added <code>HL()</code> and supporting functions. These are analogues to <code>HLC()</code>, <code>OHLC()</code>, etc. Thanks for Karl Gauvin for the nudge to implement them.</p>
</li>
<li>
<p>Added adjusted close price to <code>getSymbols.tiingo()</code> output. Thanks to Ethan Smith for the suggestion and patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/289">#289</a>, <a href="https://github.com/joshuaulrich/quantmod/pull/345">#345</a>)</p>
</li>
<li>
<p>Updated <code>getSymbols.tiingo()</code> to use a Date index for daily data. Thanks to Ethan Smith for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/350">#350</a>)</p>
</li>
<li>
<p>Updated <code>getOptionChain()</code> to return all the fields that Yahoo Finance provides. Thanks to Adam Childers (@rhizomatican) for the patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/318">#318</a>, <a href="https://github.com/joshuaulrich/quantmod/pull/336">#336</a>)</p>
</li>
<li>
<p>Added <a href="https://docs.orats.io">orats</a> as a source for <code>getOptionChain()</code>. Thanks to Steve Bronder (@SteveBronder) for the suggestion and implementation! (<a href="https://github.com/joshuaulrich/quantmod/pull/325">#325</a>)</p>
</li>
<li>
<p>Added &ldquo;Defaults&rdquo; handling to <code>getQuote()</code> and <code>getQuote.yahoo()</code>. Thanks to Ethan Smith for the report. (<a href="https://github.com/joshuaulrich/quantmod/issues/291">#291</a>)</p>
</li>
<li>
<p>Added Bid and Ask fields to the output from <code>getQuote()</code>. Thanks to @jrburl for the report and PR. (<a href="https://github.com/joshuaulrich/quantmod/pull/302">#302</a>)</p>
</li>
</ul>
<h3 id="bug-fixes-1">Bug Fixes</h3>
<ul>
<li>
<p>Removed check for Yahoo Finance cookies because the site no longer responds with a cookie, and that caused the connection attempt to fail. This affected <code>getSymbols()</code>, <code>getDividends()</code>, and <code>getSplits()</code>. Thanks to several users for reporting, and especially to @pverspeelt and @alihru for investigating potential fixes! (<a href="https://github.com/joshuaulrich/quantmod/issues/358">#358</a>)</p>
</li>
<li>
<p>Updated <code>getSymbols.yahooj()</code> for changes to the web page. (<a href="https://github.com/joshuaulrich/quantmod/issues/312">#312</a>)</p>
</li>
<li>
<p>Removed unneeded arguments to the <code>getSymbols.tiingo()</code> implementation. Thanks to Ethan Smith for the suggestion and patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/343">#343</a>, <a href="https://github.com/joshuaulrich/quantmod/pull/344">#344</a>)</p>
</li>
<li>
<p>Load dividends and splits data into the correct environment when the user provides a value for the <code>env</code> argument. The previous behavior always loaded the data into the environment the function was called from. Thanks to Stewart Wright for the report and patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/33">#33</a>)</p>
</li>
<li>
<p>Improved the error message when <code>getSymbols()</code> cannot import data for a symbol because the symbol is not valid or does not have historical data. Thanks to Peter Carl for the report. (<a href="https://github.com/joshuaulrich/quantmod/issues/333">#333</a>)</p>
</li>
<li>
<p>Fixed the <code>getMetals()</code> example in the documentation. The example section previously had an example of <code>getFX()</code>. Thanks to Gerhard Nachtmann (@nachti) for the report and patch! (<a href="https://github.com/joshuaulrich/quantmod/issues/330">#330</a>)</p>
</li>
<li>
<p>Fixed <code>getQuote()</code> so it returns data when the ticker symbol contains an &ldquo;&amp;&rdquo;. Thanks to @pankaj3009 for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/324">#324</a>)</p>
</li>
<li>
<p>Fixed <code>addMACD()</code> when <code>col</code> is specified. Thanks to @nvalueanalytics for the report! (<a href="https://github.com/joshuaulrich/quantmod/issues/321">#321</a>)</p>
</li>
<li>
<p>Fixed issues handling https:// in <code>getSymbols.yahooj()</code>. Thanks to @lobo1981 and @tchevri for the reports and Ethan Smith for the suggestion to move from XML to xml2. (<a href="https://github.com/joshuaulrich/quantmod/issues/310">#310</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/312">#312</a>)</p>
</li>
<li>
<p>Fixed <code>getSymbols.yahoo()</code>, <code>getDividends()</code>, and <code>getSplits()</code> so they all handle download errors and retry again. Thanks for @helgasoft for the report on <code>getSymbols.yahoo()</code> and @msfsalla for the report on <code>getDividends()</code> and <code>getSplits()</code>. (<a href="https://github.com/joshuaulrich/quantmod/issues/307">#307</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/314">#314</a>)</p>
</li>
<li>
<p>Added implied volatility and last trade date to <code>getOptionChain()</code> output. Thanks to @hd2581 and @romanlelek for the reports. And thanks to @rjvelasquezm for noticing the error when <code>lastTradeDate</code> is <code>NULL</code>. (<a href="https://github.com/joshuaulrich/quantmod/issues/224">#224</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/304">#304</a>)</p>
</li>
<li>
<p>Fixed <code>getOptionChain()</code> to throw a warning and return <code>NULL</code> for every expiry that doesn&rsquo;t have data. (<a href="https://github.com/joshuaulrich/quantmod/issues/299">#299</a>)</p>
</li>
<li>
<p>Fixed &ldquo;Defaults&rdquo; to handle unexported function (e.g. <code>getQuote.av()</code>. Thanks to @helgasoft for the report. (<a href="https://github.com/joshuaulrich/quantmod/issues/316">#316</a>)</p>
</li>
<li>
<p><code>importDefaults()</code> didn&rsquo;t call <code>get()</code> on vector with length &gt; 1. Thanks to Kurt Hornik for the report. (<a href="https://github.com/joshuaulrich/quantmod/issues/319">#319</a>)</p>
</li>
<li>
<p><code>chartTheme()</code> now works when quantmod is not attached. Thanks to Kurt Hornik for the report.</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176087" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176087" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176088" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176089" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176090" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176090" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176091" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176091" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=quantmod">quantmod</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>. It adds functions <code>HL()</code>, <code>is.HL()</code>, and <code>has.HL()</code> to check for &lsquo;high&rsquo; and &rsquo;low&rsquo; price columns. It also makes accessing Yahoo Finance price, dividend, and split data more robust. <code>getSymbols.FRED()</code> got <code>to</code> and <code>from</code> arguments, like other <code>getSymbols()</code> methods. The remaining changes are bug fixes and maintenace chores.</p>
<p>This was mainly a maintenance and bug fix release, but it does include a couple nice features. quantmod versions 0.4.17 through 0.4.21 included several relevant features that weren&rsquo;t highlighted in any previous posts. They&rsquo;re included in a separate section below.</p>
<h3 id="new-features">New Features</h3>
<ul>
<li>
<p>Exported <code>HL()</code>, <code>is.HL()</code>, and <code>has.HL()</code> functions and added documentation. These were added in 0.4.20 but not exported or included in the documentation.</p>
</li>
<li>
<p>Switched to the Yahoo Finance v8 JSON endpoint and removed the v7 CSV endpoint. There seems to be a rate limit for the number of tickers you can request via the CSV endpoint. The <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ranaroussi/yfinance">yfinance python library</a> uses the JSON endpoint and doesn&rsquo;t seem to have rate limit issues. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/360">#360</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/362">#362</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/364">#364</a>)</p>
</li>
<li>
<p><code>getSymbols.FRED()</code> now supports <code>to</code> and <code>from</code> arguments. So users can set the &lsquo;from&rsquo; and &rsquo;to&rsquo; arguments for FRED data like they can for other data sources like Yahoo. Those values had been ignored and the entire series was always returned. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/368">#368</a>)</p>
</li>
</ul>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fixed <code>getDividends()</code> and <code>getSplits()</code> for stocks that issue monthly dividends. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/372">#372</a>)</p>
</li>
<li>
<p>Added error handling to <code>getSplits()</code> and <code>getDividends()</code>. <code>getDividends()</code> didn&rsquo;t handle cases where the download failed, or when dividends needed to be split-adjusted but there were no splits. It also tried to set colnames on the empty xts object that&rsquo;s returned when there are no dividends. <code>getSplits()</code> had the same colnames issue. Thanks to Chris Cheung for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/366">#366</a>)</p>
</li>
<li>
<p>Remove &ldquo;^&rdquo; prefix from <code>getSymbols()</code> return value. The name of the object <code>getSymbols()</code> created and the symbol value it returned were inconsistent when the &lsquo;Symbols&rsquo; argument has a &ldquo;^&rdquo; prefix and <code>auto.assign = TRUE</code>:</p>
<ul>
<li><code>getSymbols()</code> removed the &ldquo;^&rdquo; from the object it creates, but</li>
<li>returned the &lsquo;Symbols&rsquo; argument unchanged, and</li>
<li>removed the &ldquo;^&rdquo; from the column names of the object it creates.</li>
</ul>
<p>The example below will create an object named <code>IXIC</code> but the value of <code>sym</code> will be &ldquo;^IXIC&rdquo;.</p>
<pre><code> sym &lt;- getSymbols("^IXIC")
</code></pre>
<p>That means <code>x &lt;- get(sym)</code> will not work because an object named <code>^IXIC</code> doesn&rsquo;t exist. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/371">#371</a>)</p>
</li>
</ul>
<h3 id="chores">Chores</h3>
<ul>
<li>
<p>Moved <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=jsonlite">jsonlite</a> from Suggests to Imports so it doesn&rsquo;t cause a problem when a package that doesn&rsquo;t also Suggest jsonlite but uses <code>getSymbols()</code>. Thanks to Kurt Hornik for the report and fix! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/380">#380</a>)</p>
</li>
<li>
<p>Fixed S3 method issues. R-devel (83995-ish) added a check that found methods that were not registered (<code>str.replot()</code>, <code>seriesHi.timeSeries()</code>, and <code>seriesLo.timeSeries()</code>). It was also confused by <code>range.bars()</code> and <code>unique.formula.names()</code> because they are named like S3 methods. Neither were exported so they didn&rsquo;t affect users. Thanks to Kurt Hornik for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/375">#375</a>)</p>
</li>
</ul>
<hr>
<h1 id="changes-in-prior-versions">Changes in Prior Versions</h1>
<h3 id="new-features-1">New Features</h3>
<ul>
<li>
<p>Added <code>HL()</code> and supporting functions. These are analogues to <code>HLC()</code>, <code>OHLC()</code>, etc. Thanks for Karl Gauvin for the nudge to implement them.</p>
</li>
<li>
<p>Added adjusted close price to <code>getSymbols.tiingo()</code> output. Thanks to Ethan Smith for the suggestion and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/289">#289</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/345">#345</a>)</p>
</li>
<li>
<p>Updated <code>getSymbols.tiingo()</code> to use a Date index for daily data. Thanks to Ethan Smith for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/350">#350</a>)</p>
</li>
<li>
<p>Updated <code>getOptionChain()</code> to return all the fields that Yahoo Finance provides. Thanks to Adam Childers (@rhizomatican) for the patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/318">#318</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/336">#336</a>)</p>
</li>
<li>
<p>Added <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://docs.orats.io">orats</a> as a source for <code>getOptionChain()</code>. Thanks to Steve Bronder (@SteveBronder) for the suggestion and implementation! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/325">#325</a>)</p>
</li>
<li>
<p>Added &ldquo;Defaults&rdquo; handling to <code>getQuote()</code> and <code>getQuote.yahoo()</code>. Thanks to Ethan Smith for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/291">#291</a>)</p>
</li>
<li>
<p>Added Bid and Ask fields to the output from <code>getQuote()</code>. Thanks to @jrburl for the report and PR. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/302">#302</a>)</p>
</li>
</ul>
<h3 id="bug-fixes-1">Bug Fixes</h3>
<ul>
<li>
<p>Removed check for Yahoo Finance cookies because the site no longer responds with a cookie, and that caused the connection attempt to fail. This affected <code>getSymbols()</code>, <code>getDividends()</code>, and <code>getSplits()</code>. Thanks to several users for reporting, and especially to @pverspeelt and @alihru for investigating potential fixes! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/358">#358</a>)</p>
</li>
<li>
<p>Updated <code>getSymbols.yahooj()</code> for changes to the web page. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/312">#312</a>)</p>
</li>
<li>
<p>Removed unneeded arguments to the <code>getSymbols.tiingo()</code> implementation. Thanks to Ethan Smith for the suggestion and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/343">#343</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/344">#344</a>)</p>
</li>
<li>
<p>Load dividends and splits data into the correct environment when the user provides a value for the <code>env</code> argument. The previous behavior always loaded the data into the environment the function was called from. Thanks to Stewart Wright for the report and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/33">#33</a>)</p>
</li>
<li>
<p>Improved the error message when <code>getSymbols()</code> cannot import data for a symbol because the symbol is not valid or does not have historical data. Thanks to Peter Carl for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/333">#333</a>)</p>
</li>
<li>
<p>Fixed the <code>getMetals()</code> example in the documentation. The example section previously had an example of <code>getFX()</code>. Thanks to Gerhard Nachtmann (@nachti) for the report and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/330">#330</a>)</p>
</li>
<li>
<p>Fixed <code>getQuote()</code> so it returns data when the ticker symbol contains an &ldquo;&amp;&rdquo;. Thanks to @pankaj3009 for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/324">#324</a>)</p>
</li>
<li>
<p>Fixed <code>addMACD()</code> when <code>col</code> is specified. Thanks to @nvalueanalytics for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/321">#321</a>)</p>
</li>
<li>
<p>Fixed issues handling https:// in <code>getSymbols.yahooj()</code>. Thanks to @lobo1981 and @tchevri for the reports and Ethan Smith for the suggestion to move from XML to xml2. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/310">#310</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/312">#312</a>)</p>
</li>
<li>
<p>Fixed <code>getSymbols.yahoo()</code>, <code>getDividends()</code>, and <code>getSplits()</code> so they all handle download errors and retry again. Thanks for @helgasoft for the report on <code>getSymbols.yahoo()</code> and @msfsalla for the report on <code>getDividends()</code> and <code>getSplits()</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/307">#307</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/314">#314</a>)</p>
</li>
<li>
<p>Added implied volatility and last trade date to <code>getOptionChain()</code> output. Thanks to @hd2581 and @romanlelek for the reports. And thanks to @rjvelasquezm for noticing the error when <code>lastTradeDate</code> is <code>NULL</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/224">#224</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/304">#304</a>)</p>
</li>
<li>
<p>Fixed <code>getOptionChain()</code> to throw a warning and return <code>NULL</code> for every expiry that doesn&rsquo;t have data. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/299">#299</a>)</p>
</li>
<li>
<p>Fixed &ldquo;Defaults&rdquo; to handle unexported function (e.g. <code>getQuote.av()</code>. Thanks to @helgasoft for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/316">#316</a>)</p>
</li>
<li>
<p><code>importDefaults()</code> didn&rsquo;t call <code>get()</code> on vector with length &gt; 1. Thanks to Kurt Hornik for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/319">#319</a>)</p>
</li>
<li>
<p><code>chartTheme()</code> now works when quantmod is not attached. Thanks to Kurt Hornik for the report.</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672292/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672292/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176087" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176087" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176088" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176089" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176090" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176090" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176091" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176091" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2023/02/xts-0-13-0-on-cran/</feedburner:origLink><title>xts_0.13.0 on CRAN</title><link>https://feeds.feedblitz.com/~/748672295/0/fosstrading/</link><pubDate>Tue, 21 Feb 2023 14:58:00 -0500</pubDate><guid>https://blog.fosstrading.com/2023/02/xts-0-13-0-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=xts">xts</a> is now on <a href="http://cran.r-project.org/">CRAN</a>. This release adds several exciting changes: open-ended time-of-day subsetting, smarter conversions to xts from data.frames/data.tables/tibbles; <code>to.period()</code> handles custom endpoint values, <code>print()</code> truncates rows like data.table, and <code>str()</code> provides more informative output. There are also changes to make xts more consistent with zoo, some minor speed improvements, and the usual smattering of bug fixes.</p>
<p>For some reason, I decided it was a good idea to go through the oldest GitHub issues and determine whether they should be fixed or closed without being fixed. Some of the GitHub issues are open issues from when xts was still on R-Forge! The oldest issue fixed in this release was opened on 2013-09-15, and another one was opened on 2014-03-09! Better late than never I guess. ;-)</p>
<h3 id="new-features">New Features</h3>
<p>The coolest new feature is the ability to use open-ended ranges for time-of-day subsetting. So you can subset by time of day from the start/end of the day without providing the start/end times (i.e. 00:00:00.000/23:59:59.999). Thanks to Chris Katsulis for the suggestion! (<a href="https://github.com/joshuaulrich/xts/issues/243">#243</a>)</p>
<p>Here&rsquo;s an example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># an hourly sequence of times, and an xts object using them</span>
</span></span><span class="line"><span class="cl"><span class="n">times</span> <span class="o">&lt;-</span> <span class="nf">timeBasedSeq</span><span class="p">(</span><span class="s">&#34;2023-02-01/2023-02-05/H&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">xts</span><span class="p">(</span><span class="nf">seq_along</span><span class="p">(</span><span class="n">times</span><span class="p">),</span> <span class="n">times</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># function to show the first and last index values for each day</span>
</span></span><span class="line"><span class="cl"><span class="n">index_range_by_day</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">by_day</span> <span class="o">&lt;-</span> <span class="nf">split</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s">&#34;days&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">index_range</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">paste</span><span class="p">(</span><span class="nf">start</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="nf">end</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">sep</span> <span class="o">=</span> <span class="s">&#34; / &#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="nf">lapply</span><span class="p">(</span><span class="n">by_day</span><span class="p">,</span> <span class="n">index_range</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># between the start of the day and 5pm</span>
</span></span><span class="line"><span class="cl"><span class="nf">index_range_by_day</span><span class="p">(</span><span class="n">x[</span><span class="s">&#34;/T1800&#34;</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-01`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-01 / 2023-02-01 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-02`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-02 / 2023-02-02 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-03`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-03 / 2023-02-03 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-04`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-04 / 2023-02-04 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-05`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-05 / 2023-02-05 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># between 5am and the end of the day</span>
</span></span><span class="line"><span class="cl"><span class="nf">index_range_by_day</span><span class="p">(</span><span class="n">x[</span><span class="s">&#34;T0500/&#34;</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-01`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-01 05:00:00 / 2023-02-01 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-02`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-02 05:00:00 / 2023-02-02 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-03`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-03 05:00:00 / 2023-02-03 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-04`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-04 05:00:00 / 2023-02-04 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-05`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-05 05:00:00 / 2023-02-05 23:00:00&#34;</span>
</span></span></code></pre></div><hr>
<p>You can now pass custom endpoints to <code>to.period()</code> using the &lsquo;period&rsquo; argument. So you can aggregate on something other than the times that <code>endpoints()</code> supports. Thanks to Ethan B. Smith for the suggestion! (<a href="https://github.com/joshuaulrich/xts/issues/302">#302</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># aggregate to OHLC by week ending on Friday</span>
</span></span><span class="line"><span class="cl"><span class="n">week_fri</span> <span class="o">&lt;-</span> <span class="nf">to.period</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="nf">endpoints</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s">&#34;weeks&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">week_fri</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## x.Open x.High x.Low x.Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-07 50.03978 50.42188 49.95041 49.99185</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-14 50.03555 50.62395 49.80454 50.60145</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-21 50.61724 50.77336 50.02142 50.42090</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-28 50.36008 50.43875 49.87468 49.88096</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-04 49.85624 50.55509 49.76308 50.55509</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-11 50.52389 50.91776 50.45977 50.91160</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># aggregate to OHLC by week ending on Wednesday</span>
</span></span><span class="line"><span class="cl"><span class="n">wednesdays</span> <span class="o">&lt;-</span> <span class="nf">which</span><span class="p">(</span><span class="nf">.indexwday</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">week_wed</span> <span class="o">&lt;-</span> <span class="nf">to.period</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">wednesdays</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">week_wed</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## x.Open x.High x.Low x.Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-03 50.03978 50.42188 49.95041 50.39767</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-10 50.42096 50.42096 49.80454 49.97246</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-17 49.88529 50.77336 49.88529 50.48644</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-24 50.48051 50.60712 50.02142 50.23145</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-31 50.20738 50.28268 49.76308 50.22578</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-07 50.22448 50.71661 50.19101 50.60611</span>
</span></span></code></pre></div><h3 id="enhancements">Enhancements</h3>
<p>The release also contains some quality of life changes to <code>print()</code> and <code>str()</code>. Now <code>print()</code> only shows the first and last &lsquo;show.rows&rsquo; rows (default 10) if number of rows is &gt; &lsquo;max.rows&rsquo; (default 100), similar to <a href="https://cran.r-project.org/package=data.table">data.table</a> (<a href="https://github.com/joshuaulrich/xts/issues/321">#321</a>).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Open High Low Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-02 50.03978 50.11778 49.95041 50.11778</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-03 50.23050 50.42188 50.23050 50.39767</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-04 50.42096 50.42096 50.26414 50.33236</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-05 50.37347 50.37347 50.22103 50.33459</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-06 50.24433 50.24433 50.11121 50.18112</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-07 50.13211 50.21561 49.99185 49.99185</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-08 50.03555 50.10363 49.96971 49.98806</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-09 49.99489 49.99489 49.80454 49.91333</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-10 49.91228 50.13053 49.91228 49.97246</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-11 49.88529 50.23910 49.88529 50.23910</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ... </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-21 47.71012 47.71012 47.61106 47.62921</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-22 47.56849 47.59266 47.32549 47.32549</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-23 47.22873 47.24771 47.09144 47.24771</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-24 47.23996 47.30287 47.20932 47.22764</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-25 47.20471 47.42772 47.13405 47.42772</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-26 47.44300 47.61611 47.44300 47.61611</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-27 47.62323 47.71673 47.60015 47.62769</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-28 47.67604 47.70460 47.57241 47.60716</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-29 47.63629 47.77563 47.61733 47.66471</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-30 47.67468 47.94127 47.67468 47.76719</span>
</span></span></code></pre></div><hr>
<p>Now <code>str()</code> outputs more descriptive information for xts objects. It differentiates between xts objects that are empty (no data and zero-length index), zero-width (no data and has index values), or zero-length (no data&ndash;but has a column dimension and may have column names&ndash;and zero-length index). It also adds column names to the output. (<a href="https://github.com/joshuaulrich/xts/issues/168">#168</a>, <a href="https://github.com/joshuaulrich/xts/issues/378">#378</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">empty</span> <span class="o">&lt;-</span> <span class="nf">numeric</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># empty -- no data and zero-length index</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">.xts</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="n">empty</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## An empty xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 0]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># zero length -- no rows of data and a zero-length index,</span>
</span></span><span class="line"><span class="cl"><span class="c1"># but has a column dimension and may have column names</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">.xts</span><span class="p">(</span><span class="n">empty</span><span class="p">,</span> <span class="n">empty</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-length xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 1]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">zero_length_with_colnames</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">.xts</span><span class="p">(</span><span class="nf">matrix</span><span class="p">(</span><span class="n">empty</span><span class="p">,</span> <span class="n">dimnames</span> <span class="o">=</span> <span class="nf">list</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="s">&#34;zero&#34;</span><span class="p">)),</span> <span class="n">empty</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="n">zero_length_with_colnames</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-length xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 1]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Columns: zero</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># zero width -- no data and has index values</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">xts</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="nf">Sys.Date</span><span class="p">()))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-width xts object on 2023-02-21 / 2023-02-21 containing:</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 0]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: Date [1] (TZ: &#34;UTC&#34;)</span>
</span></span></code></pre></div><hr>
<p>There&rsquo;s a nice improvement to <code>as.xts()</code> for data.frame and similar objects (e.g. data.table, tibble). It will look for a time-based column in the data.frame if it cannot create an index from the row names. (<a href="https://github.com/joshuaulrich/xts/issues/381">#381</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">d</span> <span class="o">&lt;-</span> <span class="nf">data.frame</span><span class="p">(</span><span class="nf">as.Date</span><span class="p">(</span><span class="s">&#34;2023-02-21&#34;</span><span class="p">),</span> <span class="n">A</span> <span class="o">=</span> <span class="m">21</span><span class="p">,</span> <span class="n">B</span> <span class="o">=</span> <span class="m">42</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">as.xts</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A B</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2023-02-21 21 42</span>
</span></span></code></pre></div><hr>
<p>This release also includes a new xts method for <code>na.fill()</code> that significantly increases performance when &lsquo;fill&rsquo; is a scalar. And it adds a startup warning that <code>dplyr::lag()</code> breaks method dispatch, which means calls to <code>lag(my_xts)</code> won&rsquo;t work any more, and suggests a couple ways to work around that breakage.</p>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fixed a typo in the Description section of the documentation for <code>period.apply()</code> (<a href="https://github.com/joshuaulrich/xts/issues/205">#205</a>), and added detail to the argument definitions. The original Description has:</p>
<blockquote>
<p>the data from <code>INDEX[k]</code> to <code>INDEX[k+1]</code></p></blockquote>
<p>But that&rsquo;s not consistent with the code. It should be:</p>
<blockquote>
<p>the data from <code>INDEX[k]+1</code> to <code>INDEX[k+1]</code></p></blockquote>
</li>
<li>
<p>Made <code>merge.xts()</code> results consistent with <code>merge.zoo()</code> for zero-width objects. Previously, <code>merge.xts()</code> returned an empty xts object if called on two or more zero-width xts objects. <code>merge.zoo()</code> would return a zero-width object with the correct index. (<a href="https://github.com/joshuaulrich/xts/issues/227">#227</a>, <a href="https://github.com/joshuaulrich/xts/issues/379">#379</a>)</p>
</li>
<li>
<p>Also made <code>merge.xts()</code> results consistent with <code>merge.zoo()</code> for zero-length xts objects that have columns. The result of <code>merge.xts()</code> did not include the columns of any objects that had one or more columns, but zero rows. A join should include all the columns of the joined objects, regardless of the number of rows in the object. This is consistent with <code>merge.zoo()</code>. Thanks to Ethan B. Smith for the report and testing! (<a href="https://github.com/joshuaulrich/xts/issues/222">#222</a>)</p>
</li>
<li>
<p>Fixed a long-standing issue with <code>Ops.xts()</code>. Now it always returns an object with the same class as the first (left-hand side) argument. It previously returned an xts object even if the first argument was a subclass of xts. (<a href="https://github.com/joshuaulrich/xts/issues/49">#49</a>)</p>
</li>
<li>
<p>Squashed a bug in <code>reclass()</code> that did not copy the <code>tclass</code>, <code>tzone</code>, or <code>tformat</code> from &lsquo;match.to&rsquo; to the result object. Now it always copies those index attributes. (<a href="https://github.com/joshuaulrich/xts/issues/43">#43</a>)</p>
</li>
</ul>
<h3 id="other">Other</h3>
<ul>
<li>
<p>Migrated unit tests from <a href="https://github.com/romanzenka/RUnit">RUnit</a> (which is actively maintained, but no longer actively developed) to <a href="https://github.com/markvanderloo/tinytest">tinytest</a>. Thanks <a href="https://github.com/markvanderloo">Mark van der Loo</a>!</p>
</li>
<li>
<p>Added to the <code>endpoints()</code> documentation to make it clearer that the result is based on the UNIX epoch (midnight 1970, UTC) and not the first observation in the xts index. Thanks to GitHub user Eluvias for the suggestion! (<a href="https://github.com/joshuaulrich/xts/issues/299">#299</a>)</p>
</li>
<li>
<p>Removed an unnecessary check in <code>na.locf()</code> (which is not user-facing). Thanks to GitHub user @cgiachalis for the suggestion! (<a href="https://github.com/joshuaulrich/xts/issues/307">#307</a>)</p>
</li>
<li>
<p>Updated C entry points so they&rsquo;re not able to accidentally be found via dynamic lookup (i.e. <code>.Call(&quot;foo&quot;, ...)</code>). This makes each call to the C code a few microseconds faster, which is nice. (<a href="https://github.com/joshuaulrich/xts/issues/260">#260</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176092" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176092" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176093" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176094" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176095" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176095" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176096" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176096" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>. This release adds several exciting changes: open-ended time-of-day subsetting, smarter conversions to xts from data.frames/data.tables/tibbles; <code>to.period()</code> handles custom endpoint values, <code>print()</code> truncates rows like data.table, and <code>str()</code> provides more informative output. There are also changes to make xts more consistent with zoo, some minor speed improvements, and the usual smattering of bug fixes.</p>
<p>For some reason, I decided it was a good idea to go through the oldest GitHub issues and determine whether they should be fixed or closed without being fixed. Some of the GitHub issues are open issues from when xts was still on R-Forge! The oldest issue fixed in this release was opened on 2013-09-15, and another one was opened on 2014-03-09! Better late than never I guess. ;-)</p>
<h3 id="new-features">New Features</h3>
<p>The coolest new feature is the ability to use open-ended ranges for time-of-day subsetting. So you can subset by time of day from the start/end of the day without providing the start/end times (i.e. 00:00:00.000/23:59:59.999). Thanks to Chris Katsulis for the suggestion! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/243">#243</a>)</p>
<p>Here&rsquo;s an example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># an hourly sequence of times, and an xts object using them</span>
</span></span><span class="line"><span class="cl"><span class="n">times</span> <span class="o">&lt;-</span> <span class="nf">timeBasedSeq</span><span class="p">(</span><span class="s">&#34;2023-02-01/2023-02-05/H&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">xts</span><span class="p">(</span><span class="nf">seq_along</span><span class="p">(</span><span class="n">times</span><span class="p">),</span> <span class="n">times</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># function to show the first and last index values for each day</span>
</span></span><span class="line"><span class="cl"><span class="n">index_range_by_day</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">by_day</span> <span class="o">&lt;-</span> <span class="nf">split</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s">&#34;days&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">index_range</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">paste</span><span class="p">(</span><span class="nf">start</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="nf">end</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="n">sep</span> <span class="o">=</span> <span class="s">&#34; / &#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="nf">lapply</span><span class="p">(</span><span class="n">by_day</span><span class="p">,</span> <span class="n">index_range</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># between the start of the day and 5pm</span>
</span></span><span class="line"><span class="cl"><span class="nf">index_range_by_day</span><span class="p">(</span><span class="n">x[</span><span class="s">&#34;/T1800&#34;</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-01`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-01 / 2023-02-01 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-02`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-02 / 2023-02-02 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-03`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-03 / 2023-02-03 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-04`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-04 / 2023-02-04 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-05`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-05 / 2023-02-05 18:00:00&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># between 5am and the end of the day</span>
</span></span><span class="line"><span class="cl"><span class="nf">index_range_by_day</span><span class="p">(</span><span class="n">x[</span><span class="s">&#34;T0500/&#34;</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-01`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-01 05:00:00 / 2023-02-01 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-02`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-02 05:00:00 / 2023-02-02 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-03`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-03 05:00:00 / 2023-02-03 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-04`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-04 05:00:00 / 2023-02-04 23:00:00&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $`2023-02-05`</span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;2023-02-05 05:00:00 / 2023-02-05 23:00:00&#34;</span>
</span></span></code></pre></div><hr>
<p>You can now pass custom endpoints to <code>to.period()</code> using the &lsquo;period&rsquo; argument. So you can aggregate on something other than the times that <code>endpoints()</code> supports. Thanks to Ethan B. Smith for the suggestion! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/302">#302</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># aggregate to OHLC by week ending on Friday</span>
</span></span><span class="line"><span class="cl"><span class="n">week_fri</span> <span class="o">&lt;-</span> <span class="nf">to.period</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="nf">endpoints</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="s">&#34;weeks&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">week_fri</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## x.Open x.High x.Low x.Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-07 50.03978 50.42188 49.95041 49.99185</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-14 50.03555 50.62395 49.80454 50.60145</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-21 50.61724 50.77336 50.02142 50.42090</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-28 50.36008 50.43875 49.87468 49.88096</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-04 49.85624 50.55509 49.76308 50.55509</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-11 50.52389 50.91776 50.45977 50.91160</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># aggregate to OHLC by week ending on Wednesday</span>
</span></span><span class="line"><span class="cl"><span class="n">wednesdays</span> <span class="o">&lt;-</span> <span class="nf">which</span><span class="p">(</span><span class="nf">.indexwday</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">==</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">week_wed</span> <span class="o">&lt;-</span> <span class="nf">to.period</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">wednesdays</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">week_wed</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## x.Open x.High x.Low x.Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-03 50.03978 50.42188 49.95041 50.39767</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-10 50.42096 50.42096 49.80454 49.97246</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-17 49.88529 50.77336 49.88529 50.48644</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-24 50.48051 50.60712 50.02142 50.23145</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-31 50.20738 50.28268 49.76308 50.22578</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-02-07 50.22448 50.71661 50.19101 50.60611</span>
</span></span></code></pre></div><h3 id="enhancements">Enhancements</h3>
<p>The release also contains some quality of life changes to <code>print()</code> and <code>str()</code>. Now <code>print()</code> only shows the first and last &lsquo;show.rows&rsquo; rows (default 10) if number of rows is &gt; &lsquo;max.rows&rsquo; (default 100), similar to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=data.table">data.table</a> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/321">#321</a>).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">sample_matrix</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Open High Low Close</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-02 50.03978 50.11778 49.95041 50.11778</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-03 50.23050 50.42188 50.23050 50.39767</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-04 50.42096 50.42096 50.26414 50.33236</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-05 50.37347 50.37347 50.22103 50.33459</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-06 50.24433 50.24433 50.11121 50.18112</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-07 50.13211 50.21561 49.99185 49.99185</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-08 50.03555 50.10363 49.96971 49.98806</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-09 49.99489 49.99489 49.80454 49.91333</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-10 49.91228 50.13053 49.91228 49.97246</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-01-11 49.88529 50.23910 49.88529 50.23910</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ... </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-21 47.71012 47.71012 47.61106 47.62921</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-22 47.56849 47.59266 47.32549 47.32549</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-23 47.22873 47.24771 47.09144 47.24771</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-24 47.23996 47.30287 47.20932 47.22764</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-25 47.20471 47.42772 47.13405 47.42772</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-26 47.44300 47.61611 47.44300 47.61611</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-27 47.62323 47.71673 47.60015 47.62769</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-28 47.67604 47.70460 47.57241 47.60716</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-29 47.63629 47.77563 47.61733 47.66471</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2007-06-30 47.67468 47.94127 47.67468 47.76719</span>
</span></span></code></pre></div><hr>
<p>Now <code>str()</code> outputs more descriptive information for xts objects. It differentiates between xts objects that are empty (no data and zero-length index), zero-width (no data and has index values), or zero-length (no data&ndash;but has a column dimension and may have column names&ndash;and zero-length index). It also adds column names to the output. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/168">#168</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/378">#378</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">empty</span> <span class="o">&lt;-</span> <span class="nf">numeric</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># empty -- no data and zero-length index</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">.xts</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="n">empty</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## An empty xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 0]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># zero length -- no rows of data and a zero-length index,</span>
</span></span><span class="line"><span class="cl"><span class="c1"># but has a column dimension and may have column names</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">.xts</span><span class="p">(</span><span class="n">empty</span><span class="p">,</span> <span class="n">empty</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-length xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 1]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">zero_length_with_colnames</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="nf">.xts</span><span class="p">(</span><span class="nf">matrix</span><span class="p">(</span><span class="n">empty</span><span class="p">,</span> <span class="n">dimnames</span> <span class="o">=</span> <span class="nf">list</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="s">&#34;zero&#34;</span><span class="p">)),</span> <span class="n">empty</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="n">zero_length_with_colnames</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-length xts object </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 1]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Columns: zero</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: POSIXct,POSIXt [0] (TZ: &#34;&#34;)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># zero width -- no data and has index values</span>
</span></span><span class="line"><span class="cl"><span class="nf">str</span><span class="p">(</span><span class="nf">xts</span><span class="p">(</span><span class="kc">NULL</span><span class="p">,</span> <span class="nf">Sys.Date</span><span class="p">()))</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A zero-width xts object on 2023-02-21 / 2023-02-21 containing:</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Data: double [0, 0]</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Index: Date [1] (TZ: &#34;UTC&#34;)</span>
</span></span></code></pre></div><hr>
<p>There&rsquo;s a nice improvement to <code>as.xts()</code> for data.frame and similar objects (e.g. data.table, tibble). It will look for a time-based column in the data.frame if it cannot create an index from the row names. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/381">#381</a>)</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">d</span> <span class="o">&lt;-</span> <span class="nf">data.frame</span><span class="p">(</span><span class="nf">as.Date</span><span class="p">(</span><span class="s">&#34;2023-02-21&#34;</span><span class="p">),</span> <span class="n">A</span> <span class="o">=</span> <span class="m">21</span><span class="p">,</span> <span class="n">B</span> <span class="o">=</span> <span class="m">42</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">as.xts</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## A B</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2023-02-21 21 42</span>
</span></span></code></pre></div><hr>
<p>This release also includes a new xts method for <code>na.fill()</code> that significantly increases performance when &lsquo;fill&rsquo; is a scalar. And it adds a startup warning that <code>dplyr::lag()</code> breaks method dispatch, which means calls to <code>lag(my_xts)</code> won&rsquo;t work any more, and suggests a couple ways to work around that breakage.</p>
<h3 id="bug-fixes">Bug Fixes</h3>
<ul>
<li>
<p>Fixed a typo in the Description section of the documentation for <code>period.apply()</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/205">#205</a>), and added detail to the argument definitions. The original Description has:</p>
<blockquote>
<p>the data from <code>INDEX[k]</code> to <code>INDEX[k+1]</code></p></blockquote>
<p>But that&rsquo;s not consistent with the code. It should be:</p>
<blockquote>
<p>the data from <code>INDEX[k]+1</code> to <code>INDEX[k+1]</code></p></blockquote>
</li>
<li>
<p>Made <code>merge.xts()</code> results consistent with <code>merge.zoo()</code> for zero-width objects. Previously, <code>merge.xts()</code> returned an empty xts object if called on two or more zero-width xts objects. <code>merge.zoo()</code> would return a zero-width object with the correct index. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/227">#227</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/379">#379</a>)</p>
</li>
<li>
<p>Also made <code>merge.xts()</code> results consistent with <code>merge.zoo()</code> for zero-length xts objects that have columns. The result of <code>merge.xts()</code> did not include the columns of any objects that had one or more columns, but zero rows. A join should include all the columns of the joined objects, regardless of the number of rows in the object. This is consistent with <code>merge.zoo()</code>. Thanks to Ethan B. Smith for the report and testing! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/222">#222</a>)</p>
</li>
<li>
<p>Fixed a long-standing issue with <code>Ops.xts()</code>. Now it always returns an object with the same class as the first (left-hand side) argument. It previously returned an xts object even if the first argument was a subclass of xts. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/49">#49</a>)</p>
</li>
<li>
<p>Squashed a bug in <code>reclass()</code> that did not copy the <code>tclass</code>, <code>tzone</code>, or <code>tformat</code> from &lsquo;match.to&rsquo; to the result object. Now it always copies those index attributes. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/43">#43</a>)</p>
</li>
</ul>
<h3 id="other">Other</h3>
<ul>
<li>
<p>Migrated unit tests from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/romanzenka/RUnit">RUnit</a> (which is actively maintained, but no longer actively developed) to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/markvanderloo/tinytest">tinytest</a>. Thanks <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/markvanderloo">Mark van der Loo</a>!</p>
</li>
<li>
<p>Added to the <code>endpoints()</code> documentation to make it clearer that the result is based on the UNIX epoch (midnight 1970, UTC) and not the first observation in the xts index. Thanks to GitHub user Eluvias for the suggestion! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/299">#299</a>)</p>
</li>
<li>
<p>Removed an unnecessary check in <code>na.locf()</code> (which is not user-facing). Thanks to GitHub user @cgiachalis for the suggestion! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/307">#307</a>)</p>
</li>
<li>
<p>Updated C entry points so they&rsquo;re not able to accidentally be found via dynamic lookup (i.e. <code>.Call("foo", ...)</code>). This makes each call to the C code a few microseconds faster, which is nice. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/260">#260</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672295/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672295/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a><div style="padding:0.3em;">&nbsp;</div><div width="970" style="clear:both;width:100%;max-width:970px;"><table border="0" cellpadding="0" cellspacing="0" align="center" style="margin:auto;max-width:100% !important;table-layout:fixed"><tr style="line-height:1px;margin:0px;padding:0px"><td colspan="2" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176092" rel="nofollow"><img src="https://feedads.feedblitz.com/i/marquee/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176092" border="0" width="900" style="display: block; width:100%; height:auto !important;max-width:100% !important"></a></td></tr><tr style="height:1px; line-height:1px;margin:0px;padding:0px"><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176093" height="1" width="1" /></td><td style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><img src="https://feedads.feedblitz.com/i/1x1/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176094" height="1" width="1" /></td></tr><tr><td align="left" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176095" rel="nofollow"><img src="https://feedads.feedblitz.com/i/116x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176095" border="0" style="max-height:15px !important;width:initial;"/></a></td><td align="right" style="width:initial;max-width:100%!important;line-height:1px;font-size:1px;"><a href="https://feedads.feedblitz.com/l/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176096" rel="nofollow"><img src="https://feedads.feedblitz.com/i/69x15/18676/36056564/1fa1b46266d5bf1e5866844450eaecbf2cabfafdd521a72765c13a55cc7374c0/khtml/176096" border="0" style="max-height:15px !important;width:initial;"/></a></td></tr></table></div>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2022/10/xts-0-12-2-on-cran/</feedburner:origLink><title>xts_0.12.2 on CRAN</title><link>https://feeds.feedblitz.com/~/748672298/0/fosstrading/</link><pubDate>Sat, 15 Oct 2022 10:21:00 -0500</pubDate><guid>https://blog.fosstrading.com/2022/10/xts-0-12-2-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=xts">xts</a> is now on <a href="http://cran.r-project.org/">CRAN</a>. This release is a big one, with lots of changes. Plotting functionality got a lot of attention. Another notable change is that <code>merge.xts()</code> now supports suffixes. Plus the obligatory bug fixes and refinements to make xts more robust.</p>
<h3 id="plotting-functionality-enhancements-and-bug-fixes">Plotting functionality enhancements and bug fixes</h3>
<ul>
<li>
<p>You can now omit the data time range from the upper-right portion of a plot by setting <code>main.timespan = FALSE</code>. (<a href="https://github.com/joshuaulrich/xts/issues/247">#247</a>)</p>
</li>
<li>
<p><code>plot.xts()</code> gained a <code>yaxis.ticks</code> argument to control the number of y-axis grid lines, instead of always drawing 5 y-axes grid lines. Thanks to <a href="https://github.com/FredrikWartenberg">Fredrik Wartenberg</a> for the feature request and patch! (<a href="https://github.com/joshuaulrich/xts/issues/374">#374</a>)</p>
</li>
<li>
<p>Fixed <code>addEventLines()</code> when plotted objects have a &lsquo;yearmon&rsquo; index. The ISO-8601 range string was not created correctly. Thanks to <a href="https://github.com/paessens">@paessens</a> for the report. (<a href="https://github.com/joshuaulrich/xts/issues/353">#353</a>)</p>
</li>
<li>
<p>The &lsquo;ylim&rsquo; argument is now robust against numerical precision issues. Thanks to <a href="https://github.com/bollard">@bollard</a> for the report, PR, and a ton of help debugging intermediate solutions! (<a href="https://github.com/joshuaulrich/xts/issues/368">#368</a>)</p>
</li>
<li>
<p>Series added to a panel now extend the panel&rsquo;s y-axis. Previously the y-axis limits were based on the first series&rsquo; values and not updated when new series were added. So values of the new series did not appear on the plot if they were outside of the original series&rsquo; min/max. Thanks to <a href="https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
<li>
<p>All series added to any panel of a plot now update the x-axis of all panels. So the entire plot&rsquo;s x-axis will include every series&rsquo; time index values within the original plot&rsquo;s time range. This behavior is consistent with <code>chart_Series()</code>. Thanks to <a href="https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="https://github.com/joshuaulrich/xts/issues/360">#360</a>, <a href="https://github.com/joshuaulrich/xts/issues/216">#216</a>)</p>
</li>
<li>
<p>All y-values are now plotted for series that have duplicate index values, but different data values. Thanks to <a href="https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
<li>
<p>Adding a series can now extend the x-axis before/after the plot&rsquo;s existing time index range by setting <code>extend.xaxis = TRUE</code>. That ensures all of the new series&rsquo; time index values are included in the plot. <code>extend.xaxis = FALSE</code> by default to maintain backward compatibility. Thanks to <a href="https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
</ul>
<h3 id="other-enhancements-and-bug-fixes">Other enhancements and bug fixes</h3>
<ul>
<li>
<p><code>Ops.xts()</code> no longer changes column names (via <code>make.names()</code>) when the two objects do not have identical indexes. This makes it consistent with <code>Ops.zoo()</code>. Thanks to <a href="https://github.com/tonytonov">Anton Antonov</a> for the report! (<a href="https://github.com/joshuaulrich/xts/issues/114">#114</a>)</p>
</li>
<li>
<p>Subsetting a zero-length xts object now returns an object with the same storage type as the input. It previously always returned a &rsquo;logical&rsquo; xts object. (<a href="https://github.com/joshuaulrich/xts/issues/376">#376</a>)</p>
</li>
<li>
<p><code>tclass()</code> and <code>tzone()</code> now return the correct values for zero-length xts objects, instead of the defaults from the <code>.xts()</code> constructor. Thanks to <a href="https://github.com/AndreMikulec">Andre Mikulec</a> for the report and suggested patch! (<a href="https://github.com/joshuaulrich/xts/issues/255">#255</a>)</p>
</li>
<li>
<p><code>first()</code> and <code>last()</code> now return a zero-length xts object when <code>n = 0</code>. They previously returned the entire object. This is consistent with the default <code>head()</code> and <code>tail()</code> functions, and data.table&rsquo;s <code>first()</code> and <code>last()</code> functions. Thanks to <a href="https://github.com/ethanbsmith">Ethan B. Smith</a> for the report and patch! (<a href="https://github.com/joshuaulrich/xts/issues/350">#350</a>)</p>
</li>
<li>
<p>Subsetting a zero-width xts now returns an object with the same class, tclass, tzone, and xtsAttributes as the input. Thanks to <a href="https://github.com/shikokuchuo">@shikokuchuo</a> for the report! (<a href="https://github.com/joshuaulrich/xts/issues/359">#359</a>)</p>
</li>
<li>
<p>Now <code>endpoints()</code> always returns last observation. Thanks to GitHub user <a href="https://github.com/Eluvias">Eluvias</a> for the report. (<a href="https://github.com/joshuaulrich/xts/issues/300">#300</a>)</p>
</li>
<li>
<p>Now <code>endpoints()</code> errors for every <code>on</code> value when <code>k &lt; 1</code>. It was not throwing an error for <code>k &lt; 1</code> for <code>on</code> of &ldquo;years&rdquo;, &ldquo;quarters&rdquo;, or &ldquo;months&rdquo;. Thanks to <a href="https://github.com/Eluvias">Eluvias</a>for the report. (<a href="https://github.com/joshuaulrich/xts/issues/301">#301</a>)</p>
</li>
<li>
<p>Fixed a breaking change (introduced in 0.11.0) in <code>window()</code> for yearmon and yearqtr indexes. In xts &lt; 0.11.0, <code>window.zoo()</code> was dispatched when <code>window()</code> was called on a xts object because there was no <code>window.xts()</code> method. <code>window.zoo()</code> supports additional types of values for the <code>start</code> argument, and possibly other features. Thanks to <a href="https://github.com/annaymj">@annaymj</a> for the report. (<a href="https://github.com/joshuaulrich/xts/issues/312">#312</a>)</p>
</li>
<li>
<p>Clarified documentation for <code>axTicksByTime()</code> to say that returns index locations (e.g. 1, 2, 3) and not timestamps. Thanks to <a href="https://github.com/ggrothendieck">Gabor Grothendieck</a> for the suggestion and feedback. (<a href="https://github.com/joshuaulrich/xts/issues/354">#354</a>)</p>
</li>
<li>
<p>Fixed <code>merge.xts()</code> on xts objects containing complex types when <code>fill</code> is provided. It previously threw an error because it treated <code>fill</code> as double instead of complex. Thanks to <a href="https://github.com/ggrothendieck">Gabor Grothendieck</a> for the report. (<a href="https://github.com/joshuaulrich/xts/issues/346">#346</a>)</p>
</li>
<li>
<p>Added a message to tell the user how to disable the &ldquo;object timezone is different from the system timezone&rdquo; warning (set <code>options(xts_check_TZ = FALSE)</code>). Thanks to <a href="https://github.com/algoquant">Jerzy Pawlowski</a> for the nudge. (<a href="https://github.com/joshuaulrich/xts/issues/113">#113</a>)</p>
</li>
<li>
<p><code>rbind()</code> now handles xts objects without dim attribute. It previously threw an obscure error if one of the xts objects did not have a dim attribute. (<a href="https://github.com/joshuaulrich/xts/issues/361">#361</a>)</p>
</li>
<li>
<p><code>split.xts()</code> now always return a named list, making it consistent with <code>split.zoo()</code>. Thanks to <a href="https://github.com/ggrothendieck">Gabor Grothendieck</a> for the report. (<a href="https://github.com/joshuaulrich/xts/issues/357">#357</a>)</p>
</li>
<li>
<p>xts objects with a zero-length POSIXct index now have a zero-length POSIXct vector instead of a zero-length integer vector for the index. Thanks to <a href="https://github.com/JasperSch">Jasper Schelfhout</a> for the report and PR! (<a href="https://github.com/joshuaulrich/xts/issues/363">#363</a>, <a href="https://github.com/joshuaulrich/xts/pulls/364">#364</a>)</p>
</li>
<li>
<p>Add supported for suffixes in <code>merge.xts()</code> results. The suffixes are consistent with <code>merge.default()</code> and not <code>merge.zoo()</code>, because <code>merge.zoo()</code> automatically uses &ldquo;.&rdquo; as a separator between column names, but the default method doesn&rsquo;t. Thanks to Alex Chernyakov for the initial report, <a href="https://github.com/stucash">QiuxiaoMu</a> for testing, and <a href="https://github.com/pierre-lamarche">Pierre Lamarche</a> for the nudge. Better late than never? (<a href="https://github.com/joshuaulrich/xts/issues/38">#38</a>, <a href="https://github.com/joshuaulrich/xts/issues/371">#371</a>)</p>
</li>
</ul>
<hr>
<p>You may have noticed that several of these issues have been open a long time. I&rsquo;ve been revisiting historical issues and deciding whether to implement them or close them. I&rsquo;ve already implemented some cool ones in the development version of xts.</p>
<p>I&rsquo;m most excited about open-ended time-of-day subsetting. Now you can do things like:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">x[</span><span class="s">&#34;/T1700&#34;</span><span class="n">]</span> <span class="c1"># start of the day until 5pm</span>
</span></span><span class="line"><span class="cl"><span class="n">x[</span><span class="s">&#34;T0500/&#34;</span><span class="n">]</span> <span class="c1"># 5am until the end of the day</span>
</span></span></code></pre></div>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>. This release is a big one, with lots of changes. Plotting functionality got a lot of attention. Another notable change is that <code>merge.xts()</code> now supports suffixes. Plus the obligatory bug fixes and refinements to make xts more robust.</p>
<h3 id="plotting-functionality-enhancements-and-bug-fixes">Plotting functionality enhancements and bug fixes</h3>
<ul>
<li>
<p>You can now omit the data time range from the upper-right portion of a plot by setting <code>main.timespan = FALSE</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/247">#247</a>)</p>
</li>
<li>
<p><code>plot.xts()</code> gained a <code>yaxis.ticks</code> argument to control the number of y-axis grid lines, instead of always drawing 5 y-axes grid lines. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/FredrikWartenberg">Fredrik Wartenberg</a> for the feature request and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/374">#374</a>)</p>
</li>
<li>
<p>Fixed <code>addEventLines()</code> when plotted objects have a &lsquo;yearmon&rsquo; index. The ISO-8601 range string was not created correctly. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/paessens">@paessens</a> for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/353">#353</a>)</p>
</li>
<li>
<p>The &lsquo;ylim&rsquo; argument is now robust against numerical precision issues. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/bollard">@bollard</a> for the report, PR, and a ton of help debugging intermediate solutions! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/368">#368</a>)</p>
</li>
<li>
<p>Series added to a panel now extend the panel&rsquo;s y-axis. Previously the y-axis limits were based on the first series&rsquo; values and not updated when new series were added. So values of the new series did not appear on the plot if they were outside of the original series&rsquo; min/max. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
<li>
<p>All series added to any panel of a plot now update the x-axis of all panels. So the entire plot&rsquo;s x-axis will include every series&rsquo; time index values within the original plot&rsquo;s time range. This behavior is consistent with <code>chart_Series()</code>. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/360">#360</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/216">#216</a>)</p>
</li>
<li>
<p>All y-values are now plotted for series that have duplicate index values, but different data values. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
<li>
<p>Adding a series can now extend the x-axis before/after the plot&rsquo;s existing time index range by setting <code>extend.xaxis = TRUE</code>. That ensures all of the new series&rsquo; time index values are included in the plot. <code>extend.xaxis = FALSE</code> by default to maintain backward compatibility. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/vspinu">Vitalie Spinu</a> for the report and help debugging and testing! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/360">#360</a>)</p>
</li>
</ul>
<h3 id="other-enhancements-and-bug-fixes">Other enhancements and bug fixes</h3>
<ul>
<li>
<p><code>Ops.xts()</code> no longer changes column names (via <code>make.names()</code>) when the two objects do not have identical indexes. This makes it consistent with <code>Ops.zoo()</code>. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/tonytonov">Anton Antonov</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/114">#114</a>)</p>
</li>
<li>
<p>Subsetting a zero-length xts object now returns an object with the same storage type as the input. It previously always returned a &rsquo;logical&rsquo; xts object. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/376">#376</a>)</p>
</li>
<li>
<p><code>tclass()</code> and <code>tzone()</code> now return the correct values for zero-length xts objects, instead of the defaults from the <code>.xts()</code> constructor. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/AndreMikulec">Andre Mikulec</a> for the report and suggested patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/255">#255</a>)</p>
</li>
<li>
<p><code>first()</code> and <code>last()</code> now return a zero-length xts object when <code>n = 0</code>. They previously returned the entire object. This is consistent with the default <code>head()</code> and <code>tail()</code> functions, and data.table&rsquo;s <code>first()</code> and <code>last()</code> functions. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ethanbsmith">Ethan B. Smith</a> for the report and patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/350">#350</a>)</p>
</li>
<li>
<p>Subsetting a zero-width xts now returns an object with the same class, tclass, tzone, and xtsAttributes as the input. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/shikokuchuo">@shikokuchuo</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/359">#359</a>)</p>
</li>
<li>
<p>Now <code>endpoints()</code> always returns last observation. Thanks to GitHub user <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/Eluvias">Eluvias</a> for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/300">#300</a>)</p>
</li>
<li>
<p>Now <code>endpoints()</code> errors for every <code>on</code> value when <code>k &lt; 1</code>. It was not throwing an error for <code>k &lt; 1</code> for <code>on</code> of &ldquo;years&rdquo;, &ldquo;quarters&rdquo;, or &ldquo;months&rdquo;. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/Eluvias">Eluvias</a>for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/301">#301</a>)</p>
</li>
<li>
<p>Fixed a breaking change (introduced in 0.11.0) in <code>window()</code> for yearmon and yearqtr indexes. In xts &lt; 0.11.0, <code>window.zoo()</code> was dispatched when <code>window()</code> was called on a xts object because there was no <code>window.xts()</code> method. <code>window.zoo()</code> supports additional types of values for the <code>start</code> argument, and possibly other features. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/annaymj">@annaymj</a> for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/312">#312</a>)</p>
</li>
<li>
<p>Clarified documentation for <code>axTicksByTime()</code> to say that returns index locations (e.g. 1, 2, 3) and not timestamps. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ggrothendieck">Gabor Grothendieck</a> for the suggestion and feedback. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/354">#354</a>)</p>
</li>
<li>
<p>Fixed <code>merge.xts()</code> on xts objects containing complex types when <code>fill</code> is provided. It previously threw an error because it treated <code>fill</code> as double instead of complex. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ggrothendieck">Gabor Grothendieck</a> for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/346">#346</a>)</p>
</li>
<li>
<p>Added a message to tell the user how to disable the &ldquo;object timezone is different from the system timezone&rdquo; warning (set <code>options(xts_check_TZ = FALSE)</code>). Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/algoquant">Jerzy Pawlowski</a> for the nudge. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/113">#113</a>)</p>
</li>
<li>
<p><code>rbind()</code> now handles xts objects without dim attribute. It previously threw an obscure error if one of the xts objects did not have a dim attribute. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/361">#361</a>)</p>
</li>
<li>
<p><code>split.xts()</code> now always return a named list, making it consistent with <code>split.zoo()</code>. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ggrothendieck">Gabor Grothendieck</a> for the report. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/357">#357</a>)</p>
</li>
<li>
<p>xts objects with a zero-length POSIXct index now have a zero-length POSIXct vector instead of a zero-length integer vector for the index. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/JasperSch">Jasper Schelfhout</a> for the report and PR! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/363">#363</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/pulls/364">#364</a>)</p>
</li>
<li>
<p>Add supported for suffixes in <code>merge.xts()</code> results. The suffixes are consistent with <code>merge.default()</code> and not <code>merge.zoo()</code>, because <code>merge.zoo()</code> automatically uses &ldquo;.&rdquo; as a separator between column names, but the default method doesn&rsquo;t. Thanks to Alex Chernyakov for the initial report, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/stucash">QiuxiaoMu</a> for testing, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/pierre-lamarche">Pierre Lamarche</a> for the nudge. Better late than never? (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/38">#38</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/371">#371</a>)</p>
</li>
</ul>
<hr>
<p>You may have noticed that several of these issues have been open a long time. I&rsquo;ve been revisiting historical issues and deciding whether to implement them or close them. I&rsquo;ve already implemented some cool ones in the development version of xts.</p>
<p>I&rsquo;m most excited about open-ended time-of-day subsetting. Now you can do things like:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">x[</span><span class="s">&#34;/T1700&#34;</span><span class="n">]</span> <span class="c1"># start of the day until 5pm</span>
</span></span><span class="line"><span class="cl"><span class="n">x[</span><span class="s">&#34;T0500/&#34;</span><span class="n">]</span> <span class="c1"># 5am until the end of the day</span>
</span></span></code></pre></div>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672298/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672298/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2020/09/xlf-rolling-mean-correlation/</feedburner:origLink><title>Mean rolling correlation of XLF constituents</title><link>https://feeds.feedblitz.com/~/748672301/0/fosstrading/</link><pubDate>Sat, 19 Sep 2020 07:23:00 -0500</pubDate><guid>https://blog.fosstrading.com/2020/09/xlf-rolling-mean-correlation/</guid><description><![CDATA[<p>I follow <a href="https://twitter.com/Quantocracy">Quantocracy on Twitter</a>, and I found <a href="https://robotwealth.com/rolling-mean-correlations-in-the-tidyverse/">Rolling mean correlation in the tidyverse</a> by <a href="https://robotwealth.com">Robot Wealth</a>. They say to let them know if you&rsquo;d approach it differently. I would, so I thought it would be interesting to replicate the analysis using tools I&rsquo;m familiar with: <a href="https://cran.r-project.org/package=xts">xts</a> and <a href="https://cran.r-project.org/package=TTR">TTR</a>.</p>
<p>The xts package is an extension of the very excellent <a href="https://cran.r-project.org/package=zoo">zoo</a> package. zoo objects are for ordered observations. Underneath, they are a matrix that can be ordered by anything: numbers, letters, dates, times, and more. xts objects are a special type of zoo object that can only be ordered by a date-time. They are the most common data structure used for working with financial time series, and are used in many of the major time series packages. You can find more details about xts objects in the <a href="https://cran.r-project.org/web/packages/xts/vignettes/xts.pdf">xts vignette</a>.</p>
<p>I like xts so much, I took over as maintainer when Jeff Ryan started working at a hedge fund that didn&rsquo;t let him continue open source work.</p>
<p>TTR is the first R package I wrote, all the way back in 2007, before R was cool! TTR has a collection of over 50 technical indicators for creating technical trading rules. The package also provides fast implementations of common rolling-window functions, and several volatility calculations. We&rsquo;re going to use its <code>ROC()</code> (rate-of-change) function to calculate returns.</p>
<p>Okay, now on to the code!</p>
<p>First, you need to download the data set. I&rsquo;ve saved a copy of the data that was provided in the Robot Wealth post. You can <a href="https://feeds.feedblitz.com/~/748672301/0/fosstrading/xlfprices.RData">download it here</a>. The Robot Wealth post used the <a href="https://www.tidyverse.org/">tidyverse</a>, so data is saved in the preferred tidyverse data structure, a <a href="https://cran.r-project.org/package=tibble">tibble</a> (it&rsquo;s like a data frame).</p>
<p>Then we need to <code>load()</code> the data into our R session. This creates an object named <code>prices_xlf</code>. The data has 10 columns: ticker, date, open, high, low,close, volume, dividends, closeunadj, inSPX. We&rsquo;re only going to use the date, ticker, and close columns.</p>
<p>Now we need to convert the <code>prices_xlf</code> tibble into an xts object. There&rsquo;s no standard way to do this, because tibbles don&rsquo;t have a pre-defined structure for financial time series. We can &lsquo;read&rsquo; and convert the data from a tibble into a zoo object using <code>read.zoo()</code>. We&rsquo;re using <code>read.zoo()</code> because there isn&rsquo;t a <code>read.xts()</code> function, and we can easily convert from zoo to xts using <code>as.xts()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">load</span><span class="p">(</span><span class="s">&#34;xlfprices.RData&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">xts</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">read.zoo</span><span class="p">(</span><span class="n">prices_xlf[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="s">&#34;ticker&#34;</span><span class="p">,</span> <span class="s">&#34;close&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">index.column</span> <span class="o">=</span> <span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="n">split</span> <span class="o">=</span> <span class="s">&#34;ticker&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Warning in zoo(rval4[[i]], ix[[i]]):</span>
</span></span><span class="line"><span class="cl"><span class="c1">## some methods for &#34;zoo&#34; objects do not work</span>
</span></span><span class="line"><span class="cl"><span class="c1">## if the index entries in &#39;order.by&#39; are not unique</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error in merge.zoo(AFL = structure(c(30.54, 29.74, 29.475, 29.66, 29.95, :</span>
</span></span><span class="line"><span class="cl"><span class="c1">## series cannot be merged with non-unique index entries in a series</span>
</span></span></code></pre></div><p>We pass <code>prices_xlf</code> to <code>read.zoo()</code>, but only with the columns we need for our analysis. The <code>index.column</code> argument tells <code>read.zoo()</code> which column in the data has the ordered index. The <code>split</code> argument allows us to reshape the data from a long format into a wide format, where each ticker is in its own column. This is the standard format for xts objects, because it makes working with financial time series a lot easier.</p>
<p>Now to run the code. Hmm&hellip; it throws an error. The error means there are duplicate dates for at least one of the tickers in the <code>prices_xlf</code> object. Depending on how many duplicates there are, this may or may not bias the results, but we should remove them anyway so the analysis is correct. This is another benefit of xts/zoo objects.</p>
<p>Let&rsquo;s take a look at the duplicates, and then remove them.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># find the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="n">duplicate_rows</span> <span class="o">&lt;-</span> <span class="nf">duplicated</span><span class="p">(</span><span class="n">prices_xlf</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># view the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">prices_xlf[duplicate_rows</span><span class="p">,</span> <span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ticker date open high low close volume dividends</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61839 CB 2016-01-29 110.18 113.17 110.00 113.07 4205800 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61904 CB 2016-01-28 108.55 109.84 108.42 109.52 3313800 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61969 CB 2016-01-27 108.15 109.91 107.07 108.10 3433200 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62034 CB 2016-01-26 108.51 109.76 108.00 108.58 2669500 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62099 CB 2016-01-25 109.95 109.99 107.82 108.00 2985000 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62164 CB 2016-01-22 109.70 110.97 109.48 110.04 2296000 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## closeunadj inSPX</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61839 113.07 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61904 109.52 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61969 108.10 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62034 108.58 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62099 108.00 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62164 110.04 TRUE</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># remove the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">unique</span><span class="p">(</span><span class="n">prices_xlf</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>duplicated()</code> function returns a logical (true/false) vector as long as the number of rows in your data. Any row it finds that matches a previous row in the data will be <code>TRUE</code> in the vector. Note that <em>only</em> the duplicated rows are <code>TRUE</code>. The first rows found will be <code>FALSE</code>. Subsetting <code>prices_xlf</code> by the <code>duplicated()</code> result will return the rows that exist somewhere in previous rows in the data.</p>
<p>You can probably guess what the <code>unique()</code> function does. It removes all the duplicated rows. Now that we removed the duplicates, we can try the <code>read.zoo()</code> call again.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># reshape data into wide format</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">read.zoo</span><span class="p">(</span><span class="n">prices[</span><span class="p">,</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="s">&#34;ticker&#34;</span><span class="p">,</span> <span class="s">&#34;close&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">index.column</span> <span class="o">=</span> <span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="n">split</span> <span class="o">=</span> <span class="s">&#34;ticker&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Great, that worked! Now we will convert from zoo to xts, because xts gives us a handful of fancy features in addition to all the awesomeness that comes with zoo. We&rsquo;re not going to use those fancy features in this post, but I promise, they&rsquo;re <em>fancy</em>.</p>
<p>Next we will calculate returns using the <code>ROC()</code> (rate-of-change) function from the TTR package.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># convert from zoo to xts</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate returns</span>
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">TTR</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="nf">ROC</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="c1"># log returns</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="nf">ROC</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;discrete&#34;</span><span class="p">)</span> <span class="c1"># arithmetic returns</span>
</span></span></code></pre></div><p>The single call to <code>as.xts()</code> is all you need to convert from zoo to xts. <code>ROC()</code> calculates log returns by default, but it will calculate discrete (or arithmetic) returns if you set <code>type = &quot;discrete&quot;</code>. We&rsquo;re going to use discrete returns to keep things consistent with the Robot Wealth post.</p>
<p>Next we will create a function to calculate the mean pairwise correlation for each pair of columns in our xts object. We can get all the pairwise correlations from the correlation matrix.</p>
<p>Once we calculate the correlation matrix, we can calculate the mean correlation by taking the mean of the entire matrix. You may be thinking that this will take the mean of each correlation value two times (once for the upper triangle of the matrix, and another time for the lower triangle). But the values in both triangles are the same, because the matrix is symmetric about the diagonal. So this will not affect the mean calculation.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">mean_cor</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># calculate the correlation matrix</span>
</span></span><span class="line"><span class="cl"> <span class="n">cor_matrix</span> <span class="o">&lt;-</span> <span class="nf">cor</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="n">use</span> <span class="o">=</span> <span class="s">&#34;pairwise.complete&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># set the diagonal to NA (may not be necessary)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">diag</span><span class="p">(</span><span class="n">cor_matrix</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># calculate the mean correlation, removing the NA</span>
</span></span><span class="line"><span class="cl"> <span class="nf">mean</span><span class="p">(</span><span class="n">cor_matrix</span><span class="p">,</span> <span class="n">na.rm</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Since our data are in a wide format, calculating the correlation matrix is takes a single call to the <code>cor()</code> function that comes with your R installation.</p>
<p>Then we set the diagonal of the matrix to <code>NA</code> because they are all equal to 1. That may not be necessary, but it could bias the results, and I&rsquo;m not ready to spend time thinking about it. :)</p>
<p>Finally, we take the mean of the entire correlation matrix.</p>
<p>Now that we have a handy-dandy <code>mean_cor()</code> function to calculate the mean pairwise correlations, we can call the function on a rolling, 60-day period. We can do this with the <code>rollapply()</code> function from the zoo package.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># calculate the rolling mean correlation over 60 periods</span>
</span></span><span class="line"><span class="cl"><span class="n">cors</span> <span class="o">&lt;-</span> <span class="nf">rollapply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="n">mean_cor</span><span class="p">,</span> <span class="n">by.column</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span> <span class="n">align</span> <span class="o">=</span> <span class="s">&#34;right&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>We set <code>align = &quot;right&quot;</code> in order &lsquo;right-align&rsquo; the result. That means the timestamp for each rolling window will be the right-most (or last/largest) value in the window. This is important because we do not know the value for the rolling period until the end of the window. We would severely bias our results if we used the &rsquo;left&rsquo; (first) or &lsquo;center&rsquo; (middle) timestamp for our window calculation.</p>
<p>We also need to set <code>by.column = FALSE</code>. Otherwise, the <code>rollapply()</code> function will run the function on each column of the xts object individually. And it doesn&rsquo;t make sense to try and calculation the correlation matrix of a single series.</p>
<p>Now, let&rsquo;s plot our rolling 60-day correlations. We only need to call the <code>plot()</code> function to get a quick look.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">cors</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Rolling mean XLF correlations&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/plot-rolling-mean-xlf-correlations-1.png" alt="plot of chunk plot-rolling-mean-xlf-correlations" >
</p>
<p>The main thing I like about my approach is how few lines of code it takes. The most complicated piece is the <code>mean_cor()</code> function, but even that is fairly straightforward.</p>
<p>You can do similar analysis using this same pattern. You need to create another function to calculate the metric, but everything else will be the same.</p>
<p>Like the Robot Wealth version, you can easily do this entire analysis in memory. You don&rsquo;t have to bother with chunking it up into smaller pieces and piecing it back together.</p>
<p>One difference is that the data in their version is just under 3 million (!) rows, and 6 columns (~18 million data points). This version is 1346 rows and 65 columns (less than 100,000 data points). So you could quickly do the analysis in memory this way on ETFs or indexes with many more constituents (e.g. the Russell 3000). I&rsquo;ve worked on xts data sets with ~1 <em>billion</em> rows of tick data on my machine with 32GB of RAM.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I follow <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://twitter.com/Quantocracy">Quantocracy on Twitter</a>, and I found <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://robotwealth.com/rolling-mean-correlations-in-the-tidyverse/">Rolling mean correlation in the tidyverse</a> by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://robotwealth.com">Robot Wealth</a>. They say to let them know if you&rsquo;d approach it differently. I would, so I thought it would be interesting to replicate the analysis using tools I&rsquo;m familiar with: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=xts">xts</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=TTR">TTR</a>.</p>
<p>The xts package is an extension of the very excellent <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=zoo">zoo</a> package. zoo objects are for ordered observations. Underneath, they are a matrix that can be ordered by anything: numbers, letters, dates, times, and more. xts objects are a special type of zoo object that can only be ordered by a date-time. They are the most common data structure used for working with financial time series, and are used in many of the major time series packages. You can find more details about xts objects in the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/web/packages/xts/vignettes/xts.pdf">xts vignette</a>.</p>
<p>I like xts so much, I took over as maintainer when Jeff Ryan started working at a hedge fund that didn&rsquo;t let him continue open source work.</p>
<p>TTR is the first R package I wrote, all the way back in 2007, before R was cool! TTR has a collection of over 50 technical indicators for creating technical trading rules. The package also provides fast implementations of common rolling-window functions, and several volatility calculations. We&rsquo;re going to use its <code>ROC()</code> (rate-of-change) function to calculate returns.</p>
<p>Okay, now on to the code!</p>
<p>First, you need to download the data set. I&rsquo;ve saved a copy of the data that was provided in the Robot Wealth post. You can <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://blog.fosstrading.com/2020/09/xlf-rolling-mean-correlation/xlfprices.RData">download it here</a>. The Robot Wealth post used the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tidyverse.org/">tidyverse</a>, so data is saved in the preferred tidyverse data structure, a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=tibble">tibble</a> (it&rsquo;s like a data frame).</p>
<p>Then we need to <code>load()</code> the data into our R session. This creates an object named <code>prices_xlf</code>. The data has 10 columns: ticker, date, open, high, low,close, volume, dividends, closeunadj, inSPX. We&rsquo;re only going to use the date, ticker, and close columns.</p>
<p>Now we need to convert the <code>prices_xlf</code> tibble into an xts object. There&rsquo;s no standard way to do this, because tibbles don&rsquo;t have a pre-defined structure for financial time series. We can &lsquo;read&rsquo; and convert the data from a tibble into a zoo object using <code>read.zoo()</code>. We&rsquo;re using <code>read.zoo()</code> because there isn&rsquo;t a <code>read.xts()</code> function, and we can easily convert from zoo to xts using <code>as.xts()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">load</span><span class="p">(</span><span class="s">&#34;xlfprices.RData&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">xts</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">read.zoo</span><span class="p">(</span><span class="n">prices_xlf[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="s">&#34;ticker&#34;</span><span class="p">,</span> <span class="s">&#34;close&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">index.column</span> <span class="o">=</span> <span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="n">split</span> <span class="o">=</span> <span class="s">&#34;ticker&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Warning in zoo(rval4[[i]], ix[[i]]):</span>
</span></span><span class="line"><span class="cl"><span class="c1">## some methods for &#34;zoo&#34; objects do not work</span>
</span></span><span class="line"><span class="cl"><span class="c1">## if the index entries in &#39;order.by&#39; are not unique</span>
</span></span><span class="line"><span class="cl"><span class="c1">## Error in merge.zoo(AFL = structure(c(30.54, 29.74, 29.475, 29.66, 29.95, :</span>
</span></span><span class="line"><span class="cl"><span class="c1">## series cannot be merged with non-unique index entries in a series</span>
</span></span></code></pre></div><p>We pass <code>prices_xlf</code> to <code>read.zoo()</code>, but only with the columns we need for our analysis. The <code>index.column</code> argument tells <code>read.zoo()</code> which column in the data has the ordered index. The <code>split</code> argument allows us to reshape the data from a long format into a wide format, where each ticker is in its own column. This is the standard format for xts objects, because it makes working with financial time series a lot easier.</p>
<p>Now to run the code. Hmm&hellip; it throws an error. The error means there are duplicate dates for at least one of the tickers in the <code>prices_xlf</code> object. Depending on how many duplicates there are, this may or may not bias the results, but we should remove them anyway so the analysis is correct. This is another benefit of xts/zoo objects.</p>
<p>Let&rsquo;s take a look at the duplicates, and then remove them.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># find the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="n">duplicate_rows</span> <span class="o">&lt;-</span> <span class="nf">duplicated</span><span class="p">(</span><span class="n">prices_xlf</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># view the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">prices_xlf[duplicate_rows</span><span class="p">,</span> <span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ticker date open high low close volume dividends</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61839 CB 2016-01-29 110.18 113.17 110.00 113.07 4205800 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61904 CB 2016-01-28 108.55 109.84 108.42 109.52 3313800 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61969 CB 2016-01-27 108.15 109.91 107.07 108.10 3433200 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62034 CB 2016-01-26 108.51 109.76 108.00 108.58 2669500 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62099 CB 2016-01-25 109.95 109.99 107.82 108.00 2985000 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62164 CB 2016-01-22 109.70 110.97 109.48 110.04 2296000 0</span>
</span></span><span class="line"><span class="cl"><span class="c1">## closeunadj inSPX</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61839 113.07 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61904 109.52 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 61969 108.10 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62034 108.58 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62099 108.00 TRUE</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 62164 110.04 TRUE</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># remove the duplicates</span>
</span></span><span class="line"><span class="cl"><span class="n">prices</span> <span class="o">&lt;-</span> <span class="nf">unique</span><span class="p">(</span><span class="n">prices_xlf</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>duplicated()</code> function returns a logical (true/false) vector as long as the number of rows in your data. Any row it finds that matches a previous row in the data will be <code>TRUE</code> in the vector. Note that <em>only</em> the duplicated rows are <code>TRUE</code>. The first rows found will be <code>FALSE</code>. Subsetting <code>prices_xlf</code> by the <code>duplicated()</code> result will return the rows that exist somewhere in previous rows in the data.</p>
<p>You can probably guess what the <code>unique()</code> function does. It removes all the duplicated rows. Now that we removed the duplicates, we can try the <code>read.zoo()</code> call again.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># reshape data into wide format</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">read.zoo</span><span class="p">(</span><span class="n">prices[</span><span class="p">,</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="s">&#34;ticker&#34;</span><span class="p">,</span> <span class="s">&#34;close&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">index.column</span> <span class="o">=</span> <span class="s">&#34;date&#34;</span><span class="p">,</span> <span class="n">split</span> <span class="o">=</span> <span class="s">&#34;ticker&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Great, that worked! Now we will convert from zoo to xts, because xts gives us a handful of fancy features in addition to all the awesomeness that comes with zoo. We&rsquo;re not going to use those fancy features in this post, but I promise, they&rsquo;re <em>fancy</em>.</p>
<p>Next we will calculate returns using the <code>ROC()</code> (rate-of-change) function from the TTR package.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># convert from zoo to xts</span>
</span></span><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">as.xts</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># calculate returns</span>
</span></span><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">TTR</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="nf">ROC</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="c1"># log returns</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="nf">ROC</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;discrete&#34;</span><span class="p">)</span> <span class="c1"># arithmetic returns</span>
</span></span></code></pre></div><p>The single call to <code>as.xts()</code> is all you need to convert from zoo to xts. <code>ROC()</code> calculates log returns by default, but it will calculate discrete (or arithmetic) returns if you set <code>type = "discrete"</code>. We&rsquo;re going to use discrete returns to keep things consistent with the Robot Wealth post.</p>
<p>Next we will create a function to calculate the mean pairwise correlation for each pair of columns in our xts object. We can get all the pairwise correlations from the correlation matrix.</p>
<p>Once we calculate the correlation matrix, we can calculate the mean correlation by taking the mean of the entire matrix. You may be thinking that this will take the mean of each correlation value two times (once for the upper triangle of the matrix, and another time for the lower triangle). But the values in both triangles are the same, because the matrix is symmetric about the diagonal. So this will not affect the mean calculation.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">mean_cor</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"> <span class="kr">function</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># calculate the correlation matrix</span>
</span></span><span class="line"><span class="cl"> <span class="n">cor_matrix</span> <span class="o">&lt;-</span> <span class="nf">cor</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="n">use</span> <span class="o">=</span> <span class="s">&#34;pairwise.complete&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># set the diagonal to NA (may not be necessary)</span>
</span></span><span class="line"><span class="cl"> <span class="nf">diag</span><span class="p">(</span><span class="n">cor_matrix</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="kc">NA</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># calculate the mean correlation, removing the NA</span>
</span></span><span class="line"><span class="cl"> <span class="nf">mean</span><span class="p">(</span><span class="n">cor_matrix</span><span class="p">,</span> <span class="n">na.rm</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Since our data are in a wide format, calculating the correlation matrix is takes a single call to the <code>cor()</code> function that comes with your R installation.</p>
<p>Then we set the diagonal of the matrix to <code>NA</code> because they are all equal to 1. That may not be necessary, but it could bias the results, and I&rsquo;m not ready to spend time thinking about it. :)</p>
<p>Finally, we take the mean of the entire correlation matrix.</p>
<p>Now that we have a handy-dandy <code>mean_cor()</code> function to calculate the mean pairwise correlations, we can call the function on a rolling, 60-day period. We can do this with the <code>rollapply()</code> function from the zoo package.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># calculate the rolling mean correlation over 60 periods</span>
</span></span><span class="line"><span class="cl"><span class="n">cors</span> <span class="o">&lt;-</span> <span class="nf">rollapply</span><span class="p">(</span><span class="n">returns</span><span class="p">,</span> <span class="m">60</span><span class="p">,</span> <span class="n">mean_cor</span><span class="p">,</span> <span class="n">by.column</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span> <span class="n">align</span> <span class="o">=</span> <span class="s">&#34;right&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>We set <code>align = "right"</code> in order &lsquo;right-align&rsquo; the result. That means the timestamp for each rolling window will be the right-most (or last/largest) value in the window. This is important because we do not know the value for the rolling period until the end of the window. We would severely bias our results if we used the &rsquo;left&rsquo; (first) or &lsquo;center&rsquo; (middle) timestamp for our window calculation.</p>
<p>We also need to set <code>by.column = FALSE</code>. Otherwise, the <code>rollapply()</code> function will run the function on each column of the xts object individually. And it doesn&rsquo;t make sense to try and calculation the correlation matrix of a single series.</p>
<p>Now, let&rsquo;s plot our rolling 60-day correlations. We only need to call the <code>plot()</code> function to get a quick look.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">cors</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Rolling mean XLF correlations&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/plot-rolling-mean-xlf-correlations-1.png" alt="plot of chunk plot-rolling-mean-xlf-correlations" >
</p>
<p>The main thing I like about my approach is how few lines of code it takes. The most complicated piece is the <code>mean_cor()</code> function, but even that is fairly straightforward.</p>
<p>You can do similar analysis using this same pattern. You need to create another function to calculate the metric, but everything else will be the same.</p>
<p>Like the Robot Wealth version, you can easily do this entire analysis in memory. You don&rsquo;t have to bother with chunking it up into smaller pieces and piecing it back together.</p>
<p>One difference is that the data in their version is just under 3 million (!) rows, and 6 columns (~18 million data points). This version is 1346 rows and 65 columns (less than 100,000 data points). So you could quickly do the analysis in memory this way on ETFs or indexes with many more constituents (e.g. the Russell 3000). I&rsquo;ve worked on xts data sets with ~1 <em>billion</em> rows of tick data on my machine with 32GB of RAM.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672301/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672301/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2020/09/xts-0-12-1-on-cran/</feedburner:origLink><title>xts_0.12.1 on CRAN</title><link>https://feeds.feedblitz.com/~/748672304/0/fosstrading/</link><pubDate>Sun, 13 Sep 2020 10:49:00 -0500</pubDate><guid>https://blog.fosstrading.com/2020/09/xts-0-12-1-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=xts">xts</a> reached <a href="http://cran.r-project.org/">CRAN</a> on 2020-09-09. Time-of-day subsetting (e.g. <code>x[&quot;T10:00/T13:00&quot;]</code>) is 200x faster! (This post includes some notes on some nifty changes in 0.12.0 too, since I didn&rsquo;t post about 0.12.0 when it was released.)</p>
<p>This is a long-overdue post. I&rsquo;m trying to get int the habit of posting and announcing each of my package releases. So I&rsquo;m writing posts this morning for the most recent release of the most popular packages I maintain. I released an updated version of <a href="http://cran.r-project.org/package=xts">xts</a> to <a href="http://cran.r-project.org/">CRAN</a> on 2020-09-09.</p>
<p>I&rsquo;m going to highlight a handful of the changes that involve:</p>
<ol>
<li>moving index class and index timezone from the xts object itself to the index,</li>
<li>improvements to time-of-day subsetting (<code>x[&quot;T10:00/T13:00&quot;]</code>)</li>
<li>user contributions, and</li>
<li>several bug fixes.</li>
</ol>
<h3 id="changes-to-index-attributes">Changes to index attributes</h3>
<p>The most significant user-facing change in this release is a bug-fix for the functions that would change the <code>tclass</code> of the xts index. This would happen in calls to <code>reclass()</code>, <code>period.apply()</code>, and logical operations on <code>POSIXct</code> indexes. Thanks to <a href="https://github.com/TomAndrews">Tom Andrews</a> for the report and testing, and to <a href="https://github.com/philaris">Panagiotis Cheilaris</a> for contributing test cases (<a href="https://github.com/joshuaulrich/xts/issues/322">#322</a>, <a href="https://github.com/joshuaulrich/xts/pull/323">#323</a>).</p>
<p>This was a regression due to the main change in version 0.12-0. All the index-attributes were removed from the xts object and are now only attached to the index itself (<a href="https://github.com/joshuaulrich/xts/issues/245">#245</a>). We took great care to maintain backward compatibility, and throw warnings when deprecated functions are called and when index-attributes are found on the xts object. I apologize for taking this long to get the fix on CRAN.</p>
<h3 id="time-of-day-subsetting">Time-of-day subsetting</h3>
<p>Another change in 0.12-0 is a significant (~200x!) performance improvement to time-of-day subsetting, thanks to <a href="https://stackoverflow.com/users/3226167/user3226167">StackOverflow user3226167</a> (<a href="https://github.com/joshuaulrich/xts/issues/193">#193</a>).</p>
<p>Then <a href="https://github.com/claymoremarshall">Claymore Marshall</a> added many examples of time-of-day subsetting to <code>?subset.xts</code>. He also fixed a bug in time-of-day subsetting where subsetting by hour only returned wrong results (<a href="https://github.com/joshuaulrich/xts/issues/304">#304</a>, <a href="https://github.com/joshuaulrich/xts/issues/326">#326</a>, <a href="https://github.com/joshuaulrich/xts/pull/328">#328</a>).</p>
<h3 id="user-contributions">User contributions</h3>
<p>There were also several more user-contributed changes. I love when the community that uses open source software contributes to the project! It&rsquo;s so much more fun than working on it by myself. :)</p>
<p>These are in a bulleted list in order to highlight each user&rsquo;s contribution.</p>
<ul>
<li>
<p><a href="https://github.com/jaymon0703">Jasen Macike</a> updated <code>plot.xts()</code> to support y-axis labels via the <code>ylab</code> argument (<a href="https://github.com/joshuaulrich/xts/issues/333">#333</a>, <a href="https://github.com/joshuaulrich/xts/pull/334">#334</a>).</p>
</li>
<li>
<p><a href="https://github.com/MichaelChirico">Michael Chirico</a> added an internal <code>isUTC()</code> function that recognizes many UTC-equivalent time zones (<a href="https://github.com/joshuaulrich/xts/issues/319">#319</a>).</p>
</li>
<li>
<p><a href="https://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a> updated the C API header to fix the signatures of <code>do_merge_xts()</code> and <code>is_xts</code>, which did not return the required type to be called via <code>.Call()</code>. Thanks to <a href="https://github.com/kalibera">Tomas Kalibera</a> for the report (<a href="https://github.com/joshuaulrich/xts/issues/317">#317</a>), and to Dirk for the PR (<a href="https://github.com/joshuaulrich/xts/pull/337">#337</a>). <br>
This is a breaking change, but it&rsquo;s only in the C API, and is required to avoid the potential to crash your R session.</p>
</li>
<li>
<p><a href="https://github.com/harvey131">Harvey Smith</a> fixed the possible values for the <code>major.ticks</code>, <code>minor.ticks</code>, and <code>grid.ticks.on</code> arguments to <code>plot.xts()</code> in the Details section of the documentation (<a href="https://github.com/joshuaulrich/xts/issues/291">#291</a>).</p>
</li>
<li>
<p>Performance for the <code>period.XYZ()</code> functions (sum, prod, min, max) is much faster (<a href="https://github.com/joshuaulrich/xts/issues/278">#278</a>). Thanks to <a href="https://github.com/ckatsulis">Chris Katsulis</a> for the report, and <a href="https://github.com/harvey131">Harvey Smith</a> for several examples.</p>
</li>
</ul>
<h3 id="bug-fixes">Bug fixes</h3>
<p><code>first()</code> now operates correctly on non-xts objects when <code>n = -1</code>. Previously it would always return the last two values. Thanks to <a href="https://github.com/vxg20">GitHub user vxg20</a> for the report (<a href="https://github.com/joshuaulrich/xts/issues/325">#325</a>).</p>
<p>The <code>.xts()</code> constructor would create an xts object with row names if <code>x</code> had row names. This shouldn&rsquo;t happen, because xts objects do not have or support row names (<a href="https://github.com/joshuaulrich/xts/issues/298">#298</a>).</p>
<p>Several binary operations (e.g. +, -, !=, &lt;, etc.) on variations of uncommon xts objects with other xts, matrix, or vector objects, could result in malformed xts objects (<a href="https://github.com/joshuaulrich/xts/issues/295">#295</a>). Some examples of the types of uncommon xts objects: no dim attribute, zero-width, zero-length.</p>
<p>Calling <code>as.matrix()</code> on an xts object without a dim attribute no longer throws an error (<a href="https://github.com/joshuaulrich/xts/issues/294">#294</a>).</p>
<p><code>merge.xts()</code> now honors <code>check.names = FALSE</code> (<a href="https://github.com/joshuaulrich/xts/issues/293">#293</a>). It also creates shorter column names when passed unnamed objects, consistent with zoo (<a href="https://github.com/joshuaulrich/xts/issues/248">#248</a>).</p>
<p><code>as.zoo.xts()</code> is now only registered for zoo versions prior to 1.8-5. Methods to convert an object to another class should reside in the package that implements the target class. Thanks to Kurt Hornik for the report (<a href="https://github.com/joshuaulrich/xts/issues/287">#287</a>).</p>
<p><code>.parseISO8601()</code> no longer has a potential length-1 logical error. Thanks to Kurt Hornik for the report (<a href="https://github.com/joshuaulrich/xts/issues/280">#280</a>).</p>
<p><code>endpoints()</code> now honors <code>k &gt; 0</code> when <code>on = &quot;quarters&quot;</code>. Thanks to <a href="https://github.com/alkment">@alkment</a> for the report (<a href="https://github.com/joshuaulrich/xts/issues/279">#279</a>).</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> reached <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a> on 2020-09-09. Time-of-day subsetting (e.g. <code>x["T10:00/T13:00"]</code>) is 200x faster! (This post includes some notes on some nifty changes in 0.12.0 too, since I didn&rsquo;t post about 0.12.0 when it was released.)</p>
<p>This is a long-overdue post. I&rsquo;m trying to get int the habit of posting and announcing each of my package releases. So I&rsquo;m writing posts this morning for the most recent release of the most popular packages I maintain. I released an updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=xts">xts</a> to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a> on 2020-09-09.</p>
<p>I&rsquo;m going to highlight a handful of the changes that involve:</p>
<ol>
<li>moving index class and index timezone from the xts object itself to the index,</li>
<li>improvements to time-of-day subsetting (<code>x["T10:00/T13:00"]</code>)</li>
<li>user contributions, and</li>
<li>several bug fixes.</li>
</ol>
<h3 id="changes-to-index-attributes">Changes to index attributes</h3>
<p>The most significant user-facing change in this release is a bug-fix for the functions that would change the <code>tclass</code> of the xts index. This would happen in calls to <code>reclass()</code>, <code>period.apply()</code>, and logical operations on <code>POSIXct</code> indexes. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/TomAndrews">Tom Andrews</a> for the report and testing, and to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/philaris">Panagiotis Cheilaris</a> for contributing test cases (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/322">#322</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/pull/323">#323</a>).</p>
<p>This was a regression due to the main change in version 0.12-0. All the index-attributes were removed from the xts object and are now only attached to the index itself (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/245">#245</a>). We took great care to maintain backward compatibility, and throw warnings when deprecated functions are called and when index-attributes are found on the xts object. I apologize for taking this long to get the fix on CRAN.</p>
<h3 id="time-of-day-subsetting">Time-of-day subsetting</h3>
<p>Another change in 0.12-0 is a significant (~200x!) performance improvement to time-of-day subsetting, thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com/users/3226167/user3226167">StackOverflow user3226167</a> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/193">#193</a>).</p>
<p>Then <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/claymoremarshall">Claymore Marshall</a> added many examples of time-of-day subsetting to <code>?subset.xts</code>. He also fixed a bug in time-of-day subsetting where subsetting by hour only returned wrong results (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/304">#304</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/326">#326</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/pull/328">#328</a>).</p>
<h3 id="user-contributions">User contributions</h3>
<p>There were also several more user-contributed changes. I love when the community that uses open source software contributes to the project! It&rsquo;s so much more fun than working on it by myself. :)</p>
<p>These are in a bulleted list in order to highlight each user&rsquo;s contribution.</p>
<ul>
<li>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/jaymon0703">Jasen Macike</a> updated <code>plot.xts()</code> to support y-axis labels via the <code>ylab</code> argument (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/333">#333</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/pull/334">#334</a>).</p>
</li>
<li>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/MichaelChirico">Michael Chirico</a> added an internal <code>isUTC()</code> function that recognizes many UTC-equivalent time zones (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/319">#319</a>).</p>
</li>
<li>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a> updated the C API header to fix the signatures of <code>do_merge_xts()</code> and <code>is_xts</code>, which did not return the required type to be called via <code>.Call()</code>. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/kalibera">Tomas Kalibera</a> for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/317">#317</a>), and to Dirk for the PR (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/pull/337">#337</a>). 
<br>
This is a breaking change, but it&rsquo;s only in the C API, and is required to avoid the potential to crash your R session.</p>
</li>
<li>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/harvey131">Harvey Smith</a> fixed the possible values for the <code>major.ticks</code>, <code>minor.ticks</code>, and <code>grid.ticks.on</code> arguments to <code>plot.xts()</code> in the Details section of the documentation (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/291">#291</a>).</p>
</li>
<li>
<p>Performance for the <code>period.XYZ()</code> functions (sum, prod, min, max) is much faster (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/278">#278</a>). Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ckatsulis">Chris Katsulis</a> for the report, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/harvey131">Harvey Smith</a> for several examples.</p>
</li>
</ul>
<h3 id="bug-fixes">Bug fixes</h3>
<p><code>first()</code> now operates correctly on non-xts objects when <code>n = -1</code>. Previously it would always return the last two values. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/vxg20">GitHub user vxg20</a> for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/325">#325</a>).</p>
<p>The <code>.xts()</code> constructor would create an xts object with row names if <code>x</code> had row names. This shouldn&rsquo;t happen, because xts objects do not have or support row names (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/298">#298</a>).</p>
<p>Several binary operations (e.g. +, -, !=, &lt;, etc.) on variations of uncommon xts objects with other xts, matrix, or vector objects, could result in malformed xts objects (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/295">#295</a>). Some examples of the types of uncommon xts objects: no dim attribute, zero-width, zero-length.</p>
<p>Calling <code>as.matrix()</code> on an xts object without a dim attribute no longer throws an error (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/294">#294</a>).</p>
<p><code>merge.xts()</code> now honors <code>check.names = FALSE</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/293">#293</a>). It also creates shorter column names when passed unnamed objects, consistent with zoo (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/248">#248</a>).</p>
<p><code>as.zoo.xts()</code> is now only registered for zoo versions prior to 1.8-5. Methods to convert an object to another class should reside in the package that implements the target class. Thanks to Kurt Hornik for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/287">#287</a>).</p>
<p><code>.parseISO8601()</code> no longer has a potential length-1 logical error. Thanks to Kurt Hornik for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/280">#280</a>).</p>
<p><code>endpoints()</code> now honors <code>k &gt; 0</code> when <code>on = "quarters"</code>. Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/alkment">@alkment</a> for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/279">#279</a>).</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672304/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672304/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2020/09/ttr-0-24-2-on-cran/</feedburner:origLink><title>TTR_0.24.2 on CRAN</title><link>https://feeds.feedblitz.com/~/748672307/0/fosstrading/</link><pubDate>Sun, 13 Sep 2020 08:41:00 -0500</pubDate><guid>https://blog.fosstrading.com/2020/09/ttr-0-24-2-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://cran.r-project.org/package=TTR">TTR</a> is on <a href="http://cran.r-project.org/">CRAN</a> now. This is mainly a bug-fix release. There were several issues in the underlying C code that caused various issues. I&rsquo;ll spare you the gory details. If you&rsquo;re really interested, you can find them in the <a href="https://github.com/joshuaulrich/TTR/blob/27ea28698295f56447fcc87ad515140bdb35c8a5/CHANGES">CHANGES</a> file.</p>
<p>[This is another one of my long-overdue posts. I&rsquo;m trying to get int the habit of posting and announcing each of my package releases. So I&rsquo;m writing posts this morning for the most recent release of the most popular packages I maintain.]</p>
<p>I released an updated version of <a href="http://cran.r-project.org/package=TTR">TTR</a> to <a href="http://cran.r-project.org/">CRAN</a> on 2020-09-01.</p>
<p>Now for the bug fixes you might actually notice.</p>
<ul>
<li>
<p><code>ALMA()</code> could return an object whose length didn&rsquo;t match the length of the input when the input was not an xts object. This bug has been around for years. I&rsquo;m sorry I just now got to it.
<br>
<br>
The bug was caused by the differences in <code>rollapply.default()</code> in zoo and <code>rollapply.xts()</code>. The xts method pads with <code>NA</code> by default, whereas the default version does not. Thanks to GitHub user <a href="https://github.com/marksimmonds">marksimmonds</a> for the report! (<a href="https://github.com/joshuaulrich/TTR/issues/29">#29</a>)</p>
</li>
<li>
<p><code>MFI()</code> has been fixed for the case where money flow is always &gt; 0. The denominator of the money ratio is zero if there is no negative money flow for <code>n</code> consecutive observations (e.g. during a strong up-trend). This causes the money flow index to be <code>Inf</code>. Now the money flow index is set to 100 in this case.
<br>
<br>
Also, the money ratio will be <code>NaN</code> if there&rsquo;s no money flow for <code>n</code> consecutive observations (e.g. if there are no trades). This causes the money flow index to be <code>NaN</code>. Now the money flow index is to 50 in this case. Thanks to GitHub user <a href="https://github.com/jgehw">jgehw</a> for the report, reproducible example, and suggested patch! (<a href="https://github.com/joshuaulrich/TTR/issues/81">#81</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/ttr">[ttr]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/ttr/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/ttr/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=TTR">TTR</a> is on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a> now. This is mainly a bug-fix release. There were several issues in the underlying C code that caused various issues. I&rsquo;ll spare you the gory details. If you&rsquo;re really interested, you can find them in the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/TTR/blob/27ea28698295f56447fcc87ad515140bdb35c8a5/CHANGES">CHANGES</a> file.</p>
<p>[This is another one of my long-overdue posts. I&rsquo;m trying to get int the habit of posting and announcing each of my package releases. So I&rsquo;m writing posts this morning for the most recent release of the most popular packages I maintain.]</p>
<p>I released an updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/package=TTR">TTR</a> to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a> on 2020-09-01.</p>
<p>Now for the bug fixes you might actually notice.</p>
<ul>
<li>
<p><code>ALMA()</code> could return an object whose length didn&rsquo;t match the length of the input when the input was not an xts object. This bug has been around for years. I&rsquo;m sorry I just now got to it.

<br>

<br>
The bug was caused by the differences in <code>rollapply.default()</code> in zoo and <code>rollapply.xts()</code>. The xts method pads with <code>NA</code> by default, whereas the default version does not. Thanks to GitHub user <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/marksimmonds">marksimmonds</a> for the report! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/TTR/issues/29">#29</a>)</p>
</li>
<li>
<p><code>MFI()</code> has been fixed for the case where money flow is always &gt; 0. The denominator of the money ratio is zero if there is no negative money flow for <code>n</code> consecutive observations (e.g. during a strong up-trend). This causes the money flow index to be <code>Inf</code>. Now the money flow index is set to 100 in this case.

<br>

<br>
Also, the money ratio will be <code>NaN</code> if there&rsquo;s no money flow for <code>n</code> consecutive observations (e.g. if there are no trades). This causes the money flow index to be <code>NaN</code>. Now the money flow index is to 50 in this case. Thanks to GitHub user <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/jgehw">jgehw</a> for the report, reproducible example, and suggested patch! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/TTR/issues/81">#81</a>)</p>
</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/ttr">[ttr]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/ttr/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/ttr/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672307/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672307/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2020/03/quantmod-0-4-16-on-cran/</feedburner:origLink><title>quantmod_0.4-16 on CRAN</title><link>https://feeds.feedblitz.com/~/748672310/0/fosstrading/</link><pubDate>Tue, 10 Mar 2020 07:23:00 -0500</pubDate><guid>https://blog.fosstrading.com/2020/03/quantmod-0-4-16-on-cran/</guid><description><![CDATA[<p>A new version of <a href="http://www.quantmod.com/">quantmod</a> is on <a href="https://cran.r-project.org/package=quantmod">CRAN</a>! One really cool thing about this release is that almost all the changes are contributions from the community.</p>
<p><a href="https://github.com/ethanbsmith">Ethan Smith</a> made more excellent contributions to <code>getQuote()</code> in this release. It no longer throws an error if one or more symbols are missing.  And it handles multiple symbols in a semicolon-delimted string, just like <code>getSymbols()</code>. For example, you can get quotes for multiple symbols by calling <code>getQuote(&quot;SPY;AAPL&quot;)</code>.</p>
<p><a href="https://github.com/jrburl">@jrburl</a> made a great enhancement to <code>getOptionChain()</code>. Now, instead of throwing an error, it sets volume and open interest to <code>NA</code> if those columns are missing from the Yahoo Finance data. They also submitted a pull request to handle cases where Bid and/or Ask data are missing too. Unfortunately, that pull request came after I had already pushed to CRAN.</p>
<p>Unfortunately, <a href="https://finance.yahoo.com/">Yahoo! Finance</a> continues to make changes to how they return data. Thankfully, quantmod users are diligent and catch these changes. <a href="https://github.com/helgasoft/">@helgasoft</a> noticed the split ratio delimiter changed from <code>/</code> to <code>:</code>. So, for example, a 2-for-1 split was <code>1/2</code> but is now <code>2:1</code>.</p>
<p><a href="https://github.com/helgasoft/">@helgasoft</a> also noticed that <a href="https://www.alphavantage.co/">Alpha Vantage</a> discontinued their &ldquo;batch quote&rdquo; functionality, which broke <code>getQuote()</code>. Thankfully, they provided a patch that used the single-quote request, so <code>getQuote()</code> works with Alpha Vantage again!</p>
<p><a href="https://github.com/matiasandina">@matiasandina</a> noticed that I had incorrectly labelled the dividend pay date as the ex-dividend date in the data <code>getQuote()</code> returned from Yahoo Finance. Whoops!</p>
<p>See the <a href="https://cran.r-project.org/web/packages/quantmod/news/news.html">news</a> file for the other bug fixes. Thanks for using quantmod!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>A new version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> is on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">CRAN</a>! One really cool thing about this release is that almost all the changes are contributions from the community.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ethanbsmith">Ethan Smith</a> made more excellent contributions to <code>getQuote()</code> in this release. It no longer throws an error if one or more symbols are missing.  And it handles multiple symbols in a semicolon-delimted string, just like <code>getSymbols()</code>. For example, you can get quotes for multiple symbols by calling <code>getQuote("SPY;AAPL")</code>.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/jrburl">@jrburl</a> made a great enhancement to <code>getOptionChain()</code>. Now, instead of throwing an error, it sets volume and open interest to <code>NA</code> if those columns are missing from the Yahoo Finance data. They also submitted a pull request to handle cases where Bid and/or Ask data are missing too. Unfortunately, that pull request came after I had already pushed to CRAN.</p>
<p>Unfortunately, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/">Yahoo! Finance</a> continues to make changes to how they return data. Thankfully, quantmod users are diligent and catch these changes. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/helgasoft/">@helgasoft</a> noticed the split ratio delimiter changed from <code>/</code> to <code>:</code>. So, for example, a 2-for-1 split was <code>1/2</code> but is now <code>2:1</code>.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/helgasoft/">@helgasoft</a> also noticed that <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/">Alpha Vantage</a> discontinued their &ldquo;batch quote&rdquo; functionality, which broke <code>getQuote()</code>. Thankfully, they provided a patch that used the single-quote request, so <code>getQuote()</code> works with Alpha Vantage again!</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/matiasandina">@matiasandina</a> noticed that I had incorrectly labelled the dividend pay date as the ex-dividend date in the data <code>getQuote()</code> returned from Yahoo Finance. Whoops!</p>
<p>See the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/web/packages/quantmod/news/news.html">news</a> file for the other bug fixes. Thanks for using quantmod!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672310/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672310/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2019/10/microbenchmark-1-4-7-on-cran/</feedburner:origLink><title>microbenchmark_1.4-7 on CRAN</title><link>https://feeds.feedblitz.com/~/748672313/0/fosstrading/</link><pubDate>Thu, 10 Oct 2019 06:21:00 -0500</pubDate><guid>https://blog.fosstrading.com/2019/10/microbenchmark-1-4-7-on-cran/</guid><description><![CDATA[<p>I pushed an updated <a href="https://cran.r-project.org/package=microbenchmark">microbenchmark to CRAN</a> a couple weeks ago. There were two noteworthy changes, thanks to great contributions from <a href="https://github.com/MichaelChirico">@MichaelChirico</a> and <a href="https://github.com/harvey131">@harvey131</a>.</p>
<p>Michael fixed a bug in the check for whether the unit argument was a character string (<a href="https://github.com/joshuaulrich/microbenchmark/issues/9">#9</a>, <a href="https://github.com/joshuaulrich/microbenchmark/pull/10">#10</a>). The prior behavior was an uninformative error.</p>
<p>Harvey added a feature to allow you to use a string for common checks: &ldquo;equal&rdquo;, &ldquo;identical&rdquo;, and &ldquo;equivalent&rdquo; (<a href="https://github.com/joshuaulrich/microbenchmark/pull/16">#16</a>). So you don&rsquo;t need to create a custom function to use <code>all.equal()</code>, <code>all.equal(..., check.attributes = FALSE)</code>, and identical, respectively.</p>
<p>I also converted the unit tests to use <a href="https://cran.r-project.org/package=RUnit">RUnit</a>. I also made some changes to the repo, including adding a contributing guide and issue/pull-request templates.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/microbenchmark">[microbenchmark]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/microbenchmark/issues">issue on GitHub</a> if you find a bug or want to request a feature.
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I pushed an updated <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=microbenchmark">microbenchmark to CRAN</a> a couple weeks ago. There were two noteworthy changes, thanks to great contributions from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/MichaelChirico">@MichaelChirico</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/harvey131">@harvey131</a>.</p>
<p>Michael fixed a bug in the check for whether the unit argument was a character string (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/microbenchmark/issues/9">#9</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/microbenchmark/pull/10">#10</a>). The prior behavior was an uninformative error.</p>
<p>Harvey added a feature to allow you to use a string for common checks: &ldquo;equal&rdquo;, &ldquo;identical&rdquo;, and &ldquo;equivalent&rdquo; (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/microbenchmark/pull/16">#16</a>). So you don&rsquo;t need to create a custom function to use <code>all.equal()</code>, <code>all.equal(..., check.attributes = FALSE)</code>, and identical, respectively.</p>
<p>I also converted the unit tests to use <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=RUnit">RUnit</a>. I also made some changes to the repo, including adding a contributing guide and issue/pull-request templates.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/microbenchmark">[microbenchmark]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/microbenchmark/issues">issue on GitHub</a> if you find a bug or want to request a feature.
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672313/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672313/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2019/03/quantmod-0-4-14-on-cran/</feedburner:origLink><title>quantmod_0.4-14 on CRAN</title><link>https://feeds.feedblitz.com/~/748672316/0/fosstrading/</link><pubDate>Mon, 25 Mar 2019 06:53:00 -0500</pubDate><guid>https://blog.fosstrading.com/2019/03/quantmod-0-4-14-on-cran/</guid><description><![CDATA[<p>I just pushed a new release of <a href="http://www.quantmod.com/">quantmod</a> to <a href="https://cran.r-project.org/package=quantmod">CRAN</a>! <code>getSymbols()</code> no longer stops if there&rsquo;s a problem with a ticker symbol. And <code>getQuote()</code> can now import quotes from <a href="https://www.tiingo.com/">Tiingo</a>.</p>
<p>I&rsquo;m most excited about the update to <code>getSymbols()</code> so it doesn&rsquo;t throw an error and stop processing if there&rsquo;s a problem with one ticker symbol. Now <code>getSymbols()</code> will import all the data it can, and provide an informative error message for any ticker symbols it could not import.</p>
<p>At a close second, I&rsquo;m also excited about being able to import quotes from <a href="https://www.tiingo.com/">Tiingo</a> using <code>getQuote()</code>!. But don&rsquo;t thank me; thank <a href="https://github.com/ethanbsmith">Ethan Smith</a> for the feature request [<a href="https://github.com/joshuaulrich/quantmod/issues/247">#247</a>] and pull request [<a href="https://github.com/joshuaulrich/quantmod/pull/250">#250</a>].</p>
<p>There are also several bug fixes in this release.  The most noticeable are fixes to <code>getDividends()</code>  and <code>getSplits()</code>. <a href="https://finance.yahoo.com/">Yahoo! Finance</a> continues to have stability issues. Now it returns raw dividends instead of split-adjusted dividends (thanks to Douglas Barnard for the report [<a href="https://github.com/joshuaulrich/quantmod/issues/253">#253</a>]), and the actual split adjustment ratio instead of the inverse (e.g. now 1/2 instead of 2/1).  I suggest using a different data provider. See my post: <a href="http://blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">Yahoo! Finance Alternatives</a> for some suggestions.</p>
<p>See the <a href="https://cran.r-project.org/web/packages/quantmod/news/news.html">news</a> file for the other bug fixes. Please let me know what you think about these changes.  I need your feedback and input to make quantmod even better!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I just pushed a new release of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">CRAN</a>! <code>getSymbols()</code> no longer stops if there&rsquo;s a problem with a ticker symbol. And <code>getQuote()</code> can now import quotes from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tiingo.com/">Tiingo</a>.</p>
<p>I&rsquo;m most excited about the update to <code>getSymbols()</code> so it doesn&rsquo;t throw an error and stop processing if there&rsquo;s a problem with one ticker symbol. Now <code>getSymbols()</code> will import all the data it can, and provide an informative error message for any ticker symbols it could not import.</p>
<p>At a close second, I&rsquo;m also excited about being able to import quotes from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tiingo.com/">Tiingo</a> using <code>getQuote()</code>!. But don&rsquo;t thank me; thank <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ethanbsmith">Ethan Smith</a> for the feature request [<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/247">#247</a>] and pull request [<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/pull/250">#250</a>].</p>
<p>There are also several bug fixes in this release.  The most noticeable are fixes to <code>getDividends()</code>  and <code>getSplits()</code>. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/">Yahoo! Finance</a> continues to have stability issues. Now it returns raw dividends instead of split-adjusted dividends (thanks to Douglas Barnard for the report [<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/253">#253</a>]), and the actual split adjustment ratio instead of the inverse (e.g. now 1/2 instead of 2/1).  I suggest using a different data provider. See my post: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">Yahoo! Finance Alternatives</a> for some suggestions.</p>
<p>See the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/web/packages/quantmod/news/news.html">news</a> file for the other bug fixes. Please let me know what you think about these changes.  I need your feedback and input to make quantmod even better!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672316/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672316/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/11/xts-0-11-2-on-cran/</feedburner:origLink><title>xts 0.11-2 on CRAN</title><link>https://feeds.feedblitz.com/~/748672319/0/fosstrading/</link><pubDate>Tue, 06 Nov 2018 06:35:00 -0600</pubDate><guid>https://blog.fosstrading.com/2018/11/xts-0-11-2-on-cran/</guid><description><![CDATA[<p><a href="https://cloud.r-project.org/package=xts">xts</a> version 0.11-2 was published to <a href="https://cloud.r-project.org/">CRAN</a> yesterday. This is quick a bug-fix release.</p>
<p>Notable changes are below:</p>
<ul>
<li>The xts method for <code>shift.time()</code> is now registered. Thanks to Philippe Verspeelt for the report and PR (<a href="https://github.com/joshuaulrich/xts/issues/268">#268</a>, <a href="https://github.com/joshuaulrich/xts/issues/273">#273</a>).</li>
<li>An if-statement in the <code>xts</code> constructor will no longer try to use a logical vector with length &gt; 1. Code like <code>if (c(TRUE, TRUE))</code> will throw a warning in an upcoming R release, and this patch will prevent that warning. Thanks to Hugh Parsonage for the report and PR (<a href="https://github.com/joshuaulrich/xts/issues/270">#270</a>, <a href="https://github.com/joshuaulrich/xts/issues/272">#272</a>).</li>
<li>Fix subset when <code>index(i)</code> and <code>i</code> contain duplicates. Observations were being incorrectly dropped, and behavior is now consistent with zoo. Thanks to Stack Overflow user <a href="https://stackoverflow.com/users/4024268/scs">scs</a> for the report, and Philippe Verspeelt for the help debugging (<a href="https://github.com/joshuaulrich/xts/issues/275">#275</a>).</li>
<li>Make column names for <code>merge()</code> results with unnamed objects shorter and more like zoo (<a href="https://github.com/joshuaulrich/xts/issues/248">#248</a>). Previously, column names could be hundreds, even thousands, of characters. This change has the added benefit of making <code>na.fill()</code> much faster (<a href="https://github.com/joshuaulrich/xts/issues/259">#259</a>). NOTE: This may BREAK existing code for integer unnamed objects.</li>
<li>The <code>to.period()</code> family of functions now use the index timezone when converting intraday index values to daily values (or lower frequency). Previously, the dates would be calculated as UTC dates, instead of dates in the local timezone (as they are now). Thanks to Garrett See and Gabor Grothendieck for the reports (<a href="https://github.com/joshuaulrich/xts/issues/53">#53</a>, <a href="https://github.com/joshuaulrich/xts/issues/277">#277</a>).</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/package=xts">xts</a> version 0.11-2 was published to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/">CRAN</a> yesterday. This is quick a bug-fix release.</p>
<p>Notable changes are below:</p>
<ul>
<li>The xts method for <code>shift.time()</code> is now registered. Thanks to Philippe Verspeelt for the report and PR (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/268">#268</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/273">#273</a>).</li>
<li>An if-statement in the <code>xts</code> constructor will no longer try to use a logical vector with length &gt; 1. Code like <code>if (c(TRUE, TRUE))</code> will throw a warning in an upcoming R release, and this patch will prevent that warning. Thanks to Hugh Parsonage for the report and PR (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/270">#270</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/272">#272</a>).</li>
<li>Fix subset when <code>index(i)</code> and <code>i</code> contain duplicates. Observations were being incorrectly dropped, and behavior is now consistent with zoo. Thanks to Stack Overflow user <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com/users/4024268/scs">scs</a> for the report, and Philippe Verspeelt for the help debugging (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/275">#275</a>).</li>
<li>Make column names for <code>merge()</code> results with unnamed objects shorter and more like zoo (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/248">#248</a>). Previously, column names could be hundreds, even thousands, of characters. This change has the added benefit of making <code>na.fill()</code> much faster (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/259">#259</a>). NOTE: This may BREAK existing code for integer unnamed objects.</li>
<li>The <code>to.period()</code> family of functions now use the index timezone when converting intraday index values to daily values (or lower frequency). Previously, the dates would be calculated as UTC dates, instead of dates in the local timezone (as they are now). Thanks to Garrett See and Gabor Grothendieck for the reports (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/53">#53</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/277">#277</a>).</li>
</ul>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672319/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672319/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/09/xts-0-11-1-on-cran/</feedburner:origLink><title>xts 0.11-1 on CRAN</title><link>https://feeds.feedblitz.com/~/748672322/0/fosstrading/</link><pubDate>Wed, 12 Sep 2018 13:36:00 -0500</pubDate><guid>https://blog.fosstrading.com/2018/09/xts-0-11-1-on-cran/</guid><description><![CDATA[<p><a href="https://cloud.r-project.org/package=xts">xts</a> version 0.11-1 was published to <a href="https://cloud.r-project.org/">CRAN</a> this morning. <a href="https://cloud.r-project.org/package=xts">xts</a> provides data structure and functions to work with time-indexed data.  This release contains some awesome features that will transparently make your <a href="https://cloud.r-project.org/package=xts">xts</a> code even faster!</p>
<ul>
<li>There&rsquo;s a new <code>window.xts()</code> method, thanks to Corwin Joy (<a href="https://github.com/joshuaulrich/xts/issues/100">#100</a>, <a href="https://github.com/joshuaulrich/xts/issues/240">#240</a>). Corwin also refactored and improved the performance of the binary search algorithm used to subset xts objects. Tom Andrews reported and fixed a few related regressions (<a href="https://github.com/joshuaulrich/xts/issues/251">#251</a>, <a href="https://github.com/joshuaulrich/xts/issues/263">#263</a>, <a href="https://github.com/joshuaulrich/xts/issues/264">#264</a>).</li>
<li>The <code>na.locf.xts()</code> method loops over columns of multivariate objects in C code, for improved speed and memory performance. Thanks to Chris Katsulis and Tom Andrews for their reports and patches (<a href="https://github.com/joshuaulrich/xts/issues/232">#232</a>, <a href="https://github.com/joshuaulrich/xts/issues/233">#233</a>, <a href="https://github.com/joshuaulrich/xts/issues/234">#234</a>, <a href="https://github.com/joshuaulrich/xts/issues/235">#235</a>, <a href="https://github.com/joshuaulrich/xts/issues/237">#237</a>).</li>
<li>After many years, <code>merge.xts()</code> can finally handle multiple character or complex xts objects. Thanks to Ken Williams for the report (<a href="https://github.com/joshuaulrich/xts/issues/44">#44</a>).</li>
<li>You can use &ldquo;quarters&rdquo; to specify tick/grid mark locations on plots. Thanks to Marc Weibel for the report (<a href="https://github.com/joshuaulrich/xts/issues/256">#256</a>).</li>
</ul>
<p>There are also a few notable bug fixes:</p>
<ul>
<li><code>make.index.unique()</code> always returns a unique and sorted index. Thanks to Chris Katsulis for the report and example (<a href="https://github.com/joshuaulrich/xts/issues/241">#241</a>).</li>
<li>Plots have better axis tick mark locations, thanks to Dirk Eddelbuettel (<a href="https://github.com/joshuaulrich/xts/issues/246">#246</a>).</li>
<li><code>periodicity()</code> now warns instead of errors if the xts object contains less than 2 observations (<a href="https://github.com/joshuaulrich/xts/issues/230">#230</a>).</li>
<li><code>first()</code> and <code>last()</code> now keep dims when they would otherwise be dropped by a regular row subset. This is consistent with <code>head()</code> and <code>tail()</code>. Thanks to Davis Vaughan for the report (<a href="https://github.com/joshuaulrich/xts/issues/226">#226</a>).</li>
<li>An invalid ISO8601 range subset now returns no data instead of all rows (<a href="https://github.com/joshuaulrich/xts/issues/96">#96</a>).</li>
</ul>
<p>As always, I&rsquo;m looking forward to your questions and feedback! If you have a question, please ask on <a href="https://stackoverflow.com/">Stack Overflow</a> and use the <a href="https://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="https://stackoverflow.com/questions/tagged/xts">[xts]</a> tags. Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance mailing list</a> (you must subscribe to post). Open an issue <a href="https://github.com/joshuaulrich/xts">on GitHub</a> if you find a bug or want to request a feature, but please read the <a href="https://github.com/joshuaulrich/xts/blob/master/.github/CONTRIBUTING.md">contributing guide</a> first!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/package=xts">xts</a> version 0.11-1 was published to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/">CRAN</a> this morning. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/package=xts">xts</a> provides data structure and functions to work with time-indexed data.  This release contains some awesome features that will transparently make your <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cloud.r-project.org/package=xts">xts</a> code even faster!</p>
<ul>
<li>There&rsquo;s a new <code>window.xts()</code> method, thanks to Corwin Joy (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/100">#100</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/240">#240</a>). Corwin also refactored and improved the performance of the binary search algorithm used to subset xts objects. Tom Andrews reported and fixed a few related regressions (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/251">#251</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/263">#263</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/264">#264</a>).</li>
<li>The <code>na.locf.xts()</code> method loops over columns of multivariate objects in C code, for improved speed and memory performance. Thanks to Chris Katsulis and Tom Andrews for their reports and patches (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/232">#232</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/233">#233</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/234">#234</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/235">#235</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/237">#237</a>).</li>
<li>After many years, <code>merge.xts()</code> can finally handle multiple character or complex xts objects. Thanks to Ken Williams for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/44">#44</a>).</li>
<li>You can use &ldquo;quarters&rdquo; to specify tick/grid mark locations on plots. Thanks to Marc Weibel for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/256">#256</a>).</li>
</ul>
<p>There are also a few notable bug fixes:</p>
<ul>
<li><code>make.index.unique()</code> always returns a unique and sorted index. Thanks to Chris Katsulis for the report and example (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/241">#241</a>).</li>
<li>Plots have better axis tick mark locations, thanks to Dirk Eddelbuettel (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/246">#246</a>).</li>
<li><code>periodicity()</code> now warns instead of errors if the xts object contains less than 2 observations (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/230">#230</a>).</li>
<li><code>first()</code> and <code>last()</code> now keep dims when they would otherwise be dropped by a regular row subset. This is consistent with <code>head()</code> and <code>tail()</code>. Thanks to Davis Vaughan for the report (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/226">#226</a>).</li>
<li>An invalid ISO8601 range subset now returns no data instead of all rows (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/96">#96</a>).</li>
</ul>
<p>As always, I&rsquo;m looking forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com/">Stack Overflow</a> and use the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stackoverflow.com/questions/tagged/xts">[xts]</a> tags. Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance mailing list</a> (you must subscribe to post). Open an issue <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts">on GitHub</a> if you find a bug or want to request a feature, but please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/blob/master/.github/CONTRIBUTING.md">contributing guide</a> first!</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672322/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672322/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/08/learning-to-code-is-worth-it/</feedburner:origLink><title>Learning to code is worth it</title><link>https://feeds.feedblitz.com/~/748672325/0/fosstrading/</link><pubDate>Fri, 24 Aug 2018 13:03:00 -0500</pubDate><guid>https://blog.fosstrading.com/2018/08/learning-to-code-is-worth-it/</guid><description><![CDATA[<p>Someone recently shared this great talk by <a href="http://bitemyapp.com/">Chris Allen</a> from <a href="http://lambdaconf.us/">lambda conf</a> 2017.  The title of the talk is &ldquo;Why Johnny Can&rsquo;t Code Good,&rdquo; but the content is more about how to grow as a programmer.  His points are true whether you&rsquo;re just starting out, or have been coding for years.</p>
<p>My notes from Chris&rsquo; talk are below, in the order they appear in the presentation.  My thoughts are in parentheses.</p>
<hr>
<p>He&rsquo;s not talking about people who can&rsquo;t code, but rather those who haven&rsquo;t learned to code.  They usually work in the industry, but only know just enough to get things done.  They aren&rsquo;t super-independent, and may have trouble taking on new things.  All of us have been here before (often multiple times in different disciplines; whenever we start something new).</p>
<p>The problem is when you get stuck working on pre-defined tasks in a well-defined space.  The computer science industry&rsquo;s priorities are now wrapped around accommodating people who are comfortable staying there.</p>
<p>For example, nodejs, Go, and other new languages optimize for &ldquo;zero-to-blog&rdquo;, not for something maintainable, or that allows people to build useful abstractions.  There&rsquo;s more focus on what is marketable in a short blog post.</p>
<p>(An interesting point on hiring:) you can&rsquo;t &ldquo;hire only the best&rdquo;, unless you&rsquo;re able to attract talent. You can&rsquo;t select for it, because other employers trying to &ldquo;hire only the best&rdquo; too.</p>
<p>Using new tools is not learning new skills.  Learning how to learn, without someone feeding you pre-digested material, is how you grow.</p>
<p>Don&rsquo;t say something is easy. It&rsquo;s always going to be harder for some, it depends on their context. Either something is worth learning, or it&rsquo;s not. There may be some return-on-investment cutoff point, but it&rsquo;s either worth trying or it&rsquo;s not.</p>
<p>We&rsquo;re an amnesiac culture. We don&rsquo;t remember 5 years ago (and we don&rsquo;t like learning history).</p>
<p>Don&rsquo;t train how you play. Train harder, be more focused and structured.  (This is a sports analogy. The idea is that you work harder in training than you will work during a game.  That makes the game seem easy.  I have a habit of doing harder things when I&rsquo;m doing something of lesser consequence.  People often asked me how I learned something, and the answer is often &ldquo;I broke something and learned until I understood what I broke and what was needed to fix it.&rdquo;  This is sub-optimal at work, when a faster solution that isn&rsquo;t fully understood is preferable to a slower solution that is.)</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>Someone recently shared this great talk by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~bitemyapp.com/">Chris Allen</a> from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~lambdaconf.us/">lambda conf</a> 2017.  The title of the talk is &ldquo;Why Johnny Can&rsquo;t Code Good,&rdquo; but the content is more about how to grow as a programmer.  His points are true whether you&rsquo;re just starting out, or have been coding for years.</p>
<p>My notes from Chris&rsquo; talk are below, in the order they appear in the presentation.  My thoughts are in parentheses.</p>
<hr>
<p>He&rsquo;s not talking about people who can&rsquo;t code, but rather those who haven&rsquo;t learned to code.  They usually work in the industry, but only know just enough to get things done.  They aren&rsquo;t super-independent, and may have trouble taking on new things.  All of us have been here before (often multiple times in different disciplines; whenever we start something new).</p>
<p>The problem is when you get stuck working on pre-defined tasks in a well-defined space.  The computer science industry&rsquo;s priorities are now wrapped around accommodating people who are comfortable staying there.</p>
<p>For example, nodejs, Go, and other new languages optimize for &ldquo;zero-to-blog&rdquo;, not for something maintainable, or that allows people to build useful abstractions.  There&rsquo;s more focus on what is marketable in a short blog post.</p>
<p>(An interesting point on hiring:) you can&rsquo;t &ldquo;hire only the best&rdquo;, unless you&rsquo;re able to attract talent. You can&rsquo;t select for it, because other employers trying to &ldquo;hire only the best&rdquo; too.</p>
<p>Using new tools is not learning new skills.  Learning how to learn, without someone feeding you pre-digested material, is how you grow.</p>
<p>Don&rsquo;t say something is easy. It&rsquo;s always going to be harder for some, it depends on their context. Either something is worth learning, or it&rsquo;s not. There may be some return-on-investment cutoff point, but it&rsquo;s either worth trying or it&rsquo;s not.</p>
<p>We&rsquo;re an amnesiac culture. We don&rsquo;t remember 5 years ago (and we don&rsquo;t like learning history).</p>
<p>Don&rsquo;t train how you play. Train harder, be more focused and structured.  (This is a sports analogy. The idea is that you work harder in training than you will work during a game.  That makes the game seem easy.  I have a habit of doing harder things when I&rsquo;m doing something of lesser consequence.  People often asked me how I learned something, and the answer is often &ldquo;I broke something and learned until I understood what I broke and what was needed to fix it.&rdquo;  This is sub-optimal at work, when a faster solution that isn&rsquo;t fully understood is preferable to a slower solution that is.)</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672325/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672325/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/04/rfinance-2018-registration/</feedburner:origLink><title>R/Finance 2018 Registration</title><link>https://feeds.feedblitz.com/~/748672328/0/fosstrading/</link><pubDate>Fri, 20 Apr 2018 13:26:00 -0500</pubDate><guid>https://blog.fosstrading.com/2018/04/rfinance-2018-registration/</guid><description><![CDATA[<p>This year marks the 10th anniversary of the R/Finance Conference!  As in prior years, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 50+ presenters covering all areas of finance with R.  The conference will take place on June 1st and 2nd, at <a href="http://www.uic.edu/">UIC</a> in Chicago.</p>
<p>You can find <a href="http://www.rinfinance.com/#registration">registration information</a>on the conference website, or you can go directly to the <a href="http://go.uic.edu/rfinance">Cvent registration page</a>.</p>
<p>Note that registration fees <em><strong>will increase by 50%</strong></em> at the end of early registration on May 21, 2018.</p>
<p>We are very excited about keynote presentations by <a href="https://github.com/jjallaire">JJ Allaire</a>, <a href="https://www.linkedin.com/in/lideng">Li Deng</a>, and <a href="https://faculty.engineering.ucdavis.edu/matloff/">Norm Matloff</a>.  The conference agenda (currently) includes 18 full presentations and 33 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.  We&rsquo;re still working on the agenda, but we have another great lineup of speakers this year!</p>
<p>There is also an (optional) conference dinner at Wyndham Grand Chicago Riverfront in the 39th Floor Penthouse Ballroom and Terrace.  Situated directly on the riverfront, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2018 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p>  <a href="http://business.uic.edu/liautaud-programs/masters-finance">UIC Liautaud Master of Science in Finance</a><br>
  <a href="http://msdsug.microsoft.com/">Microsoft</a><br>
  <a href="https://www.r-consortium.org/">R Consortium</a><br>
  <a href="https://www.rstudio.com/">RStudio</a><br>
  <a href="https://www.williamblair.com/">William Blair</a><br>
  <a href="https://www.citadel.com/">Citadel</a><br>
  <a href="https://www.quasardb.net/">Quasardb</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>  Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This year marks the 10th anniversary of the R/Finance Conference!  As in prior years, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 50+ presenters covering all areas of finance with R.  The conference will take place on June 1st and 2nd, at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">UIC</a> in Chicago.</p>
<p>You can find <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/#registration">registration information</a>on the conference website, or you can go directly to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~go.uic.edu/rfinance">Cvent registration page</a>.</p>
<p>Note that registration fees <em><strong>will increase by 50%</strong></em> at the end of early registration on May 21, 2018.</p>
<p>We are very excited about keynote presentations by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/jjallaire">JJ Allaire</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.linkedin.com/in/lideng">Li Deng</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://faculty.engineering.ucdavis.edu/matloff/">Norm Matloff</a>.  The conference agenda (currently) includes 18 full presentations and 33 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.  We&rsquo;re still working on the agenda, but we have another great lineup of speakers this year!</p>
<p>There is also an (optional) conference dinner at Wyndham Grand Chicago Riverfront in the 39th Floor Penthouse Ballroom and Terrace.  Situated directly on the riverfront, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2018 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p>  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/liautaud-programs/masters-finance">UIC Liautaud Master of Science in Finance</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~msdsug.microsoft.com/">Microsoft</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.r-consortium.org/">R Consortium</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.rstudio.com/">RStudio</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.williamblair.com/">William Blair</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.citadel.com/">Citadel</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.quasardb.net/">Quasardb</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>  Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672328/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672328/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/04/goodbye-google-hello-tiingo/</feedburner:origLink><title>Goodbye Google, Hello Tiingo!</title><link>https://feeds.feedblitz.com/~/748672331/0/fosstrading/</link><pubDate>Fri, 13 Apr 2018 11:14:00 -0500</pubDate><guid>https://blog.fosstrading.com/2018/04/goodbye-google-hello-tiingo/</guid><description><![CDATA[<p>First, the bad news:</p>
<p>Google Finance no longer provides data for historical prices or financial statements, so we say goodbye to <code>getSymbols.google()</code> and <code>getFinancials.google()</code>. (<a href="https://github.com/joshuaulrich/quantmod/issues/221">#221</a>)  They are now defunct as of quantmod 0.4-13.</p>
<p>Now, the good news:</p>
<p>Thanks to <a href="https://github.com/SteveBronder">Steve Bronder</a>, <code>getSymbols()</code> can now import data from <a href="https://www.tiingo.com/">Tiingo</a>! (<a href="https://github.com/joshuaulrich/quantmod/issues/220">#220</a>)  This feature is part of quantmod 0.4-13, which is <a href="https://cran.r-project.org/package=quantmod">now on CRAN</a>.  Windows and Mac binaries should be built in a day or two.</p>
<p><a href="https://www.tiingo.com/">Tiingo</a> is a web service that provides tools and data for financial analysis.  They provide daily price history for US stocks and ADRs, Chinese stocks, Mutual Funds, and ETFs.  There is up to 30+ years of history, including raw prices and split/dividend adjusted prices.</p>
<p>All this data is accessible for free, with reasonable symbol and bandwidth limits.  All you need to get started is a one-time registration for an API token.  You should see your API token just above the beginning of the <a href="https://api.tiingo.com/docs/tiingo/daily#metaData">metadata section</a>, after logging in, of course.  Tiingo has a well-documented <a href="https://api.tiingo.com/docs/tiingo/daily">daily price data API</a> that returns either JSON or CSV.</p>
<p>To get started, install the latest <a href="https://cran.r-project.org/package=quantmod">quantmod from CRAN</a>.  Then you call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#34;MSFT&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;tiingo&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span> 
</span></span></code></pre></div><p>Where you replace <code>&quot;\[your key\]&quot;</code> with the API key you receive after registration.  You can use <code>setDefaults()</code> to set your API key one time, and use it for all <code>getSymbols.tiingo()</code> calls.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setDefaults</span><span class="p">(</span><span class="s">&#34;getSymbols.tiingo&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Other notable changes:</p>
<ul>
<li>There is now a <code>getQuote.alphavantage()</code> that allows you to pull real-time quotes from Alpha Vantage.  Thanks to <a href="https://github.com/ethanbsmith">Ethan Smith</a>! (<a href="https://github.com/joshuaulrich/quantmod/issues/213">#213</a>, <a href="https://github.com/joshuaulrich/quantmod/issues/223">#223</a>)</li>
<li>Speaking of <a href="https://www.alphavantage.co/">Alpha Vantage</a>, getSymbols.av() can now pull weekly and monthly adjusted prices. (<a href="https://github.com/joshuaulrich/quantmod/issues/212">#212</a>)</li>
<li>The URL in <code>getSymbols.oanda()</code> and <code>getFX()</code> has been updated, so they work again. (<a href="https://github.com/joshuaulrich/quantmod/issues/225">#225</a>)</li>
<li><code>getQuote.yahoo()</code> no longer errors when a field has no data for all requested tickers. (<a href="https://github.com/joshuaulrich/quantmod/issues/208">#208</a>)</li>
<li><code>saveChart()</code> actually saves charts now (<a href="https://github.com/joshuaulrich/quantmod/issues/154">#154</a>). Brilliant!</li>
</ul><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>First, the bad news:</p>
<p>Google Finance no longer provides data for historical prices or financial statements, so we say goodbye to <code>getSymbols.google()</code> and <code>getFinancials.google()</code>. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/221">#221</a>)  They are now defunct as of quantmod 0.4-13.</p>
<p>Now, the good news:</p>
<p>Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/SteveBronder">Steve Bronder</a>, <code>getSymbols()</code> can now import data from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tiingo.com/">Tiingo</a>! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/220">#220</a>)  This feature is part of quantmod 0.4-13, which is <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">now on CRAN</a>.  Windows and Mac binaries should be built in a day or two.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.tiingo.com/">Tiingo</a> is a web service that provides tools and data for financial analysis.  They provide daily price history for US stocks and ADRs, Chinese stocks, Mutual Funds, and ETFs.  There is up to 30+ years of history, including raw prices and split/dividend adjusted prices.</p>
<p>All this data is accessible for free, with reasonable symbol and bandwidth limits.  All you need to get started is a one-time registration for an API token.  You should see your API token just above the beginning of the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://api.tiingo.com/docs/tiingo/daily#metaData">metadata section</a>, after logging in, of course.  Tiingo has a well-documented <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://api.tiingo.com/docs/tiingo/daily">daily price data API</a> that returns either JSON or CSV.</p>
<p>To get started, install the latest <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">quantmod from CRAN</a>.  Then you call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#34;MSFT&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;tiingo&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span> 
</span></span></code></pre></div><p>Where you replace <code>"\[your key\]"</code> with the API key you receive after registration.  You can use <code>setDefaults()</code> to set your API key one time, and use it for all <code>getSymbols.tiingo()</code> calls.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setDefaults</span><span class="p">(</span><span class="s">&#34;getSymbols.tiingo&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Other notable changes:</p>
<ul>
<li>There is now a <code>getQuote.alphavantage()</code> that allows you to pull real-time quotes from Alpha Vantage.  Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ethanbsmith">Ethan Smith</a>! (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/213">#213</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/223">#223</a>)</li>
<li>Speaking of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/">Alpha Vantage</a>, getSymbols.av() can now pull weekly and monthly adjusted prices. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/212">#212</a>)</li>
<li>The URL in <code>getSymbols.oanda()</code> and <code>getFX()</code> has been updated, so they work again. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/225">#225</a>)</li>
<li><code>getQuote.yahoo()</code> no longer errors when a field has no data for all requested tickers. (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/208">#208</a>)</li>
<li><code>saveChart()</code> actually saves charts now (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/154">#154</a>). Brilliant!</li>
</ul><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672331/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672331/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/03/xts-0-10-2-on-cran/</feedburner:origLink><title>xts 0.10-2 on CRAN</title><link>https://feeds.feedblitz.com/~/748672334/0/fosstrading/</link><pubDate>Mon, 19 Mar 2018 05:30:00 -0500</pubDate><guid>https://blog.fosstrading.com/2018/03/xts-0-10-2-on-cran/</guid><description><![CDATA[<p>This <a href="http://joshuaulrich.github.io/xts/">xts</a> release contains mostly bugfixes, but there are a few noteworthy features. Some of these features were added in version 0.10-1, but I forgot to blog about it. Anyway, in no particular order:</p>
<ul>
<li><code>endpoints()</code> gained sub-second accuracy on Windows (<a href="https://github.com/joshuaulrich/xts/issues/202">#202</a>)!</li>
<li><code>na.locf.xts()</code> now honors <code>x</code> and <code>xout</code> arguments by dispatching to the next method (<a href="https://github.com/joshuaulrich/xts/issues/215">#215</a>). Thanks to Morten Grum for the report.</li>
<li><code>na.locf.xts()</code> and <code>na.omit.xts()</code> now support character xts objects. Thanks to Ken Williams and Samo Pahor for the reports (<a href="https://github.com/joshuaulrich/xts/issues/42">#42</a>).</li>
</ul>
<p>Many of the bug fixes were related to the new plot.xts() introduced in 0.10-0. And a handful of bug fixes were to make xts more consistent with zoo in some edge cases.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~joshuaulrich.github.io/xts/">xts</a> release contains mostly bugfixes, but there are a few noteworthy features. Some of these features were added in version 0.10-1, but I forgot to blog about it. Anyway, in no particular order:</p>
<ul>
<li><code>endpoints()</code> gained sub-second accuracy on Windows (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/202">#202</a>)!</li>
<li><code>na.locf.xts()</code> now honors <code>x</code> and <code>xout</code> arguments by dispatching to the next method (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/215">#215</a>). Thanks to Morten Grum for the report.</li>
<li><code>na.locf.xts()</code> and <code>na.omit.xts()</code> now support character xts objects. Thanks to Ken Williams and Samo Pahor for the reports (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues/42">#42</a>).</li>
</ul>
<p>Many of the bug fixes were related to the new plot.xts() introduced in 0.10-0. And a handful of bug fixes were to make xts more consistent with zoo in some edge cases.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672334/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672334/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/01/rfinance-2018-call-for-papers/</feedburner:origLink><title>R/Finance 2018: Call for Papers</title><link>https://feeds.feedblitz.com/~/748672337/0/fosstrading/</link><pubDate>Tue, 09 Jan 2018 11:32:00 -0600</pubDate><guid>https://blog.fosstrading.com/2018/01/rfinance-2018-call-for-papers/</guid><description><![CDATA[<p>R/Finance 2018: Applied Finance with R</p>
<p>June 1 and 2, 2018</p>
<p>University of Illinois at Chicago</p>
<p><strong>Call For Papers</strong></p>
<p>The tenth annual R/Finance conference for applied finance using <a href="https://www.r-project.org/">R</a> will be held June 1 and 2, 2018 in Chicago, IL, USA at the <a href="https://www.uic.edu/">University of Illinois at Chicago</a>. The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past nine years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2018.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred. We welcome submissions for both full talks and abbreviated lightning talks. Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time. Presenters are strongly encouraged to provide working R code to accompany the slides. Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>Please submit proposals online at <a href="http://go.uic.edu/rfinsubmit">http://go.uic.edu/rfinsubmit</a><a href="https://www.blogger.com/"></a>. Submissions will be reviewed and accepted on a rolling basis with a final submission deadline of February 2, 2018. Submitters will be notified via email by March 2, 2018 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Financial assistance for travel and accommodation may be available to presenters. Requests for financial assistance do not affect acceptance decisions. Requests should be made at the time of submission. Requests made after submission are much less likely to be fulfilled. Assistance will be granted at the discretion of the conference committee.</p>
<p>Additional details will be announced via the <a href="http://www.rinfinance.com/">conference website</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website. We will make a separate announcement when registration opens.</p>
<p>For the program committee:</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>R/Finance 2018: Applied Finance with R</p>
<p>June 1 and 2, 2018</p>
<p>University of Illinois at Chicago</p>
<p><strong>Call For Papers</strong></p>
<p>The tenth annual R/Finance conference for applied finance using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.r-project.org/">R</a> will be held June 1 and 2, 2018 in Chicago, IL, USA at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.uic.edu/">University of Illinois at Chicago</a>. The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past nine years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2018.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred. We welcome submissions for both full talks and abbreviated lightning talks. Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time. Presenters are strongly encouraged to provide working R code to accompany the slides. Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>Please submit proposals online at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~go.uic.edu/rfinsubmit">http://go.uic.edu/rfinsubmit</a><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.blogger.com/"></a>. Submissions will be reviewed and accepted on a rolling basis with a final submission deadline of February 2, 2018. Submitters will be notified via email by March 2, 2018 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Financial assistance for travel and accommodation may be available to presenters. Requests for financial assistance do not affect acceptance decisions. Requests should be made at the time of submission. Requests made after submission are much less likely to be fulfilled. Assistance will be granted at the discretion of the conference committee.</p>
<p>Additional details will be announced via the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">conference website</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website. We will make a separate announcement when registration opens.</p>
<p>For the program committee:</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672337/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672337/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2018/01/rquantlib-044-for-windows/</feedburner:origLink><title>RQuantLib 0.4.4 for Windows</title><link>https://feeds.feedblitz.com/~/748672340/0/fosstrading/</link><pubDate>Fri, 05 Jan 2018 14:02:00 -0600</pubDate><guid>https://blog.fosstrading.com/2018/01/rquantlib-044-for-windows/</guid><description><![CDATA[<p>I&rsquo;m pleased to announce that the <a href="https://cran.r-project.org/package=RQuantLib">RQuantLib</a> Windows binaries are now up to 0.4.4!  The RQuantLib pre-built Windows binaries have been frozen on CRAN since 0.4.2, but now you can get version 0.4.4 binaries on <a href="http://dirk.eddelbuettel.com/">Dirk&rsquo;s</a> <a href="https://ghrr.github.io/drat/">ghrr drat repo</a>.</p>
<p>Installation is as simple as:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">drat</span><span class="o">::</span><span class="nf">addRepo</span><span class="p">(</span><span class="s">&#34;ghrr&#34;</span><span class="p">)</span> <span class="c1"># maybe use &#39;install.packages(&#34;drat&#34;)&#39; first </span>
</span></span><span class="line"><span class="cl"><span class="nf">install.packages</span><span class="p">(</span><span class="s">&#34;RQuantLib&#34;</span><span class="p">,</span> <span class="n">type</span><span class="o">=</span><span class="s">&#34;binary&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>I will be able to create Windows binaries for future RQuantLib versions too, now that I have a Windows <a href="http://quantlib.org/index.shtml">QuantLib</a> build (version 1.11) to link against.</p>
<p>Dirk and I plan to talk with CRAN about getting the new binaries hosted there.  Regardless, they will always be available via the drat repo.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I&rsquo;m pleased to announce that the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=RQuantLib">RQuantLib</a> Windows binaries are now up to 0.4.4!  The RQuantLib pre-built Windows binaries have been frozen on CRAN since 0.4.2, but now you can get version 0.4.4 binaries on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~dirk.eddelbuettel.com/">Dirk&rsquo;s</a> <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://ghrr.github.io/drat/">ghrr drat repo</a>.</p>
<p>Installation is as simple as:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">drat</span><span class="o">::</span><span class="nf">addRepo</span><span class="p">(</span><span class="s">&#34;ghrr&#34;</span><span class="p">)</span> <span class="c1"># maybe use &#39;install.packages(&#34;drat&#34;)&#39; first </span>
</span></span><span class="line"><span class="cl"><span class="nf">install.packages</span><span class="p">(</span><span class="s">&#34;RQuantLib&#34;</span><span class="p">,</span> <span class="n">type</span><span class="o">=</span><span class="s">&#34;binary&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>I will be able to create Windows binaries for future RQuantLib versions too, now that I have a Windows <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~quantlib.org/index.shtml">QuantLib</a> build (version 1.11) to link against.</p>
<p>Dirk and I plan to talk with CRAN about getting the new binaries hosted there.  Regardless, they will always be available via the drat repo.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672340/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672340/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/10/getsymbols-and-alpha-vantage/</feedburner:origLink><title>getSymbols and Alpha Vantage</title><link>https://feeds.feedblitz.com/~/748672343/0/fosstrading/</link><pubDate>Fri, 06 Oct 2017 16:12:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/10/getsymbols-and-alpha-vantage/</guid><description><![CDATA[<p>Thanks to <a href="http://quantdevel.com/public/">Paul Teetor</a>, <code>getSymbols()</code> can now import data from <a href="https://www.alphavantage.co/">Alpha Vantage</a>!  This feature is part of the <a href="http://www.quantmod.com/">quantmod</a> 0.4-11 release, and provides another <a href="http://blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">another data source</a> to avoid any <a href="http://blog.fosstrading.com/2017/06/quantmod-0-4-9-on-cran.html">Yahoo Finance API changes</a>*.</p>
<p>Alpha Vantage is a free web service that provides real-time and historical equity data.  They provide daily, weekly, and monthly history for both domestic and international markets, with up to 20 years of history. Dividend and split adjusted close prices are available for daily data. They also provide near real-time price bars at a resolution of 1 minute or more, for up to 10 recent days.</p>
<p>All you need to get started is a <a href="https://www.alphavantage.co/support/#api-key">one-time registration for an API key</a>.  Alpha Vantage has <a href="https://www.alphavantage.co/documentation/">clean, documented, public API</a> that returns either JSON-encoded data or a CSV file.  The arguments to <code>getSymbols.av()</code> closely follow the native API, so be sure to use their documentation!</p>
<p>To get started, install the latest <a href="https://cran.r-project.org/package=quantmod">quantmod from CRAN</a>.  Then you call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#34;MSFT&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;av&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span> 
</span></span></code></pre></div><p>Where you replace <code>&quot;\[your key&quot;\]</code> with the API key you receive after registration.  You can use <code>setDefaults()</code> to set your API key one time, and use it for all <code>getSymbols.av()</code> calls.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setDefaults</span><span class="p">(</span><span class="s">&#34;getSymbols.av&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>* Speaking of API changes, this release also includes a fix for a Yahoo Finance change (<a href="https://github.com/joshuaulrich/quantmod/issues/174">#174</a>).</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>Thanks to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~quantdevel.com/public/">Paul Teetor</a>, <code>getSymbols()</code> can now import data from <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/">Alpha Vantage</a>!  This feature is part of the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> 0.4-11 release, and provides another <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">another data source</a> to avoid any <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2017/06/quantmod-0-4-9-on-cran.html">Yahoo Finance API changes</a>*.</p>
<p>Alpha Vantage is a free web service that provides real-time and historical equity data.  They provide daily, weekly, and monthly history for both domestic and international markets, with up to 20 years of history. Dividend and split adjusted close prices are available for daily data. They also provide near real-time price bars at a resolution of 1 minute or more, for up to 10 recent days.</p>
<p>All you need to get started is a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/support/#api-key">one-time registration for an API key</a>.  Alpha Vantage has <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/documentation/">clean, documented, public API</a> that returns either JSON-encoded data or a CSV file.  The arguments to <code>getSymbols.av()</code> closely follow the native API, so be sure to use their documentation!</p>
<p>To get started, install the latest <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">quantmod from CRAN</a>.  Then you call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#34;MSFT&#34;</span><span class="p">,</span> <span class="n">src</span> <span class="o">=</span> <span class="s">&#34;av&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span> 
</span></span></code></pre></div><p>Where you replace <code>"\[your key"\]</code> with the API key you receive after registration.  You can use <code>setDefaults()</code> to set your API key one time, and use it for all <code>getSymbols.av()</code> calls.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">setDefaults</span><span class="p">(</span><span class="s">&#34;getSymbols.av&#34;</span><span class="p">,</span> <span class="n">api.key</span> <span class="o">=</span> <span class="s">&#34;\[your key\]&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>* Speaking of API changes, this release also includes a fix for a Yahoo Finance change (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/174">#174</a>).</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672343/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672343/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/07/xts-0-10-0-on-cran/</feedburner:origLink><title>xts 0.10-0 on CRAN!</title><link>https://feeds.feedblitz.com/~/748672346/0/fosstrading/</link><pubDate>Fri, 07 Jul 2017 14:10:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/07/xts-0-10-0-on-cran/</guid><description><![CDATA[<p>A new, and long overdue, release of <a href="http://joshuaulrich.github.io/xts/">xts</a> is now on <a href="https://cran.r-project.org/package=xts">CRAN</a>!  The major change is the completely new <a href="http://joshuaulrich.github.io/xts/plotting_basics.html">plot.xts()</a> written by Michael Weylandt and Ross Bennett, and which is based on Jeff Ryan&rsquo;s <code>quantmod::chart_Series()</code> code.</p>
<p>Do note that the new <code>plot.xts()</code> includes breaking changes to the original (and rather limited) <code>plot.xts()</code>.  However, we believe the new functionality more than compensates for the potential one-time inconvenience.  And I will no longer have to tell people that I use <code>plot.zoo()</code> on xts objects!</p>
<p>This release also includes more bug fixes than you can shake a stick at.  We squashed several bugs that could have crashed your R session.  We also fixed some (always pesky and tricky) timezone issues.  We&rsquo;ve also done more sanity checking (e.g. for NA in the index), and provide more informative errors when things aren&rsquo;t right.  And last, but not least, unit tests are running again!</p>
<p>I&rsquo;m sure you were hoping to see some examples of the new <code>plot.xts()</code> functionality.  Rather than clutter up this blog post with code, check out the <a href="http://joshuaulrich.github.io/xts/plotting_basics.html">basic examples</a>, and the <a href="http://joshuaulrich.github.io/xts/plotting_panels.html">panel functionality examples</a> that Ross Bennett created.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>A new, and long overdue, release of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~joshuaulrich.github.io/xts/">xts</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=xts">CRAN</a>!  The major change is the completely new <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~joshuaulrich.github.io/xts/plotting_basics.html">plot.xts()</a> written by Michael Weylandt and Ross Bennett, and which is based on Jeff Ryan&rsquo;s <code>quantmod::chart_Series()</code> code.</p>
<p>Do note that the new <code>plot.xts()</code> includes breaking changes to the original (and rather limited) <code>plot.xts()</code>.  However, we believe the new functionality more than compensates for the potential one-time inconvenience.  And I will no longer have to tell people that I use <code>plot.zoo()</code> on xts objects!</p>
<p>This release also includes more bug fixes than you can shake a stick at.  We squashed several bugs that could have crashed your R session.  We also fixed some (always pesky and tricky) timezone issues.  We&rsquo;ve also done more sanity checking (e.g. for NA in the index), and provide more informative errors when things aren&rsquo;t right.  And last, but not least, unit tests are running again!</p>
<p>I&rsquo;m sure you were hoping to see some examples of the new <code>plot.xts()</code> functionality.  Rather than clutter up this blog post with code, check out the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~joshuaulrich.github.io/xts/plotting_basics.html">basic examples</a>, and the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~joshuaulrich.github.io/xts/plotting_panels.html">panel functionality examples</a> that Ross Bennett created.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/xts">[xts]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672346/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672346/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/06/importing-and-managing-financial-data2/</feedburner:origLink><title>Importing and managing financial data</title><link>https://feeds.feedblitz.com/~/748672349/0/fosstrading/</link><pubDate>Wed, 21 Jun 2017 07:07:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/06/importing-and-managing-financial-data2/</guid><description><![CDATA[<p>I&rsquo;m excited to announce my <a href="https://www.datacamp.com">DataCamp</a> course on <a href="https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r">importing and managing financial data in R</a>! I&rsquo;m also honored that it is included in DataCamp&rsquo;s <a href="https://www.datacamp.com/tracks/quantitative-analyst-with-r">Quantitative Analyst with R Career Track</a>!</p>
<p>You can explore the first chapter for free, so be sure to check it out!</p>
<h3 id="course-description">Course Description</h3>
<p>Financial and economic time series data come in various shapes, sizes, and periodicities. Getting the data into R can be stressful and time-consuming, especially when you need to merge data from several different sources into one data set. This course covers importing data from local files as well as from internet sources.</p>
<h3 id="course-outline">Course Outline</h3>
<h5 id="chapter-1-introduction-and-downloading-data">Chapter 1: Introduction and downloading data</h5>
<p>A wealth of financial and economic data are available online. Learn how <code>getSymbols()</code> and <code>Quandl()</code> make it easy to access data from a variety of sources.</p>
<h5 id="chapter-2-extracting-and-transforming-data">Chapter 2: Extracting and transforming data</h5>
<p>You&rsquo;ve learned how to import data from online sources, now it&rsquo;s time to see how to extract columns from the imported data. After you&rsquo;ve learned how to extract columns from a single object, you will explore how to import, transform, and extract data from multiple instruments.</p>
<h5 id="chapter-3-managing-data-from-multiple-sources">Chapter 3: Managing data from multiple sources</h5>
<p>Learn how to simplify and streamline your workflow by taking advantage of the ability to customize default arguments to <code>getSymbols()</code>. You will see how to customize defaults by data source, and then how to customize defaults by symbol. You will also learn how to handle problematic instrument symbols</p>
<h6 id="chapter-4-aligning-data-with-different-periodicities">Chapter 4: Aligning data with different periodicities</h6>
<p>You&rsquo;ve learned how to import, extract, and transform data from multiple data sources. You often have to manipulate data from different sources in order to combine them into a single data set. First, you will learn how to convert sparse, irregular data into a regular series. Then you will review how to aggregate dense data to a lower frequency. Finally, you will learn how to handle issues with intra-day data.</p>
<h5 id="chapter-5-importing-text-data-and-adjusting-for-corporate-actions">Chapter 5: Importing text data, and adjusting for corporate actions</h5>
<p>You&rsquo;ve learned the core workflow of importing and manipulating financial data. Now you will see how to import data from text files of various formats. Then you will learn how to check data for weirdness and handle missing values. Finally, you will learn how to adjust stock prices for splits and dividends.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I&rsquo;m excited to announce my <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.datacamp.com">DataCamp</a> course on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.datacamp.com/courses/importing-and-managing-financial-data-in-r">importing and managing financial data in R</a>! I&rsquo;m also honored that it is included in DataCamp&rsquo;s <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.datacamp.com/tracks/quantitative-analyst-with-r">Quantitative Analyst with R Career Track</a>!</p>
<p>You can explore the first chapter for free, so be sure to check it out!</p>
<h3 id="course-description">Course Description</h3>
<p>Financial and economic time series data come in various shapes, sizes, and periodicities. Getting the data into R can be stressful and time-consuming, especially when you need to merge data from several different sources into one data set. This course covers importing data from local files as well as from internet sources.</p>
<h3 id="course-outline">Course Outline</h3>
<h5 id="chapter-1-introduction-and-downloading-data">Chapter 1: Introduction and downloading data</h5>
<p>A wealth of financial and economic data are available online. Learn how <code>getSymbols()</code> and <code>Quandl()</code> make it easy to access data from a variety of sources.</p>
<h5 id="chapter-2-extracting-and-transforming-data">Chapter 2: Extracting and transforming data</h5>
<p>You&rsquo;ve learned how to import data from online sources, now it&rsquo;s time to see how to extract columns from the imported data. After you&rsquo;ve learned how to extract columns from a single object, you will explore how to import, transform, and extract data from multiple instruments.</p>
<h5 id="chapter-3-managing-data-from-multiple-sources">Chapter 3: Managing data from multiple sources</h5>
<p>Learn how to simplify and streamline your workflow by taking advantage of the ability to customize default arguments to <code>getSymbols()</code>. You will see how to customize defaults by data source, and then how to customize defaults by symbol. You will also learn how to handle problematic instrument symbols</p>
<h6 id="chapter-4-aligning-data-with-different-periodicities">Chapter 4: Aligning data with different periodicities</h6>
<p>You&rsquo;ve learned how to import, extract, and transform data from multiple data sources. You often have to manipulate data from different sources in order to combine them into a single data set. First, you will learn how to convert sparse, irregular data into a regular series. Then you will review how to aggregate dense data to a lower frequency. Finally, you will learn how to handle issues with intra-day data.</p>
<h5 id="chapter-5-importing-text-data-and-adjusting-for-corporate-actions">Chapter 5: Importing text data, and adjusting for corporate actions</h5>
<p>You&rsquo;ve learned the core workflow of importing and manipulating financial data. Now you will see how to import data from text files of various formats. Then you will learn how to check data for weirdness and handle missing values. Finally, you will learn how to adjust stock prices for splits and dividends.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672349/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672349/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/06/quantmod-0-4-9-on-cran/</feedburner:origLink><title>quantmod 0.4-9 on CRAN</title><link>https://feeds.feedblitz.com/~/748672352/0/fosstrading/</link><pubDate>Wed, 07 Jun 2017 12:25:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/06/quantmod-0-4-9-on-cran/</guid><description><![CDATA[<p>A new release of <a href="http://www.quantmod.com/">quantmod</a> is now on <a href="https://cran.r-project.org/package=quantmod">CRAN</a>! The only change was to address changes to <a href="https://finance.yahoo.com/">Yahoo! Finance</a> and their effects on <code>getSymbols.yahoo()</code>.  GitHub issue <a href="https://github.com/joshuaulrich/quantmod/issues/157">#157</a> contains some details about the fix implementation.</p>
<p>Unfortunately, the URL wasn&rsquo;t the only thing that changed.  The actual data available for download changed as well.</p>
<p>The most noticeable difference is that the adjusted close column is no longer dividend-adjusted (i.e. it&rsquo;s only split-adjusted).  Also, only the close price is unadjusted; the open, high, and low are split-adjusted.</p>
<p>There also appear to be issues with the adjusted prices in some instruments.  For example, users reported issues with split data for XLF and SPXL in GitHub issue <a href="https://github.com/joshuaulrich/quantmod/issues/160">#160</a>.  For XLF, there a split <em>and</em> a dividend on 2016-09-16, even on the <a href="https://finance.yahoo.com/quote/XLF/history?period1=1473138000&amp;period2=1474866000&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical price page for XLF</a>. As far as I can tell, there was only a special dividend.  The problem with SPXL is that the adjusted close price isn&rsquo;t adjusted for the 4/1 split on 2017-05-01, which is also reflected on the <a href="https://finance.yahoo.com/quote/SPXL/history?period1=1488088800&amp;period2=1495774800&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical prices page for SPXL</a>.</p>
<p>Another change is that the downloaded data may contain rows where all the values are &ldquo;null&rdquo;.  These appear on the website as &ldquo;0&rdquo;.  This is a major issue for some instruments.  Take XLU for example; 188 of the 624 days of data are missing between 2014-12-04 and 2017-05-26 (ouch!).  You can see this is even true on the <a href="https://finance.yahoo.com/quote/XLU/history?period1=1417672800&amp;period2=1422079200&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical price page for XLU</a>.</p>
<p>If these changes have made you look for a new data provider, see my post: <a href="http://blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">Yahoo! Finance Alternatives</a>.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>A new release of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> is now on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">CRAN</a>! The only change was to address changes to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/">Yahoo! Finance</a> and their effects on <code>getSymbols.yahoo()</code>.  GitHub issue <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/157">#157</a> contains some details about the fix implementation.</p>
<p>Unfortunately, the URL wasn&rsquo;t the only thing that changed.  The actual data available for download changed as well.</p>
<p>The most noticeable difference is that the adjusted close column is no longer dividend-adjusted (i.e. it&rsquo;s only split-adjusted).  Also, only the close price is unadjusted; the open, high, and low are split-adjusted.</p>
<p>There also appear to be issues with the adjusted prices in some instruments.  For example, users reported issues with split data for XLF and SPXL in GitHub issue <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/160">#160</a>.  For XLF, there a split <em>and</em> a dividend on 2016-09-16, even on the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/quote/XLF/history?period1=1473138000&amp;period2=1474866000&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical price page for XLF</a>. As far as I can tell, there was only a special dividend.  The problem with SPXL is that the adjusted close price isn&rsquo;t adjusted for the 4/1 split on 2017-05-01, which is also reflected on the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/quote/SPXL/history?period1=1488088800&amp;period2=1495774800&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical prices page for SPXL</a>.</p>
<p>Another change is that the downloaded data may contain rows where all the values are &ldquo;null&rdquo;.  These appear on the website as &ldquo;0&rdquo;.  This is a major issue for some instruments.  Take XLU for example; 188 of the 624 days of data are missing between 2014-12-04 and 2017-05-26 (ouch!).  You can see this is even true on the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/quote/XLU/history?period1=1417672800&amp;period2=1422079200&amp;interval=1d&amp;filter=history&amp;frequency=1d">Yahoo! Finance historical price page for XLU</a>.</p>
<p>If these changes have made you look for a new data provider, see my post: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2017/06/yahoo-finance-alternatives.html">Yahoo! Finance Alternatives</a>.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672352/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672352/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/06/yahoo-finance-alternatives/</feedburner:origLink><title>Yahoo Finance Alternatives</title><link>https://feeds.feedblitz.com/~/748672355/0/fosstrading/</link><pubDate>Wed, 07 Jun 2017 12:20:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/06/yahoo-finance-alternatives/</guid><description><![CDATA[<p>I assume that you&rsquo;re reading this because you are one of many people who were affected by the changes to Yahoo Finance data in May (2017).  Not only did the URL change, but the actual data changed as well!</p>
<p>The most noticeable difference is that the adjusted close column is now only split-adjusted, whereas it used to be split- and dividend-adjusted.  Another oddity is that only the close prices is unadjusted (strangely, the open, high, and low are split-adjusted).</p>
<p>All these issues can be dealt with using tools that are currently available.  For example, you can unadjust the open, high, and low prices using the ratio of close to adjusted close prices.  And you can adjust for both splits and dividends using <code>quantmod::adjustOHLC()</code>.</p>
<p>Unfortunately, there also appear to be issues with data quality.  Some instruments have rows where all the prices and volume are zeros (e.g. <a href="https://finance.yahoo.com/quote/XLU/history?period1=1417672800&amp;period2=1422079200&amp;interval=1d&amp;filter=history&amp;frequency=1d">XLU</a>).  The adjusted close in some instruments is incorrect because of missing split events, or double-counting splits and special dividends.</p>
<p>So, what are your alternatives?  If you&rsquo;re just tinkering, you can try other free data sources like <a href="https://www.google.com/finance">Google Finance</a> or <a href="https://www.quandl.com/">Quandl</a>.  Note that Google Finance data is already split-adjusted, so you might need to adjust for dividends, or un-adjust for splits, depending on your needs.  Quandl has a <a href="https://www.quandl.com/data/WIKI-Wiki-EOD-Stock-Prices">wiki of end-of-day stock prices</a> curated by the community.  You only need a free account to access the data.</p>
<p>If you&rsquo;re using the data to make actual investment decisions, you should really be using a professional data provider.  At the very least, you get someone to yell at when the data have errors. :)  First, you should check if your broker provides the historical data you need (e.g. <a href="https://www.interactivebrokers.com/">Interactive Brokers</a> provides historical and real-time data to account-holders).</p>
<p>If your broker doesn&rsquo;t provide historical data, here are a few providers you may want to consider:</p>
<p><a href="https://api.tiingo.com/">Tiingo</a></p>
<ul>
<li>Free historical end-of-day data (registration and API key required)</li>
<li>Up to 50+ years of daily data (split and dividend adjusted) for over 65,000 equities, mutual funds, and ETFs</li>
<li>Free historical and real-time crypto data (4+ year of daily prices, 2+ years of intraday data)</li>
<li>Free historical and real-time intraday data from IEX, beginning in August 2017</li>
<li><a href="http://blog.fosstrading.com/2018/04/goodbye-google-hello-tiingo.html">Available via <code>getSymbols()</code></a></li>
</ul>
<p><a href="https://www.alphavantage.co/">Alpha Vantage</a></p>
<ul>
<li>Free historical and intraday equity data (registration and API key required)</li>
<li>Up to 20 years of daily data (split and dividend adjusted available)</li>
<li>Up to 10 days of intraday data (1min, 5min, 15min, 30min, 60min)</li>
<li><a href="http://blog.fosstrading.com/2017/10/getsymbols-and-alpha-vantage.html">Available via <code>getSymbols()</code></a></li>
</ul>
<p><a href="http://www.eoddata.com/download.aspx">eoddata</a></p>
<ul>
<li>Provide limited historical data for free</li>
<li>For a one-time fee:
<ul>
<li>$20-$50 for 10 years of daily data</li>
<li>$40-$100 for 20 years of daily data</li>
</ul>
</li>
</ul>
<p><a href="https://www.csicheckout.com/cgi-bin/ua_order_form_nw.pl?referrer=JU">CSI Data</a> <strong>*</strong></p>
<ul>
<li>Massive historical equity database</li>
<li>$600 annually for 30 years of daily data</li>
<li>Ability to adjust for splits and dividends</li>
</ul>
<p><a href="http://www.iqfeed.net/">IQFeed</a></p>
<ul>
<li>Mainly a real-time data provider, but also has historical data</li>
<li><a href="http://www.iqfeed.net/index.cfm?displayaction=data&amp;section=services">Features</a></li>
<li><a href="http://www.iqfeed.net/index.cfm?displayaction=data&amp;section=fees">Pricing</a>, starts at $78/month</li>
</ul>
<p>Leave a comment if you know of another end-of-day data provider that I didn&rsquo;t list!</p>
<p><strong>* FULL DISCLOSURE</strong>: I receive a referral fee for annual subscriptions to CSI products if you use the FOSS coupon code.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I assume that you&rsquo;re reading this because you are one of many people who were affected by the changes to Yahoo Finance data in May (2017).  Not only did the URL change, but the actual data changed as well!</p>
<p>The most noticeable difference is that the adjusted close column is now only split-adjusted, whereas it used to be split- and dividend-adjusted.  Another oddity is that only the close prices is unadjusted (strangely, the open, high, and low are split-adjusted).</p>
<p>All these issues can be dealt with using tools that are currently available.  For example, you can unadjust the open, high, and low prices using the ratio of close to adjusted close prices.  And you can adjust for both splits and dividends using <code>quantmod::adjustOHLC()</code>.</p>
<p>Unfortunately, there also appear to be issues with data quality.  Some instruments have rows where all the prices and volume are zeros (e.g. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://finance.yahoo.com/quote/XLU/history?period1=1417672800&amp;period2=1422079200&amp;interval=1d&amp;filter=history&amp;frequency=1d">XLU</a>).  The adjusted close in some instruments is incorrect because of missing split events, or double-counting splits and special dividends.</p>
<p>So, what are your alternatives?  If you&rsquo;re just tinkering, you can try other free data sources like <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.google.com/finance">Google Finance</a> or <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.quandl.com/">Quandl</a>.  Note that Google Finance data is already split-adjusted, so you might need to adjust for dividends, or un-adjust for splits, depending on your needs.  Quandl has a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.quandl.com/data/WIKI-Wiki-EOD-Stock-Prices">wiki of end-of-day stock prices</a> curated by the community.  You only need a free account to access the data.</p>
<p>If you&rsquo;re using the data to make actual investment decisions, you should really be using a professional data provider.  At the very least, you get someone to yell at when the data have errors. :)  First, you should check if your broker provides the historical data you need (e.g. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.interactivebrokers.com/">Interactive Brokers</a> provides historical and real-time data to account-holders).</p>
<p>If your broker doesn&rsquo;t provide historical data, here are a few providers you may want to consider:</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://api.tiingo.com/">Tiingo</a></p>
<ul>
<li>Free historical end-of-day data (registration and API key required)</li>
<li>Up to 50+ years of daily data (split and dividend adjusted) for over 65,000 equities, mutual funds, and ETFs</li>
<li>Free historical and real-time crypto data (4+ year of daily prices, 2+ years of intraday data)</li>
<li>Free historical and real-time intraday data from IEX, beginning in August 2017</li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2018/04/goodbye-google-hello-tiingo.html">Available via <code>getSymbols()</code></a></li>
</ul>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.alphavantage.co/">Alpha Vantage</a></p>
<ul>
<li>Free historical and intraday equity data (registration and API key required)</li>
<li>Up to 20 years of daily data (split and dividend adjusted available)</li>
<li>Up to 10 days of intraday data (1min, 5min, 15min, 30min, 60min)</li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~blog.fosstrading.com/2017/10/getsymbols-and-alpha-vantage.html">Available via <code>getSymbols()</code></a></li>
</ul>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.eoddata.com/download.aspx">eoddata</a></p>
<ul>
<li>Provide limited historical data for free</li>
<li>For a one-time fee:
<ul>
<li>$20-$50 for 10 years of daily data</li>
<li>$40-$100 for 20 years of daily data</li>
</ul>
</li>
</ul>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.csicheckout.com/cgi-bin/ua_order_form_nw.pl?referrer=JU">CSI Data</a> <strong>*</strong></p>
<ul>
<li>Massive historical equity database</li>
<li>$600 annually for 30 years of daily data</li>
<li>Ability to adjust for splits and dividends</li>
</ul>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.iqfeed.net/">IQFeed</a></p>
<ul>
<li>Mainly a real-time data provider, but also has historical data</li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.iqfeed.net/index.cfm?displayaction=data&amp;section=services">Features</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.iqfeed.net/index.cfm?displayaction=data&amp;section=fees">Pricing</a>, starts at $78/month</li>
</ul>
<p>Leave a comment if you know of another end-of-day data provider that I didn&rsquo;t list!</p>
<p><strong>* FULL DISCLOSURE</strong>: I receive a referral fee for annual subscriptions to CSI products if you use the FOSS coupon code.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672355/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672355/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/04/quantmod-0-4-8-on-cran/</feedburner:origLink><title>quantmod 0.4-8 on CRAN</title><link>https://feeds.feedblitz.com/~/748672358/0/fosstrading/</link><pubDate>Wed, 19 Apr 2017 10:45:00 -0500</pubDate><guid>https://blog.fosstrading.com/2017/04/quantmod-0-4-8-on-cran/</guid><description><![CDATA[<p>I pushed a bug-fix release of <a href="http://www.quantmod.com/">quantmod</a> to <a href="https://cran.r-project.org/">CRAN</a> last night. The major changes were to</p>
<ul>
<li><code>getSymbols.FRED()</code> (<a href="https://github.com/joshuaulrich/quantmod/issues/141">#141</a>)</li>
<li><code>getSymbols.oanda()</code> (<a href="https://github.com/joshuaulrich/quantmod/issues/144">#144</a>)</li>
<li><code>getSymbols.yahoo()</code> (<a href="https://github.com/joshuaulrich/quantmod/issues/149">#149</a>)</li>
</ul>
<p>All three providers made breaking changes to their URLs/interfaces.</p>
<p><code>getSymbols.google()</code> also got some love. It now honors all arguments set via <code>setSymbolLookup()</code> (<a href="https://github.com/joshuaulrich/quantmod/issues/138">#138</a>), and it correctly parses the date column in non-English locales (<a href="https://github.com/joshuaulrich/quantmod/issues/140">#140</a>).</p>
<p>There&rsquo;s a handy new argument to <code>getDividends()</code>: <code>split.adjust</code>. It allows you to request dividends unadjusted for splits (<a href="https://github.com/joshuaulrich/quantmod/issues/140">#128</a>). Yahoo provides split-adjusted dividends, so you previously had to manually unadjust them for splits if you wanted the original raw values. To import the raw unadjusted dividends, just call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rawDiv</span> <span class="o">&lt;-</span> <span class="nf">getDividends</span><span class="p">(</span><span class="s">&#34;IBM&#34;</span><span class="p">,</span> <span class="n">split.adjust</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that the default is <code>split.adjust = TRUE</code> to maintain backward-compatibility.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I pushed a bug-fix release of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/">CRAN</a> last night. The major changes were to</p>
<ul>
<li><code>getSymbols.FRED()</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/141">#141</a>)</li>
<li><code>getSymbols.oanda()</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/144">#144</a>)</li>
<li><code>getSymbols.yahoo()</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/149">#149</a>)</li>
</ul>
<p>All three providers made breaking changes to their URLs/interfaces.</p>
<p><code>getSymbols.google()</code> also got some love. It now honors all arguments set via <code>setSymbolLookup()</code> (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/138">#138</a>), and it correctly parses the date column in non-English locales (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/140">#140</a>).</p>
<p>There&rsquo;s a handy new argument to <code>getDividends()</code>: <code>split.adjust</code>. It allows you to request dividends unadjusted for splits (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/140">#128</a>). Yahoo provides split-adjusted dividends, so you previously had to manually unadjust them for splits if you wanted the original raw values. To import the raw unadjusted dividends, just call:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">rawDiv</span> <span class="o">&lt;-</span> <span class="nf">getDividends</span><span class="p">(</span><span class="s">&#34;IBM&#34;</span><span class="p">,</span> <span class="n">split.adjust</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that the default is <code>split.adjust = TRUE</code> to maintain backward-compatibility.</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672358/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672358/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/02/stack-financials/</feedburner:origLink><title>Stack Financials: Analyze Financial Statement Data</title><link>https://feeds.feedblitz.com/~/748672361/0/fosstrading/</link><pubDate>Tue, 14 Feb 2017 10:49:00 -0600</pubDate><guid>https://blog.fosstrading.com/2017/02/stack-financials/</guid><description><![CDATA[<p>A <a href="http://www.quantmod.com/">quantmod</a> user asked an interesting question on <a href="http://stackoverflow.com/">StackOverflow</a>: <a href="http://stackoverflow.com/q/42047746/271616">Looping viewFinancials from quantmod</a>. Basically, they wanted to create a <code>data.frame</code> that contained financial statement data for several companies for several years. I answered their question, and thought others might find the function I wrote useful&hellip; hence, this post!</p>
<p>I called the function <code>stackFinancials()</code> because it would use <code>getFinancials()</code> and <code>viewFinancials()</code> to pull financial statement data for multiple symbols, and stack them together in long form. I chose a long data format because I don’t know whether the output of <code>viewFinancials()</code> always has the same number of rows and columns for a given <code>type</code> and <code>period</code>. The long format makes it easy to put all the data in one object.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">stackFinancials</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;BS&#34;</span><span class="p">,</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="s">&#34;CF&#34;</span><span class="p">),</span> <span class="n">period</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;A&#34;</span><span class="p">,</span> <span class="s">&#34;Q&#34;</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Ensure the type and period arguments match viewFinancials </span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span> <span class="o">&lt;-</span> <span class="nf">match.arg</span><span class="p">(</span><span class="nf">toupper</span><span class="p">(</span><span class="n">type[1]</span><span class="p">),</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;BS&#34;</span><span class="p">,</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="s">&#34;CF&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="n">period</span> <span class="o">&lt;-</span> <span class="nf">match.arg</span><span class="p">(</span><span class="nf">toupper</span><span class="p">(</span><span class="n">period[1]</span><span class="p">),</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;A&#34;</span><span class="p">,</span> <span class="s">&#34;Q&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># Simple function to get financials for one symbol </span>
</span></span><span class="line"><span class="cl"> <span class="n">getOne</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">gf</span> <span class="o">&lt;-</span> <span class="nf">getFinancials</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">auto.assign</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">vf</span> <span class="o">&lt;-</span> <span class="nf">viewFinancials</span><span class="p">(</span><span class="n">gf</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Put viewFinancials output into a data.frame </span>
</span></span><span class="line"><span class="cl"> <span class="n">df</span> <span class="o">&lt;-</span> <span class="nf">data.frame</span><span class="p">(</span><span class="n">vf</span><span class="p">,</span> <span class="n">line.item</span> <span class="o">=</span> <span class="nf">rownames</span><span class="p">(</span><span class="n">vf</span><span class="p">),</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">,</span> <span class="n">symbol</span> <span class="o">=</span> <span class="n">symbol</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">stringsAsFactors</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span> <span class="n">check.names</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Reshape data.frame into long format </span>
</span></span><span class="line"><span class="cl"> <span class="n">long</span> <span class="o">&lt;-</span> <span class="nf">reshape</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="s">&#34;long&#34;</span><span class="p">,</span> <span class="n">varying</span><span class="o">=</span><span class="nf">seq</span><span class="p">(</span><span class="nf">ncol</span><span class="p">(</span><span class="n">vf</span><span class="p">)),</span>
</span></span><span class="line"><span class="cl"> <span class="n">v.names</span><span class="o">=</span><span class="s">&#34;value&#34;</span><span class="p">,</span> <span class="n">idvar</span><span class="o">=</span><span class="s">&#34;line.item&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">times</span><span class="o">=</span><span class="nf">colnames</span><span class="p">(</span><span class="n">vf</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Reset row.names to &#34;automatic&#34; </span>
</span></span><span class="line"><span class="cl"> <span class="nf">rownames</span><span class="p">(</span><span class="n">long</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="kc">NULL</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Return data </span>
</span></span><span class="line"><span class="cl"> <span class="n">long</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Loop over all symbols </span>
</span></span><span class="line"><span class="cl"> <span class="n">allData</span> <span class="o">&lt;-</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">getOne</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># rbind() all into one data.frame </span>
</span></span><span class="line"><span class="cl"> <span class="nf">do.call</span><span class="p">(</span><span class="n">rbind</span><span class="p">,</span> <span class="n">allData</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Here’s a simple example of how to use <code>stackFinancials()</code> to pull the quarterly (<code>period = &quot;Q&quot;</code>) income statements (<code>type = &quot;IS&quot;</code>) for General Electric and Apple:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">Data</span> <span class="o">&lt;-</span> <span class="nf">stackFinancials</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;GE&#34;</span><span class="p">,</span> <span class="s">&#34;AAPL&#34;</span><span class="p">),</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="s">&#34;Q&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="m">4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## line.item type period symbol time value </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 1 Revenue IS Q GE 2016-12-31 33088 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2 Other Revenue, Total IS Q GE 2016-12-31 NA </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 3 Total Revenue IS Q GE 2016-12-31 33088 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 4 Cost of Revenue, Total IS Q GE 2016-12-31 24775</span>
</span></span></code></pre></div><p>Now that we have the output in <code>Data</code>, let’s do something with it. You could simply subset <code>Data</code> to extract the components you want. For example, if you wanted to look at Apple’s quarterly revenue, you could subset <code>Data</code> where <code>symbol == &quot;AAPL&quot;</code> and <code>line.item == &quot;Total Revenue&quot;</code>. But if you’re going to slicing-and-dicing a lot, it can often help to write a general function to simplify things. So I wrote <code>extractLineItem()</code>. It takes the output of <code>stackFinancials()</code> and a regular expression of the line item you want, and it returns an xts object that contains the given line items for all symbols in the data.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">extractLineItem</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">stackedFinancials</span><span class="p">,</span> <span class="n">line.item</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="nf">missing</span><span class="p">(</span><span class="n">stackedFinancials</span><span class="p">)</span> <span class="o">||</span> <span class="nf">missing</span><span class="p">(</span><span class="n">line.item</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">stop</span><span class="p">(</span><span class="s">&#34;You must provide output from stackFinancials(),&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;and the line.item to extract&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Select line items matching user input </span>
</span></span><span class="line"><span class="cl"> <span class="n">match.rows</span> <span class="o">&lt;-</span> <span class="nf">grepl</span><span class="p">(</span><span class="n">line.item</span><span class="p">,</span> <span class="n">Data</span><span class="o">$</span><span class="n">line.item</span><span class="p">,</span> <span class="n">ignore.case</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">sfSubset</span> <span class="o">&lt;-</span> <span class="n">Data[match.rows</span><span class="p">,</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"> <span class="n">getItem</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Create xts object </span>
</span></span><span class="line"><span class="cl"> <span class="n">output</span> <span class="o">&lt;-</span> <span class="nf">xts</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">value</span><span class="p">,</span> <span class="nf">as.yearmon</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">time</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Ensure column names are syntactically valid </span>
</span></span><span class="line"><span class="cl"> <span class="n">valid.names</span> <span class="o">&lt;-</span> <span class="nf">make.names</span><span class="p">(</span><span class="nf">paste</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">symbol[1]</span><span class="p">,</span> <span class="n">x</span><span class="o">$</span><span class="n">line.item[1]</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Remove repeating periods </span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">gsub</span><span class="p">(</span><span class="s">&#34;\\.+&#34;</span><span class="p">,</span> <span class="s">&#34;\\.&#34;</span><span class="p">,</span> <span class="n">valid.names</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">output</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Split subset by line.item and symbol </span>
</span></span><span class="line"><span class="cl"> <span class="n">symbol.item</span> <span class="o">&lt;-</span> <span class="nf">split</span><span class="p">(</span><span class="n">sfSubset</span><span class="p">,</span> <span class="n">sfSubset[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;symbol&#34;</span><span class="p">,</span> <span class="s">&#34;line.item&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Apply getItem() to each chunk, and merge into one object </span>
</span></span><span class="line"><span class="cl"> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbol.item</span><span class="p">,</span> <span class="n">getItem</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Let’s use <code>extractLineItem()</code> to compare total revenue for GE and AAPL.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">totalRevenue</span> <span class="o">&lt;-</span> <span class="nf">extractLineItem</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="s">&#34;total revenue&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">totalRevenue</span>
</span></span><span class="line"><span class="cl"><span class="c1">## AAPL.Total.Revenue GE.Total.Revenue </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2015 75872 24654 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Mar 2016 50557 27845 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Jun 2016 42358 61339 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Sep 2016 46852 90605 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2016 78351 33088</span>
</span></span><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">totalRevenue</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Quarterly Total Revenue, AAPL (black) vs GE (red)&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/stack-financials-1.png" alt="" >
</p>
<p>You could also combine multiple calls to <code>extractLineItem()</code> to calculate ratios not included in the output from <code>viewFinancials()</code>. For example, you could divide operating income by total revenue to calculate operating margin.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">operatingIncome</span> <span class="o">&lt;-</span> <span class="nf">extractLineItem</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="s">&#34;operating income&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">operatingIncome</span>
</span></span><span class="line"><span class="cl"><span class="c1">## AAPL.Operating.Income GE.Operating.Income </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2015 24171 2863 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Mar 2016 13987 545 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Jun 2016 10105 4736 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Sep 2016 11761 6138 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2016 23359 2892</span>
</span></span><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">operatingIncome</span> <span class="o">/</span> <span class="n">totalRevenue</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Quarterly Operating Margin, AAPL (black) vs GE (red)&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/stack-financials-2.png" alt="" >
</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>A <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> user asked an interesting question on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">StackOverflow</a>: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/q/42047746/271616">Looping viewFinancials from quantmod</a>. Basically, they wanted to create a <code>data.frame</code> that contained financial statement data for several companies for several years. I answered their question, and thought others might find the function I wrote useful&hellip; hence, this post!</p>
<p>I called the function <code>stackFinancials()</code> because it would use <code>getFinancials()</code> and <code>viewFinancials()</code> to pull financial statement data for multiple symbols, and stack them together in long form. I chose a long data format because I don’t know whether the output of <code>viewFinancials()</code> always has the same number of rows and columns for a given <code>type</code> and <code>period</code>. The long format makes it easy to put all the data in one object.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">stackFinancials</span> <span class="o">&lt;-</span>
</span></span><span class="line"><span class="cl"><span class="kr">function</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;BS&#34;</span><span class="p">,</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="s">&#34;CF&#34;</span><span class="p">),</span> <span class="n">period</span> <span class="o">=</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;A&#34;</span><span class="p">,</span> <span class="s">&#34;Q&#34;</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Ensure the type and period arguments match viewFinancials </span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span> <span class="o">&lt;-</span> <span class="nf">match.arg</span><span class="p">(</span><span class="nf">toupper</span><span class="p">(</span><span class="n">type[1]</span><span class="p">),</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;BS&#34;</span><span class="p">,</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="s">&#34;CF&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="n">period</span> <span class="o">&lt;-</span> <span class="nf">match.arg</span><span class="p">(</span><span class="nf">toupper</span><span class="p">(</span><span class="n">period[1]</span><span class="p">),</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;A&#34;</span><span class="p">,</span> <span class="s">&#34;Q&#34;</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># Simple function to get financials for one symbol </span>
</span></span><span class="line"><span class="cl"> <span class="n">getOne</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">gf</span> <span class="o">&lt;-</span> <span class="nf">getFinancials</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">auto.assign</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">vf</span> <span class="o">&lt;-</span> <span class="nf">viewFinancials</span><span class="p">(</span><span class="n">gf</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Put viewFinancials output into a data.frame </span>
</span></span><span class="line"><span class="cl"> <span class="n">df</span> <span class="o">&lt;-</span> <span class="nf">data.frame</span><span class="p">(</span><span class="n">vf</span><span class="p">,</span> <span class="n">line.item</span> <span class="o">=</span> <span class="nf">rownames</span><span class="p">(</span><span class="n">vf</span><span class="p">),</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">,</span> <span class="n">symbol</span> <span class="o">=</span> <span class="n">symbol</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">stringsAsFactors</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">,</span> <span class="n">check.names</span> <span class="o">=</span> <span class="kc">FALSE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Reshape data.frame into long format </span>
</span></span><span class="line"><span class="cl"> <span class="n">long</span> <span class="o">&lt;-</span> <span class="nf">reshape</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="s">&#34;long&#34;</span><span class="p">,</span> <span class="n">varying</span><span class="o">=</span><span class="nf">seq</span><span class="p">(</span><span class="nf">ncol</span><span class="p">(</span><span class="n">vf</span><span class="p">)),</span>
</span></span><span class="line"><span class="cl"> <span class="n">v.names</span><span class="o">=</span><span class="s">&#34;value&#34;</span><span class="p">,</span> <span class="n">idvar</span><span class="o">=</span><span class="s">&#34;line.item&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">times</span><span class="o">=</span><span class="nf">colnames</span><span class="p">(</span><span class="n">vf</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Reset row.names to &#34;automatic&#34; </span>
</span></span><span class="line"><span class="cl"> <span class="nf">rownames</span><span class="p">(</span><span class="n">long</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="kc">NULL</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Return data </span>
</span></span><span class="line"><span class="cl"> <span class="n">long</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Loop over all symbols </span>
</span></span><span class="line"><span class="cl"> <span class="n">allData</span> <span class="o">&lt;-</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbols</span><span class="p">,</span> <span class="n">getOne</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="n">period</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># rbind() all into one data.frame </span>
</span></span><span class="line"><span class="cl"> <span class="nf">do.call</span><span class="p">(</span><span class="n">rbind</span><span class="p">,</span> <span class="n">allData</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Here’s a simple example of how to use <code>stackFinancials()</code> to pull the quarterly (<code>period = "Q"</code>) income statements (<code>type = "IS"</code>) for General Electric and Apple:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">Data</span> <span class="o">&lt;-</span> <span class="nf">stackFinancials</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="s">&#34;GE&#34;</span><span class="p">,</span> <span class="s">&#34;AAPL&#34;</span><span class="p">),</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;IS&#34;</span><span class="p">,</span> <span class="n">period</span> <span class="o">=</span> <span class="s">&#34;Q&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">head</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="m">4</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## line.item type period symbol time value </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 1 Revenue IS Q GE 2016-12-31 33088 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 2 Other Revenue, Total IS Q GE 2016-12-31 NA </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 3 Total Revenue IS Q GE 2016-12-31 33088 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 4 Cost of Revenue, Total IS Q GE 2016-12-31 24775</span>
</span></span></code></pre></div><p>Now that we have the output in <code>Data</code>, let’s do something with it. You could simply subset <code>Data</code> to extract the components you want. For example, if you wanted to look at Apple’s quarterly revenue, you could subset <code>Data</code> where <code>symbol == "AAPL"</code> and <code>line.item == "Total Revenue"</code>. But if you’re going to slicing-and-dicing a lot, it can often help to write a general function to simplify things. So I wrote <code>extractLineItem()</code>. It takes the output of <code>stackFinancials()</code> and a regular expression of the line item you want, and it returns an xts object that contains the given line items for all symbols in the data.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">extractLineItem</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">stackedFinancials</span><span class="p">,</span> <span class="n">line.item</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kr">if</span> <span class="p">(</span><span class="nf">missing</span><span class="p">(</span><span class="n">stackedFinancials</span><span class="p">)</span> <span class="o">||</span> <span class="nf">missing</span><span class="p">(</span><span class="n">line.item</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nf">stop</span><span class="p">(</span><span class="s">&#34;You must provide output from stackFinancials(),&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">&#34;and the line.item to extract&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Select line items matching user input </span>
</span></span><span class="line"><span class="cl"> <span class="n">match.rows</span> <span class="o">&lt;-</span> <span class="nf">grepl</span><span class="p">(</span><span class="n">line.item</span><span class="p">,</span> <span class="n">Data</span><span class="o">$</span><span class="n">line.item</span><span class="p">,</span> <span class="n">ignore.case</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">sfSubset</span> <span class="o">&lt;-</span> <span class="n">Data[match.rows</span><span class="p">,</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"> <span class="n">getItem</span> <span class="o">&lt;-</span> <span class="kr">function</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Create xts object </span>
</span></span><span class="line"><span class="cl"> <span class="n">output</span> <span class="o">&lt;-</span> <span class="nf">xts</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">value</span><span class="p">,</span> <span class="nf">as.yearmon</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">time</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Ensure column names are syntactically valid </span>
</span></span><span class="line"><span class="cl"> <span class="n">valid.names</span> <span class="o">&lt;-</span> <span class="nf">make.names</span><span class="p">(</span><span class="nf">paste</span><span class="p">(</span><span class="n">x</span><span class="o">$</span><span class="n">symbol[1]</span><span class="p">,</span> <span class="n">x</span><span class="o">$</span><span class="n">line.item[1]</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Remove repeating periods </span>
</span></span><span class="line"><span class="cl"> <span class="nf">colnames</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> <span class="o">&lt;-</span> <span class="nf">gsub</span><span class="p">(</span><span class="s">&#34;\\.+&#34;</span><span class="p">,</span> <span class="s">&#34;\\.&#34;</span><span class="p">,</span> <span class="n">valid.names</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="n">output</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Split subset by line.item and symbol </span>
</span></span><span class="line"><span class="cl"> <span class="n">symbol.item</span> <span class="o">&lt;-</span> <span class="nf">split</span><span class="p">(</span><span class="n">sfSubset</span><span class="p">,</span> <span class="n">sfSubset[</span><span class="p">,</span> <span class="nf">c</span><span class="p">(</span><span class="s">&#34;symbol&#34;</span><span class="p">,</span> <span class="s">&#34;line.item&#34;</span><span class="p">)</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># Apply getItem() to each chunk, and merge into one object </span>
</span></span><span class="line"><span class="cl"> <span class="nf">do.call</span><span class="p">(</span><span class="n">merge</span><span class="p">,</span> <span class="nf">lapply</span><span class="p">(</span><span class="n">symbol.item</span><span class="p">,</span> <span class="n">getItem</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Let’s use <code>extractLineItem()</code> to compare total revenue for GE and AAPL.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">totalRevenue</span> <span class="o">&lt;-</span> <span class="nf">extractLineItem</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="s">&#34;total revenue&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">totalRevenue</span>
</span></span><span class="line"><span class="cl"><span class="c1">## AAPL.Total.Revenue GE.Total.Revenue </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2015 75872 24654 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Mar 2016 50557 27845 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Jun 2016 42358 61339 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Sep 2016 46852 90605 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2016 78351 33088</span>
</span></span><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">totalRevenue</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Quarterly Total Revenue, AAPL (black) vs GE (red)&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/stack-financials-1.png" alt="" >
</p>
<p>You could also combine multiple calls to <code>extractLineItem()</code> to calculate ratios not included in the output from <code>viewFinancials()</code>. For example, you could divide operating income by total revenue to calculate operating margin.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">operatingIncome</span> <span class="o">&lt;-</span> <span class="nf">extractLineItem</span><span class="p">(</span><span class="n">Data</span><span class="p">,</span> <span class="s">&#34;operating income&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">operatingIncome</span>
</span></span><span class="line"><span class="cl"><span class="c1">## AAPL.Operating.Income GE.Operating.Income </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2015 24171 2863 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Mar 2016 13987 545 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Jun 2016 10105 4736 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Sep 2016 11761 6138 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Dec 2016 23359 2892</span>
</span></span><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">operatingIncome</span> <span class="o">/</span> <span class="n">totalRevenue</span><span class="p">,</span> <span class="n">main</span> <span class="o">=</span> <span class="s">&#34;Quarterly Operating Margin, AAPL (black) vs GE (red)&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/stack-financials-2.png" alt="" >
</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672361/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672361/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2017/01/rfinance-2017-call-for-papers/</feedburner:origLink><title>R/Finance 2017: Call for Papers</title><link>https://feeds.feedblitz.com/~/748672364/0/fosstrading/</link><pubDate>Wed, 04 Jan 2017 08:11:00 -0600</pubDate><guid>https://blog.fosstrading.com/2017/01/rfinance-2017-call-for-papers/</guid><description><![CDATA[<p>R/Finance 2017: Applied Finance with R</p>
<p>May 19 and 20, 2017</p>
<p>University of Illinois at Chicago</p>
<p>The ninth annual R/Finance conference for applied finance using <a href="https://www.r-project.org/">R</a> will be held on May 19 and 20, 2017 in Chicago, IL, USA at the <a href="http://www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics.  All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past eight years, R/Finance has included attendees from around the world.  It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2017.</p>
<p>We invite you to submit complete papers in pdf format for consideration.  We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks.&rdquo; Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time.  Presenters are strongly encouraged to provide working R code to accompany the slides.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors).  Preference may be given to presenters who have released R packages.</p>
<p>Financial assistance for travel and accommodation may be available to presenters, however requests must be made at the time of submission.  Assistance will be granted at the discretion of the conference committee.</p>
<p>Please submit proposals online at <a href="https://goo.gl/vMweMX">http://go.uic.edu/rfinsubmit</a>.  Submissions will be reviewed and accepted on a rolling basis with a final deadline of February 28, 2017.  Submitters will be notified via email by March 31, 2017 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Additional details will be announced via the conference website <a href="http://www.rinfinance.com/">www.RinFinance.com</a> as they become available.  Information on previous years&rsquo; presenters and their presentations are also at the conference website.  We will make a separate announcement when registration opens.</p>
<p>For the program committee:</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>R/Finance 2017: Applied Finance with R</p>
<p>May 19 and 20, 2017</p>
<p>University of Illinois at Chicago</p>
<p>The ninth annual R/Finance conference for applied finance using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.r-project.org/">R</a> will be held on May 19 and 20, 2017 in Chicago, IL, USA at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics.  All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past eight years, R/Finance has included attendees from around the world.  It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2017.</p>
<p>We invite you to submit complete papers in pdf format for consideration.  We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks.&rdquo; Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time.  Presenters are strongly encouraged to provide working R code to accompany the slides.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors).  Preference may be given to presenters who have released R packages.</p>
<p>Financial assistance for travel and accommodation may be available to presenters, however requests must be made at the time of submission.  Assistance will be granted at the discretion of the conference committee.</p>
<p>Please submit proposals online at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://goo.gl/vMweMX">http://go.uic.edu/rfinsubmit</a>.  Submissions will be reviewed and accepted on a rolling basis with a final deadline of February 28, 2017.  Submitters will be notified via email by March 31, 2017 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Additional details will be announced via the conference website <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">www.RinFinance.com</a> as they become available.  Information on previous years&rsquo; presenters and their presentations are also at the conference website.  We will make a separate announcement when registration opens.</p>
<p>For the program committee:</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672364/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672364/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2016/08/quantmod-0-4-6-on-cran/</feedburner:origLink><title>quantmod 0.4-6 on CRAN</title><link>https://feeds.feedblitz.com/~/748672367/0/fosstrading/</link><pubDate>Mon, 29 Aug 2016 11:38:00 -0500</pubDate><guid>https://blog.fosstrading.com/2016/08/quantmod-0-4-6-on-cran/</guid><description><![CDATA[<p><a href="https://cran.r-project.org/">CRAN</a> just accepted a bugfix release of <a href="http://www.quantmod.com/">quantmod</a>.  The most pertinent changes were to fix getSymbols.oanda (<a href="https://github.com/joshuaulrich/quantmod/issues/36">#36</a>) and getOptionChain.yahoo (<a href="https://github.com/joshuaulrich/quantmod/issues/92">#92</a>).  It also includes a fix to addTRIX (<a href="https://github.com/joshuaulrich/quantmod/issues/72">#72</a>).</p>
<p>Oanda changed their URL format from http to https, and getSymbols.oanda did not follow the redirect.  Yahoo Finance changed the HTML for displaying options data, which broke getOptionChain.yahoo.  The fix downloads JSON instead of scraping HTML, so hopefully it will be less likely to break.  For more information, see the links to the GitHub issues above.</p>
<p>I added documentation for getPrice (<a href="https://github.com/joshuaulrich/quantmod/issues/77">#77</a>), and removed the unused unsetSymbolLookup function and corresponding documentation (<a href="https://github.com/joshuaulrich/quantmod/issues/115">#115</a>).</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/">CRAN</a> just accepted a bugfix release of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a>.  The most pertinent changes were to fix getSymbols.oanda (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/36">#36</a>) and getOptionChain.yahoo (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/92">#92</a>).  It also includes a fix to addTRIX (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/72">#72</a>).</p>
<p>Oanda changed their URL format from http to https, and getSymbols.oanda did not follow the redirect.  Yahoo Finance changed the HTML for displaying options data, which broke getOptionChain.yahoo.  The fix downloads JSON instead of scraping HTML, so hopefully it will be less likely to break.  For more information, see the links to the GitHub issues above.</p>
<p>I added documentation for getPrice (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/77">#77</a>), and removed the unused unsetSymbolLookup function and corresponding documentation (<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues/115">#115</a>).</p>
<div class="container" role="main">
<div class="row">
<p>I look forward to your questions and feedback! If you have a question, please ask on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/">Stack Overflow</a> and use the
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/r">[r]</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~stackoverflow.com/questions/tagged/quantmod">[quantmod]</a> tags.
Or you can send an email to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/mailman/listinfo/r-sig-finance">R-SIG-Finance</a> mailing list (you must subscribe to post).
Open an <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/issues">issue on GitHub</a> if you find a bug or want to request a feature.
Please read the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod/wiki/Contributing-Guide">contributing guide</a> first!
It will help save time for both of us. ;-)</p>
</div>
</div><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672367/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672367/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2016/06/importing-and-managing-financial-data/</feedburner:origLink><title>DataCamp course: Importing and managing financial data</title><link>https://feeds.feedblitz.com/~/748672370/0/fosstrading/</link><pubDate>Fri, 17 Jun 2016 11:32:00 -0500</pubDate><guid>https://blog.fosstrading.com/2016/06/importing-and-managing-financial-data/</guid><description><![CDATA[<p>The team at <a href="https://www.datacamp.com/">DataCamp</a> announced a new R/Finance course series in a recent email:</p>
<blockquote>
<p>Subject: Data Mining Tutorial, R/Finance course series, and more!</p>
<p><strong>R/Finance - A new course series in the works</strong><br>
We are working on a whole new course series on applied finance using R. This new series will cover topics such as time series (David S. Matteson), portfolio analysis (Kris Boudt), the xts and zoo packages (Jeffrey Ryan), and much more. Start our first course <a href="https://www.datacamp.com/courses/introduction-to-credit-risk-modeling-in-r">Intro to Credit Risk Modeling in R</a> today.</p></blockquote>
<p>I&rsquo;m excited to announce that I&rsquo;m working on a course for this new series! It will provide an introduction to importing and managing financial data.</p>
<p>If you&rsquo;ve ever done anything with financial or economic time series, you know the data come in various shapes, sizes, and periodicities. Getting the data into R can be stressful and time-consuming, especially when you need to merge data from several different sources into one data set. This course will cover importing data from local files as well as from internet sources.</p>
<p>The tentative course outline is below. I&rsquo;d really appreciate your feedback on what should be included in this introductory course! So let me know if I&rsquo;ve omitted something, or if you think any of the topics are too advanced.</p>
<p>Introduction to importing and managing financial data</p>
<ol>
<li>
<p>Introduction and downloading data</p>
</li>
<li>
<p>getSymbols design overview, Quandl</p>
</li>
<li>
<p>Finding and downloading data from internet sources</p>
</li>
<li>
<p>E.g. getSymbols.yahoo, getSymbols.FRED, Quandl</p>
</li>
<li>
<p>Loading and transforming multiple instruments</p>
</li>
<li>
<p>Checking for errors (i.e. summary stats, visualizing)</p>
</li>
<li>
<p>Managing data from multiple sources</p>
</li>
<li>
<p>Setting per-instrument sources and default arguments</p>
</li>
<li>
<p>setSymbolLookup, saveSymbolLookup, loadSymbolLookup, setDefaults</p>
</li>
<li>
<p>Handling instruments names that clash or are not valid R object names</p>
</li>
<li>
<p>Aligning data with different periodicities</p>
</li>
<li>
<p>Making irregular data regular</p>
</li>
<li>
<p>Aggregating to lowest frequency</p>
</li>
<li>
<p>Combining monthly with daily</p>
</li>
<li>
<p>Combining daily with intraday</p>
</li>
<li>
<p>Storing and updating data</p>
</li>
<li>
<p>Creating an initial RData-backed storage</p>
</li>
<li>
<p>Adjusting financial time-series</p>
</li>
<li>
<p>Handling errors during update process</p>
</li>
</ol><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>The team at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.datacamp.com/">DataCamp</a> announced a new R/Finance course series in a recent email:</p>
<blockquote>
<p>Subject: Data Mining Tutorial, R/Finance course series, and more!</p>
<p><strong>R/Finance - A new course series in the works</strong>
<br>
We are working on a whole new course series on applied finance using R. This new series will cover topics such as time series (David S. Matteson), portfolio analysis (Kris Boudt), the xts and zoo packages (Jeffrey Ryan), and much more. Start our first course <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.datacamp.com/courses/introduction-to-credit-risk-modeling-in-r">Intro to Credit Risk Modeling in R</a> today.</p></blockquote>
<p>I&rsquo;m excited to announce that I&rsquo;m working on a course for this new series! It will provide an introduction to importing and managing financial data.</p>
<p>If you&rsquo;ve ever done anything with financial or economic time series, you know the data come in various shapes, sizes, and periodicities. Getting the data into R can be stressful and time-consuming, especially when you need to merge data from several different sources into one data set. This course will cover importing data from local files as well as from internet sources.</p>
<p>The tentative course outline is below. I&rsquo;d really appreciate your feedback on what should be included in this introductory course! So let me know if I&rsquo;ve omitted something, or if you think any of the topics are too advanced.</p>
<p>Introduction to importing and managing financial data</p>
<ol>
<li>
<p>Introduction and downloading data</p>
</li>
<li>
<p>getSymbols design overview, Quandl</p>
</li>
<li>
<p>Finding and downloading data from internet sources</p>
</li>
<li>
<p>E.g. getSymbols.yahoo, getSymbols.FRED, Quandl</p>
</li>
<li>
<p>Loading and transforming multiple instruments</p>
</li>
<li>
<p>Checking for errors (i.e. summary stats, visualizing)</p>
</li>
<li>
<p>Managing data from multiple sources</p>
</li>
<li>
<p>Setting per-instrument sources and default arguments</p>
</li>
<li>
<p>setSymbolLookup, saveSymbolLookup, loadSymbolLookup, setDefaults</p>
</li>
<li>
<p>Handling instruments names that clash or are not valid R object names</p>
</li>
<li>
<p>Aligning data with different periodicities</p>
</li>
<li>
<p>Making irregular data regular</p>
</li>
<li>
<p>Aggregating to lowest frequency</p>
</li>
<li>
<p>Combining monthly with daily</p>
</li>
<li>
<p>Combining daily with intraday</p>
</li>
<li>
<p>Storing and updating data</p>
</li>
<li>
<p>Creating an initial RData-backed storage</p>
</li>
<li>
<p>Adjusting financial time-series</p>
</li>
<li>
<p>Handling errors during update process</p>
</li>
</ol><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672370/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672370/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2016/04/registration-for-rfinance-2016-is-open/</feedburner:origLink><title>Registration for R/Finance 2016 is open!</title><link>https://feeds.feedblitz.com/~/748672373/0/fosstrading/</link><pubDate>Mon, 11 Apr 2016 08:14:00 -0500</pubDate><guid>https://blog.fosstrading.com/2016/04/registration-for-rfinance-2016-is-open/</guid><description><![CDATA[<p>You can find <a href="http://www.rinfinance.com/register/">registration information</a> and <a href="http://www.rinfinance.com/agenda/">agenda details</a> on the conference website.  Or you can go directly to the <a href="http://go.uic.edu/rfinance">Cvent registration page</a>.</p>
<p>Note that registration fees <em><strong>will increase by 50%</strong></em> at the end of early registration on May 6, 2016.</p>
<p>The conference will take place on May 20 and 21, at <a href="http://www.uic.edu/">UIC</a> in Chicago.  Building on the success of the previous conferences in 2009-2015, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 50 presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="http://www.burns-stat.com/">Patrick Burns</a>, <a href="http://www.ssc.upenn.edu/~fdiebold/">Frank Diebold</a>, <a href="https://www.linkedin.com/in/tarekeldin">Tarek Eldin</a>, and <a href="http://www.thequantbook.com/about-the-author.html">Rishi Narang</a>.  The conference agenda (currently) includes 17 full presentations and 33 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.</p>
<p>There is also an (optional) conference dinner at The Riverside Room and Gallery at Trump.  Situated directly on the hotel&rsquo;s new River Walk, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2016 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p>  <a href="http://business.uic.edu/liautaud-programs/masters-finance">UIC Liautaud Master of Science in Finance</a></p>
<p>  <a href="http://msdsug.microsoft.com/">Microsoft</a><br>
  <a href="http://depts.washington.edu/compfin/">MS-Computational Finance and Risk Management at University of Washington</a></p>
<p>  <a href="https://www.schwab.com/">Charles Schwab</a><br>
  <a href="http://www.hullinvest.com/HI/">Hull Investments</a><br>
  <a href="https://www.interactivebrokers.com/">Interactive Brokers</a><br>
  <a href="https://www.onetick.com/">OneMarketData</a><br>
  <a href="https://www.rstudio.com/">RStudio</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>  Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>You can find <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/register/">registration information</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/">agenda details</a> on the conference website.  Or you can go directly to the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~go.uic.edu/rfinance">Cvent registration page</a>.</p>
<p>Note that registration fees <em><strong>will increase by 50%</strong></em> at the end of early registration on May 6, 2016.</p>
<p>The conference will take place on May 20 and 21, at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">UIC</a> in Chicago.  Building on the success of the previous conferences in 2009-2015, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 50 presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.burns-stat.com/">Patrick Burns</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.ssc.upenn.edu/~fdiebold/">Frank Diebold</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.linkedin.com/in/tarekeldin">Tarek Eldin</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.thequantbook.com/about-the-author.html">Rishi Narang</a>.  The conference agenda (currently) includes 17 full presentations and 33 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.</p>
<p>There is also an (optional) conference dinner at The Riverside Room and Gallery at Trump.  Situated directly on the hotel&rsquo;s new River Walk, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2016 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p>  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/liautaud-programs/masters-finance">UIC Liautaud Master of Science in Finance</a></p>
<p>  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~msdsug.microsoft.com/">Microsoft</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~depts.washington.edu/compfin/">MS-Computational Finance and Risk Management at University of Washington</a></p>
<p>  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.schwab.com/">Charles Schwab</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.hullinvest.com/HI/">Hull Investments</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.interactivebrokers.com/">Interactive Brokers</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.onetick.com/">OneMarketData</a>
<br>
  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.rstudio.com/">RStudio</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>  Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672373/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672373/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/11/overnight-spy-anomaly/</feedburner:origLink><title>Comment on Overnight SPY Anomaly</title><link>https://feeds.feedblitz.com/~/748672376/0/fosstrading/</link><pubDate>Mon, 16 Nov 2015 11:25:00 -0600</pubDate><guid>https://blog.fosstrading.com/2015/11/overnight-spy-anomaly/</guid><description><![CDATA[<p>This post is in response to Michael Harris&rsquo; <a href="http://www.priceactionlab.com/Blog/2015/11/overnight-trading-anomaly-backtesting-r/">Price Action Lab post</a>, where he uses some simple R code to evaluate the asymmetry of returns from the day&rsquo;s close to the following day&rsquo;s open.  I&rsquo;d like to respond to his 3 notes, which I&rsquo;ve included below.</p>
<blockquote>
<ol>
<li>The R backtest assumes fractional shares. This means that equity is fully invested at each new position. This is important because it affects drawdown calculations.</li>
<li>When calculating the Sharpe ratio, the “geometric = FALSE” option must be used otherwise the result may not be correct. It took some time to figure that out.</li>
<li>The profit factor result in R does not reconcile with results from other platforms or even from excel. PF in R is shown as 1.23 but the correct value is 1.17. Actually, the profit factor is calculated on a per share basis in R, although returns are geometric.</li>
</ol></blockquote>
<p>I completely agree with the first point.  I&rsquo;m not sure Mike considers the output of  <code>SharpeRatio.annualized</code> with <code>geometric=TRUE</code> to be suspect (he doesn&rsquo;t elaborate).  The <code>overnightRets</code> are calculated as arithmetic returns, so it&rsquo;s proper to aggregate them using geometric chaining (i.e. multiplication).</p>
<p>I also agree with the third point, because the R code used to calculate profit factor is wrong.  My main impetus to write this post was to provide a corrected profit factor calculation.  The calculation (with slightly modified syntax) in Mike&rsquo;s post is:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">require</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#39;SPY&#39;</span><span class="p">,</span> <span class="n">from</span> <span class="o">=</span> <span class="s">&#39;1900-01-01&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">SPY</span> <span class="o">&lt;-</span> <span class="nf">adjustOHLC</span><span class="p">(</span><span class="n">SPY</span><span class="p">,</span> <span class="n">use.Adjusted</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">overnightRets</span> <span class="o">&lt;-</span> <span class="nf">na.omit</span><span class="p">(</span><span class="nf">Op</span><span class="p">(</span><span class="n">SPY</span><span class="p">)</span><span class="o">/</span><span class="nf">lag</span><span class="p">(</span><span class="nf">Cl</span><span class="p">(</span><span class="n">SPY</span><span class="p">))</span> <span class="o">-</span> <span class="m">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">posRet</span> <span class="o">&lt;-</span> <span class="n">overnightRets</span> <span class="o">&gt;</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl"><span class="n">profitFactor</span> <span class="o">&lt;-</span> <span class="o">-</span><span class="nf">sum</span><span class="p">(</span><span class="n">overnightRets[posRet]</span><span class="p">)</span><span class="o">/</span><span class="nf">sum</span><span class="p">(</span><span class="n">overnightRets[</span><span class="o">!</span><span class="n">posRet]</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that profit factor in the code above is calculated by summing positive and negative <em>returns</em>, when it should be calculated using positive and negative <em>P&amp;L</em>.  In order to do that, we need to calculate the equity curve and then take its first difference to get P&amp;L.  The corrected calculation is below, and it provides the correct result Mike expected.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">grossEquity</span> <span class="o">&lt;-</span> <span class="nf">cumprod</span><span class="p">(</span><span class="n">overnightRets</span><span class="m">+1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossPnL</span> <span class="o">&lt;-</span> <span class="nf">diff</span><span class="p">(</span><span class="n">grossEquity</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossProfit</span> <span class="o">&lt;-</span> <span class="nf">sum</span><span class="p">(</span><span class="n">grossPnL[grossPnL</span> <span class="o">&gt;</span> <span class="m">0</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossLoss</span> <span class="o">&lt;-</span> <span class="nf">sum</span><span class="p">(</span><span class="n">grossPnL[grossPnL</span> <span class="o">&lt;</span> <span class="m">0</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">profitFactor</span> <span class="o">&lt;-</span> <span class="n">grossProfit</span> <span class="o">/</span> <span class="nf">abs</span><span class="p">(</span><span class="n">grossLoss</span><span class="p">)</span>
</span></span></code></pre></div><p>I&rsquo;d also like to respond to Mike&rsquo;s comment:</p>
<blockquote>
<p>Since in the past I have identified serious flaws in commercially available backtesting platforms, I would not be surprised if some of the R libraries have some flaws.</p></blockquote>
<p>I&rsquo;m certain all of the backtesting R packages have flaws/bugs.  All software has bugs because all software is written by fallible humans.  One nice thing about (most) R packages is that they&rsquo;re open source, which means anyone/everyone can check the code for bugs, and fix any bugs that are found.  With closed-source software, commercial or not, you depend on the vendor to deliver a patched version at their discretion and in their timing.</p>
<p>Now, I&rsquo;m not making an argument that open source software is inherently better. I simply wanted to point out this one difference.  As much as I love open source software, there are times where commercial vendor-supported software presents a more appealing set of tradeoffs than using open source software.  Each situation is different.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This post is in response to Michael Harris&rsquo; <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.priceactionlab.com/Blog/2015/11/overnight-trading-anomaly-backtesting-r/">Price Action Lab post</a>, where he uses some simple R code to evaluate the asymmetry of returns from the day&rsquo;s close to the following day&rsquo;s open.  I&rsquo;d like to respond to his 3 notes, which I&rsquo;ve included below.</p>
<blockquote>
<ol>
<li>The R backtest assumes fractional shares. This means that equity is fully invested at each new position. This is important because it affects drawdown calculations.</li>
<li>When calculating the Sharpe ratio, the “geometric = FALSE” option must be used otherwise the result may not be correct. It took some time to figure that out.</li>
<li>The profit factor result in R does not reconcile with results from other platforms or even from excel. PF in R is shown as 1.23 but the correct value is 1.17. Actually, the profit factor is calculated on a per share basis in R, although returns are geometric.</li>
</ol></blockquote>
<p>I completely agree with the first point.  I&rsquo;m not sure Mike considers the output of  <code>SharpeRatio.annualized</code> with <code>geometric=TRUE</code> to be suspect (he doesn&rsquo;t elaborate).  The <code>overnightRets</code> are calculated as arithmetic returns, so it&rsquo;s proper to aggregate them using geometric chaining (i.e. multiplication).</p>
<p>I also agree with the third point, because the R code used to calculate profit factor is wrong.  My main impetus to write this post was to provide a corrected profit factor calculation.  The calculation (with slightly modified syntax) in Mike&rsquo;s post is:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">require</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#39;SPY&#39;</span><span class="p">,</span> <span class="n">from</span> <span class="o">=</span> <span class="s">&#39;1900-01-01&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">SPY</span> <span class="o">&lt;-</span> <span class="nf">adjustOHLC</span><span class="p">(</span><span class="n">SPY</span><span class="p">,</span> <span class="n">use.Adjusted</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">overnightRets</span> <span class="o">&lt;-</span> <span class="nf">na.omit</span><span class="p">(</span><span class="nf">Op</span><span class="p">(</span><span class="n">SPY</span><span class="p">)</span><span class="o">/</span><span class="nf">lag</span><span class="p">(</span><span class="nf">Cl</span><span class="p">(</span><span class="n">SPY</span><span class="p">))</span> <span class="o">-</span> <span class="m">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">posRet</span> <span class="o">&lt;-</span> <span class="n">overnightRets</span> <span class="o">&gt;</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl"><span class="n">profitFactor</span> <span class="o">&lt;-</span> <span class="o">-</span><span class="nf">sum</span><span class="p">(</span><span class="n">overnightRets[posRet]</span><span class="p">)</span><span class="o">/</span><span class="nf">sum</span><span class="p">(</span><span class="n">overnightRets[</span><span class="o">!</span><span class="n">posRet]</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that profit factor in the code above is calculated by summing positive and negative <em>returns</em>, when it should be calculated using positive and negative <em>P&amp;L</em>.  In order to do that, we need to calculate the equity curve and then take its first difference to get P&amp;L.  The corrected calculation is below, and it provides the correct result Mike expected.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">grossEquity</span> <span class="o">&lt;-</span> <span class="nf">cumprod</span><span class="p">(</span><span class="n">overnightRets</span><span class="m">+1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossPnL</span> <span class="o">&lt;-</span> <span class="nf">diff</span><span class="p">(</span><span class="n">grossEquity</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossProfit</span> <span class="o">&lt;-</span> <span class="nf">sum</span><span class="p">(</span><span class="n">grossPnL[grossPnL</span> <span class="o">&gt;</span> <span class="m">0</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">grossLoss</span> <span class="o">&lt;-</span> <span class="nf">sum</span><span class="p">(</span><span class="n">grossPnL[grossPnL</span> <span class="o">&lt;</span> <span class="m">0</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">profitFactor</span> <span class="o">&lt;-</span> <span class="n">grossProfit</span> <span class="o">/</span> <span class="nf">abs</span><span class="p">(</span><span class="n">grossLoss</span><span class="p">)</span>
</span></span></code></pre></div><p>I&rsquo;d also like to respond to Mike&rsquo;s comment:</p>
<blockquote>
<p>Since in the past I have identified serious flaws in commercially available backtesting platforms, I would not be surprised if some of the R libraries have some flaws.</p></blockquote>
<p>I&rsquo;m certain all of the backtesting R packages have flaws/bugs.  All software has bugs because all software is written by fallible humans.  One nice thing about (most) R packages is that they&rsquo;re open source, which means anyone/everyone can check the code for bugs, and fix any bugs that are found.  With closed-source software, commercial or not, you depend on the vendor to deliver a patched version at their discretion and in their timing.</p>
<p>Now, I&rsquo;m not making an argument that open source software is inherently better. I simply wanted to point out this one difference.  As much as I love open source software, there are times where commercial vendor-supported software presents a more appealing set of tradeoffs than using open source software.  Each situation is different.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672376/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672376/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/07/new-quantmod-and-ttr-on-cran/</feedburner:origLink><title>New quantmod and TTR on CRAN</title><link>https://feeds.feedblitz.com/~/748672379/0/fosstrading/</link><pubDate>Fri, 24 Jul 2015 16:04:00 -0500</pubDate><guid>https://blog.fosstrading.com/2015/07/new-quantmod-and-ttr-on-cran/</guid><description><![CDATA[<p>I just sent <a href="https://cran.r-project.org/package=quantmod">quantmod_0.4-5</a> to <a href="https://cran.r-project.org/">CRAN</a>, and <a href="https://cran.r-project.org/package=TTR">TTR_0.23-0</a> has been there for a couple weeks. I&rsquo;d like to thank <a href="http://www.quintuitive.com/">Ivan Popivanov</a> for many useful reports and patches to TTR. He provided patches to add <code>HMA()</code> (Hull MA), <code>ALMA()</code>, and <code>ultimateOscillator()</code> functions.</p>
<p><a href="http://jtoll.com/">James Toll</a> provided a patch to the <code>volatility()</code> function that uses a zero mean (instead of the sample mean) in close-to-close volatility. The other big change is that moving average functions no longer return objects with column names based on the input object column names. There are many other bug fixes (see the CHANGES file in the package).</p>
<p>The biggest changes in quantmod were to fix <code>getSymbols.MySQL()</code> to use the correct <code>dbConnect()</code> call based on changes made in RMySQL_0.10 and to fix <code>getSymbols.FRED()</code> to use https:// instead of http:// when downloading FRED data. <code>getSymbols.csv()</code> also got some much-needed love.</p>
<p>I&rsquo;d also like to mention that development has moved to GitHub for both <a href="https://github.com/joshuaulrich/TTR">TTR</a> and <a href="https://github.com/joshuaulrich/quantmod">quantmod</a>.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I just sent <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=quantmod">quantmod_0.4-5</a> to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/">CRAN</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://cran.r-project.org/package=TTR">TTR_0.23-0</a> has been there for a couple weeks. I&rsquo;d like to thank <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quintuitive.com/">Ivan Popivanov</a> for many useful reports and patches to TTR. He provided patches to add <code>HMA()</code> (Hull MA), <code>ALMA()</code>, and <code>ultimateOscillator()</code> functions.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~jtoll.com/">James Toll</a> provided a patch to the <code>volatility()</code> function that uses a zero mean (instead of the sample mean) in close-to-close volatility. The other big change is that moving average functions no longer return objects with column names based on the input object column names. There are many other bug fixes (see the CHANGES file in the package).</p>
<p>The biggest changes in quantmod were to fix <code>getSymbols.MySQL()</code> to use the correct <code>dbConnect()</code> call based on changes made in RMySQL_0.10 and to fix <code>getSymbols.FRED()</code> to use https:// instead of http:// when downloading FRED data. <code>getSymbols.csv()</code> also got some much-needed love.</p>
<p>I&rsquo;d also like to mention that development has moved to GitHub for both <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/TTR">TTR</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/quantmod">quantmod</a>.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672379/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672379/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/04/plotxts-rfc/</feedburner:origLink><title>plot.xts RFC</title><link>https://feeds.feedblitz.com/~/748672382/0/fosstrading/</link><pubDate>Mon, 20 Apr 2015 12:45:00 -0500</pubDate><guid>https://blog.fosstrading.com/2015/04/plotxts-rfc/</guid><description><![CDATA[<p>We have been working on a new charting engine for <code>xts::plot.xts</code> for the past couple years. It started with Michael Weylandt&rsquo;s work during the 2012 Google Summer of Code, and Ross Bennett took up the torch during the 2014 GSoC.</p>
<p>This new engine improves the functionality, modularity, and flexibility of <code>plot.xts</code> by building off the framework Jeff Ryan began with <code>quantmod::chart_Series</code>.  The modular framework allows users to plot an xts object and incrementally build custom charts by adding panels of new data (including transformations of the original xts object).</p>
<p>The main objective was to provide functionality similar to <code>chartSeries</code> and <code>addTA</code> for xts objects. The current code includes support for:</p>
<ul>
<li>Basic time series plots with sensible defaults</li>
<li>Plotting xts objects by column &ldquo;automagically&rdquo; as separate panels</li>
<li>Small multiples with multiple pages</li>
<li>&ldquo;Layout-safe&rdquo; so multiple specifications/panels can be charted in a single device</li>
<li>Easily add data to an existing plot or add panels similar to <code>quantmod::add*</code></li>
<li>Event lines</li>
</ul>
<p>The xts team would greatly appreciate any comments, feedback, and bug reports before the upcoming CRAN release at the end of April.</p>
<p>The new version of <code>plot.xts</code> is in the main xts development code base, which is available on GitHub in the <a href="https://github.com/joshuaulrich/xts">develop branch</a>.  GitHub is also the place to submit <a href="https://github.com/joshuaulrich/xts/issues">b</a><a href="https://github.com/joshuaulrich/xts/issues">ug reports and feature requests</a>.</p>
<p>Note that the new <code>plot.xts</code> includes breaking changes to the original (and rather limited) <code>plot.xts</code>.  However, we believe the new functionality more than compensates for the potential one-time inconvenience.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>We have been working on a new charting engine for <code>xts::plot.xts</code> for the past couple years. It started with Michael Weylandt&rsquo;s work during the 2012 Google Summer of Code, and Ross Bennett took up the torch during the 2014 GSoC.</p>
<p>This new engine improves the functionality, modularity, and flexibility of <code>plot.xts</code> by building off the framework Jeff Ryan began with <code>quantmod::chart_Series</code>.  The modular framework allows users to plot an xts object and incrementally build custom charts by adding panels of new data (including transformations of the original xts object).</p>
<p>The main objective was to provide functionality similar to <code>chartSeries</code> and <code>addTA</code> for xts objects. The current code includes support for:</p>
<ul>
<li>Basic time series plots with sensible defaults</li>
<li>Plotting xts objects by column &ldquo;automagically&rdquo; as separate panels</li>
<li>Small multiples with multiple pages</li>
<li>&ldquo;Layout-safe&rdquo; so multiple specifications/panels can be charted in a single device</li>
<li>Easily add data to an existing plot or add panels similar to <code>quantmod::add*</code></li>
<li>Event lines</li>
</ul>
<p>The xts team would greatly appreciate any comments, feedback, and bug reports before the upcoming CRAN release at the end of April.</p>
<p>The new version of <code>plot.xts</code> is in the main xts development code base, which is available on GitHub in the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts">develop branch</a>.  GitHub is also the place to submit <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">b</a><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/joshuaulrich/xts/issues">ug reports and feature requests</a>.</p>
<p>Note that the new <code>plot.xts</code> includes breaking changes to the original (and rather limited) <code>plot.xts</code>.  However, we believe the new functionality more than compensates for the potential one-time inconvenience.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672382/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672382/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/03/registration-open-for-rfinance-2015/</feedburner:origLink><title>Registration Open for R/Finance 2015!</title><link>https://feeds.feedblitz.com/~/748672385/0/fosstrading/</link><pubDate>Tue, 31 Mar 2015 10:35:00 -0500</pubDate><guid>https://blog.fosstrading.com/2015/03/registration-open-for-rfinance-2015/</guid><description><![CDATA[<p>You can find <a href="http://www.rinfinance.com/register/">registration information</a> and <a href="http://www.rinfinance.com/agenda/">agenda details</a> (as they become available) on the conference website.  Or you can go <a href="http://www.cvent.com/d/94q27k">directly to the registration page</a>.  Note that there&rsquo;s an early-bird registration deadline of May 15.</p>
<p>The conference will take place on May 29 and 30, at <a href="http://www.uic.edu/">UIC</a> in Chicago.  Building on the success of the previous conferences in 2009-2014, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 30+ presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="http://www.emanuelderman.com/info/about">Emanuel Derman</a>, <a href="http://fitnr.com/about-louis-marascio.html">Louis Marascio</a>, <a href="http://www.macs.hw.ac.uk/~mcneil/">Alexander McNeil</a>, and <a href="http://www.thequantbook.com/about-the-author.html">Rishi Narang</a>.  The main agenda (currently) includes 18 full presentations and 19 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.</p>
<p>There is also an (optional) conference dinner that will once-again be held at <a href="http://www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a> Hotel. Overlooking the Chicago river and skyline, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2015 sponsors for the continued support enabling us to host such an exciting conference:</p>
<p><a href="http://business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a></p>
<p><a href="http://www.revolutionanalytics.com/">Revolution Analytics</a><br>
<a href="http://depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a></p>
<p><a href="http://www.onetick.com/">OneMarketData</a><br>
<a href="http://www.ketchumtrading.com/">Ketchum Trading</a><br>
<a href="http://www.rstudio.org/">RStudio</a><br>
<a href="http://www.symmys.com/arpm-bootcamp">SYMMYS</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>For the program committee:<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>You can find <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/register/">registration information</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/">agenda details</a> (as they become available) on the conference website.  Or you can go <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.cvent.com/d/94q27k">directly to the registration page</a>.  Note that there&rsquo;s an early-bird registration deadline of May 15.</p>
<p>The conference will take place on May 29 and 30, at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">UIC</a> in Chicago.  Building on the success of the previous conferences in 2009-2014, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 30+ presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.emanuelderman.com/info/about">Emanuel Derman</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~fitnr.com/about-louis-marascio.html">Louis Marascio</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.macs.hw.ac.uk/~mcneil/">Alexander McNeil</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.thequantbook.com/about-the-author.html">Rishi Narang</a>.  The main agenda (currently) includes 18 full presentations and 19 shorter &ldquo;lightning talks&rdquo;.  As in previous years, several (optional) pre-conference seminars are offered on Friday morning.</p>
<p>There is also an (optional) conference dinner that will once-again be held at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a> Hotel. Overlooking the Chicago river and skyline, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>We would to thank our 2015 sponsors for the continued support enabling us to host such an exciting conference:</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a></p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.revolutionanalytics.com/">Revolution Analytics</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a></p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.onetick.com/">OneMarketData</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.ketchumtrading.com/">Ketchum Trading</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rstudio.org/">RStudio</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.symmys.com/arpm-bootcamp">SYMMYS</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>For the program committee:
<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672385/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672385/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/03/import-japanese-equity-data-into-r/</feedburner:origLink><title>Import Japanese equity data into R with quantmod 0.4-4</title><link>https://feeds.feedblitz.com/~/748672388/0/fosstrading/</link><pubDate>Tue, 10 Mar 2015 12:09:00 -0500</pubDate><guid>https://blog.fosstrading.com/2015/03/import-japanese-equity-data-into-r/</guid><description><![CDATA[<p>I pushed <a href="http://cran.r-project.org/web/packages/quantmod/">quantmod 0.4-4 to CRAN</a> this weekend.  It adds a <code>getSymbols.yahooj</code> function to pull stock data from Yahoo Finance Japan, and fixes issues in <code>getOptionChain.yahoo</code> and <code>getSymbols.oanda</code>.</p>
<p>Changes to the Yahoo Finance and Oanda websites broke the <code>getOptionChain.yahoo</code> and <code>getSymbols.oanda</code> functions, respectively.  I didn&rsquo;t use <code>getOptionChain.yahoo</code> much, so I’m not certain I restored all the prior functionality.  Let me know if there’s something I missed. I’d be glad to add a test case for that, or to add a test you&rsquo;ve written.</p>
<p>The <code>getSymbols.yahooj</code> function is a major enhancement provided by <a href="http://morannon.org/">Wouter Thielen</a>.  It allows quantmod users to pull stock data from Yahoo Finance Japan. </p>
<p>Japanese ticker symbols usually start with a number and it is cumbersome to use variable names that start with a number in the R environment, so the string &ldquo;YJ&rdquo; will be prepended to each of the Symbols.  I recommend using <code>setSymbolLookup</code> to prepend the ticker symbols with &ldquo;YJ&rdquo; yourself, so you can just use the main <code>getSymbols</code> function.</p>
<p>For example, if you want to pull Sony data, you would run:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">require</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">setSymbolLookup</span><span class="p">(</span><span class="n">YJ6758.T</span><span class="o">=</span><span class="s">&#39;yahooj&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#39;YJ6758.T&#39;</span><span class="p">)</span>
</span></span></code></pre></div><p>The full list of supported data sources for quantmod is now: Yahoo Finance-US, Yahoo Finance-Japan, Google Finance, csv, RData (including rds and rda), FRED, SQLite, MySQL, and Oanda. </p>
<p>Contributions to add support for additional data sources are welcomed.  The existing <code>getSymbols</code> functions are good templates to start from.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>I pushed <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/quantmod/">quantmod 0.4-4 to CRAN</a> this weekend.  It adds a <code>getSymbols.yahooj</code> function to pull stock data from Yahoo Finance Japan, and fixes issues in <code>getOptionChain.yahoo</code> and <code>getSymbols.oanda</code>.</p>
<p>Changes to the Yahoo Finance and Oanda websites broke the <code>getOptionChain.yahoo</code> and <code>getSymbols.oanda</code> functions, respectively.  I didn&rsquo;t use <code>getOptionChain.yahoo</code> much, so I’m not certain I restored all the prior functionality.  Let me know if there’s something I missed. I’d be glad to add a test case for that, or to add a test you&rsquo;ve written.</p>
<p>The <code>getSymbols.yahooj</code> function is a major enhancement provided by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~morannon.org/">Wouter Thielen</a>.  It allows quantmod users to pull stock data from Yahoo Finance Japan. </p>
<p>Japanese ticker symbols usually start with a number and it is cumbersome to use variable names that start with a number in the R environment, so the string &ldquo;YJ&rdquo; will be prepended to each of the Symbols.  I recommend using <code>setSymbolLookup</code> to prepend the ticker symbols with &ldquo;YJ&rdquo; yourself, so you can just use the main <code>getSymbols</code> function.</p>
<p>For example, if you want to pull Sony data, you would run:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">require</span><span class="p">(</span><span class="n">quantmod</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">setSymbolLookup</span><span class="p">(</span><span class="n">YJ6758.T</span><span class="o">=</span><span class="s">&#39;yahooj&#39;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">getSymbols</span><span class="p">(</span><span class="s">&#39;YJ6758.T&#39;</span><span class="p">)</span>
</span></span></code></pre></div><p>The full list of supported data sources for quantmod is now: Yahoo Finance-US, Yahoo Finance-Japan, Google Finance, csv, RData (including rds and rda), FRED, SQLite, MySQL, and Oanda. </p>
<p>Contributions to add support for additional data sources are welcomed.  The existing <code>getSymbols</code> functions are good templates to start from.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672388/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672388/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2015/03/google-summer-of-code-2015/</feedburner:origLink><title>Google Summer of Code 2015</title><link>https://feeds.feedblitz.com/~/748672391/0/fosstrading/</link><pubDate>Tue, 03 Mar 2015 09:04:00 -0600</pubDate><guid>https://blog.fosstrading.com/2015/03/google-summer-of-code-2015/</guid><description><![CDATA[<figure class="floatright"><img src="https://blog.fosstrading.com/post-images/gsoc2015-300x270.jpg">
</figure>
<p>The R Project has once again been selected as a <a href="https://github.com/rstats-gsoc/gsoc2015/wiki/Admin_Application">mentoring organization</a> for this year&rsquo;s <a href="https://www.google-melange.com/gsoc/homepage/google/gsoc2015">Google Summer of Code</a> (GSoC).  If you&rsquo;re not familiar with GSoC, it&rsquo;s a global program that offers students a stipend to write code for open source projects, under the direction of a mentor.  Mentors get code written for their project, but no money.  Students get something like a paid summer internship, with open-source contributions they can reference on their resume.</p>
<p>If you’re interested in participating as a student or a mentor, there&rsquo;s an overview of the GSoC program on <a href="https://github.com/rstats-gsoc/gsoc2015/wiki">The R Project GSoC 2015 Wiki</a>.  The wiki also includes a timeline and links to prior year&rsquo;s projects.</p>
<p>Several mentors from various backgrounds have already <a href="https://github.com/rstats-gsoc/gsoc2015/wiki/table%20of%20proposed%20coding%20projects">proposed projects</a> for students to work on this summer.  Mentors have until March 9th to submit projects they would be willing to support, and student applications begin on March 16th.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<figure class="floatright"><img src="https://blog.fosstrading.com/post-images/gsoc2015-300x270.jpg">
</figure>
<p>The R Project has once again been selected as a <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/rstats-gsoc/gsoc2015/wiki/Admin_Application">mentoring organization</a> for this year&rsquo;s <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.google-melange.com/gsoc/homepage/google/gsoc2015">Google Summer of Code</a> (GSoC).  If you&rsquo;re not familiar with GSoC, it&rsquo;s a global program that offers students a stipend to write code for open source projects, under the direction of a mentor.  Mentors get code written for their project, but no money.  Students get something like a paid summer internship, with open-source contributions they can reference on their resume.</p>
<p>If you’re interested in participating as a student or a mentor, there&rsquo;s an overview of the GSoC program on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/rstats-gsoc/gsoc2015/wiki">The R Project GSoC 2015 Wiki</a>.  The wiki also includes a timeline and links to prior year&rsquo;s projects.</p>
<p>Several mentors from various backgrounds have already <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/rstats-gsoc/gsoc2015/wiki/table%20of%20proposed%20coding%20projects">proposed projects</a> for students to work on this summer.  Mentors have until March 9th to submit projects they would be willing to support, and student applications begin on March 16th.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672391/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672391/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2014/12/updated-quantmod-on-cran/</feedburner:origLink><title>Updated quantmod on CRAN</title><link>https://feeds.feedblitz.com/~/748672394/0/fosstrading/</link><pubDate>Mon, 15 Dec 2014 09:43:00 -0600</pubDate><guid>https://blog.fosstrading.com/2014/12/updated-quantmod-on-cran/</guid><description><![CDATA[<p>An updated version of <a href="http://www.quantmod.com/">quantmod</a> has just been released on <a href="http://cran.r-project.org/">CRAN</a>.  This is my first submission as the new maintainer.  The major change was removing the dependency on the <a href="http://cran.r-project.org/web/packages/Defaults/">now-archived Defaults</a> package.  End-users shouldn&rsquo;t notice a difference, since I basically copied the necessary functionality from Defaults and added it to quantmod.</p>
<p>There are also several bug fixes. A few worth noting are:</p>
<ul>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=4768&amp;group_id=125&amp;atid=544">getSplits</a></li>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5680&amp;group_id=125&amp;atid=544">adjustOHLC</a></li>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=735&amp;group_id=125&amp;atid=544">getSymbols (when adjust=TRUE)</a></li>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=2665&amp;group_id=125&amp;atid=544">saveSymbols</a></li>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5950&amp;group_id=125&amp;atid=544">newTA</a></li>
<li><a href="http://r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5807&amp;group_id=125&amp;atid=544">findValleys</a></li>
</ul><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>An updated version of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quantmod.com/">quantmod</a> has just been released on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/">CRAN</a>.  This is my first submission as the new maintainer.  The major change was removing the dependency on the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/Defaults/">now-archived Defaults</a> package.  End-users shouldn&rsquo;t notice a difference, since I basically copied the necessary functionality from Defaults and added it to quantmod.</p>
<p>There are also several bug fixes. A few worth noting are:</p>
<ul>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=4768&amp;group_id=125&amp;atid=544">getSplits</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5680&amp;group_id=125&amp;atid=544">adjustOHLC</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=735&amp;group_id=125&amp;atid=544">getSymbols (when adjust=TRUE)</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=2665&amp;group_id=125&amp;atid=544">saveSymbols</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5950&amp;group_id=125&amp;atid=544">newTA</a></li>
<li><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/tracker/index.php?func=detail&amp;aid=5807&amp;group_id=125&amp;atid=544">findValleys</a></li>
</ul><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672394/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672394/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2014/11/rfinance-2015-call-for-papers/</feedburner:origLink><title>R/Finance 2015 Call for Papers</title><link>https://feeds.feedblitz.com/~/748672397/0/fosstrading/</link><pubDate>Tue, 18 Nov 2014 13:52:00 -0600</pubDate><guid>https://blog.fosstrading.com/2014/11/rfinance-2015-call-for-papers/</guid><description><![CDATA[<p>Call for Papers:</p>
<p>R/Finance 2015: Applied Finance with R<br>
May 29 and 30, 2015<br>
University of Illinois at Chicago</p>
<p>The seventh annual R/Finance conference for applied finance using <a href="http://www.r-project.org/">R</a> will be held on May 29 and 30, 2015 in Chicago, IL, USA at the <a href="http://www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past six years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2015.  This year will include invited keynote presentations by <a href="http://www.emanuelderman.com/info/about">Emanuel Derman</a>, <a href="http://fitnr.com/about-louis-marascio.html">Louis Marascio</a>, <a href="http://www.macs.hw.ac.uk/~mcneil/">Alexander McNeil</a>, and <a href="http://www.thequantbook.com/about-the-author.html">Rishi Narang</a>.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks.&rdquo; Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time. Presenters are strongly encouraged to provide working R code to accompany the slides.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>The conference will award two (or more) $1000 prizes for best papers. A submission must be a full paper to be eligible for a best paper award. Extended abstracts, even if a full paper is provided by conference time, are not eligible for a best paper award.  Financial assistance for travel and accommodation may be available to presenters, however requests must be made at the time of submission.  Assistance will be granted at the discretion of the conference committee.</p>
<p>Please make your submission online at: <a href="http://www.cvent.com/d/t4qy73">http://www.cvent.com/d/t4qy73</a>. The submission deadline is January 31, 2015. Submitters will be notified via email by February 28, 2015 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Additional details will be announced via the <a href="http://www.rinfinance.com/">conference website</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website.</p>
<p>For the program committee:<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>Call for Papers:</p>
<p>R/Finance 2015: Applied Finance with R
<br>
May 29 and 30, 2015
<br>
University of Illinois at Chicago</p>
<p>The seventh annual R/Finance conference for applied finance using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.r-project.org/">R</a> will be held on May 29 and 30, 2015 in Chicago, IL, USA at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past six years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2015.  This year will include invited keynote presentations by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.emanuelderman.com/info/about">Emanuel Derman</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~fitnr.com/about-louis-marascio.html">Louis Marascio</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.macs.hw.ac.uk/~mcneil/">Alexander McNeil</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.thequantbook.com/about-the-author.html">Rishi Narang</a>.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format) although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks.&rdquo; Both academic and practitioner proposals related to R are encouraged.</p>
<p>All slides will be made publicly available at conference time. Presenters are strongly encouraged to provide working R code to accompany the slides.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>The conference will award two (or more) $1000 prizes for best papers. A submission must be a full paper to be eligible for a best paper award. Extended abstracts, even if a full paper is provided by conference time, are not eligible for a best paper award.  Financial assistance for travel and accommodation may be available to presenters, however requests must be made at the time of submission.  Assistance will be granted at the discretion of the conference committee.</p>
<p>Please make your submission online at: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.cvent.com/d/t4qy73">http://www.cvent.com/d/t4qy73</a>. The submission deadline is January 31, 2015. Submitters will be notified via email by February 28, 2015 of acceptance, presentation length, and financial assistance (if requested).</p>
<p>Additional details will be announced via the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">conference website</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website.</p>
<p>For the program committee:
<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672397/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672397/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2014/06/rfinance-2014-review/</feedburner:origLink><title>R/Finance 2014 Review</title><link>https://feeds.feedblitz.com/~/748672400/0/fosstrading/</link><pubDate>Mon, 30 Jun 2014 07:40:00 -0500</pubDate><guid>https://blog.fosstrading.com/2014/06/rfinance-2014-review/</guid><description><![CDATA[<p>It&rsquo;s been more than a month since <a href="http://www.rinfinance.com/">R/Finance 2014</a>, and my job has finally slowed down enough to allow me to write down my thoughts (though I&rsquo;m writing this over two days during my train to and from Chicago).</p>
<p>The comments below are based on my personal experience. If I don&rsquo;t comment on a seminar or presentation, it doesn&rsquo;t mean I didn&rsquo;t like it or it wasn&rsquo;t good; it may have been over my head or I may have been distracted with my duties as a committee member. All the currently available conference slides are available <a href="http://www.rinfinance.com/agenda/">on the website</a>.</p>
<p>Friday morning seminar:<br>
I went to <a href="http://www.rinfinance.com/agenda/2014/workshop/DirkEddelbuettel.pdf">Dirk Eddelbuettel&rsquo;s</a> seminar because I may be writing a R package to query <a href="http://www.deltixlab.com/">Deltix&rsquo;s</a> <a href="https://www.blogger.com/null"></a> <a href="http://www.deltixlab.com/solutions/timebase.html">TimeBase</a> database. Deltix provides a C++ API, so this is a perfect opportunity to use Rcpp.</p>
<p>Friday talks:<br>
The first presentation was given by keynote <a href="http://www.rinfinance.com/agenda/2014/talk/LukeTierney.pdf">Luke Tierney</a>, who discussed recent and upcoming performance improvements to R, and introduced some new profiling tools in his <a href="https://github.com/ltierney/Rpkg-proftools">proftools</a> package (and a new <a href="https://github.com/ltierney/Rpkg-proftools-GUI">proftools-GUI</a> package).</p>
<p><a href="http://www.rinfinance.com/agenda/2014/talk/YangLu.pdf">Yang Lu</a> explored the low-risk anomaly on high/low volatility portfolios with similar industry, size, and volume. <a href="http://www.rinfinance.com/agenda/2014/talk/AveryMoon.pdf">Avery Moon</a> discussed how they use R at <a href="http://www.wealthfront.com/">Wealthfront</a> to run cashflow simulations for their tax-loss harvesting strategy. <a href="http://www.rinfinance.com/agenda/2014/talk/StevenPav.pdf">Steven Pav</a> used math and memes to discuss portfolio inference. <a href="http://www.rinfinance.com/agenda/2014/talk/TobiasSetz.pdf">Tobias Setz</a> used the Bayesian Change Point method to analyze time series stability.</p>
<p><a href="http://www.rinfinance.com/agenda/2014/talk/PaulTeetor.pdf">Paul Teetor</a> and <a href="http://www.rinfinance.com/agenda/2014/talk/MatthewClegg.pdf">Matthew Clegg</a> discussed different aspects of pairs trading. <a href="http://www.rinfinance.com/agenda/2014/talk/KentHoxsey.pdf">Kent Hoxsey</a> demonstrated a simple way to explore trading signal expectation. <a href="http://www.rinfinance.com/agenda/2014/talk/MatthewBarry.pdf">Matthew Barry</a> introduced the <a href="https://github.com/mrbcuda/pbo">pbo</a> package, which implements some of the ideas in the paper, <a href="http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2326253">The Probability of Backtest Overfitting</a>.</p>
<p><a href="http://www.rinfinance.com/agenda/2014/talk/AlexiosGhalanos.pdf">Alexios Ghalanos</a> was the day&rsquo;s second keynote, and he discussed smooth transition autoregressive models and his new package, <a href="https://bitbucket.org/alexiosg/twinkle">twinkle</a>. Alexios <a href="http://unstarched.net/2014/05/27/twinkletwinkle-little-star/">wrote a post</a> discussing his presentation, which you should definitely read.</p>
<p>Friday food/networking:<br>
During the two-hour conference reception at UIC, I had some drinks and hors d&rsquo;ouvres, talked with speakers, and meet people I encouraged to attend and/or present. Next was the (optional) dinner at <a href="http://www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a>. It was cold and windy again this year, so we were inside the entire night. Same as last year, the food was fantastic, but the conversations were even better.</p>
<p>Saturday talks:<br>
The first presentation was a lightning talk by <a href="http://www.rinfinance.com/agenda/2014/talk/ChiragAnand.pdf">Chirag Anand</a>, where he introduced the <a href="http://cran.r-project.org/web/packages/eventstudies/">eventstudies</a> package, which is very well done. <a href="http://www.rinfinance.com/agenda/2014/talk/CaseyKing.pptx">Casey King</a> gave an incredibly informative and entertaining presentation on anti-money laundering and suspicious activity reporting in penny stocks using message board posts. <a href="http://www.rinfinance.com/agenda/2014/talk/BryanLewis.pdf">Bryan Lewis</a> introduced his <a href="https://github.com/bwlewis/IRL">IRL</a> package and ran a 16 million node network analysis in &lt; 2 minutes on his Chromebook, during his talk. <a href="http://www.rinfinance.com/agenda/2014/talk/StephenRush.pdf">Stephen Rush</a> discussed his work on <a href="http://en.wikipedia.org/wiki/VPIN">VPIN</a> (volume synchronized probability of informed trading), while competing with Steven Pav for the &ldquo;presentation with the most memes&rdquo;.</p>
<p><a href="http://www.rinfinance.com/agenda/2014/talk/BobMcDonald.pdf">Bob McDonald</a> gave the third keynote presentation, where he discussed using R to teach derivatives in MBA classes. He also explained his decision to adopt R in terms of valuing an option. <a href="http://www.rinfinance.com/agenda/2014/talk/EricZivot.pdf">Eric Zivot</a> discussed his upcoming book, &ldquo;Modeling Financial Time Series with S-Plus R&rdquo;. <a href="http://www.rinfinance.com/agenda/2014/talk/RohiniGrover.pdf">Rohini Grover</a> measured the imprecision of implied volatility estimates in volatility indexes using the <a href="https://r-forge.r-project.org/projects/ifrogs/">ifrogs</a> package.</p>
<p><a href="http://www.rinfinance.com/agenda/2014/talk/BillCleveland.pdf">Bill Cleveland</a> gave the final keynote and talked about the &ldquo;divide-and-recombine&rdquo; method for large, complex data, using R and Hadoop. <a href="http://www.rinfinance.com/agenda/2014/talk/GregorKastner.pdf">Gregor Kastner</a> introduced his <a href="http://cran.r-project.org/web/packages/stochvol/">stochvol</a> package, and <a href="http://www.rinfinance.com/agenda/2014/talk/MatthewDixon.pdf">Matthew Dixon</a> showed how to calibrate stochastic volatility models using his &ldquo;alpha&rdquo; <a href="https://github.com/mfrdixon/gpusvcalibration">gpusvcalibration</a> package. <a href="http://www.rinfinance.com/agenda/2014/talk/DirkEddelbuettel.pdf">Dirk Eddelbuettel</a> closed the conference with a lightning talk on his recently-released <a href="http://cran.r-project.org/web/packages/RcppRedis/">RcppRedis</a> package.</p>
<p>The committee also presented the awards for best papers. The winners were:</p>
<ul>
<li><em>Portfolio inference with this one weird trick</em>, Steven E. Pav</li>
<li><em>Dealing with Stochastic Volatility in Time Series Using the R Package stochvol</em>, Gregor Kastner</li>
<li><em>Re-Evaluation of the Low-Risk Anomaly in Finance via Matching</em>, Yang Lu, Daniel Wu, Kwok Yu</li>
<li><em>All words are not equal: Sentiment dynamics and information content within CEO letters</em>, Kris Boudt, James Thewissen</li>
</ul>
<p>Saturday food/networking:<br>
As always, the conference ended with one more trip to <a href="http://jakstap.com/">Jaks Tap</a>. I spent some time giving college students some advice about starting their careers, and discussed the presentation I gave earlier in the week at the <a href="http://www.meetup.com/ChicagoRUG/">Chicago R User Group</a> on <a href="http://files.meetup.com/1625815/ProfilingForSpeed_Ulrich_05-14.pdf">Profiling for Speed</a>.</p>
<p>Last, but not least: none of this would be possible without the support of fantastic sponsors:<br>
<a href="http://business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a>, <a href="http://www.revolutionanalytics.com/">Revolution Analytics</a>, <a href="http://depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a>, <a href="http://www.onetick.com/">OneMarketData</a>, <a href="http://www.rstudio.org/">RStudio</a>, <a href="http://spotfire.tibco.com/">TIBCO</a>, <a href="http://www.symmys.com/arpm-bootcamp">SYMMS</a>, and <a href="http://www.paradigm4.com/">paradigm4</a>.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>It&rsquo;s been more than a month since <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">R/Finance 2014</a>, and my job has finally slowed down enough to allow me to write down my thoughts (though I&rsquo;m writing this over two days during my train to and from Chicago).</p>
<p>The comments below are based on my personal experience. If I don&rsquo;t comment on a seminar or presentation, it doesn&rsquo;t mean I didn&rsquo;t like it or it wasn&rsquo;t good; it may have been over my head or I may have been distracted with my duties as a committee member. All the currently available conference slides are available <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/">on the website</a>.</p>
<p>Friday morning seminar:
<br>
I went to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/workshop/DirkEddelbuettel.pdf">Dirk Eddelbuettel&rsquo;s</a> seminar because I may be writing a R package to query <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.deltixlab.com/">Deltix&rsquo;s</a> <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.blogger.com/null"></a> <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.deltixlab.com/solutions/timebase.html">TimeBase</a> database. Deltix provides a C++ API, so this is a perfect opportunity to use Rcpp.</p>
<p>Friday talks:
<br>
The first presentation was given by keynote <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/LukeTierney.pdf">Luke Tierney</a>, who discussed recent and upcoming performance improvements to R, and introduced some new profiling tools in his <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ltierney/Rpkg-proftools">proftools</a> package (and a new <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/ltierney/Rpkg-proftools-GUI">proftools-GUI</a> package).</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/YangLu.pdf">Yang Lu</a> explored the low-risk anomaly on high/low volatility portfolios with similar industry, size, and volume. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/AveryMoon.pdf">Avery Moon</a> discussed how they use R at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.wealthfront.com/">Wealthfront</a> to run cashflow simulations for their tax-loss harvesting strategy. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/StevenPav.pdf">Steven Pav</a> used math and memes to discuss portfolio inference. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/TobiasSetz.pdf">Tobias Setz</a> used the Bayesian Change Point method to analyze time series stability.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/PaulTeetor.pdf">Paul Teetor</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/MatthewClegg.pdf">Matthew Clegg</a> discussed different aspects of pairs trading. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/KentHoxsey.pdf">Kent Hoxsey</a> demonstrated a simple way to explore trading signal expectation. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/MatthewBarry.pdf">Matthew Barry</a> introduced the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/mrbcuda/pbo">pbo</a> package, which implements some of the ideas in the paper, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~papers.ssrn.com/sol3/papers.cfm?abstract_id=2326253">The Probability of Backtest Overfitting</a>.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/AlexiosGhalanos.pdf">Alexios Ghalanos</a> was the day&rsquo;s second keynote, and he discussed smooth transition autoregressive models and his new package, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://bitbucket.org/alexiosg/twinkle">twinkle</a>. Alexios <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~unstarched.net/2014/05/27/twinkletwinkle-little-star/">wrote a post</a> discussing his presentation, which you should definitely read.</p>
<p>Friday food/networking:
<br>
During the two-hour conference reception at UIC, I had some drinks and hors d&rsquo;ouvres, talked with speakers, and meet people I encouraged to attend and/or present. Next was the (optional) dinner at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a>. It was cold and windy again this year, so we were inside the entire night. Same as last year, the food was fantastic, but the conversations were even better.</p>
<p>Saturday talks:
<br>
The first presentation was a lightning talk by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/ChiragAnand.pdf">Chirag Anand</a>, where he introduced the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/eventstudies/">eventstudies</a> package, which is very well done. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/CaseyKing.pptx">Casey King</a> gave an incredibly informative and entertaining presentation on anti-money laundering and suspicious activity reporting in penny stocks using message board posts. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/BryanLewis.pdf">Bryan Lewis</a> introduced his <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/bwlewis/IRL">IRL</a> package and ran a 16 million node network analysis in &lt; 2 minutes on his Chromebook, during his talk. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/StephenRush.pdf">Stephen Rush</a> discussed his work on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~en.wikipedia.org/wiki/VPIN">VPIN</a> (volume synchronized probability of informed trading), while competing with Steven Pav for the &ldquo;presentation with the most memes&rdquo;.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/BobMcDonald.pdf">Bob McDonald</a> gave the third keynote presentation, where he discussed using R to teach derivatives in MBA classes. He also explained his decision to adopt R in terms of valuing an option. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/EricZivot.pdf">Eric Zivot</a> discussed his upcoming book, &ldquo;Modeling Financial Time Series with S-Plus R&rdquo;. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/RohiniGrover.pdf">Rohini Grover</a> measured the imprecision of implied volatility estimates in volatility indexes using the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://r-forge.r-project.org/projects/ifrogs/">ifrogs</a> package.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/BillCleveland.pdf">Bill Cleveland</a> gave the final keynote and talked about the &ldquo;divide-and-recombine&rdquo; method for large, complex data, using R and Hadoop. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/GregorKastner.pdf">Gregor Kastner</a> introduced his <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/stochvol/">stochvol</a> package, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/MatthewDixon.pdf">Matthew Dixon</a> showed how to calibrate stochastic volatility models using his &ldquo;alpha&rdquo; <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/mfrdixon/gpusvcalibration">gpusvcalibration</a> package. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2014/talk/DirkEddelbuettel.pdf">Dirk Eddelbuettel</a> closed the conference with a lightning talk on his recently-released <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/RcppRedis/">RcppRedis</a> package.</p>
<p>The committee also presented the awards for best papers. The winners were:</p>
<ul>
<li><em>Portfolio inference with this one weird trick</em>, Steven E. Pav</li>
<li><em>Dealing with Stochastic Volatility in Time Series Using the R Package stochvol</em>, Gregor Kastner</li>
<li><em>Re-Evaluation of the Low-Risk Anomaly in Finance via Matching</em>, Yang Lu, Daniel Wu, Kwok Yu</li>
<li><em>All words are not equal: Sentiment dynamics and information content within CEO letters</em>, Kris Boudt, James Thewissen</li>
</ul>
<p>Saturday food/networking:
<br>
As always, the conference ended with one more trip to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~jakstap.com/">Jaks Tap</a>. I spent some time giving college students some advice about starting their careers, and discussed the presentation I gave earlier in the week at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.meetup.com/ChicagoRUG/">Chicago R User Group</a> on <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~files.meetup.com/1625815/ProfilingForSpeed_Ulrich_05-14.pdf">Profiling for Speed</a>.</p>
<p>Last, but not least: none of this would be possible without the support of fantastic sponsors:
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.revolutionanalytics.com/">Revolution Analytics</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.onetick.com/">OneMarketData</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rstudio.org/">RStudio</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~spotfire.tibco.com/">TIBCO</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.symmys.com/arpm-bootcamp">SYMMS</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.paradigm4.com/">paradigm4</a>.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672400/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672400/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2014/03/intro-to-portfolioanalytics/</feedburner:origLink><title>Introduction to PortfolioAnalytics</title><link>https://feeds.feedblitz.com/~/748672403/0/fosstrading/</link><pubDate>Sat, 29 Mar 2014 12:25:00 -0500</pubDate><guid>https://blog.fosstrading.com/2014/03/intro-to-portfolioanalytics/</guid><description><![CDATA[<p>This is a guest post by Ross Bennett. Ross is currently enrolled in the University of Washington Master of Science in Computational Finance &amp; Risk Management program with an expected graduation date of December 2014. He worked on the PortfolioAnalytics package as part of the Google Summer of Code 2013 project and continues to work on the package as a Research Assistant at the University of Washington.</p>
<p>His work on the package focused on implementing a portfolio specification to separate and modularize assets, constraints, and objectives. Support for additional constraints including group, diversification, and factor exposure constraints was also added. The random portfolio solver was expanded to include two additional methods of generating random portfolios. The optimization backends were further standardized for sets of constraints and objectives that can be solved via linear and quadratic programming solvers using the ROI package. Charts including risk budget and efficient frontiers were added as well as standardizing the charting across all optimization engines.</p>
<p>This post is meant to provide a very basic introduction to the PortfolioAnalytics package. PortfolioAnalytics is an R package designed to provide numerical solutions and visualizations for portfolio problems with complex constraints and objectives. A key feature of PortfolioAnalytics is the ability to specify a portfolio with assets, constraints, and objectives that is solver agnostic, where the objective can be comprised of any valid R function. PortfolioAnalytics utilizes multiple solvers as backends for the optimization; linear programming, quadratic programming, differential evolution, random portfolios, particle swarm, and generalized simulated annealing. For optimization problems that can be formulated as linear or quadratic problems, these can be solved very fast and efficiently using the appropriate linear or quadratic solver supported by PortfolioAnalytics. For optimization problems with more complex constraints and objectives, a global solver such as differential evolution or random portfolios can be used to find a solution.</p>
<p>Ross will be giving a tutorial on PortfolioAnalytics at the <a href="http://www.rinfinance.com">R/Finance 2014 Conference</a>. The tutorial will cover the key features of PortfolioAnalytics along with several comprehensive examples. Those who want to learn more about how R is used in finance are encouraged to attend.</p>
<p>The primary functions in PortfolioAnalytics to specify a portfolio with constraints and objectives are <code>portfolio.spec()</code>, <code>add.constraint()</code>, and <code>add.objective()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">PortfolioAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">edhec</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">edhec[</span><span class="p">,</span> <span class="m">1</span><span class="o">:</span><span class="m">6</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="n">funds</span> <span class="o">&lt;-</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span></code></pre></div><p>Here we create a portfolio object with <code>portfolio.spec()</code>. The <code>assets</code> argument is a required argument to the <code>portfolio.spec()</code> function. <code>assets</code> can be a character vector with the names of the assets, a named numeric vector, or a scalar value specifying the number of assets. If a character vector or scalar value is passed in for <code>assets</code>, equal weights will be created for the initial portfolio weights.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">portfolio.spec</span><span class="p">(</span><span class="n">assets</span> <span class="o">=</span> <span class="n">funds</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>portfolio</code> object is an S3 class that contains portfolio level data as well as the constraints and objectives for the optimization problem. You can see that the constraints and objectives lists are currently empty, but we will add sets of constraints and objectives with <code>add.constraint()</code> and <code>add.objective()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print.default</span><span class="p">(</span><span class="n">init.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.1667 0.1667 0.1667 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.1667 0.1667 0.1667 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $category_labels </span>
</span></span><span class="line"><span class="cl"><span class="c1">## NULL </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $weight_seq </span>
</span></span><span class="line"><span class="cl"><span class="c1">## NULL </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## list() </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## list() </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $call </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## attr(,&#34;class&#34;) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;portfolio.spec&#34; &#34;portfolio&#34; </span>
</span></span></code></pre></div><p>Here we add the full investment constraint. The full investment constraint is a special case of the leverage constraint that specifies the weights must sum to 1 and is specified with the alias <code>type=&quot;full_investment&quot;</code> as shown below.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.constraint</span><span class="p">(</span><span class="n">portfolio</span> <span class="o">=</span> <span class="n">init.portfolio</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;full_investment&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Now we add box constraint to specify a long only portfolio. The long only constraint is a special case of a box constraint where the lower bound of the weights of each asset is equal to 0 and the upper bound of the weights of each asset is equal to 1. This is specified with <code>type=&quot;long_only&quot;</code> as shown below. The box constraint also allows for per asset weights to be specified.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.constraint</span><span class="p">(</span><span class="n">portfolio</span> <span class="o">=</span> <span class="n">init.portfolio</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;long_only&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The following constraint types are supported:</p>
<ul>
<li>leverage</li>
<li>box</li>
<li>group</li>
<li>position_limit1</li>
<li>turnover2</li>
<li>diversification</li>
<li>return</li>
<li>factor_exposure</li>
<li>transaction_cost2</li>
</ul>
<ol>
<li>Not supported for problems formulated as quadratic programming problems solved with <code>optimize_method=&quot;ROI&quot;</code>.</li>
<li>Not supported for problems formulated as linear programming problems solved with <code>optimize_method=&quot;ROI&quot;</code>.</li>
</ol>
<p>Below we create two new portfolio objects. Note that we areassigning new names for the portfolios. This re-uses the constraints from <code>init.portfolio()</code> and adds the objectives specified below to <code>minSD.portfolio</code> and <code>meanES.portfolio</code> while leaving <code>init.portfolio</code> unchanged. This is useful for testing multiple portfolios with different objectives using the same constraints because the constraints only need to be specified once and several new portfolios can be created using an initial portfolio object.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Add objective for portfolio to minimize portfolio standard deviation </span>
</span></span><span class="line"><span class="cl"><span class="n">minSD.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">init.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;risk&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;StdDev&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Add objectives for portfolio to maximize mean per unit ES </span>
</span></span><span class="line"><span class="cl"><span class="n">meanES.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">init.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;return&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;mean&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">meanES.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">meanES.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;risk&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;ES&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that the <code>name</code> argument in <code>add.objective()</code> can be any valid R function. Several functions are provided in the PerformanceAnalytics package that can be specified as the <code>name</code> argument such as ES/ETL/CVaR, StdDev, etc.</p>
<p>The following objective types are supported:</p>
<ul>
<li>return</li>
<li>risk</li>
<li>risk_budget</li>
<li>weight_concentration</li>
</ul>
<p>As demonstrated above, the <code>add.constraint()</code> and <code>add.objective()</code> functions were designed to be very flexible and modular so that constraints and objectives can easily be specified and added to <code>portfolio</code> objects.</p>
<p>PortfolioAnalytics provides a <code>print()</code> method so that we can easily view the assets, constraints, and objectives that we have specified for the portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">minSD.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Portfolio Specification </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of assets: 6 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Asset Names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;Convertible Arbitrage&#34; &#34;CTA Global&#34; &#34;Distressed Securities&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [4] &#34;Emerging Markets&#34; &#34;Equity Market Neutral&#34; &#34;Event Driven&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled constraint types </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - full_investment </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - long_only </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled constraints: 0 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of objectives: 1 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled objectives: 1 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled objective names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - StdDev </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled objectives: 0 </span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">meanES.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Portfolio Specification </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of assets: 6 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Asset Names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;Convertible Arbitrage&#34; &#34;CTA Global&#34; &#34;Distressed Securities&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [4] &#34;Emerging Markets&#34; &#34;Equity Market Neutral&#34; &#34;Event Driven&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled constraint types </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - full_investment </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - long_only </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled constraints: 0 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of objectives: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled objectives: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled objective names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - mean </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - ES </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled objectives: 0 </span>
</span></span></code></pre></div><p>Now that we have portfolios set up with the desired constraints and objectives, we use <code>optimize.portfolio()</code> to run the optimizations. The examples below use <code>optimize_method=&quot;ROI&quot;</code>, but several other solvers are supported including the following:</p>
<ul>
<li>DEoptim (differential evolution)</li>
<li>random portfolios
<ul>
<li>sample</li>
<li>simplex</li>
<li>grid</li>
</ul>
</li>
<li>GenSA (generalized simulated annealing)</li>
<li>pso (particle swarm optimization)</li>
<li>ROI (R Optimization Infrastructure)
<ul>
<li>Rglpk</li>
<li>quadprog</li>
</ul>
</li>
</ul>
<p>The objective to minimize standard deviation can be formulated as a quadratic programming problem and can be solved quickly with <code>optimize_method=&quot;ROI&quot;</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Run the optimization for the minimum standard deviation portfolio </span>
</span></span><span class="line"><span class="cl"><span class="n">minSD.opt</span> <span class="o">&lt;-</span> <span class="nf">optimize.portfolio</span><span class="p">(</span><span class="n">R</span> <span class="o">=</span> <span class="n">returns</span><span class="p">,</span> <span class="n">portfolio</span> <span class="o">=</span> <span class="n">minSD.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">optimize_method</span> <span class="o">=</span> <span class="s">&#34;ROI&#34;</span><span class="p">,</span> <span class="n">trace</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">minSD.opt</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Optimization </span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize.portfolio(R = returns, portfolio = minSD.portfolio, </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize_method = &#34;ROI&#34;, trace = TRUE) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Optimal Weights: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.0652 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.9348 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objective Measure: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## StdDev </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.008855 </span>
</span></span></code></pre></div><p>The objective to maximize mean return per ES can be formulated as a linear programming problem and can be solved quickly with <code>optimize_method=&quot;ROI&quot;</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Run the optimization for the maximize mean per unit ES </span>
</span></span><span class="line"><span class="cl"><span class="n">meanES.opt</span> <span class="o">&lt;-</span> <span class="nf">optimize.portfolio</span><span class="p">(</span><span class="n">R</span> <span class="o">=</span> <span class="n">returns</span><span class="p">,</span> <span class="n">portfolio</span> <span class="o">=</span> <span class="n">meanES.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">optimize_method</span> <span class="o">=</span> <span class="s">&#34;ROI&#34;</span><span class="p">,</span> <span class="n">trace</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">meanES.opt</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Optimization </span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize.portfolio(R = returns, portfolio = meanES.portfolio, </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize_method = &#34;ROI&#34;, trace = TRUE) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Optimal Weights: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.2940 0.2509 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.4552 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objective Measure: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## mean </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.006635 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ES </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.01837 </span>
</span></span></code></pre></div><p>The PortfolioAnalytics package provides functions for charting to better understand the optimization problem through visualization. The <code>plot()</code> function produces a plot of of the optimal weights and the optimal portfolio in risk-return space. The optimal weights and chart in risk-return space can be plotted separately with <code>chart.Weights()</code> and <code>chart.RiskReward()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">minSD.opt</span><span class="p">,</span> <span class="n">risk.col</span><span class="o">=</span><span class="s">&#34;StdDev&#34;</span><span class="p">,</span> <span class="n">chart.assets</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span><span class="o">=</span><span class="s">&#34;Min SD Optimization&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">ylim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.0083</span><span class="p">),</span> <span class="n">xlim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.06</span><span class="p">))</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/unnamed-chunk-102.png" alt="" >
</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">meanES.opt</span><span class="p">,</span> <span class="n">chart.assets</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span><span class="o">=</span><span class="s">&#34;Mean ES Optimization&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">ylim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.0083</span><span class="p">),</span> <span class="n">xlim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.16</span><span class="p">))</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/unnamed-chunk-101.png" alt="" >
</p>
<p>This post demonstrates how to construct a portfolio object, add constraints, and add objectives for two simple optimization problems; one to minimize portfolio standard deviation and another to maximize mean return per unit expected shortfall. We then run optimizations on both portfolio objects and plot the results of each portfolio optimization. Although this post demonstrates fairly simple constraints and objectives, PortfolioAnalytics supports complex constraints and objectives as well as many other features that will be covered in subsequent posts.</p>
<p>The PortfolioAnalytics package is part of the <a href="http://r-forge.r-project.org/projects/returnanalytics/">ReturnAnalytics</a> project on R-Forge. For additional examples and information, refer to the several vignettes and demos are provided in the package.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>This is a guest post by Ross Bennett. Ross is currently enrolled in the University of Washington Master of Science in Computational Finance &amp; Risk Management program with an expected graduation date of December 2014. He worked on the PortfolioAnalytics package as part of the Google Summer of Code 2013 project and continues to work on the package as a Research Assistant at the University of Washington.</p>
<p>His work on the package focused on implementing a portfolio specification to separate and modularize assets, constraints, and objectives. Support for additional constraints including group, diversification, and factor exposure constraints was also added. The random portfolio solver was expanded to include two additional methods of generating random portfolios. The optimization backends were further standardized for sets of constraints and objectives that can be solved via linear and quadratic programming solvers using the ROI package. Charts including risk budget and efficient frontiers were added as well as standardizing the charting across all optimization engines.</p>
<p>This post is meant to provide a very basic introduction to the PortfolioAnalytics package. PortfolioAnalytics is an R package designed to provide numerical solutions and visualizations for portfolio problems with complex constraints and objectives. A key feature of PortfolioAnalytics is the ability to specify a portfolio with assets, constraints, and objectives that is solver agnostic, where the objective can be comprised of any valid R function. PortfolioAnalytics utilizes multiple solvers as backends for the optimization; linear programming, quadratic programming, differential evolution, random portfolios, particle swarm, and generalized simulated annealing. For optimization problems that can be formulated as linear or quadratic problems, these can be solved very fast and efficiently using the appropriate linear or quadratic solver supported by PortfolioAnalytics. For optimization problems with more complex constraints and objectives, a global solver such as differential evolution or random portfolios can be used to find a solution.</p>
<p>Ross will be giving a tutorial on PortfolioAnalytics at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com">R/Finance 2014 Conference</a>. The tutorial will cover the key features of PortfolioAnalytics along with several comprehensive examples. Those who want to learn more about how R is used in finance are encouraged to attend.</p>
<p>The primary functions in PortfolioAnalytics to specify a portfolio with constraints and objectives are <code>portfolio.spec()</code>, <code>add.constraint()</code>, and <code>add.objective()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">library</span><span class="p">(</span><span class="n">PortfolioAnalytics</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nf">data</span><span class="p">(</span><span class="n">edhec</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">returns</span> <span class="o">&lt;-</span> <span class="n">edhec[</span><span class="p">,</span> <span class="m">1</span><span class="o">:</span><span class="m">6</span><span class="n">]</span>
</span></span><span class="line"><span class="cl"><span class="n">funds</span> <span class="o">&lt;-</span> <span class="nf">colnames</span><span class="p">(</span><span class="n">returns</span><span class="p">)</span>
</span></span></code></pre></div><p>Here we create a portfolio object with <code>portfolio.spec()</code>. The <code>assets</code> argument is a required argument to the <code>portfolio.spec()</code> function. <code>assets</code> can be a character vector with the names of the assets, a named numeric vector, or a scalar value specifying the number of assets. If a character vector or scalar value is passed in for <code>assets</code>, equal weights will be created for the initial portfolio weights.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">portfolio.spec</span><span class="p">(</span><span class="n">assets</span> <span class="o">=</span> <span class="n">funds</span><span class="p">)</span>
</span></span></code></pre></div><p>The <code>portfolio</code> object is an S3 class that contains portfolio level data as well as the constraints and objectives for the optimization problem. You can see that the constraints and objectives lists are currently empty, but we will add sets of constraints and objectives with <code>add.constraint()</code> and <code>add.objective()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print.default</span><span class="p">(</span><span class="n">init.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## $assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.1667 0.1667 0.1667 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.1667 0.1667 0.1667 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $category_labels </span>
</span></span><span class="line"><span class="cl"><span class="c1">## NULL </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $weight_seq </span>
</span></span><span class="line"><span class="cl"><span class="c1">## NULL </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## list() </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## list() </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## $call </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## attr(,&#34;class&#34;) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;portfolio.spec&#34; &#34;portfolio&#34; </span>
</span></span></code></pre></div><p>Here we add the full investment constraint. The full investment constraint is a special case of the leverage constraint that specifies the weights must sum to 1 and is specified with the alias <code>type="full_investment"</code> as shown below.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.constraint</span><span class="p">(</span><span class="n">portfolio</span> <span class="o">=</span> <span class="n">init.portfolio</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;full_investment&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Now we add box constraint to specify a long only portfolio. The long only constraint is a special case of a box constraint where the lower bound of the weights of each asset is equal to 0 and the upper bound of the weights of each asset is equal to 1. This is specified with <code>type="long_only"</code> as shown below. The box constraint also allows for per asset weights to be specified.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">init.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.constraint</span><span class="p">(</span><span class="n">portfolio</span> <span class="o">=</span> <span class="n">init.portfolio</span><span class="p">,</span> <span class="n">type</span> <span class="o">=</span> <span class="s">&#34;long_only&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>The following constraint types are supported:</p>
<ul>
<li>leverage</li>
<li>box</li>
<li>group</li>
<li>position_limit1</li>
<li>turnover2</li>
<li>diversification</li>
<li>return</li>
<li>factor_exposure</li>
<li>transaction_cost2</li>
</ul>
<ol>
<li>Not supported for problems formulated as quadratic programming problems solved with <code>optimize_method="ROI"</code>.</li>
<li>Not supported for problems formulated as linear programming problems solved with <code>optimize_method="ROI"</code>.</li>
</ol>
<p>Below we create two new portfolio objects. Note that we areassigning new names for the portfolios. This re-uses the constraints from <code>init.portfolio()</code> and adds the objectives specified below to <code>minSD.portfolio</code> and <code>meanES.portfolio</code> while leaving <code>init.portfolio</code> unchanged. This is useful for testing multiple portfolios with different objectives using the same constraints because the constraints only need to be specified once and several new portfolios can be created using an initial portfolio object.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Add objective for portfolio to minimize portfolio standard deviation </span>
</span></span><span class="line"><span class="cl"><span class="n">minSD.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">init.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;risk&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;StdDev&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Add objectives for portfolio to maximize mean per unit ES </span>
</span></span><span class="line"><span class="cl"><span class="n">meanES.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">init.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;return&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;mean&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">meanES.portfolio</span> <span class="o">&lt;-</span> <span class="nf">add.objective</span><span class="p">(</span><span class="n">portfolio</span><span class="o">=</span><span class="n">meanES.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">type</span><span class="o">=</span><span class="s">&#34;risk&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span><span class="o">=</span><span class="s">&#34;ES&#34;</span><span class="p">)</span>
</span></span></code></pre></div><p>Note that the <code>name</code> argument in <code>add.objective()</code> can be any valid R function. Several functions are provided in the PerformanceAnalytics package that can be specified as the <code>name</code> argument such as ES/ETL/CVaR, StdDev, etc.</p>
<p>The following objective types are supported:</p>
<ul>
<li>return</li>
<li>risk</li>
<li>risk_budget</li>
<li>weight_concentration</li>
</ul>
<p>As demonstrated above, the <code>add.constraint()</code> and <code>add.objective()</code> functions were designed to be very flexible and modular so that constraints and objectives can easily be specified and added to <code>portfolio</code> objects.</p>
<p>PortfolioAnalytics provides a <code>print()</code> method so that we can easily view the assets, constraints, and objectives that we have specified for the portfolio.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">minSD.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Portfolio Specification </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of assets: 6 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Asset Names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;Convertible Arbitrage&#34; &#34;CTA Global&#34; &#34;Distressed Securities&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [4] &#34;Emerging Markets&#34; &#34;Equity Market Neutral&#34; &#34;Event Driven&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled constraint types </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - full_investment </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - long_only </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled constraints: 0 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of objectives: 1 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled objectives: 1 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled objective names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - StdDev </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled objectives: 0 </span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">meanES.portfolio</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Portfolio Specification </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ************************************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## portfolio.spec(assets = funds) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Assets </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of assets: 6 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Asset Names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [1] &#34;Convertible Arbitrage&#34; &#34;CTA Global&#34; &#34;Distressed Securities&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## [4] &#34;Emerging Markets&#34; &#34;Equity Market Neutral&#34; &#34;Event Driven&#34; </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Constraints </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled constraints: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled constraint types </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - full_investment </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - long_only </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled constraints: 0 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objectives </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of objectives: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of enabled objectives: 2 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Enabled objective names </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - mean </span>
</span></span><span class="line"><span class="cl"><span class="c1">## - ES </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Number of disabled objectives: 0 </span>
</span></span></code></pre></div><p>Now that we have portfolios set up with the desired constraints and objectives, we use <code>optimize.portfolio()</code> to run the optimizations. The examples below use <code>optimize_method="ROI"</code>, but several other solvers are supported including the following:</p>
<ul>
<li>DEoptim (differential evolution)</li>
<li>random portfolios
<ul>
<li>sample</li>
<li>simplex</li>
<li>grid</li>
</ul>
</li>
<li>GenSA (generalized simulated annealing)</li>
<li>pso (particle swarm optimization)</li>
<li>ROI (R Optimization Infrastructure)
<ul>
<li>Rglpk</li>
<li>quadprog</li>
</ul>
</li>
</ul>
<p>The objective to minimize standard deviation can be formulated as a quadratic programming problem and can be solved quickly with <code>optimize_method="ROI"</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Run the optimization for the minimum standard deviation portfolio </span>
</span></span><span class="line"><span class="cl"><span class="n">minSD.opt</span> <span class="o">&lt;-</span> <span class="nf">optimize.portfolio</span><span class="p">(</span><span class="n">R</span> <span class="o">=</span> <span class="n">returns</span><span class="p">,</span> <span class="n">portfolio</span> <span class="o">=</span> <span class="n">minSD.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">optimize_method</span> <span class="o">=</span> <span class="s">&#34;ROI&#34;</span><span class="p">,</span> <span class="n">trace</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">minSD.opt</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Optimization </span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize.portfolio(R = returns, portfolio = minSD.portfolio, </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize_method = &#34;ROI&#34;, trace = TRUE) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Optimal Weights: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.0652 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.9348 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objective Measure: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## StdDev </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.008855 </span>
</span></span></code></pre></div><p>The objective to maximize mean return per ES can be formulated as a linear programming problem and can be solved quickly with <code>optimize_method="ROI"</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="c1"># Run the optimization for the maximize mean per unit ES </span>
</span></span><span class="line"><span class="cl"><span class="n">meanES.opt</span> <span class="o">&lt;-</span> <span class="nf">optimize.portfolio</span><span class="p">(</span><span class="n">R</span> <span class="o">=</span> <span class="n">returns</span><span class="p">,</span> <span class="n">portfolio</span> <span class="o">=</span> <span class="n">meanES.portfolio</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">optimize_method</span> <span class="o">=</span> <span class="s">&#34;ROI&#34;</span><span class="p">,</span> <span class="n">trace</span> <span class="o">=</span> <span class="kc">TRUE</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nf">print</span><span class="p">(</span><span class="n">meanES.opt</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## PortfolioAnalytics Optimization </span>
</span></span><span class="line"><span class="cl"><span class="c1">## *********************************** </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Call: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize.portfolio(R = returns, portfolio = meanES.portfolio, </span>
</span></span><span class="line"><span class="cl"><span class="c1">## optimize_method = &#34;ROI&#34;, trace = TRUE) </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Optimal Weights: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Convertible Arbitrage CTA Global Distressed Securities </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.2940 0.2509 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Emerging Markets Equity Market Neutral Event Driven </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.0000 0.4552 0.0000 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## Objective Measure: </span>
</span></span><span class="line"><span class="cl"><span class="c1">## mean </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.006635 </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## </span>
</span></span><span class="line"><span class="cl"><span class="c1">## ES </span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.01837 </span>
</span></span></code></pre></div><p>The PortfolioAnalytics package provides functions for charting to better understand the optimization problem through visualization. The <code>plot()</code> function produces a plot of of the optimal weights and the optimal portfolio in risk-return space. The optimal weights and chart in risk-return space can be plotted separately with <code>chart.Weights()</code> and <code>chart.RiskReward()</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">minSD.opt</span><span class="p">,</span> <span class="n">risk.col</span><span class="o">=</span><span class="s">&#34;StdDev&#34;</span><span class="p">,</span> <span class="n">chart.assets</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span><span class="o">=</span><span class="s">&#34;Min SD Optimization&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">ylim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.0083</span><span class="p">),</span> <span class="n">xlim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.06</span><span class="p">))</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/unnamed-chunk-102.png" alt="" >
</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">plot</span><span class="p">(</span><span class="n">meanES.opt</span><span class="p">,</span> <span class="n">chart.assets</span><span class="o">=</span><span class="kc">TRUE</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">main</span><span class="o">=</span><span class="s">&#34;Mean ES Optimization&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">ylim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.0083</span><span class="p">),</span> <span class="n">xlim</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">0.16</span><span class="p">))</span>
</span></span></code></pre></div><p><img src="https://blog.fosstrading.com/post-images/unnamed-chunk-101.png" alt="" >
</p>
<p>This post demonstrates how to construct a portfolio object, add constraints, and add objectives for two simple optimization problems; one to minimize portfolio standard deviation and another to maximize mean return per unit expected shortfall. We then run optimizations on both portfolio objects and plot the results of each portfolio optimization. Although this post demonstrates fairly simple constraints and objectives, PortfolioAnalytics supports complex constraints and objectives as well as many other features that will be covered in subsequent posts.</p>
<p>The PortfolioAnalytics package is part of the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/projects/returnanalytics/">ReturnAnalytics</a> project on R-Forge. For additional examples and information, refer to the several vignettes and demos are provided in the package.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672403/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672403/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2014/03/rfinance-2014-registration-open/</feedburner:origLink><title>R/Finance 2014 Registration Open</title><link>https://feeds.feedblitz.com/~/748672406/0/fosstrading/</link><pubDate>Sat, 29 Mar 2014 12:24:00 -0500</pubDate><guid>https://blog.fosstrading.com/2014/03/rfinance-2014-registration-open/</guid><description><![CDATA[<p>As announced on the <a href="https://stat.ethz.ch/pipermail/r-sig-finance/2014q1/012330.html">R-SIG-Finance</a> mailing list, registration for R/Finance 2014 is <strong>now open</strong>! The conference will take place May 17 and 18 in Chicago.</p>
<p>Building on the success of the previous conferences in 2009-2013, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 30+ presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="https://www.kellogg.northwestern.edu/faculty/directory/mcdonald_robert.aspx">Bob McDonald</a>, <a href="http://www.stat.purdue.edu/~wsc/">Bill Cleveland</a>, <a href="http://www.unstarched.net/about/">Alexios Ghalanos</a>, and <a href="http://homepage.stat.uiowa.edu/~luke/">Luke Tierney</a>. The main agenda (currently) includes 16 full presentations and 21 shorter &ldquo;lightning talks&rdquo;. We are also excited to offer four optional pre-conference seminars on Friday morning.</p>
<p>The (optional) conference dinner will once-again be held at <a href="http://www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a> Hotel. Overlooking the Chicago river and skyline, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>More details of the agenda are available at:<br>
<a href="http://www.rinfinance.com/agenda/">http://www.RinFinance.com/agenda/</a></p>
<p>Registration information is available at:<br>
<a href="http://www.rinfinance.com/register/">http://www.RinFinance.com/register/</a></p>
<p>and can also be directly accessed by going to:<br>
<a href="http://www.regonline.com/RFinance2014">http://www.regonline.com/RFinance2014</a></p>
<p>We would to thank our 2014 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p><a href="http://business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a></p>
<p><a href="http://www.revolutionanalytics.com/">Revolution Analytics</a><br>
<a href="http://depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a></p>
<p><a href="http://www.onetick.com/">OneMarketData</a><br>
<a href="http://www.rstudio.org/">RStudio</a><br>
<a href="http://spotfire.tibco.com/">TIBCO</a><br>
<a href="http://www.symmys.com/arpm-bootcamp">SYMMS</a><br>
<a href="http://www.paradigm4.com/">paradigm4</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>As announced on the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://stat.ethz.ch/pipermail/r-sig-finance/2014q1/012330.html">R-SIG-Finance</a> mailing list, registration for R/Finance 2014 is <strong>now open</strong>! The conference will take place May 17 and 18 in Chicago.</p>
<p>Building on the success of the previous conferences in 2009-2013, we expect more than 250 attendees from around the world. R users from industry, academia, and government will joining 30+ presenters covering all areas of finance with R.</p>
<p>We are very excited about the four keynote presentations given by <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://www.kellogg.northwestern.edu/faculty/directory/mcdonald_robert.aspx">Bob McDonald</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.stat.purdue.edu/~wsc/">Bill Cleveland</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.unstarched.net/about/">Alexios Ghalanos</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~homepage.stat.uiowa.edu/~luke/">Luke Tierney</a>. The main agenda (currently) includes 16 full presentations and 21 shorter &ldquo;lightning talks&rdquo;. We are also excited to offer four optional pre-conference seminars on Friday morning.</p>
<p>The (optional) conference dinner will once-again be held at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a> Hotel. Overlooking the Chicago river and skyline, it is a perfect venue to continue conversations while dining and drinking.</p>
<p>More details of the agenda are available at:
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/">http://www.RinFinance.com/agenda/</a></p>
<p>Registration information is available at:
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/register/">http://www.RinFinance.com/register/</a></p>
<p>and can also be directly accessed by going to:
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.regonline.com/RFinance2014">http://www.regonline.com/RFinance2014</a></p>
<p>We would to thank our 2014 Sponsors for the continued support enabling us to host such an exciting conference:</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a></p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.revolutionanalytics.com/">Revolution Analytics</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a></p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.onetick.com/">OneMarketData</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rstudio.org/">RStudio</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~spotfire.tibco.com/">TIBCO</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.symmys.com/arpm-bootcamp">SYMMS</a>
<br>
<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.paradigm4.com/">paradigm4</a></p>
<p>On behalf of the committee and sponsors, we look forward to seeing you in Chicago!</p>
<p>Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson, Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672406/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672406/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2013/11/optimizing-quantstrat-from-30-hours-to-30-minutes/</feedburner:origLink><title>Optimizing quantstrat: from 30 hours to 30 minutes</title><link>https://feeds.feedblitz.com/~/920189075/0/fosstrading/</link><pubDate>Mon, 04 Nov 2013 06:37:00 -0600</pubDate><guid>https://blog.fosstrading.com/2013/11/optimizing-quantstrat-from-30-hours-to-30-minutes/</guid><description><![CDATA[<p>The complaint I hear most frequently about quantstrat is that it&rsquo;s slow, especially for large data.  Some of this slow performance is due to quantstrat treating all strategies as path-dependent by default.  Path dependence requires rules to be re-evaluated for each timestamp with a signal.  More signals equates to longer run-times.</p>
<p>If your strategy is not path-dependent, you can get a fairly substantial performance improvement by turning path-dependence off.  If your strategy truly is path-dependent, keep reading&hellip;</p>
<p>I started working with Brian Peterson in late August of this year, and we&rsquo;ve been working on a series of very large backtests over the last several weeks.  Each backtest consisted of ~7 months of 5-second data on 72 instruments with 15-20 different configurations for each.</p>
<p>These backtests really pushed quantstrat to its limits.  The longest-running job took 32 hours.  I had some time while they were running, so I decided to profile quantstrat.  I was able to make some substantial improvements, so I thought I&rsquo;d write a post to tell you what&rsquo;s changed and highlight some of the performance gains we&rsquo;re seeing.</p>
<p>The biggest improvement came from changing how we subset the xts object in <code>ruleOrderProc</code> and <code>ruleSignal</code>. We were using the POSIXct timestamp to get the current row, even though we know the row number. It&rsquo;s much faster to subset an xts object by the row number than a POSIXct object. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">.xts</span><span class="p">(</span><span class="m">1</span><span class="o">:</span><span class="m">1e8</span><span class="p">,</span> <span class="m">1</span><span class="o">:</span><span class="m">1e8</span><span class="p">)</span> <span class="c1"># 10mm obs</span>
</span></span><span class="line"><span class="cl"><span class="n">n</span> <span class="o">&lt;-</span> <span class="m">1e8</span><span class="o">/</span><span class="m">2</span> <span class="c1"># row number</span>
</span></span><span class="line"><span class="cl"><span class="n">i</span> <span class="o">&lt;-</span> <span class="nf">index</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="n">[n]</span> <span class="c1"># timestamp for row &#39;n&#39;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># by POSIXct timestamp</span>
</span></span><span class="line"><span class="cl"><span class="nf">system.time</span><span class="p">(</span><span class="n">x[i</span><span class="p">,</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## user system elapsed</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.181 0.299 0.481</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># by integer (basically instantaneous)</span>
</span></span><span class="line"><span class="cl"><span class="nf">system.time</span><span class="p">(</span><span class="n">x[n</span><span class="p">,</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## user system elapsed</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.001 0.000 0.000</span>
</span></span></code></pre></div><p>This change alone got the job runtime down to just over 2 hours (from 32 hours). If you think I would be happy enough with that, you don&rsquo;t know me.  Several other changes helped get that 2-hour run down to under 30 minutes.</p>
<ul>
<li>
<p>We now calculate <code>periodicity(mktdata)</code> in <code>applyRules</code> and pass that value to <code>ruleOrderProc</code>  This avoids re-calculating that value for every order, since <code>mktdata</code> doesn&rsquo;t change inside <code>applyRules</code></p>
</li>
<li>
<p>The dimension reduction algorithm has to look for the first time the price crosses the limit order price.  We were doing that with a call to <code>which(sigThreshold(...))[1]</code>.  The relational operators (<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>, and <code>==</code>) and <code>which</code> operate on the entire vector, but we only need the first value, so I replaced that code with a with C-based <code>.firstThreshold</code> function that stops as soon as it finds the first cross.</p>
</li>
<li>
<p><code>applyStrategy</code> only accumulates values returned from <code>applyIndicators</code>, <code>applySignals</code>, and <code>applyRules</code> if <code>debug=TRUE</code>.  This saves a little time, but can save a lot of memory for large <code>mktdata</code> objects.</p>
</li>
<li>
<p>The internal <code>ruleProc</code> function now constructs the rule function call using the <code>mktdata</code> symbol instead of its deparsed values. So the rule function call now looks like</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">ruleFunction</span><span class="p">(</span><span class="n">mktdata</span><span class="p">,</span> <span class="kc">...</span><span class="p">)</span>
</span></span></code></pre></div><p>instead of</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">ruleFunction</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="m">50.04</span><span class="p">,</span> <span class="m">50.23</span><span class="p">,</span> <span class="m">50.42</span><span class="p">,</span> <span class="m">50.37</span><span class="p">,</span> <span class="m">50.24</span><span class="p">,</span> <span class="m">50.13</span><span class="p">,</span> <span class="m">50.12</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="m">50.37</span><span class="p">,</span> <span class="m">50.24</span><span class="p">,</span> <span class="m">50.22</span><span class="p">,</span> <span class="m">49.95</span><span class="p">,</span> <span class="m">50.23</span><span class="p">,</span> <span class="m">50.26</span><span class="p">,</span> <span class="m">50.22</span><span class="p">,</span> <span class="m">50.11</span><span class="p">,</span> <span class="m">49.99</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="m">50.33</span><span class="p">,</span> <span class="m">50.33</span><span class="p">,</span> <span class="m">50.18</span><span class="p">,</span> <span class="m">49.99</span><span class="p">),</span> <span class="kc">...</span><span class="p">)</span>
</span></span></code></pre></div><p>You can imagine how large the old call would be for a 10-million-row <code>mktdata</code> object.</p>
</li>
</ul>
<p>All these changes are most significant for large data sets.  The small demo strategies included with quantstrat are also faster, but the net performance gains increase as the size of the data, the number of signals (and therefore the number of rule evaluations), and number of instruments increases.</p>
<p>You&rsquo;re still reading?  What are you waiting for?  Go <a href="https://github.com/braverock/quantstrat">install the latest from GitHub</a> and try it for yourself!</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>The complaint I hear most frequently about quantstrat is that it&rsquo;s slow, especially for large data.  Some of this slow performance is due to quantstrat treating all strategies as path-dependent by default.  Path dependence requires rules to be re-evaluated for each timestamp with a signal.  More signals equates to longer run-times.</p>
<p>If your strategy is not path-dependent, you can get a fairly substantial performance improvement by turning path-dependence off.  If your strategy truly is path-dependent, keep reading&hellip;</p>
<p>I started working with Brian Peterson in late August of this year, and we&rsquo;ve been working on a series of very large backtests over the last several weeks.  Each backtest consisted of ~7 months of 5-second data on 72 instruments with 15-20 different configurations for each.</p>
<p>These backtests really pushed quantstrat to its limits.  The longest-running job took 32 hours.  I had some time while they were running, so I decided to profile quantstrat.  I was able to make some substantial improvements, so I thought I&rsquo;d write a post to tell you what&rsquo;s changed and highlight some of the performance gains we&rsquo;re seeing.</p>
<p>The biggest improvement came from changing how we subset the xts object in <code>ruleOrderProc</code> and <code>ruleSignal</code>. We were using the POSIXct timestamp to get the current row, even though we know the row number. It&rsquo;s much faster to subset an xts object by the row number than a POSIXct object. For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="n">x</span> <span class="o">&lt;-</span> <span class="nf">.xts</span><span class="p">(</span><span class="m">1</span><span class="o">:</span><span class="m">1e8</span><span class="p">,</span> <span class="m">1</span><span class="o">:</span><span class="m">1e8</span><span class="p">)</span> <span class="c1"># 10mm obs</span>
</span></span><span class="line"><span class="cl"><span class="n">n</span> <span class="o">&lt;-</span> <span class="m">1e8</span><span class="o">/</span><span class="m">2</span> <span class="c1"># row number</span>
</span></span><span class="line"><span class="cl"><span class="n">i</span> <span class="o">&lt;-</span> <span class="nf">index</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="n">[n]</span> <span class="c1"># timestamp for row &#39;n&#39;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># by POSIXct timestamp</span>
</span></span><span class="line"><span class="cl"><span class="nf">system.time</span><span class="p">(</span><span class="n">x[i</span><span class="p">,</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## user system elapsed</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.181 0.299 0.481</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># by integer (basically instantaneous)</span>
</span></span><span class="line"><span class="cl"><span class="nf">system.time</span><span class="p">(</span><span class="n">x[n</span><span class="p">,</span><span class="n">]</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">## user system elapsed</span>
</span></span><span class="line"><span class="cl"><span class="c1">## 0.001 0.000 0.000</span>
</span></span></code></pre></div><p>This change alone got the job runtime down to just over 2 hours (from 32 hours). If you think I would be happy enough with that, you don&rsquo;t know me.  Several other changes helped get that 2-hour run down to under 30 minutes.</p>
<ul>
<li>
<p>We now calculate <code>periodicity(mktdata)</code> in <code>applyRules</code> and pass that value to <code>ruleOrderProc</code>  This avoids re-calculating that value for every order, since <code>mktdata</code> doesn&rsquo;t change inside <code>applyRules</code></p>
</li>
<li>
<p>The dimension reduction algorithm has to look for the first time the price crosses the limit order price.  We were doing that with a call to <code>which(sigThreshold(...))[1]</code>.  The relational operators (<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code>, and <code>==</code>) and <code>which</code> operate on the entire vector, but we only need the first value, so I replaced that code with a with C-based <code>.firstThreshold</code> function that stops as soon as it finds the first cross.</p>
</li>
<li>
<p><code>applyStrategy</code> only accumulates values returned from <code>applyIndicators</code>, <code>applySignals</code>, and <code>applyRules</code> if <code>debug=TRUE</code>.  This saves a little time, but can save a lot of memory for large <code>mktdata</code> objects.</p>
</li>
<li>
<p>The internal <code>ruleProc</code> function now constructs the rule function call using the <code>mktdata</code> symbol instead of its deparsed values. So the rule function call now looks like</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">ruleFunction</span><span class="p">(</span><span class="n">mktdata</span><span class="p">,</span> <span class="kc">...</span><span class="p">)</span>
</span></span></code></pre></div><p>instead of</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-r" data-lang="r"><span class="line"><span class="cl"><span class="nf">ruleFunction</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="m">50.04</span><span class="p">,</span> <span class="m">50.23</span><span class="p">,</span> <span class="m">50.42</span><span class="p">,</span> <span class="m">50.37</span><span class="p">,</span> <span class="m">50.24</span><span class="p">,</span> <span class="m">50.13</span><span class="p">,</span> <span class="m">50.12</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="m">50.37</span><span class="p">,</span> <span class="m">50.24</span><span class="p">,</span> <span class="m">50.22</span><span class="p">,</span> <span class="m">49.95</span><span class="p">,</span> <span class="m">50.23</span><span class="p">,</span> <span class="m">50.26</span><span class="p">,</span> <span class="m">50.22</span><span class="p">,</span> <span class="m">50.11</span><span class="p">,</span> <span class="m">49.99</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="m">50.33</span><span class="p">,</span> <span class="m">50.33</span><span class="p">,</span> <span class="m">50.18</span><span class="p">,</span> <span class="m">49.99</span><span class="p">),</span> <span class="kc">...</span><span class="p">)</span>
</span></span></code></pre></div><p>You can imagine how large the old call would be for a 10-million-row <code>mktdata</code> object.</p>
</li>
</ul>
<p>All these changes are most significant for large data sets.  The small demo strategies included with quantstrat are also faster, but the net performance gains increase as the size of the data, the number of signals (and therefore the number of rule evaluations), and number of instruments increases.</p>
<p>You&rsquo;re still reading?  What are you waiting for?  Go <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://github.com/braverock/quantstrat">install the latest from GitHub</a> and try it for yourself!</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/920189075/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/920189075/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2013/10/rfinance-2014-call-for-papers/</feedburner:origLink><title>R/Finance 2014 Call for Papers</title><link>https://feeds.feedblitz.com/~/748672412/0/fosstrading/</link><pubDate>Thu, 17 Oct 2013 20:28:00 -0500</pubDate><guid>https://blog.fosstrading.com/2013/10/rfinance-2014-call-for-papers/</guid><description><![CDATA[<p>We&rsquo;re getting ready for this year&rsquo;s R/Finance conference.  Here&rsquo;s the call for papers.  I hope to see you there!</p>
<p>R/Finance 2014: Applied Finance with R<br>
May 16 and 17, 2014<br>
University of Illinois at Chicago</p>
<p>The sixth annual R/Finance conference for applied finance using <a href="http://draft.blogger.com/">R</a> will be held on May 16 and 17, 2014 in Chicago, IL, USA at the <a href="http://www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past five years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2014.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format), although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks&rdquo;.  Both academic and practitioner proposals related to R are encouraged.</p>
<p>Presenters are strongly encouraged to provide working R code to accompany the presentation/paper.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>The conference will award two (or more) $1000 prizes for best papers.  A submission must be a full paper to be eligible for a best paper award. Extended abstracts, even if a full paper is provided by conference time, are not eligible for a best paper award.  Financial assistance for travel and accommodation may be available to presenters at the discretion of the conference committee. Requests for assistance should be made at the time of submission.</p>
<p>Please submit your papers or abstracts online at: <a href="http://goo.gl/OmKnu7">goo.gl/OmKnu7</a>.  The submission deadline is January 31, 2014.  Submitters will be notified via email by February 28, 2014 of acceptance, presentation length, and decisions on requested funding.</p>
<p>Additional details will be announced via the conference website <a href="http://www.rinfinance.com/">www.RinFinance.com</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website.</p>
<p>For the program committee:<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson,<br>
  Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>We&rsquo;re getting ready for this year&rsquo;s R/Finance conference.  Here&rsquo;s the call for papers.  I hope to see you there!</p>
<p>R/Finance 2014: Applied Finance with R
<br>
May 16 and 17, 2014
<br>
University of Illinois at Chicago</p>
<p>The sixth annual R/Finance conference for applied finance using <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~draft.blogger.com/">R</a> will be held on May 16 and 17, 2014 in Chicago, IL, USA at the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.uic.edu/">University of Illinois at Chicago</a>.  The conference will cover topics including portfolio management, time series analysis, advanced risk tools, high-performance computing, market microstructure, and econometrics. All will be discussed within the context of using R as a primary tool for financial risk management, portfolio construction, and trading.</p>
<p>Over the past five years, R/Finance has included attendees from around the world. It has featured presentations from prominent academics and practitioners, and we anticipate another exciting line-up for 2014.</p>
<p>We invite you to submit complete papers in pdf format for consideration. We will also consider one-page abstracts (in txt or pdf format), although more complete papers are preferred.  We welcome submissions for both full talks and abbreviated &ldquo;lightning talks&rdquo;.  Both academic and practitioner proposals related to R are encouraged.</p>
<p>Presenters are strongly encouraged to provide working R code to accompany the presentation/paper.  Data sets should also be made public for the purposes of reproducibility (though we realize this may be limited due to contracts with data vendors). Preference may be given to presenters who have released R packages.</p>
<p>The conference will award two (or more) $1000 prizes for best papers.  A submission must be a full paper to be eligible for a best paper award. Extended abstracts, even if a full paper is provided by conference time, are not eligible for a best paper award.  Financial assistance for travel and accommodation may be available to presenters at the discretion of the conference committee. Requests for assistance should be made at the time of submission.</p>
<p>Please submit your papers or abstracts online at: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~goo.gl/OmKnu7">goo.gl/OmKnu7</a>.  The submission deadline is January 31, 2014.  Submitters will be notified via email by February 28, 2014 of acceptance, presentation length, and decisions on requested funding.</p>
<p>Additional details will be announced via the conference website <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">www.RinFinance.com</a> as they become available. Information on previous years&rsquo; presenters and their presentations are also at the conference website.</p>
<p>For the program committee:
<br>
Gib Bassett, Peter Carl, Dirk Eddelbuettel, Brian Peterson,
<br>
  Dale Rosenthal, Jeffrey Ryan, Joshua Ulrich</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672412/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672412/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
<item>
<feedburner:origLink>https://blog.fosstrading.com/2013/05/r-finance-2013-review/</feedburner:origLink><title>R/Finance 2013 Review</title><link>https://feeds.feedblitz.com/~/748672415/0/fosstrading/</link><pubDate>Tue, 28 May 2013 08:00:00 -0500</pubDate><guid>https://blog.fosstrading.com/2013/05/r-finance-2013-review/</guid><description><![CDATA[<p>It&rsquo;s been one week since the <a href="http://www.rinfinance.com/">5th Annual R/Finance conference</a>, and I finally feel sufficiently recovered enough to share my thoughts. The conference is a two-day whirlwind of applied quantitative finance, fantastic networking, and general geekery.</p>
<p>The comments below are based on my personal experience.  If I don&rsquo;t comment on a seminar or presentation, it doesn&rsquo;t mean I didn&rsquo;t like it or it wasn&rsquo;t good; it may have been over my head or I may have been distracted with my duties as a committee member.  All the currently available conference slides are available <a href="http://www.rinfinance.com/agenda/">on the website</a>.</p>
<p>Friday morning seminar:<br>
I went to (and live-tweeted) <a href="http://www.rinfinance.com/agenda/2013/workshop/JeffRyan.pdf">Jeff Ryan&rsquo;s seminar</a> because I wanted to learn more about how he uses <a href="http://cran.r-project.org/web/packages/mmap/">mmap</a>+<a href="http://r-forge.r-project.org/projects/indexing">indexing</a> with options data.  There I realized that <a href="http://www.inside-r.org/r-doc/base/DateTimeClasses">POSIXlt</a> components use a zero-based index because they mirror the underlying <a href="http://www.cplusplus.com/reference/ctime/tm/">tm struct</a>, and that mmap+indexing files can be shared across cores and you can read them from other languages (e.g. <a href="http://www.python.org/">Python</a>).</p>
<p>Friday talks:<br>
The first presentation was by keynote <a href="http://www.rinfinance.com/agenda/2013/talk/RyanSheftel.pdf">Ryan Sheftel</a>, who talked about how he uses R on his bond trading desk.  <a href="http://www.rinfinance.com/agenda/2013/talk/DavidArdia.pdf">David Ardia</a> showed how expected returns can be estimated via the covariance matrix.  <a href="http://www.rinfinance.com/agenda/2013/talk/RonaldHochreiter.pdf">Ronald Hochreiter</a> gave an overview of modeling optimization via his <a href="http://www.modopt.com/">modopt</a> package.  Tammer Kamel gave a live demo of the <a href="http://www.quandl.com/help/packages/r">Quandl package</a> and said, &ldquo;Quandl hopes to do to Bloomberg what Wikipedia did to Britannica.&rdquo;</p>
<p>I had the pleasure of introducing both <a href="http://www.rinfinance.com/agenda/2013/talk/DougMartin.pdf">Doug Martin</a>, who talked about robust covariance estimation, and <a href="http://www.rinfinance.com/agenda/2013/talk/GilesHeywood.pdf">Giles Heywood</a>, who discussed several ways of estimating and forecasting covariance, and proposed an &ldquo;open source equity risk and backtest system&rdquo; as a means of matching talent with capital.</p>
<p><a href="http://www.rinfinance.com/agenda/2013/talk/RueyTsay.pdf">Ruey Tsay</a> was the next keynote, and spoke about using principal volatility components to simplify multivariate volatility modeling.  <a href="http://www.rinfinance.com/agenda/2013/talk/AlexiosGhalanos.pdf">Alexios Ghalanos</a> spoke about modeling multivariate time-varying skewness and kurtosis.  Unfortunately, I missed both <a href="http://www.rinfinance.com/agenda/2013/talk/KrisBoudt.pdf">Kris Boudt&rsquo;s</a> and <a href="http://www.rinfinance.com/agenda/2013/talk/DavidMatteson.pdf">David Matteson&rsquo;s</a> presentations, but I did get to see Winston Chang&rsquo;s live demo of <a href="http://www.rstudio.com/shiny/">Shiny</a>.</p>
<p>Friday food/networking:<br>
The two-hour conference reception at UIC was a great time to have a drink, talk with speakers, and say hello to people I had never met in person.  Next was the (optional) dinner at <a href="http://www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a>.  Unfortunately, it was cold and windy, so we only spent 15-20 minutes on the terrace before moving inside.  The food was fantastic, but the conversations were even better.</p>
<p>Saturday talks:</p>
<p>I missed the first block of lightning talks.  <a href="http://www.rinfinance.com/agenda/2013/talk/Azzarello&#43;Putnam.pdf">Samantha Azzarello</a> discussed her work with Blu Putnam, which used a dynamic linear model to evaluate the Fed&rsquo;s performance vis-a-vis the Taylor Rule.  <a href="http://www.rinfinance.com/agenda/2013/talk/JiahanLi.pdf">Jiahan Li</a> used constrained least squares on 4 economic fundamentals to forecast foreign exchange rates.  <a href="http://www.rinfinance.com/agenda/2013/talk/ThomasHarte.pdf">Thomas Harte</a> talked about regulatory requirements of foreign exchange pricing (and wins the award for most slides, 270); basically documentation is important, <a href="http://www.inside-r.org/r-doc/utils/Sweave">Sweave</a> to the rescue!</p>
<p><a href="http://www.rinfinance.com/agenda/2013/talk/SanjivDas.pptx">Sanjiv Das</a> gave a keynote on 4 applications: 1) network analysis on SEC and FDIC filings to determine banks that pose systematic risk, 2) determining which home mortgage modification is optimal, 3) portfolio optimization with mental accounting, 4) venture capital communities.</p>
<p>I had the pleasure of introducing the following speakers: <a href="http://www.rinfinance.com/agenda/2013/talk/DirkEddelbuettel.pdf">Dirk Eddelbuettel</a> showed how it&rsquo;s easy to write fast linear algebra code with <a href="http://cran.r-project.org/web/packages/RcppArmadillo/index.html">RcppArmadillo</a>.  <a href="http://www.rinfinance.com/agenda/2013/talk/KlausSpanderen.pdf">Klaus Spanderen</a> showed how to use <a href="http://quantlib.org/index.shtml">QuantLib</a> from R, and even how to to call C++ from R from C++.  <a href="http://www.rinfinance.com/agenda/2013/talk/BryanLewis.pdf">Bryan Lewis</a> talked about <a href="http://www.scidb.org/">SciDB</a> and the <a href="http://cran.r-project.org/web/packages/scidb/">scidb</a> package (SciDB contains fast linear algebra routines that operate <strong>on</strong> the database!).  <a href="http://www.rinfinance.com/agenda/2013/talk/MatthewDowle.pdf">Matthew Dowle</a> gave an introduction to <a href="http://cran.r-project.org/web/packages/data.table/index.html">data.table</a> (in addition to a seminar).</p>
<p>Attilio Meucci gave his keynote on visualizing advanced risk management and portfolio optimization.  Immediately following, <a href="http://www.rinfinance.com/agenda/2013/talk/BrianPeterson.pdf">Brian Peterson</a> gave a lightning on implementing Meucci&rsquo;s work in R (Attilio works in Matlab), which was part of a Google Summer of Code project last year.</p>
<p><a href="http://www.rinfinance.com/agenda/2013/talk/Chance&#43;Hanson&#43;etal.pdf">Thomas Hanson</a> presented his work with Don Chance (and others) on computational issues in estimating the volatility smile.  <a href="http://www.rinfinance.com/agenda/2013/talk/JeffRyan.pdf">Jeffrey Ryan</a> showed how to manipulate options data in R with the <a href="https://code.google.com/p/rgreeks/">greeks</a> package.</p>
<p>The conference wrapped up by giving away three books, generously donated by Springer, to three random people who submitted feedback surveys.  I performed the random drawing live on stage, using my patent-pending TUMC method (I tossed the papers up in the air).</p>
<p>The committee also presented the awards for best papers.  The winners were: </p>
<ul>
<li><em>Regime switches in volatility and correlation of ﬁnancial institutions</em>, Boudt et. al.</li>
<li><em>A Bayesian interpretation of the Federal Reserve&rsquo;s dual mandate and the Taylor Rule</em>, Putnam &amp; Azzarello</li>
<li><em>Nonparametric Estimation of Stationarity and Change Points in Finance</em>, Matteson et. al.</li>
<li><em>Estimating High Dimensional Covariance Matrix Using a Factor Model</em>, Sun (best student paper)</li>
</ul>
<p>Saturday food/networking:</p>
<p>The whirlwind came to a close at <a href="http://jakstap.com/">Jaks Tap</a>.  I was finally able to ask speed-obsessed Matthew Dowle about potential implementations of a multi-type xts object (a Google Summer of Code project this year).    I also spoke to a few people about how to add options strategy backtesting to quantstrat.</p>
<p>Last, but not least: none of this would be possible without the support of fantastic sponsors: <a href="http://business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a>, <a href="http://www.revolutionanalytics.com/">Revolution Analytics</a>, <a href="http://depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a>, <a href="http://www.google.com/">Google</a>, <a href="http://www.lemnica.com/">lemnica</a>, <a href="http://www.opengamma.com/">OpenGamma</a>, <a href="http://www.onetick.com/">OneMarketData</a>, and <a href="http://www.rstudio.org/">RStudio</a>.</p><div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</description><content:encoded><![CDATA[<p>It&rsquo;s been one week since the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/">5th Annual R/Finance conference</a>, and I finally feel sufficiently recovered enough to share my thoughts. The conference is a two-day whirlwind of applied quantitative finance, fantastic networking, and general geekery.</p>
<p>The comments below are based on my personal experience.  If I don&rsquo;t comment on a seminar or presentation, it doesn&rsquo;t mean I didn&rsquo;t like it or it wasn&rsquo;t good; it may have been over my head or I may have been distracted with my duties as a committee member.  All the currently available conference slides are available <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/">on the website</a>.</p>
<p>Friday morning seminar:
<br>
I went to (and live-tweeted) <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/workshop/JeffRyan.pdf">Jeff Ryan&rsquo;s seminar</a> because I wanted to learn more about how he uses <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/mmap/">mmap</a>+<a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~r-forge.r-project.org/projects/indexing">indexing</a> with options data.  There I realized that <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.inside-r.org/r-doc/base/DateTimeClasses">POSIXlt</a> components use a zero-based index because they mirror the underlying <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.cplusplus.com/reference/ctime/tm/">tm struct</a>, and that mmap+indexing files can be shared across cores and you can read them from other languages (e.g. <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.python.org/">Python</a>).</p>
<p>Friday talks:
<br>
The first presentation was by keynote <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/RyanSheftel.pdf">Ryan Sheftel</a>, who talked about how he uses R on his bond trading desk.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/DavidArdia.pdf">David Ardia</a> showed how expected returns can be estimated via the covariance matrix.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/RonaldHochreiter.pdf">Ronald Hochreiter</a> gave an overview of modeling optimization via his <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.modopt.com/">modopt</a> package.  Tammer Kamel gave a live demo of the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.quandl.com/help/packages/r">Quandl package</a> and said, &ldquo;Quandl hopes to do to Bloomberg what Wikipedia did to Britannica.&rdquo;</p>
<p>I had the pleasure of introducing both <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/DougMartin.pdf">Doug Martin</a>, who talked about robust covariance estimation, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/GilesHeywood.pdf">Giles Heywood</a>, who discussed several ways of estimating and forecasting covariance, and proposed an &ldquo;open source equity risk and backtest system&rdquo; as a means of matching talent with capital.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/RueyTsay.pdf">Ruey Tsay</a> was the next keynote, and spoke about using principal volatility components to simplify multivariate volatility modeling.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/AlexiosGhalanos.pdf">Alexios Ghalanos</a> spoke about modeling multivariate time-varying skewness and kurtosis.  Unfortunately, I missed both <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/KrisBoudt.pdf">Kris Boudt&rsquo;s</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/DavidMatteson.pdf">David Matteson&rsquo;s</a> presentations, but I did get to see Winston Chang&rsquo;s live demo of <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rstudio.com/shiny/">Shiny</a>.</p>
<p>Friday food/networking:
<br>
The two-hour conference reception at UIC was a great time to have a drink, talk with speakers, and say hello to people I had never met in person.  Next was the (optional) dinner at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.trumphotelcollection.com/chicago/rooftop-restaurants-chicago.php">The Terrace at Trump</a>.  Unfortunately, it was cold and windy, so we only spent 15-20 minutes on the terrace before moving inside.  The food was fantastic, but the conversations were even better.</p>
<p>Saturday talks:</p>
<p>I missed the first block of lightning talks.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/Azzarello&#43;Putnam.pdf">Samantha Azzarello</a> discussed her work with Blu Putnam, which used a dynamic linear model to evaluate the Fed&rsquo;s performance vis-a-vis the Taylor Rule.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/JiahanLi.pdf">Jiahan Li</a> used constrained least squares on 4 economic fundamentals to forecast foreign exchange rates.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/ThomasHarte.pdf">Thomas Harte</a> talked about regulatory requirements of foreign exchange pricing (and wins the award for most slides, 270); basically documentation is important, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.inside-r.org/r-doc/utils/Sweave">Sweave</a> to the rescue!</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/SanjivDas.pptx">Sanjiv Das</a> gave a keynote on 4 applications: 1) network analysis on SEC and FDIC filings to determine banks that pose systematic risk, 2) determining which home mortgage modification is optimal, 3) portfolio optimization with mental accounting, 4) venture capital communities.</p>
<p>I had the pleasure of introducing the following speakers: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/DirkEddelbuettel.pdf">Dirk Eddelbuettel</a> showed how it&rsquo;s easy to write fast linear algebra code with <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/RcppArmadillo/index.html">RcppArmadillo</a>.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/KlausSpanderen.pdf">Klaus Spanderen</a> showed how to use <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~quantlib.org/index.shtml">QuantLib</a> from R, and even how to to call C++ from R from C++.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/BryanLewis.pdf">Bryan Lewis</a> talked about <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.scidb.org/">SciDB</a> and the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/scidb/">scidb</a> package (SciDB contains fast linear algebra routines that operate <strong>on</strong> the database!).  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/MatthewDowle.pdf">Matthew Dowle</a> gave an introduction to <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~cran.r-project.org/web/packages/data.table/index.html">data.table</a> (in addition to a seminar).</p>
<p>Attilio Meucci gave his keynote on visualizing advanced risk management and portfolio optimization.  Immediately following, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/BrianPeterson.pdf">Brian Peterson</a> gave a lightning on implementing Meucci&rsquo;s work in R (Attilio works in Matlab), which was part of a Google Summer of Code project last year.</p>
<p><a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/Chance&#43;Hanson&#43;etal.pdf">Thomas Hanson</a> presented his work with Don Chance (and others) on computational issues in estimating the volatility smile.  <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rinfinance.com/agenda/2013/talk/JeffRyan.pdf">Jeffrey Ryan</a> showed how to manipulate options data in R with the <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~https://code.google.com/p/rgreeks/">greeks</a> package.</p>
<p>The conference wrapped up by giving away three books, generously donated by Springer, to three random people who submitted feedback surveys.  I performed the random drawing live on stage, using my patent-pending TUMC method (I tossed the papers up in the air).</p>
<p>The committee also presented the awards for best papers.  The winners were: </p>
<ul>
<li><em>Regime switches in volatility and correlation of ﬁnancial institutions</em>, Boudt et. al.</li>
<li><em>A Bayesian interpretation of the Federal Reserve&rsquo;s dual mandate and the Taylor Rule</em>, Putnam &amp; Azzarello</li>
<li><em>Nonparametric Estimation of Stationarity and Change Points in Finance</em>, Matteson et. al.</li>
<li><em>Estimating High Dimensional Covariance Matrix Using a Factor Model</em>, Sun (best student paper)</li>
</ul>
<p>Saturday food/networking:</p>
<p>The whirlwind came to a close at <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~jakstap.com/">Jaks Tap</a>.  I was finally able to ask speed-obsessed Matthew Dowle about potential implementations of a multi-type xts object (a Google Summer of Code project this year).    I also spoke to a few people about how to add options strategy backtesting to quantstrat.</p>
<p>Last, but not least: none of this would be possible without the support of fantastic sponsors: <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~business.uic.edu/academic-centers-and-research/cba-research-centers/international-center-for-futures-and-derivatives">International Center for Futures and Derivatives at UIC</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.revolutionanalytics.com/">Revolution Analytics</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~depts.washington.edu/compfin/">MS-Computational Finance at University of Washington</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.google.com/">Google</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.lemnica.com/">lemnica</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.opengamma.com/">OpenGamma</a>, <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.onetick.com/">OneMarketData</a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/fosstrading/~www.rstudio.org/">RStudio</a>.</p><Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/748672415/0/fosstrading">
<div style="clear:both;padding-top:0.2em;"><a href="https://feeds.feedblitz.com/_/28/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/16/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/linkedin20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/1/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/reddit20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/24/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a href="https://feeds.feedblitz.com/_/20/748672415/fosstrading"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;</div>]]>
</content:encoded></item>
</channel></rss>

