Borrar filtros
Borrar filtros

Log return of a timetable

13 visualizaciones (últimos 30 días)
Ruben Moreno
Ruben Moreno el 26 de Mzo. de 2021
Respondida: dpb el 26 de Mzo. de 2021
Hi, i have a timetable with 3 different adj.close prices for three stock indices. I want to calculate the log return of the timeseries for all three without doing it indivdually and loose the timetable, and the timetable has to be adjusted to delete the first date as this naturally has no return.
so far i have only managed to compute the returns of each one individually, but as mentioned i loose the timetable, how can i do this?
the timetable is called data and below you can see the code and each variables name.
logret_GDAXI = (diff(log(data.AdjClose_GDAXI)));
logret_GSPC = diff(log(data.AdjClose_GSPC));
logret_N225 = diff(log(data.AdjClose_N225));

Respuesta aceptada

dpb
dpb el 26 de Mzo. de 2021
To put the computed return at the end time point of the interval, augment the diff vector with a missing-value indicator---
data.logret_GDAXI=[nan;diff(log(data.AdjClose_GDAXI))];
data.logret_GSPC =[nan; diff(log(data.AdjClose_GSPC)];
data.logret_N225 =[nan; diff(log(data.AdjClose_N225)];
Needing to extend the length of a diff series is a very common occurrence to keep sizes same for indexing or other similar purposes.

Más respuestas (0)

Categorías

Más información sobre Time Series en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by