<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> gsoc-porta-bounces@lists.r-forge.r-project.org [mailto:gsoc-porta-bounces@lists.r-forge.r-project.org] <b>On Behalf Of </b>Ross Bennett<br><b>Sent:</b> Sunday, July 28, 2013 7:39 PM<br><b>To:</b> PortfolioAnalytics<br><b>Subject:</b> Re: [GSoC-PortA] Constraints and Objectives Separately in Optimize.Portfolio<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>There are a couple different topics in this email thread so I just want to comment on both.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>Specifying constraints and objectives separately<o:p></o:p></p><div><p class=MsoNormal>I'll spend some time on this to get it working. Appreciate the suggestion from Brian to simply insert the constraints/objectives in the appropriate slots into the portfolio object so the optimize.portfolio function and subfunctions can still work off of the portfolio object.<o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[Doug] That will be great.</span></i></b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Backtesting capability<o:p></o:p></p></div><div><p class=MsoNormal>The backtest.weight function we used in class was convenient in that we could specify a function with the FUN argument, but the downside was that we had to write functions for each optimization case (i.e. port.gmv, port.etl, port.lo, etc.).<o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[Doug] I agree.<o:p></o:p></span></i></b></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>As Brian already mentioned, PortfolioAnalytics supports backtesting for an out of sample test<span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[Doug] And according Brian also saves everything you would want, including optimizer trace output, etc.<o:p></o:p></span></i></b></p><p class=MsoNormal> and I have modified it to work with the new portfolio interface. This is nice and modular because the user just has to pass in the return object, portfolio object with the constraints and objectives, and a few other parameters to run the backtest and return the set of weights.<o:p></o:p></p></div><div><div><p class=MsoNormal>opt_rebal <- optimize.portfolio.rebalancing(R=ret, portfolio=pspec, optimize_method="DEoptim", search_size=2000, rebalance_on="quarters")<o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><i><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>[Doug] This is also very good.  So for example with a single objective and many constraints, just need to build a bunch of constraint objects that the user names, and use them as inputs.</span></i></b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p></o:p></span></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Ross<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Sun, Jul 28, 2013 at 1:53 PM, Brian G. Peterson <<a href="mailto:brian@braverock.com" target="_blank">brian@braverock.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal>On 07/28/2013 01:50 PM, Doug Martin wrote:<o:p></o:p></p><p class=MsoNormal>*/[Doug] Indeed, this is crucial.  I did the following with backtest<o:p></o:p></p><div><p class=MsoNormal><br>code I used in the spring – it has a function backtest.weight that<br>generates the time series of rebalanced weights, and looks like this<o:p></o:p></p></div><p class=MsoNormal>locally (one of a bunch of examples):/*<br><br>*//*<br><br>*/weight.mvlub <- backtest.weight(ret, <a href="http://t.mw" target="_blank">t.mw</a>, FUN =<br>"port.mvlub",blo,bup)$weight/*<br><br>*/weight.mveq <- backtest.weight(ret, <a href="http://t.mw" target="_blank">t.mw</a>, port.eq)$weight/*<br><br>*//*<br><br>*/So I’m wondering if we can’t have FUN = optimize.portfolio, and pass<o:p></o:p></p><div><p class=MsoNormal><br>the arguments for constraints and/or ojbectives as in the case of blo<br>and bup for each instance of executing backtest.weight?  I will, as we<br>discussed in Hood River, end up using the PortfolioAnalytics backtest<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>capability./*<br><br>*//*<o:p></o:p></p><p class=MsoNormal><br>Well, optimize.portfolio.rebalancing already exists, and I think covers thae most common use case of periodic rebalancing of a portfolio for an 'out of sample' test of your portfolio specification (w/ constraints/objectives).<br><br>optimize.portfolio.rebalancing already returns the weights used for each rebalancing period, as well as the out of sample returns of the portfolio.<o:p></o:p></p><div><div><p class=MsoNormal><br><br><br>-- <br>Brian G. Peterson<br><a href="http://braverock.com/brian/" target="_blank">http://braverock.com/brian/</a><br>Ph: <a href="tel:773-459-4973" target="_blank">773-459-4973</a><br>IM: bgpbraverock<br>_______________________________________________<br>GSoC-PortA mailing list<br><a href="mailto:GSoC-PortA@lists.r-forge.r-project.org" target="_blank">GSoC-PortA@lists.r-forge.r-project.org</a><br><a href="http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta" target="_blank">http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta</a><o:p></o:p></p></div></div></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>