sharpe ratio in Financial time series toolbox
5 次查看(过去 30 天)
显示 更早的评论
Dear all,
I used the "sharpe" function to calculate the sharpe ratio of my monthly return data. But the result is different from the the function I wrote using the definition from http://financetrainingcourse.com/education/2011/04/market-risk-metrics-sharpe-and-treynor-ratios/.
Here is my code:
RI = (sum(Return))*12/N; % holding period return
MonSigma = std(Return); % monthly volatility
AnuSigma = MonSigma*sqrt(12); % annual volatility
IPO.SharpeRatio = (RI-RIF)/AnuSigma;
could anyone help me out with this?
Thank you.
1 个评论
james
2024-11-5,11:31
% Sharpe Ratio Calculation using Financial Time Series Toolbox
% For more insights on effective intraday strategies, visit:
% Example data: Replace with your actual return series
% Assume 'returns' is a vector of asset returns (e.g., daily returns)
returns = [0.01, -0.005, 0.007, 0.002, -0.003, 0.004, 0.006]; % Sample data
% Define the risk-free rate (annualized). Adjust based on your context.
riskFreeRateAnnual = 0.02; % 2% annual risk-free rate
% Convert annual risk-free rate to the same period as returns (e.g., daily)
% Assuming 252 trading days in a year
riskFreeRate = riskFreeRateAnnual / 252;
% Calculate excess returns
excessReturns = returns - riskFreeRate;
% Compute the mean and standard deviation of excess returns
meanExcessReturn = mean(excessReturns);
stdExcessReturn = std(excessReturns);
% Calculate the Sharpe Ratio (assuming returns are in the same period as risk-free rate)
sharpeRatio = meanExcessReturn / stdExcessReturn;
% Annualize the Sharpe Ratio if needed
% sharpeRatioAnnualized = sharpeRatio * sqrt(252);
% Display the Sharpe Ratio
fprintf('Sharpe Ratio: %.4f\n', sharpeRatio);
% fprintf('Annualized Sharpe Ratio: %.4f\n', sharpeRatioAnnualized);
回答(1 个)
Sean de Wolski
2013-2-21
Just run:
edit sharpe
Scroll down and you can see exactly what it's doing. Looks like likes 75:79 are the engine.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Risk Management Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!