sharpe ratio in Financial time series toolbox

조회 수: 5 (최근 30일)
Kaijie Cui
Kaijie Cui 2013년 2월 21일
댓글: james 2024년 11월 5일 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
james
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
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
Kaijie Cui
Kaijie Cui 2013년 2월 21일
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 2013년 2월 21일
It describes it in the doc for sharpe and provides an example.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Risk Management Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by