Portfolio Object
Portfolio Object Properties and Functions
ThePortfolio
object implements mean-variance portfolio optimization. Every property and function of thePortfolio
object is public, although some properties and functions are hidden. SeePortfolio
for the properties and functions of thePortfolio
object. ThePortfolio
object is a value object where every instance of the object is a distinct version of the object. Since thePortfolio
object is also a MATLAB®object, it inherits the default functions associated with MATLAB objects.
Working with Portfolio Objects
ThePortfolio
object and its functions are an interface for mean-variance portfolio optimization. So, almost everything you do with thePortfolio
object can be done using the associated functions. The basic workflow is:
Design your portfolio problem.
Use
Portfolio
to create thePortfolio
object or use the variousset
functions to set up your portfolio problem.Use estimate functions to solve your portfolio problem.
In addition, functions are available to help you view intermediate results and to diagnose your computations. Since MATLAB features are part of aPortfolio
object, you can save and load objects from your workspace and create and manipulate arrays of objects. After settling on a problem, which, in the case of mean-variance portfolio optimization, means that you have either data or moments for asset returns and a collection of constraints on your portfolios, usePortfolio
to set the properties for thePortfolio
object.Portfolio
lets you create an object from scratch or update an existing object. Since thePortfolio
object is a value object, it is easy to create a basic object, then use functions to build upon the basic object to create new versions of the basic object. This is useful to compare a basic problem with alternatives derived from the basic problem. For details, seeCreating the Portfolio Object.
Setting and Getting Properties
You can set properties of aPortfolio
object using eitherPortfolio
or variousset
functions.
Note
Although you can also set properties directly, it is not recommended since error-checking is not performed when you set a property directly.
ThePortfolio
object supports setting properties with name-value pair arguments such that each argument name is a property and each value is the value to assign to that property. For example, to set theAssetMean
andAssetCovar
properties in an existingPortfolio
objectp
with the valuesm
andC
, use the syntax:
p = Portfolio(p,'AssetMean', m,'AssetCovar', C);
In addition toPortfolio
, which lets you set individual properties one at a time, groups of properties are set in aPortfolio
object with various “set” and “add” functions. For example, to set up an average turnover constraint, use thesetTurnover
function to specify the bound on portfolio average turnover and the initial portfolio. To get individual properties from a Portfolio object, obtain properties directly or use an assortment of “get” functions that obtain groups of properties from aPortfolio
object. ThePortfolio
object and theset
functions have several useful features:
Portfolio
and theset
functions try to determine the dimensions of your problem with either explicit or implicit inputs.Portfolio
and theset
functions try to resolve ambiguities with default choices.Portfolio
and theset
functions perform scalar expansion on arrays when possible.The associated
Portfolio
object functions try to diagnose and warn about problems.
Displaying Portfolio Objects
ThePortfolio
object uses the default display functions provided by MATLAB, wheredisplay
anddisp
display a Portfolio object and its properties with or without the object variable name.
Saving and Loading Portfolio Objects
Save and loadPortfolio
objects using the MATLABsave
andload
commands.
Estimating Efficient Portfolios and Frontiers
Estimating efficient portfolios and efficient frontiers is the primary purpose of the portfolio optimization tools. Anefficient portfolioare the portfolios that satisfy the criteria of minimum risk for a given level of return and maximum return for a given level of risk. A collection of “estimate” and “plot” functions provide ways to explore the efficient frontier. The “estimate” functions obtain either efficient portfolios or risk and return proxies to form efficient frontiers. At the portfolio level, a collection of functions estimates efficient portfolios on the efficient frontier with functions to obtain efficient portfolios:
At the endpoints of the efficient frontier
That attains targeted values for return proxies
That attains targeted values for risk proxies
Along the entire efficient frontier
These functions also provide purchases and sales needed to shift from an initial or current portfolio to each efficient portfolio. At the efficient frontier level, a collection of functions plot the efficient frontier and estimate either risk or return proxies for efficient portfolios on the efficient frontier. You can use the resultant efficient portfolios or risk and return proxies in subsequent analyses.
Arrays of Portfolio Objects
Although all functions associated with aPortfolio
object are designed to work on a scalarPortfolio
object, the array capabilities of MATLAB enable you to set up and work with arrays ofPortfolio
objects. The easiest way to do this is with therepmat
function. For example, to create a 3-by-2 array ofPortfolio
objects:
p = repmat(Portfolio, 3, 2); disp(p)
disp(p) 3×2 Portfolio array with properties: BuyCost SellCost RiskFreeRate AssetMean AssetCovar TrackingError TrackingPort Turnover BuyTurnover SellTurnover Name NumAssets AssetList InitPort AInequality bInequality AEquality bEquality LowerBound UpperBound LowerBudget UpperBudget GroupMatrix LowerGroup UpperGroup GroupA GroupB LowerRatio UpperRatio MinNumAssets MaxNumAssets BoundType
Portfolio
objects, you can work on individualPortfolio
objects in the array by indexing. For example:p(i,j) = Portfolio(p(i,j), ... );
Portfolio
for the (i
,j
) element of a matrix ofPortfolio
objects in the variablep
.
If you set up an array ofPortfolio
objects, you can access properties of a particularPortfolio
object in the array by indexing so that you can set the lower and upper boundslb
andub
for the (i
,j
,k
) element of a 3-D array ofPortfolio
objects with
p(i,j,k) = setBounds(p(i,j,k),lb, ub);
[lb, ub] = getBounds(p(i,j,k));
Portfolio
object functions work on only onePortfolio
object at a time.
Subclassing Portfolio Objects
You can subclass thePortfolio
object to override existing functions or to add new properties or functions. To do so, create a derived class from thePortfolio
class. This gives you all the properties and functions of thePortfolio
class along with any new features that you choose to add to your subclassed object. ThePortfolio
class is derived from an abstract class calledAbstractPortfolio
. Because of this, you can also create a derived class fromAbstractPortfolio
that implements an entirely different form of portfolio optimization using properties and functions of theAbstractPortfolio
class.
Conventions for Representation of Data
The portfolio optimization tools follow these conventions regarding the representation of different quantities associated with portfolio optimization:
Asset returns or prices are in matrix form with samples for a given asset going down the rows and assets going across the columns. In the case of prices, the earliest dates must be at the top of the matrix, with increasing dates going down.
The mean and covariance of asset returns are stored in a vector and a matrix and the tools have no requirement that the mean must be either a column or row vector.
Portfolios are in vector or matrix form with weights for a given portfolio going down the rows and distinct portfolios going across the columns.
Constraints on portfolios are formed in such a way that a portfolio is a column vector.
Portfolio risks and returns are either scalars or column vectors (for multiple portfolio risks and returns).
See Also
Related Examples
- Creating the Portfolio Object
- Working with Portfolio Constraints Using Defaults
- Asset Allocation Case Study
- Portfolio Optimization Examples
- Portfolio Optimization with Semicontinuous and Cardinality Constraints
- Black-Litterman Portfolio Optimization
- Portfolio Optimization Using Factor Models
- Portfolio Optimization Using a Social Performance Measure
- Diversification of Portfolios