[R-SIG-Finance] Time interval logic

Manoj manojsw at gmail.com
Wed Nov 9 11:48:59 CET 2011


Hello,
    I am working on some tick-data and needed help computing the
following statistics:

     Assume the dataset to be an xts object of Price and Volume as shown below:
-------
Time	Prc	Vol	CumVol	Vol-Threshold	Vol_Residual	Time_Elapsed
10:01	24.01	20	20			
10:02	24.05	200	220			
10:03	23.99	120	340	300	40	3
10:04	24.02	125	465			
10:05	24.01	99	564			
10:06	24.02	231	795	300	195	4
10:07	23.99	1000	1795	300	895	2

-------

      From the above trade data - I am interested in finding out the
time taken to complete a certain volume threshold. The column in
question from above data is the "Time_Elapsed" column. I have used 300
shares as volume threshold in above example. Once the threshold is
reached, the excess volume for the currently processed trade is
allocated to next group. In example above - it takes 3 minutes to
complete 1st volume threshold (20+200+80) leaving behind a residual of
40 shares for next group. The second and third volume thresholds are
completed in 4 minutes and 2 minutes in the example above.

      What's the optimal way of speeding up the logic above?

Thanks.

Manoj



More information about the R-SIG-Finance mailing list