How do I calculate log returns for stock prices?
32 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
dpb
2015-4-19
编辑:dpb
2015-4-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Log Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!