How to calculate risk indicator for a portfolio as Upside Portfolio Ratio, Sterling Ratio, Omega Ratio, Volatility, MAR?
조회 수: 2 (최근 30일)
이전 댓글 표시
Based on the following code, is it possible to have the correct formula to calculate RISK INDICATOR as Upside Portfolio Ratio, Sterling Ratio, Omega Ratio, Volatility, MAR for the portfolio in this code?
clear all;
clc;
NumPorts=2000;
% Set Up the Data
open ("MatlabBOGLE.xlsx");
t = readtable("MatlabBOGLE.xlsx");
symbol = t.Properties.VariableNames(2:end);
dailyreturn= tick2ret(t(:,2:end));
dailyreturn2 = table2array(dailyreturn);
% Create a Portfolio Object (with the risk-free rate)
RiskFreeRate=0.00/252;
p = Portfolio("AssetList",symbol,"RiskFreeRate",RiskFreeRate);
x0 =[0.1,0.1,0.3,0.5,0,0];
p = setInitPort(p,x0);
p = estimateAssetMoments(p,dailyreturn);
[initialrisk,initialreturn] = estimatePortMoments(p,p.InitPort);
display(initialrisk); %"Rischio" Iniziale del lazy Portfolio con le %di allocazioni inalterate
display(initialreturn); %Rendimento Iniziale del lazy Portfolio con le %di allocazioni inalterate
clf;
portfolioexamples_plot('Asset Risks and Returns', ...
{'scatter', initialrisk,initialreturn, {'StartPort'}}, ...
{'scatter', sqrt(diag(p.AssetCovar)), p.AssetMean, p.AssetList, '.r'});
% Set Up a Portfolio Optimization Problem
p=setDefaultConstraints(p);
pwgt = estimateFrontier(p,NumPorts);
[portrisk,portret] = estimatePortMoments (p,pwgt);
figure
portfolioexamples_plot('Efficient Frontier', ...
{'line', portrisk, portret}, ...
{'scatter', initialrisk, initialreturn, {'StartPort'}}, ...
{'scatter', sqrt(diag(p.AssetCovar)), p.AssetMean, p.AssetList, '.r'});
% Maximize the Sharpe Ratio
p = setInitPort(p, x0);
swgt = estimateMaxSharpeRatio(p);
[srsk,sret] = estimatePortMoments(p,swgt);
display(swgt);
display(srsk);
display(sret);
figure
portfolioexamples_plot('Efficient Frontier with Maximum Sharpe Ratio Portfolio', ...
{'line', portrisk, portret}, ...
{'scatter', srsk, sret, {'Sharpe'}}, ...
{'scatter', initialrisk,initialreturn, {'StartPort'}}, ...
{'scatter', sqrt(diag(p.AssetCovar)), p.AssetMean, p.AssetList, '.r'});
댓글 수: 1
Sai Teja G
2023년 8월 25일
Hey, can you share the files related to the code and also try to add your code in proper format.
답변 (1개)
Shivam Lahoti
2024년 1월 3일
Hi Mattia,
I understand that you want to calculate risk Indicators for a portfolio as upside Portfolio Ratio, Sterling Ratio, Omega Ratio, Volatility, and MAR.
- Volatility is already defined as ‘initialrisk’ in your code:
[initialrisk,initialreturn] = estimatePortMoments(p,p.InitPort);
- MAR (Minimum Acceptable Return) is a predefined threshold and is not calculated from the data. You need to define what your MAR is.
- Omega ratio’s calculation requires a defined threshold, let's assume MAR to be the threshold for now. Then Omega ratio could be calculated as:
threshold_return = MAR; % Using MAR as the threshold
gains = dailyreturn2(dailyreturn2 > threshold_return) - threshold_return;
losses = threshold_return - dailyreturn2(dailyreturn2 <= threshold_return);
OmegaRatio = sum(gains) / sum(losses);
- To calculate other Risk indicators, we would require additional data, which is not provided in the provided code.
I hope this was helpful.
Regards,
Shivam Lahoti.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!