SHARPE RATIO PORTFOLIO OPTIMIZATION

17 visualizaciones (últimos 30 días)
Tran Hua
Tran Hua el 11 de Feb. de 2022
Respondida: nick el 29 de Sept. de 2023
I am trying to calculate the optimal portfolio weight under Sharpe ratio maximization. Although it ran, I am not sure it is the correct answer. I have checked with Excel and it yielded another one (which I think is more accurate since the ratio is actually bigger). In excel it is BAOVIETHOLDING that have 100% weight.
Please help me to detect the error. Really appreciate it. This is my thesis and the deadline is approaching.
Here is my code
load('vn30.mat', 'p15')
symbol = p15.Properties.VariableNames(2:end);
nAsset = numel(symbol);
ret = tick2ret(p15{:,symbol});
p2x = Portfolio('AssetList', symbol,'RiskFreeRate', 0.2567244);
p2x = estimateAssetMoments(p2x, ret);
p2x = setDefaultConstraints(p2x);
w2x = estimateMaxSharpeRatio(p2x);
disp(table(transpose(symbol),w2x))
Var1 w2x _____________________________ ___ {'ASIACOMMERCIAL' } 0 {'BAOVIETHOLDINGS' } 0 {'FPT' } 0 {'HOAPHATGROUP' } 0 {'KHANGDIENHSETRIN' } 0 {'MASANGROUP' } 0 {'PHATDATRLSTDEV' } 0 {'PHUNHUANJEWELRY' } 0 {'SAIGONTHUONGTINREALESTATE'} 0 {'SSISECURITIES' } 0 {'JSTCMLBKFORFRTOFVIETNAM' } 0 {'VTMJSTCMLBKFORINTRD' } 0 {'VIETNAMDAIRYPRODUCTS' } 1 {'VINCOM' } 0

Respuestas (1)

nick
nick el 29 de Sept. de 2023
Hi Tran Hua,
As per my understanding you are facing an issue related to calculation of optimal portfolio under Sharpe Ratio maximisation and have obtained different results on MATLAB and Excel.
The instantiation of Portfolio object with a risk-free rate of 25.67% per day is not practical as such a high risk free rate will lead to negative sharpe ratios. You might want to look at a lower risk-free rate per day that is comparable to the portfolio returns per day.
I have computed under the assumption that the risk-free rate is 2.5% p.a. and there are 252 trading days in a year. Using the code as specified below we attain a Sharpe Ratio of 8.3%
symbol = p15.Properties.VariableNames(2:end);
nAsset = numel(symbol);
dailyret = tick2ret(p15{:,symbol});
p2x = Portfolio('AssetList', symbol, 'RiskFreeRate',0.02567244/252);
p2x = estimateAssetMoments(p2x, dailyret);
p2x = setDefaultConstraints(p2x);
w2x = estimateMaxSharpeRatio(p2x,Method='iterative');
disp(table(transpose(symbol),w2x))
estimatePortSharpeRatio(p2x,w2x)
Assuming that result from Excel is correct and weight of BAVOIETHOLDING is 100%. I have calculated the Sharpe Ratio and it turns out to be 0.53%.
symbol = p15.Properties.VariableNames(2:end);
nAsset = numel(symbol);
dailyret = tick2ret(p15{:,symbol});
p2x = Portfolio('AssetList', symbol, 'RiskFreeRate',0.02567244/252);
p2x = estimateAssetMoments(p2x, dailyret);
p2x = setDefaultConstraints(p2x);
testWeight = zeros(14,1); % The index of BAVOIETHOLDING is 2 in the table
testWeight(2) = 1;% 100% weight allocation to BAVOIETHOLDINGS
disp(table(transpose(symbol),testWeight))
sharpe_w = estimatePortSharpeRatio(p2x,testWeight)
I have also verified the above result via matrix operations under the same assumptions and the Sharpe ratio is 0.53%.
cls=p15(:,["BAOVIETHOLDINGS"]); % Creating subtable with only BAVOIETHOLDINGS
dailyret=(cls{2:end, :}-cls{1:end-1, :})./cls{1:end-1, :}; % Daily Returns
excessRet = dailyret - 0.02567244/252; % Excess daily returns assuming risk-free rate of 2.5% per annum and 252 trading days in a year
sharpeRatio = mean(excessRet)/std(excessRet)
You might have to recheck the calculations performed in Excel by which you have arrived at the results.
I have attached some references to help you familiarize with portfolio optimization.

Categorías

Más información sobre Portfolio Optimization and Asset Allocation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by