[GSoC-PortA] print and summary methods

Brian G. Peterson brian at braverock.com
Mon Jul 1 21:53:57 CEST 2013


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


More information about the GSoC-PortA mailing list