2
# This library is free software; you can redistribute it and/or
3
# modify it under the terms of the GNU Library General Public
4
# License as published by the Free Software Foundation; either
5
# version 2 of the License, or (at your option) any later version.
7
# This library is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR Description. See the
10
# GNU Library General Public License for more details.
12
# You should have received a copy of the GNU Library General
13
# Public License along with this library; if not, write to the
14
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
################################################################################
19
# FUNCTION: DESCRIPTION:
20
# show.fPORTFOLIO S4 Print method for 'fPPORTFOLIO' objects
21
# show.fPFOLIODATA Print method for 'fPFOLIODATA' objects
22
# show.fPFOLIOSPEC Print method for 'fPFOLIOSPEC' objects
23
# show.fPFOLIOCON Print method for 'fPFOLIOCON' objects
25
################################################################################
28
setMethod("show", "fPORTFOLIO",
32
# S4 Print Method for an object of class "fPORTFOLIO"
35
# object - an object of class "fPORTFOLIO"
41
cat(getType(object), getTitle(object), "\n")
42
cat(" Estimator: ", getEstimator(object), "\n")
43
cat(" Solver: ", getSolver(object), "\n")
44
cat(" Optimize: ", getOptimize(object), "\n")
45
cat(" Constraints: ", getConstraintsTypes(object), "\n")
46
if(getType(object) == "CVaR")
47
cat(" VaR Alpha: ", getAlpha(object), "\n")
48
#at(" Objective: ", getObjective(object), "\n")
52
# print.default(getCall(object))
54
# Print Target Weights:
55
cat("\nPortfolio Weights:\n")
56
weights = data.frame(round(getWeights(object), digits = 4))
57
if (NROW(weights) == 1) rownames(weights) = ""
60
# Print Covariance Risk Budgets:
61
cat("\nCovariance Risk Budgets:\n")
62
covRiskBudgets = data.frame(round(getCovRiskBudgets(object), digits = 4))
63
if (NROW(covRiskBudgets) == 1) rownames(covRiskBudgets) = ""
66
# Print Tail Risk Budgets:
68
if (!is.na(getTailRiskBudgets(object))) {
69
cat("\nRiskBudget(s):\n")
70
riskBudgets = round(getTailRiskBudgets(object), digits = 4)
71
print.table(riskBudgets)
75
# Print Target Return and Risks:
76
cat("\nTarget Return and Risks:\n")
77
targetReturn = getTargetReturn(object)
78
targetRisk = getTargetRisk(object)
79
target = data.frame(targetReturn, targetRisk)
80
if (NROW(target) == 1) rownames(target) = ""
81
print(round(target, digits = 4))
84
cat("\nDescription:\n ")
85
cat(getDescription(object), "\n")
92
# ------------------------------------------------------------------------------
95
setMethod("show", "fPFOLIODATA",
99
# S4 Print Method for an object of class "fPFOLIODATA"
102
# object - an object of class "fPFOLIOSPEC"
107
cat("\nSeries Data:\n\n")
108
print(object@data$series)
111
cat("\nStatistics:\n\n")
112
print(object@statistics)
122
# ------------------------------------------------------------------------------
125
setMethod("show", "fPFOLIOSPEC",
129
# S4 Print Method for an object of class "fPFOLIOSPEC"
132
# object - an object of class "fPFOLIOSPEC"
137
cat("\nPortfolio Specification:\t")
138
cat("\n Portfolio Type: ",
141
object@model$optimize)
142
cat("\n Covariance Estimator: ",
143
object@model$estimator)
146
if (!is.null(object@portfolio$weights)) {
147
cat("\n Portfolio Weights: ",
148
object@portfolio$weights)
150
if (!is.null(object@portfolio$targetReturn)) {
151
cat("\n Target Return: ",
152
object@portfolio$targetReturn)
154
if (!is.null(object@portfolio$targetAlpha)) {
155
cat("\n Target Alpha: ",
156
as.character(object@portfolio$targetAlpha))
158
if (!is.null(object@portfolio$riskFreeRate)) {
159
cat("\n Portfolio Risk-Free Rate: ",
160
as.character(object@portfolio$riskFreeRate))
162
if (!is.null(object@portfolio$nFrontierPoints)) {
163
cat("\n Number of Frontier Points:",
164
as.character(object@portfolio$nFrontierPoints))
168
cat("\n Optimizer: ",
169
object@optim$solver, "\n")
176
# ------------------------------------------------------------------------------
179
setMethod("show", "fPFOLIOCON",
183
# S4 Print Method for an object of class "fPFOLIODATA"
186
# object - an object of class "fPFOLIOSPEC"
192
cat("Portfolio Constraints\n")
194
cat("\nConstraint String:\n")
195
print(object@stringConstraints)
197
cat("\nBox Constraints:\n")
198
print(object@boxConstraints)
200
cat("Group-Equal Constraints:\n")
201
print(object@groupEqConstraints)
203
cat("Group-Matrix Constraints:\n")
204
print(object@groupMatConstraints)
206
cat("Cov Risk Budget Constraints:\n")
207
print(object@riskBudgetConstraints)
209
cat("Box/Group Constraints:\n")
210
print(object@boxGroupConstraints)
218
# ------------------------------------------------------------------------------
221
setMethod("show", "fPFOLIOCON",
225
# S4 Print Method for an object of class "fPFOLIODATA"
228
# object - an object of class "fPFOLIOSPEC"
234
cat("Portfolio Constraints\n")
236
minmaxW = rbind(object@minWConstraints, object@maxWConstraints)
237
if (length(minmaxW)) {
238
cat("\nLower/Upper Bounds:\n")
242
eqsumW = object@eqsumWConstraints
243
if (sum(dim(eqsumW)) > 2) {
244
cat("\nEqual Matrix Constraints:\n")
248
minsumW = object@minsumWConstraints
249
if (sum(dim(minsumW)) > 2) {
250
cat("\nLower Matrix Constraints:\n")
254
maxsumW = object@maxsumWConstraints
255
if (sum(dim(minsumW)) > 2) {
256
cat("\nUpper Matrix Constraints:\n")
260
minmaxB = rbind(object@minBConstraints, object@maxBConstraints)
261
if (length(minmaxB) > 0) {
262
cat("\nLower/Upper Cov Risk Budget Bounds:\n")
263
rownames(minmaxB) = c("Lower", "Upper")
272
################################################################################