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

1 Ansicht (letzte 30 Tage)
NS
NS am 19 Feb. 2019
Kommentiert: NS am 20 Feb. 2019
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Price and Analyze Financial Instruments finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by