[R-SIG-Finance] How does one handle missing dates in quantmod/quantstrat time series?

Brian G. Peterson brian at braverock.com
Thu Mar 22 10:24:00 CET 2012

On Wed, 2012-03-21 at 23:36 -0700, Wei Wu wrote:
> Sometimes the missing data could be data error/problem. But let's say the missing dates(data) were real. Then I would think we will need to filling in some data points with the same o/h/l/c as the previous close and zero volume. Any other alternatives?

Handling missing data is a topic that will be very specific to your data
source (if you buy your data, you can work with the provider to fill in
missing periods), to your project (are you comparing data from related
firms for some analysis, building a strategy, or something else...), and
to the analytical technique you hope to apply (filling data will distort
your calculations).

With Bid and Ask data, it is more or less safe to na.locf, as the
prevailing market is still a real market.  If however markets are
closed, your market connectivity was down, etc, then you cannot trade,
so having no data at all is more appropriate.  Copying OHLC data forward
is almost always likely to be a bad idea.

> What is the best and efficient way to handle this? Any exiting code/package that can handle this already?

zoo (which xts shares a bunch of code with) already has interpolation
methods, na.locf, etc.

Please search the list archives before posting follow-up questions, as
there have been many many posts to this list over the years about
missing, filling, or interpolating data.

   - Brian

Brian G. Peterson
Ph: 773-459-4973
IM: bgpbraverock

More information about the R-SIG-Finance mailing list