1

I have minutely data that I wish to convert to daily. I can do this using to.daily without issue.

x = to.daily(x, index=to.daily(x, indexAt="endof", drop.time=FALSE, OHLC=TRUE) 
> head(x)
                     x.Open  x.High   x.Low x.Close x.Volume
2007-01-05 23:59:00 1774.50 1813.50 1769.75 1803.50      963
2007-01-06 07:15:00 1803.50 1803.75 1782.75 1794.25      436
2007-01-08 23:59:00 1795.00 1800.25 1794.75 1799.75      284
2007-01-09 23:58:00 1799.75 1809.25 1789.25 1805.25      771
2007-01-10 23:59:00 1805.25 1815.75 1789.00 1800.50     1027
2007-01-11 23:59:00 1800.75 1836.00 1795.00 1830.25      962

The problem is for the instrument I am looking at the start of the day is 07:30 and the end of the day is 07:15. So it opens at 7:30am trades to 7:15am the next day and closes for 15min then opens again.

I have tried using to.period and then change the endpoints but cannot seem to get it working.

How can I change the minutely data to daily with 7:30am being the open time and 7:15am be the close?

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • 1
    There is a `seq.POSIXt` function that should be able to create a set of appropriate breaks to use `cut.POSIXt`. I don't make any effort to answer questions when the data is from xts objects presented with print output. The `dput` output is much easier to work with and that is really your responsibility, not ours. Maybe someone should ask a question requesting a simple function to read xts/zoo output when the index columns is POSIXt? It would require handling two columns of `Datetime` data. – IRTFM Nov 11 '15 at 02:56
  • Is this a duplicate of http://stackoverflow.com/q/12087092/841830 ? – Darren Cook Nov 11 '15 at 18:55

1 Answers1

0

I'm not really familiar with xts objects but it seems the easiest thing to do would be to subtract 7.5 hours from the timestamp first then convert to daily. Since your intention is to get rid of the time anyway this should be harmless.

Dean MacGregor
  • 11,847
  • 9
  • 34
  • 72