How do I calculate log returns for prices series? i.e. what is the syntax to use the continuous method with the "tick2ret" function?

5 次查看(过去 30 天)
The help documentation for tick2ret suggests that there are two methods (simple and continuous), however it doesn't provide the syntax for choosing the method used. I would like to compute returns using both methods.

回答(1 个)

Moksh
Moksh 2023-11-8
编辑:Moksh 2023-11-17
Hi Brindha,
I understand that you are trying to use the “tick2ret” function in MATLAB for getting return for price series using “continuous” approach.
You can specify the “Method” parameter as “continuous” in the function argument while passing the input to get the required results.
Here is an example code for this:
% Example tick data
tickData = [1; 2; 3; 4; 5];
% Compute returns using the simple method
returns_simple = tick2ret(tickData);
% Compute returns using the continuous method
returns_continuous = tick2ret(tickData, 'Method', 'continuous');
display(returns_continuous);
returns_continuous = 4×1
0.6931 0.4055 0.2877 0.2231
For more information about the “tick2ret” function please refer to the following MATLAB documentation:
Hope this information helps resolve the query.
Best Regards,
Moksh Aggarwal

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by