constraints.realized {PortfolioProbe} | R Documentation

## Show Violations of Linear Constraints

### Description

Returns a list of matrices 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. Components of the list correspond to linear (and count) constraints, and distance constraints.

### Usage

    constraints.realized(portfol, lin.constraints, prices = portfol$prices,
    	lin.table=portfol$lin.table, lin.trade = NULL, lin.abs = NULL,
    	lin.style = NULL, lin.direction = NULL, lin.riskfrac.col = NULL,
    	risk.fraction = portfol$risk.fraction, exclude.inf = FALSE)

### Arguments

`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 (some of) the constraints.
`lin.table` | a data frame describing (some of) the constraints. Values within this can be overridden by the other arguments.
`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.
`lin.riskfrac.col` | numeric vector stating the column of `risk.fraction` to be used in the constraint.
`risk.fraction` | matrix giving the risk fraction values.
`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`.

### Value

a list with component `linear` which itself has components:

`constraints` | matrix containing the realized value for each (sub)constraint, along with possible information pertaining to bounds.
`lin.table` | data frame giving the settings for the constraints.

### Details

If there are no bounds given explicitly or by default for the linear constraints, then infinite bounds are created for all of the constraints and `exclude.inf` is forced to be `FALSE`.

This function produces the `con.realized` component of the output of `trade.optimizer` – this component is part of the output of the `summary` for such objects.

### Revision

This help was last revised 2012 June 06.

### See Also

`build.constraints`, `summary.portfolBurSt`, `trade.optimizer`.

### Examples

    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)

[Package PortfolioProbe version 1.06 Index]