<div dir="ltr">All,<div><br></div><div>I am working on adding functionality to accept a list of portfolio objects for optimize.portfolio and optimize.portfolio.rebalancing.</div>
<div><br></div><div>I added a block of code at the beginning of optimize.portfolio and optimize.portfolio.rebalancing to detect a list of portfolio objects and then loop through each portfolio in the list of portfolios and recursively call optimize.portfolio or optimize.portfolio.rebalancing. I have a return statement at the end of that block of code. Some frown upon multiple return statements in a function, is it ok that I do this here or is there a different approach I should follow.</div>
<div><br></div><div>I also added <span style="font-family:Menlo;font-size:11px">demo/multiple_portfolio_optimization.R</span> so you can test out the functionality.</div>
<div><br></div><div>I just committed my changes with r3318.</div><div><br></div><div>Ross</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 5, 2014 at 6:54 AM, Ross Bennett <span dir="ltr"><<a href="mailto:rossbennett34@gmail.com" target="_blank">rossbennett34@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Makes a lot more sense from that perspective to avoid making optimize.portfolio and optimize.portfolio.rebalancing S3 generic methods. I'll proceed as you have outlined.<div>
<br></div><div>Thanks for the clarification and guidance.</div><span class="HOEnZb"><font color="#888888">
<div><br></div><div>Ross</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 4, 2014 at 11:29 PM, Brian G. Peterson <span dir="ltr"><<a href="mailto:brian@braverock.com" target="_blank">brian@braverock.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 02/02/2014 10:25 PM, Ross Bennett wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Enhance the print and summary methods for<br>
optimize.portfolio.<u></u>rebalancing. Currently, a list of<br></div>
optimize.portfolio objects at each rebalance period is returned.____<br>
<br>
*/[Doug] So does that imply one can now input a list of portfolio<div><br>
optimization strategy objects to “optimize.portfolio.<u></u>rebalancing”,<br>
e.g., each with different constraints and different objectives?<br></div>
(this would be very useful)/*<div><br>
<br>
<br>
No, that is currently not possible, but should not be too hard to<br>
implement. I could do this for optimize.portfolio as well. I think the<br>
most robust way to implement this would be to make optimize.portfolio()<br>
and optimize.portfolio.<u></u>rebalancing() generic methods.<br>
<br>
This would require a few minor design changes and I don't think it would<br>
break backwards compatibility. We would have to change the order of<br>
arguments for optimize.portfolio() and optimize.portfolio.<u></u>rebalancing()<br>
so that 'portfolio' is the first argument, currently 'R' is the first<br>
argument.<br>
</div></blockquote>
<br>
I think the desired functionality (take a list of portfolio objects) is a good idea.<br>
<br>
I don't think relying on S3 dispatch and making optimize.portfolio.* into S3 generics makes sense though.<br>
<br>
I say this because there's far too much shared code. The sub-functions for the different optimizer methods and special cases are far less code than the wrapper/framework function. I wouldn't want to duplicate all that code, or add a bunch of extra function calls in code that's called lots and lots of times.<br>
<br>
Also, I *really* hate breaking backwards compatibility by rearranging arguments unless there's a compelling reason. For R generics like print/plot/summary, using S3 dispatch is the obvious and only answer, but for optimize.portfolio.*, I'd say leaving the arguments list alone makes the most sense.<br>
<br>
I think you could add the loop over portfolio specification list elements (if it is a list) and collection of the results into a list of optimization results into the optimize.portfolio.* functions without too much work, and without breaking existing code.<br>
<br>
Regards,<br>
<br>
Brian<span><font color="#888888"><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" value="+17734594973" target="_blank">773-459-4973</a><br>
IM: bgpbraverock</font></span><div><div><br>
______________________________<u></u>_________________<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-<u></u>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-<u></u>project.org/cgi-bin/mailman/<u></u>listinfo/gsoc-porta</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>