[R-SIG-Finance] [R-sig-finance] Aggregating tick by tick timeSeries [NC]

anass.mouhsine at sgcib.com anass.mouhsine at sgcib.com
Thu Mar 6 11:38:31 CET 2008


thank you gus for your thoughts!!

I am starting to replicate some C++ code I developed years ago on LOB
(Limit Order Book) analysis into R.
So I start with the simple VWAP, VWAS, TWAS etc...but the objective is to
analyse the Order book resiliency and depthness.
For that purpose, I need to apply a set of  functions to a multivariate
tick by tick timeSeries and aggregate by time bar or even volume bars.

thanks again for your help

cheers,

Anass


|------------------------------                                            
|            brian at braverock.c                                             
|            om                                                            
|                                                                          
|            03/05/2008 18:21                                              
|                                                                          
                                                                           
                                                                           
                                                                        To 
                                                                           
                                                                        cc 
                                               Anass                       
                                               MOUHSINE/fr/socgen at socgen,  
                                               r-sig-finance at stat.math.eth 
                                               z.ch                        
                                                                   Subject 
                                               Re: [R-SIG-Finance]         
                                               [R-sig-finance] Aggregating 
                                               tick by tick    timeSeries  
                                               [NC]                        
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




So, to Gabor's point,  A combination of apply() or rollapply() and
aggregate() should be able to apply or run specific statistics on your
(spread, volume) or (price,volume) series.

To Jeff's point, you will need to write some code to wrap the various
functions you want to call, but it doesn't sound like anything you've
described so far is particularly difficult.


If you could be more specific about what you want to do, the list may be
able to help a little more.

Cheers,

   - Brian

Gabor Grothendieck wrote:
> If you are referring to rolling statistics then see ?rollapply in the
> zoo package
> and note the by.column argument.
>
> On Wed, Mar 5, 2008 at 10:29 AM,  <anass.mouhsine at sgcib.com> wrote:
>> Thank you Jeff,
>>
>>
>> my aim was to calculate standard statistics + volume weighted prices and
>> spreads.
>>
>>
>> I will try out the xts package, but I am wondering if it can aggregate
>> Multivariate timeSeries (e.g, (spread, volume) or (price,volume)).
>>
>>
>> thanks again
>>
>>
>> |------------------------------
>> |            jeff.a.ryan at gmail
>> |            .com
>> |
>> |            03/05/2008 16:21
>> |
>>
>>
>>
To
>>                                               Anass
>>                                               MOUHSINE/fr/socgen at socgen
>>
cc
>>
r-sig-finance at stat.math.eth
>>                                               z.ch
>>
Subject
>>                                               Re: [R-SIG-Finance]
>>                                               [R-sig-finance]
Aggregating
>>                                               tick by tick timeSeries
>>                                               [C1]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Anass,
>>
>> If you want the mean/sd/etc for each hour ?aggregate from zoo will do
>> the job very well. To get there from timeSeries you can use the new
>> 'xts' package:
>>
>> myTS [a timeSeries object]
>>
>> as.xts(myTS) [ now an 'xts' object - which inherits from zoo]
>>
>> --or--
>>
>> as.zoo(myTS)
>>
>> you can even put it back to a timeSeries with little information loss
>> if you use xts via 'reclass' (changing the series outside of xts
>> functions currently isn't perfect - but it is good)
>>
>> If you want to just aggregate the data into OHLC per time period -
>> to.period in xts is fast and flexible:
>>
>> to.period(myTS,'minutes',15)
>> to.period(myTS,'hours')
>> to.monthly(myTS)
>>
>> All these work by converting and reconverting to an 'xts' class
>> internally - so most any (including timeSeries) class will just work
>> with the function.  In addition it is all compiled code - so it works
>> well.
>>
>> One caveat - you'll need to get the most recent xts from
>> http://r-forge.r-project.org/projects/xts - as there was a minor bug
>> in the transition of 'to.period' code from quantmod to xts.
>>
>> Jeff
>>
>> On Wed, Mar 5, 2008 at 8:21 AM,  <anass.mouhsine at sgcib.com> wrote:
>>>  Hi guys,
>>>
>>>
>>>  I have a timeSeries object like this one
>>>                         V10
>>>  2005-04-08 17:31:41 0.01
>>>  2005-04-08 17:31:57 0.02
>>>  2005-04-08 17:32:00 0.02
>>>  2005-04-08 17:32:57 0.02
>>>  2005-04-08 17:38:34 0.02
>>>  2005-04-08 17:38:49 0.01
>>>
>>>  and I would like to aggregate the timeSeries in hours or minutes in
>> order
>>>  to apply whatever function on the aggregated data (e.g mean, standard
>> dev,
>>>  etc...)
>>>  I have seen some aggreagation functions like aggregate in the fSeries
>>>  package but it aggregates only monthly or quaterly.
>>>  I am sure some of you guys were faced to this kind of issue.
>>>
>>>  Could anyone give me some hints on how to solve my problem?
>>>
>>>  thanks in advance
>>>
>>>  Anass

*************************************************************************
This message and any attachments (the "message") are con...{{dropped:10}}



More information about the R-SIG-Finance mailing list