| constraints.realized {PortfolioProbe} | R Documentation |
Returns a matrix containing the bounds, the achieved level, plus the amount it violates the nearest bound or else the proximity to the nearest bound if it is not violated.
constraints.realized(portfol, lin.constraints, prices = portfol$prices,
lin.bounds = portfol$lin.realized[, c("lower", "upper"),
drop=FALSE], lin.trade = portfol$lin.trade,
lin.abs = portfol$lin.abs, lin.style = portfol$lin.style,
lin.direction = portfol$lin.direction, exclude.inf = FALSE)
portfol |
required.
An object of class portfolBurSt (or a similar object).
|
lin.constraints |
required. matrix or data frame describing the linear constraints. |
prices |
named vector of prices containing (at least) all of the assets involved with the constraints. |
lin.bounds |
a two-column matrix giving the bounds for the constraints described
by the input lin.constraints.
|
lin.trade |
logical vector stating which columns of lin.constraints refer to
constraints on the trade (as opposed to on the portfolio).
This is replicated if necessary.
|
lin.abs |
logical vector stating which columns of lin.constraints are
absolute constraints (constraints on the gross as opposed to the net).
This is replicated if necessary.
|
lin.style |
character vector stating the style of each of the linear constraints. |
lin.direction |
numeric vector stating the direction of each of the linear constraints. |
exclude.inf |
logical value stating whether or not (sub)constraints whose
bounds are both infinite should be dropped.
If all bounds are infinite, this is effectively
forced to be FALSE.
|
a matrix with columns that are the bounds, the realized level, the nearest bound if the constraint is not broken, and the distance to the nearest bound if the constraint is broken. Exactly one of the latter two columns is non-missing for each bound. Numbers that are negative mean that the lower bound is the reference, positive numbers mean the upper bound is involved.
If there are no bounds given explicitly or by default, then infinite
bounds are created for all of the constraints and exclude.inf
is forced to be FALSE.
This function produces the lin.realized component of the output
of trade.optimizer – this component is part of the output of
the summary for such objects.
This help was last revised 2009 October 19.
build.constraints, summary.portfolBurSt,
trade.optimizer.
my.sc <- matrix(c("energy", "telecom", "energy", "Germany", "France",
"France"), nrow=3, ncol=2, dimnames=list(c("Asset 1", "Asset 2",
"Asset 3"), c("Sector", "Country")))
my.constr <- build.constraints(my.sc)
my.constr$bounds[,1] <- c(-.05, -.10, 0, .05)
my.constr$bounds[,2] <- c(.15, .15, .20, .55)
op <- trade.optimizer(prices, varian,
lin.constraints=my.constr$lin.constraints,
lin.bounds=my.constr$bounds, gross.value=1e6,
net.value=c(-1e5, 6e5))
constraints.realized(op, my.constr$lin.constraints,
bounds=my.constr$bounds)
op2 <- trade.optimizer(prices, varian, gross.value=1e6,
net.value=c(-1e5, 6e5))
# view values for unconstrained portfolio
constraints.realized(op2, my.constr$lin.constraints)