[GSoC-PortA] print and summary methods

Ross Bennett rossbennett34 at gmail.com
Mon Jul 1 22:22:28 CEST 2013


Brian,

That is odd you are getting that for an output, I haven't done any work on
the print or summary methods. What you have outlined below for a print or
summary method makes perfect sense.

I just ran testing_portfolio_**specification.R and here is what I get.
> print(pspec$constraints)
[[1]]
$type
[1] "weight_sum"

$enabled
[1] TRUE

$min_sum
[1] 0.99

$max_sum
[1] 1.01

$call
add.constraint(portfolio = pspec, type = "weight_sum", enabled = TRUE,
    min_sum = 0.99, max_sum = 1.01, indexnum = 1)

attr(,"class")
[1] "weight_sum_constraint" "constraint"

[[2]]
$type
[1] "box"

$enabled
[1] FALSE

$min
Convertible Arbitrage            CTA Global Distressed Securities
                 0.10                  0.05                  0.10
     Emerging Markets Equity Market Neutral
                 0.15                  0.20

$max
Convertible Arbitrage            CTA Global Distressed Securities
                 0.40                  0.40                  0.50
     Emerging Markets Equity Market Neutral
                 0.45                  0.60

$call
add.constraint(portfolio = pspec, type = "box", min = c(0.1,
    0.05, 0.1, 0.15, 0.2), max = c(0.4, 0.4, 0.5, 0.45, 0.6),
    indexnum = 2)

attr(,"class")
[1] "box_constraint" "constraint"

Any idea why we get such different outputs?

Ross

On Mon, Jul 1, 2013 at 2:53 PM, Brian G. Peterson <brian at braverock.com>wrote:

> Ross,
>
> I was just running through your testing scripts.
>
> I notice this in the testing_portfolio_**specification.R output:
>
> $constraints
> $constraints[[1]]
> An object containing 5 constraints.
> Some constraints are of type nonlinear.
>
> $constraints[[2]]
> An object containing 5 constraints.
> Some constraints are of type nonlinear.
>
> There are actually only two constraints slots.  Each of the constraint
> objects has 5 slots in the list, but these are the normal constraints
> slots, not 5 separate constraint objects.
>
> I guess I would expect something more like:
>
> #this is the output of str
>
> $constraints[[1]]
>   ..$ :List of 5
>   .. ..$ type   : chr "weight_sum"
>   .. ..$ enabled: logi TRUE
>   .. ..$ min_sum: num 0.99
>   .. ..$ max_sum: num 1.01
>   .. ..$ call   : language add.constraint(portfolio = pspec, type =
> "weight_sum", enabled = TRUE,      min_sum = 0.99, max_sum = 1.01, indexnum
> = 1)
>   .. ..- attr(*, "class")= chr [1:2] "weight_sum_constraint" "constraint"
> $constraints[[2]]
>   ..$ :List of 5
>   .. ..$ type   : chr "box"
>   .. ..$ enabled: logi FALSE
>   .. ..$ min    : Named num [1:5] 0.1 0.05 0.1 0.15 0.2
>   .. .. ..- attr(*, "names")= chr [1:5] "Convertible Arbitrage" "CTA
> Global" "Distressed Securities" "Emerging Markets" ...
>   .. ..$ max    : Named num [1:5] 0.4 0.4 0.5 0.45 0.6
>   .. .. ..- attr(*, "names")= chr [1:5] "Convertible Arbitrage" "CTA
> Global" "Distressed Securities" "Emerging Markets" ...
>   .. ..$ call   : language add.constraint(portfolio = pspec, type = "box",
> min = c(0.1, 0.05, 0.1,      0.15, 0.2), max = c(0.4, 0.4, 0.5, 0.45, 0.6),
> indexnum = 2)
>   .. ..- attr(*, "class")= chr [1:2] "box_constraint" "constraint"
>
>
> ## or better yet
>
> $constraints[[1]]
> type: 'weight_sum'
> enabled: TRUE
> min_sum: 0.99
> max_sum: 1.01
> $constraints[[2]]
> type: 'box'
> enabled: TRUE
> min: 0.1 0.05 0.1 0.15 0.2
> max: 0.4 0.4 0.5 0.45 0.6
> # these are named, so the named vector would be even better, of course
>
> And similar print methods for objectives?
>
> Thoughts?
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
> ______________________________**_________________
> GSoC-PortA mailing list
> 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/20130701/a46e619e/attachment.html>


More information about the GSoC-PortA mailing list