File Exchange

image thumbnail

CVaR Portfolio Optimization

version 2.0.0 (263 KB) by MathWorks Quant Team
Conditional Value at Risk (CVaR) portfolio optimization with the PortfolioCVaR object

39 Downloads

Updated 18 Sep 2018

View License

This example shows a Conditional Value at Risk (CVaR) portfolio optimization workflow, which includes:
* How to simulate asset scenarios based on normal distribution and the empirical distribution
* How to construct a portfolio using PortfolioCVaR object
* How to evaluate the efficient frontier
* How to extract the portfolio weights
* How to calculate CVaR of the portfolio

Cite As

MathWorks Quant Team (2020). CVaR Portfolio Optimization (https://www.mathworks.com/matlabcentral/fileexchange/38288-cvar-portfolio-optimization), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

i have a question maybe someone can help me. I try to use the simulation, but I already have returns and no courses. Executing the code stumbles over the command = ret = tick2ret (T {:, symbol}) ;. However, I have to create a double for RET. Does anyone know the tool for this?

Tony Tran

I am confused at the following code.

pRet1 = estimatePortReturn(p1,w1);
pRisk1 = estimatePortRisk(p1,w1);
pRet2 = estimatePortReturn(p1,w2); % p2, w2 ???
pRisk2 = estimatePortRisk(p1,w2); % p2, w2 ???

The last two rows should be p2 instead of p1?

Thanks.

Very good video! However, when I try it on my own data the plotAssetHist(symbol,ret) does not seem to work. It tells me "Undefined function 'plotAssetHist' for input arguments of type 'cell'." Is this because symbol is of type "cell"? If yes, why does it work in the video then?

ding wei

Great introduction to CVaR portfolio optimization in Matlab. Since Yahoo closed there historical stock data API could you (Seth DeLand?) provide the matrices that are generated when using "fetch the data" segment of the program?. I want to get a sense of the matrix structure so I can start modifying the code. I'm new to Matlab and computational finance so any help would be greatly appreciated.

Adam

Hello,

I am getting this error:Error using yahoo/fetch (line 387)
Unable to return historical data for given security.

Error in CVaRPortfolioOptimizationExample (line 47)
Price.(bondETFTickers{ii}) = fetch(C,bondETFTickers{ii},...

Barney

Mosif Khan

It's a good example for the PortfolioCVaR object. I had to use tick2ret instead of price2ret.

Updates

2.0.0

Major update for the example using newer capabilities of MATLAB and Toolboxes

1.3.0.1

Updated license

1.3.0.0

Minor code cleanup, fixed some typos in comments.

MATLAB Release Compatibility
Created with R2018a
Compatible with R2018a to any release
Platform Compatibility
Windows macOS Linux