[GSoC-PortA] structure of the specification objects

Doug Martin martinrd at comcast.net
Thu Jun 20 08:30:15 CEST 2013


This time with the slides.   I will add the examples soon and send.

 

Ross, you will recognize this from 543.

 

Doug

 

 

 

-----Original Message-----
From: gsoc-porta-bounces at lists.r-forge.r-project.org
[mailto:gsoc-porta-bounces at lists.r-forge.r-project.org] On Behalf Of Kris
Boudt
Sent: Tuesday, June 18, 2013 1:35 AM
To: PortfolioAnalytics; gsoc-porta at r-forge.wu-wien.ac.at
Subject: Re: [GSoC-PortA] structure of the specification objects

 

Intrinsically, it means that what we used to call "soft constraints" (the
constraints that can be violated) are classified as "objectives". Seems good
to me, but we need to make sure that each objective has then its
multiplier/scaling factor, which by default is 1, but for soft constraints
will typically be higher.  

 

1.      I would also include a turnover objective, whereby there seem to be
two possibilities:

 

[Doug] It should be noted that turnover can be handled through either
through constraints or a penalty in the objective (see the attached slides).
Last summer I was not very happy with the objective penalty behavior but
need to revisit it.

 

- provide directly the weights at the time of rebalancing

- provide the weights at the previous rebalancing data and include a
function that, uses the return data to calculate the weights at the time of
rebalancing. 

[Doug] We definitely need both of the above options, the second obviously
for back-testing.  

 

2. In practical work,  I work with a price data file that has all possible
constituents and for each selection date a list of allowed constituents.
Typically an xts with in row the selection dates and columns the assets with
1 if included and 0 otherwise. Such a constituents check could be in the
constraints object.

 

[Doug]  This is a good idea. 

[Doug] Thanks.

 

Thanks,

Kris 

 

-----Original Message-----

From:  <mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>
gsoc-porta-bounces at lists.r-forge.r-project.org [
<mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>
mailto:gsoc-porta-bounces at lists.r-forge.r-project.org] On Behalf Of Brian G.
Peterson

Sent: Monday, June 17, 2013 1:51 PM

To:  <mailto:gsoc-porta at r-forge.wu-wien.ac.at>
gsoc-porta at r-forge.wu-wien.ac.at

Subject: [GSoC-PortA] structure of the specification objects

 

I've been thinking a lot about this over the last week, and I'm going to
propose an architecture for discussion.

 

Right now, we have an object of type 'constraints' which also includes
'objectives'.

 

I have always logically separated objectives from constraints in my head by
saying that

- constraints are something that are:

   1. operable only on the weight vector and

   2. metadata information about the portfolio (e.g. groups, asset names)

   3. describe the *inputs* to the objective function

 

- objectives are part of the *objective function* that

   1. you calculate on the weight vector

   2. describe business objectives for the *outcome* of the optimization

 

I think we need to split these apart explicitly, and make the distinctions,
and why they exist, more obvious to the user.

 

First, I think we need a container object of type 'portfolio' or
'portfoliospec' that know what assets you have, and how you want to group
them (e.g. sectors, size, whatever).  This is data about the portfolio, and
is *independent* of and constraints or objectives you might have on that
portfolio.

 

Next, I think we need a constraints object.  Constraints, by their nature,
are tied to the portfolio that they are created for.  They require knowledge
of the portfolio metadata, or at the very least things like box constraints
are typically derived from the size of the portfolio.

 

Finally, I think we need a separate 'objectives' object.  To have objectives
objects, with names, that specify things like minimum variance, maximum
Sharpe ratio, or risk parity objectives.  These can be completely separate
from the assets in the portfolio, and we could provide a number of template
objective objects with the package.  I think the current way objectives are
added and manipulated is fine, we just need to break it off a bit.

 

For the template objectives that can be acted on by specific more efficient
solvers, I think separating the objectives out will make it easier to
identify that.

 

optimize.portfolio needs all three of these components, even today, to do
anything.  So I think we need to sort out how to specify them, then how to
combine them.

 

I suggest that we start by getting these specifications right first. 

Then we can start surgery in other parts of the code to use the new
specification forms.

 

My current thoughts are that a portfolio *contains* one or more constraints
objects, since the constraints objects are dependent on the portfolio
composition.  Then you optimize a portfolio by passing a portfolio
specification into the optimizer, and telling it which constraints object to
use (if you have more than one attached to the

portfolio) and what objectives object you want to apply.

 

Hopefully this is clear.  It's a proposal, so comments/critique/ideas always
welcome.

 

Today is officially the first day of coding, so we need to get moving.

 

Regards,

 

Brian

 

 

 

 

On 06/06/2013 06:54 AM, Ross Bennett wrote:

> Professor Martin,

> 

> Thank you for the feedback. Based on the suggestions from yourself and 

> Brian Peterson, I will start with the constraints portion. I'll spend 

> some more time looking at Kirk Li's code to understand it better and 

> think about how to best integrate into PortfolioAnalytics. I should be 

> able to use some ideas from it.

> 

> I have been reviewing the code for PortfolioAnalytics and it seems 

> that there is already a lot of the infrastructure in place for the 

> constraint object and the optimizer so I don't want to maintain the 

> interface to the optimize.portfolio function as much as possible.

> 

> As an example, here is a code snippet of how box constraints and group 

> constraints are currently specified.

> # General constraints object

> # Box constraints of minimum weight = 0.1 and maximum weight = 0.5 for 

> assets gen.constr <- constraint(assets = colnames(edhec), min=0.1, max 

> =0.5, min_sum=1, max_sum=1)

> 

> # Add group constraints to the gen.constr object groups <- c(3,3,3,4) 

> gen.constr$groups <- groups gen.constr$cLO <- rep(0.15,length(groups)) 

> gen.constr$cUP <- rep(0.30,length(groups))

> 

> Following the outline on the GSOC2013 PortfolioAnalytics rwiki page, 

> we would remove box constraints from the constraint() function and 

> create an add.constraint() function to add/update box, group, and 

> other constraint types as applicable.

> 

> # Create the initial constraint object # Pass in a character vector of 

> asset names for assets # Portfolio weights must sum to 1 (min_sum=1 

> and max_sum=1) gen.constr <- constraint(assets = colnames(edhec), 

> min_sum=1, max_sum=1)

> 

> # Add box constraints with asset weights greater than 0.1 and less 

> than 0.5 gen.constr <- add.constraint(constraints=gen.constr, type="box",

>                                            min=0.1, max=0.5)

> 

> # Group constraints for 10 assets

> # Separate assets into groups of 3, 3, and 4 assets # Specify the 

> group weights as a vector # The first 3 assets shall have a group 

> weight of greater than 0.15 and less than 0.3 # The next 3 assets 

> shall have a group weight of greater than 0.1 and less than 0.35 # The 

> last 4 assets shall have a group weight greater than 0 and less than

> 0.4 constr <- add.constraint(constraints=constr, type="group",

>                                      groups=c(3, 3, 4),

>                                      group_min=c(0.15, 0.1, 0),

>                                      group_max=c(0.3, 0.35, 0.4))

> 

> This keeps the constraint object and interface to optimize.portfolio() 

> consistent with the existing code, but simplifies it and makes adding 

> box and group constraints very similar.

> 

> I will continue to review the PortfolioAnalytics source code and we 

> can revisit this so that I can hit the ground running when finals are 

> over and start as soon as possible.

> 

> Regards,

> Ross Bennett

> 

> 

> On Wed, Jun 5, 2013 at 9:23 AM, Doug Martin <martinrd at comcast.net 

> < <mailto:martinrd at comcast.net> mailto:martinrd at comcast.net>> wrote:

> 

>     Ross and all,____

> 

>     __ __

> 

>     I think starting with the constraints is a good idea.  But I think a

>     review of where PortfolioAnalytics functionality is as of last

>     year's GSoC should be the first priority.  How planning on that week

>     after next (Guy, Eric and I all have finals week to get out of the

>     way next week).____

> 

>     __ __

> 

>     With regard to constraints, that approach that Kirk Li (UW

>     Statistics Ph.D. student and AMATH 543 TA this spring) developed

>     looks useful.  Ross you already have the code which I posted to the

>     class web site.  I have attached it here for others on this project

>     to have a look at.   Let's review that after the end of next week

>     when final exams and the spring quarter are completely behind 

> us.____

> 

>     __ __

> 

>     Doug____

> 

>     __ __

> 

>     __ __

> 

>     *From:*gsoc-porta-bounces at lists.r-forge.r-project.org

>     < <mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>
mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>

>     [mailto:gsoc-porta-bounces at lists.r-forge.r-project.org

>     < <mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>
mailto:gsoc-porta-bounces at lists.r-forge.r-project.org>] *On Behalf

>     Of *Ross Bennett

>     *Sent:* Wednesday, June 05, 2013 4:22 AM

>     *To:*  <mailto:gsoc-porta at lists.r-forge.r-project.org>
gsoc-porta at lists.r-forge.r-project.org

>     < <mailto:gsoc-porta at lists.r-forge.r-project.org>
mailto:gsoc-porta at lists.r-forge.r-project.org>

>     *Subject:* [GSoC-PortA] Schedule for PortfolioAnalytics Coding____

> 

>     __ __

> 

>     All,____

> 

>     __ __

> 

>     In my GSOC proposal, the order of what components I planned to write

>     code for was as follows:____

> 

>      1. Utility Functions (print, summary, plot, etc.)____

>      2. Constraints____

>      3. Example Functionality____

> 

>     In speaking with Brian Peterson at R/Finance, he suggested that the

>     constraints portion be done first. I am fine with doing constraints

>     first. Would you like me to submit a revised schedule and

>     implementation plan with constraints first?____

> 

>     __ __

> 

>     Thanks,____

> 

>     Ross Bennett____

_______________________________________________

GSoC-PortA mailing list

 <mailto:GSoC-PortA at lists.r-forge.r-project.org>
GSoC-PortA at lists.r-forge.r-project.org

 <http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta>
http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta

_______________________________________________

GSoC-PortA mailing list

 <mailto:GSoC-PortA at lists.r-forge.r-project.org>
GSoC-PortA at lists.r-forge.r-project.org

 <http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta>
http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/gsoc-porta

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/gsoc-porta/attachments/20130619/e4a91453/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5. turnover constraints vs turnover objective penalty.ppt
Type: application/vnd.ms-powerpoint
Size: 229888 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/gsoc-porta/attachments/20130619/e4a91453/attachment-0003.ppt>


More information about the GSoC-PortA mailing list