Clear Filters
Clear Filters

Two ascii data files of minute data not matching up

2 views (last 30 days)
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

Answers (3)

Titus Edelhofer
Titus Edelhofer on 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

CR
CR on 8 Mar 2012
Thanks, I have to financial time series one is 17970x5 and the other is 18080x5. They both have time data. I would like to merge together and fill the 17970 missing dates/times with the last price of the most recent record, or eliminate the missing from the 18080 financial time series. I tried using the fstool merge but the result was pretty much still the same size. One financial time series has stock open close prices, the other has open close prices of another stock. I would like the final result to be date time close of stock 1 close of stock 2. Is there a good function to do this?
Thanks CR

Titus Edelhofer
Titus Edelhofer on 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

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!