How do I calculate log returns for stock prices?
Show older comments
I have the coding but I don't know how to do it.
for t=1:length(data)
Logreturn(t+1)=log(data(t+1))-log(data(t));
end
my data is for 10 years. so, t=1 or t=10?
Answers (1)
r=log(data(2:end./data(1:end-1));
Annualized is dependent upon what definition you want--the averaged annualized would then simply be
Ra=mean(r);
the annualized log return over the period is simply
Rp=log(data(end)/data(1))/length(data);
whereas the geometric ROR would be
Rg=(prod(1+r)^^1/length(data))-1;
Categories
Find more on Log Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!