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

1 次查看(过去 30 天)
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