Backward prediction stock time series

1 回表示 (過去 30 日間)
ingCr
ingCr 2021 年 8 月 20 日
コメント済み: ingCr 2021 年 8 月 24 日
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!

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 8 月 20 日
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.
  1 件のコメント
ingCr
ingCr 2021 年 8 月 24 日
Thanks! that helped me a lot. The only thing is that I stil cant make the backward prediction. Keeps telling me that there is a problem with the data structure.
Do you happen to know who to do the same but with a time-series model?
Appreciate your time!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFinancial Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by