Two ascii data files of minute data not matching up
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two ascii files of minute data of two stocks that are not matching up. I want to run some comparison and test on them. I was able to get them into matlab as financial time series. What I would like to do is get them to line up somehow. One data file has 1100 records, and the other about 1400. Not sure the difference, both came from the same feed. I think that either some of the times there just were not trades and/or maybe the stock was frozen at the time. Regardless I can't run any functions on them since the sizes do not match. What is the best way to either get them the same size by merging somehow
0 commentaires
Réponses (3)
Titus Edelhofer
le 8 Mar 2012
Hi,
you will only find a "good" way to do this, if the ascii files have also the time information stored. If this is the case, it should be fairly easy, e.g., build the union of the two time vectors and interpolate both time series objects to this (common) time using resample.
Then you can compare ...
Titus
0 commentaires
Titus Edelhofer
le 14 Mar 2012
Hi,
if I understand correctly, this is close to what you want to do...?
% the first set:
t1 = datenum(2012, 3, 1) + [1; 3; 5; 6; 7];
v1 = (1:5)';
ts1 = timeseries(t1, v1);
% the second:
t2 = datenum(2012, 3, 1) + (1:7)';
v2 = (2:8)';
ts2 = timeseries(t2, v2);
% now interpolate ts1 on t2 using the "last" price
ts1a = resample(ts1, ts2.Time, 'zoh')
If your data are fints objects, the easiest probably is to make them timeseries objects, e.g.
f1 = fints(...);
t1 = timeseries(f1.dates, fts2mat(f1));
Titus
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!