Using Price2Ret to calculate Return

Suppose I have a data with the first column is Date and the second column is Price. I would like to calculate Returns using price2ret and put that information on the third column. Please advise.

댓글 수: 3

And what have you tried so far and where, specifically, did you have a problem following price2retdoc
You need to read the data and pass to the function the data matching the input description...
doc readtable % first step, probably easiest
doc datenum % the time data
Unless the doc is out-of-date; it appears the Econ TB hasn't caught up to using the newer datetime class although I'd recommend you try it and see if it is just a documentation issue...it's what readtable will return for a datestring column.
alpedhuez
alpedhuez 2018년 7월 8일
I have done this and would like to see the code sample because I would think it is a reasonable question that would be of interest.
dpb
dpb 2018년 7월 8일
편집: dpb 2018년 7월 8일
Post your work...I don't have the requisite toolbox nor data to work from. Best would be a small self-contained example illustrating the problem you ran into instead of expecting volunteers to try recreate your (unknownst to us) problem scenario.
What happens with
t=readtable('sample4.xlsx');
[ret,ints]=price2ret(t.Price,t.Date);
??? Does it barf on datetime array?

댓글을 달려면 로그인하십시오.

답변 (1개)

Akshay Srivastava
Akshay Srivastava 2018년 7월 9일

0 개 추천

It will be better, if you could send the code you are working on to understand the exact need of your question and it would help in answering properly.

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품

태그

질문:

2018년 7월 8일

답변:

2018년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by