estimatePortMoments
Estimate moments of portfolio returns for Portfolio object
Description
[
estimate moments of portfolio returns for aprsk
,pret
] = estimatePortMoments(obj
,pwgt
)Portfolio
object. For details on the workflow, seePortfolio Object Workflow.
The estimate of port moments is specific to mean-variance portfolio optimization and computes the mean and standard deviation (which is the square-root of variance) of portfolio returns.
Examples
Identify the Range of Risks and Returns for Efficient Portfolios for a Portfolio Object
Given portfoliop
, use theestimatePortMoments
函数显示的范围risks and returns for efficient portfolios.
m = [ 0.05; 0.1; 0.12; 0.18 ]; C = [ 0.0064 0.00408 0.00192 0; 0.00408 0.0289 0.0204 0.0119; 0.00192 0.0204 0.0576 0.0336; 0 0.0119 0.0336 0.1225 ]; p = Portfolio; p = setAssetMoments(p, m, C); p = setDefaultConstraints(p); pwgt = estimateFrontierLimits(p); [prsk, pret] = estimatePortMoments(p, pwgt); disp([prsk, pret]);
0.0769 0.0590 0.3500 0.1800
Identify the Range of Risks and Returns for Efficient PortfoliosPortfolio
Object with Integrality Constraints
Create aPortfolio
object for three assets.
AssetMean = [ 0.0101110; 0.0043532; 0.0137058 ]; AssetCovar = [ 0.00324625 0.00022983 0.00420395; 0.00022983 0.00049937 0.00019247; 0.00420395 0.00019247 0.00764097 ]; p = Portfolio('AssetMean', AssetMean,'AssetCovar', AssetCovar); p = setDefaultConstraints(p);
UsesetBounds
with semi-continuous constraints to setxi=0
or0.02
<=xi
<=0.5
for alli=1
,...NumAssets.
p = setBounds(p, 0.02, 0.5,'BoundType','Conditional','NumAssets', 3);
When working with aPortfolio
object, thesetMinMaxNumAssets
function enables you to set up cardinality constraints for a long-only portfolio. This sets the cardinality constraints for thePortfolio
object, where the total number of allocated assets satisfying the nonzero semi-continuous constraints are betweenMinNumAssets
andMaxNumAssets
. By settingMinNumAssets
=MaxNumAssets
=2, only two of the three assets are invested in the portfolio.
p = setMinMaxNumAssets(p, 2, 2);
UseestimatePortMoments
to estimate moments of portfolio returns for aPortfolio
object.
pwgt = estimateFrontierLimits(p); [prsk, pret] = estimatePortMoments(p, pwgt)
prsk =2×10.0324 0.0695
pret =2×10.0072 0.0119
TheestimatePortMoments
function uses the MINLP solver to solve this problem. Use thesetSolverMINLP
function to configure theSolverType
and options.
p.solverOptionsMINLP
ans =struct with fields:MaxIterations: 1000 AbsoluteGapTolerance: 1.0000e-07 RelativeGapTolerance: 1.0000e-05 NonlinearScalingFactor: 1000 ObjectiveScalingFactor: 1000 Display: 'off' CutGeneration: 'basic' MaxIterationsInactiveCut: 30 ActiveCutTolerance: 1.0000e-07 IntMasterSolverOptions: [1x1 optim.options.Intlinprog] NumIterationsEarlyIntegerConvergence: 30
Calculate Portfolio Weights For a Target Risk Level
ThePortfolio
object is able to find an efficient portfolio with respect to a specified target risk.
Load Portfolio
Load a vector of expected returns and a covariance matrix for 30 stocks.
loadStockStats
CreatePortfolio
Object with Default Constraints
The default constraints for aPortfolio
object are that it is a long-only portfolio and that it is 100% invested. Many other constraint types are possible.
P = Portfolio('mean',expRet,'covar',expCov); P = setDefaultConstraints(P);
Plot Full Efficient Frontier
Use theplotFrontier
function with thePortfolio
object to visualize the full frontier. Other functions exist that allow you to probe into particular portfolios along the frontier.
P.plotFrontier
Capture Upper and Lower Bounds of Portfolio Risks and Returns
It is useful to know what are the upper and lower limits of the portfolio moments along the efficient frontier. This information allows you to determine what are feasible targets. Use theestimateFrontierLimits
function with thePortfolio
object to identify the weights at these extremes. Then you can use theestimatePortMoments
functionPortfolio
object to find the limiting moments.
P_Weights1 = P.estimateFrontierLimits; [P_risklimits, P_returnlimits] = P.estimatePortMoments(P_Weights1)
P_risklimits =2×10.0786 0.2868
P_returnlimits =2×10.0954 0.2370
估计有效Portfolio with Target Return
Select a target return for the portfolio somewhere in the feasible region. You can estimate its makeup withestimateFrontierByRisk
and then confirm its moments usingestimatePortMoments
.
targetReturn = 0.15; P_Weights2 = P.estimateFrontierByReturn(targetReturn); [P_risk2, P_return2] = P.estimatePortMoments(P_Weights2)
P_risk2 = 0.1068
P_return2 = 0.1500
The return matches thetargetReturn
value and the risk is in agreement with the efficient frontier plot.
估计有效Portfolio with Target Risk
ThePortfolio
object is able to find an efficient portfolio with a specified target risk.
targetRisk = 0.2; P_Weights3 = P.estimateFrontierByRisk(targetRisk); [P_risk3, P_return3] = P.estimatePortMoments(P_Weights3)
P_risk3 = 0.2000
P_return3 = 0.2182
Another useful feature of theestimateFrontierByReturn
andestimateFrontierByRisk
functions is what happens if you specify an infeasible (too high or too low) target. In this case, these functions provide a warning message to suggest the best solution.
Input Arguments
obj
—Object for portfolio
object
Object for portfolio, specified using aPortfolio
object. For more information on creating a portfolio object, see
Data Types:object
pwgt
—Collection of portfolios
matrix
Collection of portfolios, specified as aNumAssets
-by-NumPorts
matrix whereNumAssets
is the number of assets in the universe andNumPorts
is the number of portfolios in the collection of portfolios.
Data Types:double
Output Arguments
Tips
You can also use dot notation to estimate the moments of portfolio returns.
[prsk, pret] = obj.estimatePortMoments(pwgt);
Version History
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)