Backward prediction stock time series
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello Everyone,
Im currently writing my thesis and need to backward predict the values of a stock price time series.
I have data of a stock from 2018-2020, but i want to predict the values for 2016-2017 in order to have
a full time series from 2016-2020.
Could you help me with the coding or advice on how to do this? I the data of one of the stocks.
Appreciate you time guys!
0 comentarios
Respuestas (1)
Sulaymon Eshkabilov
el 20 de Ag. de 2021
In this case, you'd need to perform the followings in order to extrapolate backward:
(1) Import data, e.g.:
D = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/717269/PR1C_dailyvalues.xlsx')
(2) Select rows where nans are not present:
IDX = isnan(D.PR1C);
(3) Convert the dates to numbers:
F1 = D(IDX==1,1).Date; F1D = datenum(F1); F1D=F1D-F1D(1)+1;
F2 = D(IDX==0,1).Date; F2D = datenum(F2); F2D=F2D-F2D(1)+1;
Data = D(IDX==0,2).PR1C;
(4) Find a fit model:
FM = fit(F2D,Data,'poly3'); % Cubic polynomial
(5) Compute the extrapolation values:
FIT_Data = polyval(FM, F1D);
% etc.
Ver también
Categorías
Más información sobre Financial Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!