How do I calculate log returns for stock prices?
32 views (last 30 days)
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?
0 Comments
Answers (1)
dpb
on 19 Apr 2015
Edited: dpb
on 20 Apr 2015
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;
0 Comments
See Also
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!