sharpe ratio in Financial time series toolbox
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
james
le 5 Nov 2024 à 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);
Réponses (1)
Sean de Wolski
le 21 Fév 2013
Just run:
edit sharpe
Scroll down and you can see exactly what it's doing. Looks like likes 75:79 are the engine.
2 commentaires
Voir également
Catégories
En savoir plus sur Risk Management Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!