[R-SIG-Finance] Find first trade of day in xts object

Noah Silverman noahsilverman at ucla.edu
Wed Jun 15 05:40:05 CEST 2011


Hi,

I have a long series of hourly bars.  They are not aligned on the exact hour.  I used xts to convert actual tick data to hourly bars.

I want to access the first trade of each day.  Is there an easy way to do this? 

Furthermore, what if I want to find the first trade that occurred after 6:30am each day?  (Or any other arbitrary time each day?)


Here are a few rows of data:

finalData[4880:4890,]
                    ds.Open ds.High  ds.Low ds.Close          ret
2008-02-27 02:59:47 1461.75 1477.75 1457.25  1465.25  0.002220515
2008-02-27 03:59:32 1467.25 1474.25 1425.75  1443.25 -0.015128361
2008-02-27 04:59:30 1442.75 1477.25 1410.00  1431.25 -0.008349327
2008-02-27 05:59:59 1434.00 1438.75 1366.75  1366.75 -0.046112530
2008-02-27 09:59:59 1378.25 1439.25 1378.25  1428.00  0.043839205
2008-02-27 10:59:58 1427.75 1636.75 1395.50  1591.00  0.108087885
2008-02-27 11:59:59 1591.00 1592.25 1505.75  1551.25 -0.025301692
2008-02-27 12:59:58 1550.50 1562.25 1495.75  1525.00 -0.017066647
2008-02-27 13:14:59 1524.75 1584.25 1521.75  1545.50  0.013353073
2008-02-27 18:59:56 1545.50 1560.25 1518.25  1551.00  0.003552402
2008-02-27 19:59:53 1549.50 1549.50 1523.50  1524.00 -0.017561427



Thanks!



--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095



More information about the R-SIG-Finance mailing list