sharpe ratio in Financial time series toolbox

5 visualizaciones (últimos 30 días)
Kaijie Cui
Kaijie Cui el 21 de Feb. de 2013
Comentada: james el 5 de Nov. de 2024 a las 11:31
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 comentario
james
james el 5 de Nov. de 2024 a las 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);

Iniciar sesión para comentar.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 21 de Feb. de 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 comentarios
Kaijie Cui
Kaijie Cui el 21 de Feb. de 2013
Thank you for your answer. I checked the sharpe source code, the problem is I do not understand what kind of data is the function "sharpe" working with, annual return? monthly? or daily? That might be financial question not Matlab question...
Sean de Wolski
Sean de Wolski el 21 de Feb. de 2013
It describes it in the doc for sharpe and provides an example.

Iniciar sesión para comentar.

Categorías

Más información sobre Risk Management Toolbox en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by