<br><br><div class="gmail_quote">On Tue, Jul 16, 2013 at 7:01 PM, Doug Martin <span dir="ltr"><<a href="mailto:martinrd@comcast.net" target="_blank">martinrd@comcast.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">The code in testing_ROI_Martin new.R all seems to work. So I am putting together all the examples for a section in Chapter 2, hopefully finish by tomorrow. But here is a tiny usability improvement needed in the first example with the new interface. The following works fine:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- portfolio.spec(assets=funds)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- add.constraint(portfolio=pspec, type="full_investment", enabled=TRUE)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- add.constraint(portfolio=pspec, type="box", min=-Inf, max=Inf, enabled=TRUE)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- add.objective_v2(portfolio=pspec, type="risk", name="var", enabled=TRUE)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">However, I had expected that the following would also work fine, but does not:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- portfolio.spec(assets=funds)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- add.constraint(portfolio=pspec, type="full_investment", enabled=TRUE)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">pspec <- add.objective_v2(portfolio=pspec, type="risk", name="var", enabled=TRUE)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal">opt <- optimize.portfolio_v2(R=returns, portfolio=pspec, optimize_method="ROI")<u></u><u></u></p>
<p class="MsoNormal">Error in get_constraints(portfolio) : <u></u><u></u></p><p class="MsoNormal"> Box constraints min and max are not enabled or passed in<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">There should be default argument values for box, min and max if not provided, i.e., if box is not provided and group constraints are not provided, it should assume an unconstrained portfolio except for the full investment constraint.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> </span></p></div></div></blockquote><div>I just committed a revision (r2583) that fixes this and sets default values if leverage and box constraints are not specified. The default is set to full investment constraint (min_sum=1 and max_sum=1) if leverage constraints are not specified. The default is set to infinite bounds (min=rep(-Inf, nassets) and max=rep(Inf, nassets)) if box constraints are not specified.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Also, note the following behavior:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">> args(add.constraint)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">function (portfolio, type, enabled = FALSE, ..., indexnum = NULL) <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">NULL<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Is it possible for args to result in additional arguments of function that will make more clear what they are? Or by design are we stuck with the “…” to indicate all the other arguments possible?</span></p>
</div></div></blockquote><div> </div><div>I think we are stuck with "..." to indicate all other arguments for the add.constraint function. However, I have links to the other functions that add the constraints.</div>
<div>?add.constraint and check the "See Also" section. </div><div><br></div><div>Alternatively, if you know the type of constraint and the function, you can get the args of that function.</div><div><div>> args(box_constraint)</div>
<div>function (type, assets, min, max, min_mult, max_mult, enabled = TRUE, </div><div> ...) </div><div>NULL</div></div><div><br></div><div>Thanks for the suggestions and feedback!</div><div>Ross</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><span><font color="#888888"><u></u><u></u></font></span></span></p>
<span><font color="#888888"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Doug<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</font></span></div></div><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><br>
<br></blockquote></div><br>