MATLAB Answers

cumprod 11 period return,and require nan number in no more than 2.

1 ビュー (過去 30 日間)
HAOLUN TIAN
HAOLUN TIAN 2019 年 7 月 3 日
Commented: jeffrey francis 2019 年 7 月 30 日
Hello,
I am calculate the momentun return for 16383 stocks. My data is 611*16383. I have those stock 611 month return. some stocks missing the monthly return.
I try to calculat those stocks 12 month momentum return.
for i = 12;611
idx = returndata(i-11:i-1,:);
A= cumprod(1+idx)
momreturn(i-11,:)=A(end,:)
end
it requied a minimum of nine available monthly returns durning the 11-month measurement. otherwise, the momreturn data are considered missing.
how should i make sure prior 11 month return at least 9 avaliable data?
for example: when calculat a stock t=200 momentum return,if the returndata of this stock durning t=189 to t=199 only have 5 available data, the momentum of this stock in t=200 should be nan.
thanks for your time XD

  1 件のコメント

jeffrey francis
jeffrey francis 2019 年 7 月 30 日
why is cumprod used exactly??

サインイン to comment.

件の回答 (1)

Ganesh Regoti
Ganesh Regoti 2019 年 7 月 30 日
After the calculation of cumulative product use isnan function to check count of the valid data.
count = sum (isnan(A(end,: )));
if (count >2)
%data must be missing;
else
momreturn(i-11,: ) = A(end,: );
end
Hope this helps!

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by