필터 지우기
필터 지우기

Calculate log return between the first and last observation in a day ?

조회 수: 1 (최근 30일)
NS
NS 2019년 2월 19일
댓글: NS 2019년 2월 20일
I have 1 min prices for each day begining 09:30 to 4:00pm and i need to calculate daily log return i.e. log(close price on the day / opening price on the day)?
Since its possible that some day may not have 09:30 or 4:00 , then i want it to take next time 9:31 if 9:30 is not there and 3:59 if 4:00 pm time is not there . How to do it ? If i split my data into days and wish to calculate log return i.e log(last observation in that day/first observation in that day). How to code this in matlab R2016a?
my data looks like
2014-02-03 09:30:00 10.450000
2014-02-03 09:31:00 10.450000
2014-02-03 09:32:00 10.326600
2014-02-03 09:33:00 10.290000
.
.
2014-02-03 04:00:00 10.326500
...
2014-07-31 09:30:00 15.8500
2014-07-31 09:31:00 15.8600
2014-07-31 09:32:00 15.8600
.
2014-07-31 03:50:00 15.9101
2014-07-31 04:00:00 15.9300

채택된 답변

KSSV
KSSV 2019년 2월 20일
fid = fopen('data.txt','rt') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S = S{1} ;
firstline = S{1}
lastline = S{end}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Price and Analyze Financial Instruments에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by