0

I'm using r to analyse some stock price data, and currently have an xts object containing price at 1 minute intervals spanning multiple days. However, this xts object also contains prices outside of trading hours (8:30-16:30 in this case), and I'd like to remove these values. I can't seem to find information on a function that would allow this. Thanks.

dslater0
  • 57
  • 6

1 Answers1

0

You can filter on time inside an xts. You need the format "THH:mm:ss". Instead of filter out the hours outside the trading hours, you filter on the trading hours.

# Filter xts on trading hours (if trading hours are between 08:30 and 16:30)
my_xts["T08:30:00/T16:30:00"] 

See more examples with ?xts and ?subset.xts

phiver
  • 23,048
  • 14
  • 44
  • 56