Hi Noah,

if you want to create proper bars in realtime trading, there is no way
around running a separate thread with a timer that triggers a bar creation
at predefined times. Although in Java, you can have a look at the
activequant source code base, at TradeIndicationToCandleConverter.java :
http://tinyurl.com/3ul8hy3

We solved the same problem about 5 years ago with dedicated sleeps or
optional external synchronisation. Might be good for an inspiration.

Cheers,
Ulrich

On Fri, Sep 2, 2011 at 12:21 PM, Noah Silverman <noahsilverman@ucla.edu>wrote:

> Hello,
>
>
> If I have an incoming stream of financial transaction.  (i.e. ticks from
> Interactive Brokers.)
>
> I would like to calculate bars for a given time period.  (i.e. 10 minute
> bars)
>
> I'm "rolling my own" code and don't want to relay on an opaque function
> from a package.
>
> The goal is to have bars fall on the same time as the clock
> 9:00
> 9:10
> 9:20
> etc..
>
>
> One thought was to perform a mod on the epoch time
>
> if (epoch %% 600 < 0){  make bar}
>
> However, since the ticks flow in at random times, this is not reliable.
>  MOST of the time there will be at least one tick every second, so it will
> work, but what if there isn't a tick on the exact second that borders a bar.
> If there isn't a transaction on the "goal" second, then we won't trigger the
> rule based on epoch %% 600
>
> Any thoughts on a reliable and fast way to do this?
>
>
> --
> Noah Silverman
> UCLA Department of Statistics
> 8117 Math Sciences Building #8208
> Los Angeles, CA 90095
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



-- 
Ulrich Staudinger

http://www.activequant.org
Connect online: https://www.xing.com/profile/Ulrich_Staudinger

	[[alternative HTML version deleted]]

