feasiblePortfolio
Returns a feasible portfolio,
cmlPortfolio
returns the capital market line portfolio,
tangencyPortfolio
returns the tangency portfolio,
minvariancePortfolio
returns the minimum variance portfolio,
efficientPortfolio
returns an efficient portfolio,
portfolioFrontier
returns the efficient frontier,
show
print method for 'fPPORTFOLIO' objects,
plot
plot method for objects of class fPORTFOLIO,
weightsSlider
starts the weights slider,
frontierSlider
starts the efficient frontier Slider. }portfolioFrontier(data, spec = portfolioSpec(), constraints = NULL,
title = NULL, description = NULL)feasiblePortfolio(data, spec = portfolioSpec(), constraints = NULL)
cmlPortfolio(data, spec = portfolioSpec(), constraints = NULL)
tangencyPortfolio(data, spec = portfolioSpec(), constraints = NULL)
minvariancePortfolio(data, spec = portfolioSpec(), constraints = NULL)
efficientPortfolio(data, spec = portfolioSpec(), constraints = NULL)
show.fPORTFOLIO(object)
## S3 method for class 'fPORTFOLIO':
plot(x, which = "ask", control = list(), ...)
## S3 method for class 'fPORTFOLIO':
summary(object, \dots)
weightsSlider(object, control = list(), ...)
frontierSlider(object, control = list(), ...)
"minW[asset]=percentage"
for box constraints resp.
"maxsumW[assets]=percentage"
for sector constraints.minvariance.col
, type of point, e.g.
tangency.pch
, or the dimension of the point, e.g. cml.cex
timeSeries
. If your timeSerie is not a timeSeries
object, consult the generic function as.timeSeries
to
convert your time series.fPORTFOLIO
, containing slots call, data,
specification, constraints, portfolio, title, description, see Value
for a full slot description.fPFOLIOSPEC
, containing slots call, model,
portfolio, title, description, see PortfolioSpec
for a full slot description.which
can be either a
character string, "all"
(displays all plots) or "ask"
(interactively asks which one to display), or a vector of integer
fPORTFOLIO
.portfolioFrontier()
returns an S4 object of class "fPORTFOLIO"
, with the following
slots:series
holding the time series
data if available, otherwise NA, and statistics
, itself a
named list with two named elements mu
and Sigma
holding the vector of means and the matrix of covariances.weights
a numeric vector specifying the portfolio
weights,
targetReturn
a numeric value specifying the target
return,
targetRisk
a numeric value specifying the target
risk,
targetMean
a numeric value specifying the target
return determinated with function mean(),
targetStdev
a numeric value specifying the target risk in
standart deviation as risk measure.spec
which represents an object
of class fPFOLIOSPEC
, including all information about
the portfolio specifications, see PortfolioSpec
for further details.feasiblePortfolio
cmlPortfolio
tangencyPortfolio
minvariancePortfolio
efficientPortfolio
return an S4 object of class fPORTFOLIO
having information only
about one portfolio.portfolioFrontier
calculates the whole efficient frontier.
The portfolio information consists of five arguments: data, specifications,
constraints, title and description. The data can be either the mean vector
and the covariance matrix in a equivalently named list or a time series
table. The specifications are done by the portfolioSpec
function,
see PortfolioSpec
. The constrains have the following
syntax. For bound constraints: "minW[asset]=percentage"
and for
sector constraints "maxsumW[assets]=percentage"
. The function chooses
from this information the right algorithm to calculate the efficient frontier.
The function returns an S4 object of class fPortfolio
containing
amongst others risk, return and weights of the whole efficient frontier,
see Value for further details.
Individual Portfolios:
Individual portfolio functions allow a direct computation of portfolios
with specific properties. The functions are:
feasiblePortfolio
a feasible portfolio,
cmlPortfolio
the capital market line portfolio,
tangencyPortfolio
the tangency portfolio,
minvariancePortfolio
the minimum variance portfolio,
efficientPortfolio
an efficient portfolio. }
The functions require three arguments: data
, spec
(specifications), and constraints
, see above. The functions
are named according to their specific property and return the result
of the computed or optimized portfolio as an S4 object of class
fPortfolio
.
FeasiblePortfolio: The weights are retrieved from the
specification structure, by default they are undefined, NULL
,
and in this case the function feasiblePortfolio
assumes
equal weights. To set user specified weights in the specification
structure, use the function setWeights
.
Portfolio Sliders:
The sliders have illustrative objectives. The functions expect an S4 object
of class fPortfolio.
frontierSlider
: With the frontier slider it is possible to slide
over the efficient frontier. Risk and return of the current portfolio is
plotted in the title. The frontier slider has several addable plot features
listed in the following. Little pies at the current portfolio showing the
weights (left pie) and/or the attributed weights (right pie), legend,
minimum variance portfolio, tangency portfolio, market portfolio with
capital market line (risk free rate is slidable), Sharpe ratio plot, equal
weights portfolio, single asset portfolios, two assets short selling
efficient frontier, Monte Carlo portfolios (number is sliderable in a
range from 0 to 25000).
weightsSlider
: The weights slider gives an overview of the weights
on the efficient frontier. Three weight plots weightsPlot
,
piePlot
and the not stacked weights and a frontier plot with the
single assets, the tangency portfolio and a legend are provided. In the
two weights plots the vertical line indicates the current portfolio and a
dotted one indicates the minimum variance portfolio. The number in the
pie plot stands for the asset and the sign shows whether this asset is
short or long. In all plots colors represent the same asset.PortfolioData
,
PortfolioSpec
,
PortfolioConstraints
,
PortfolioPlots
.## minvariancePortfolio -
# Load Data and Convert to timeSeries Object:
Data = as.timeSeries(data(smallcap.ts))
Data = Data[, c("BKE", "GG", "GYMB", "KRON")]
Data
# Set Default Specifications:
Spec = portfolioSpec()
Spec
# Allow for unlimited Short Selling:
Constraints = "Short"
# Compute Short Selling Minimum Variance Portfolio
minvariancePortfolio(Data, Spec, Constraints)
## portfolioFrontier -
# Modify Constraints - Now Long Only Constraints:
Constraint = c("minW[1:nAssets]=0")
# Calculation of the Efficient Frontier
frontier = portfolioFrontier(Data, Spec, Constraint)
print(frontier)
## plot -
# Plot Efficient Frontier with Minimum Variance Portfolio
# plot(frontier, which = c(1, 3))
## frontierSlider -
# Try Frontier Slider:
# frontierSlider(frontier)
## weightsSlider -
# Try Weights Slider:
# weightsSlider(frontier)
Run the code above in your browser using DataLab