﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>RightEdge Forums / General / Plugin Development  / Synchronizing bar timing between RE and data source / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>RightEdge Forums</description><link>http://www.rightedgesystems.com/forums/</link><webMaster>rightedge@yyesoftware.com</webMaster><lastBuildDate>Wed, 08 Feb 2012 15:36:15 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>I would recommend keeping track of the most recent tick time, and if a tick comes in with a timestamp earlier than that, modify the timestamp of that tick to match the most recent one.&lt;br&gt;&lt;br&gt;Daniel</description><pubDate>Fri, 30 Oct 2009 10:39:52 GMT</pubDate><dc:creator>dplaisted</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>&lt;TABLE cellSpacing=0 cellPadding=0 width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=BigTxt vAlign=top&gt;I am working on a plugin for RE Edition2 for Russian AlfaDirect streaming data.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I have streaming data.&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;[28.10.2009 16:31:55] Received:&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;*at*&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;651927936|12910|740|66.17|&lt;SPAN style="BACKGROUND: yellow; mso-highlight: yellow"&gt;16:31:55&lt;/SPAN&gt;|341598715|0|2|0&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;[28.10.2009 16:31:55] Received:&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;*at*&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348438|27230|10|135830|&lt;SPAN style="BACKGROUND: red; mso-highlight: red"&gt;16:31:54&lt;/SPAN&gt;|341598715|6|2|0&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348439|27230|10|135810|&lt;SPAN style="BACKGROUND: yellow; mso-highlight: yellow"&gt;16:31:55&lt;/SPAN&gt;|341598715|1|2|1&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348440|27230|1|135815|16:31:55|341598715|6|2|1&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;[28.10.2009 16:31:56] Received:&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;*at*&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348442|27230|5|135820|16:31:55|341598716|6|2|0&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348443|27230|2|135810|16:31:55|341598716|1|2|1&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;111348445|27230|2|135805|16:31:55|341598716|1|2|1&lt;/FONT&gt;&lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;&lt;/FONT&gt; &lt;/P&gt;&lt;P style="MARGIN: 0cm 0cm 0pt" class=MsoNormal&gt;&lt;FONT color=#000000&gt;12910 &amp;amp; 27230 - it's tickets from different exchanege &lt;/FONT&gt;&lt;FONT color=#000000&gt;and &lt;/FONT&gt;I can't use &lt;STRONG&gt;&lt;FONT style="BACKGROUND-COLOR: #ffff11" color=#111111&gt;ticks.Sort&lt;/FONT&gt;&lt;/STRONG&gt;  &lt;FONT color=#808080&gt;&lt;FONT color=#111111&gt;because &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;651927936 (tick number) already added.&lt;/FONT&gt;</description><pubDate>Fri, 30 Oct 2009 03:01:35 GMT</pubDate><dc:creator>sda75</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>Hi steve,&lt;/P&gt;&lt;P&gt;Aggrigation sounds like the direction but you may consider aggrigating into 10 or 15 second "slots" and then into the minute.&lt;/P&gt;&lt;P&gt;This way you wouldn't have all the calcs happening at the end of minute... which should work better whith large symbol sets.&lt;/P&gt;&lt;P&gt;If you want to put the aggration rules together, i.e. how you want the data combined, I can build you an "aggrator" class...&lt;/P&gt;&lt;P&gt;Walt&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; I do have interest in a TDA plug-in since they are my broker also and I have their SDK but no time (or desire to do it all)</description><pubDate>Thu, 27 Aug 2009 18:57:41 GMT</pubDate><dc:creator>hairy_mug</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>Or maybe do the aggregation in RE, in a thread.</description><pubDate>Mon, 27 Jul 2009 16:11:10 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>I'm facing some issues for the real plug-in. Thoughts appreciated by RE staff or anyone.&lt;/P&gt;&lt;P&gt;The function that gets one minute bars, TDAC_OnOHLCBar, is triggered upon receipt of a bar for one symbol. On a large symbol list such as the S&amp;amp;P 500 the bars come in irregularly over a period of around 5 to 20 seconds, longer sometimes. Sometimes the timestamps are old. I am not sure that bars are generated if there are no trades.&lt;/P&gt;&lt;P&gt;I would need to save data for each bar, and probably in a separate thread judge when bars have stopped coming in for that minute, perhaps based on receipt of data for a threshold percentage of bars plus a threshold time span of no receipt of data, and then generate ticks in the proper time sequence and send them to the listener. I might want to generate bars using last good data for symbols whose bars have not yet come in or that have bad timestamps, but not do so if the anomaly persists for more than one minute, which could indicate that the symbol has stopped trading.&lt;/P&gt;&lt;P&gt;The reason I'm looking at one minute bars instead of streaming data in the first place is that RE gets bogged down with tick-level data on a large symbol list.&lt;/P&gt;&lt;P&gt;Given the issues here, especially the lag in TDA one minute bar receipt, I'm starting to think that I would be better off aggregating streaming data into one minute bars myself in a separate process that talks to a RE plugin every minute. This will eliminate delays and give me better control, and also can potentially work with a variety of data feeds.&lt;/P&gt;&lt;P&gt;From what other people have posted, it seems that aggregation in a separate process is feasible from the standpoint of CPU and other resource use. Perhaps if necessary I could run several processes on different local cores or networked machines.</description><pubDate>Mon, 27 Jul 2009 11:19:58 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>Daniel, thanks for looking into this.&lt;/P&gt;&lt;P&gt;Apparently timing among symbols is more tightly coupled in Edition 2 than Edition 1.</description><pubDate>Sun, 26 Jul 2009 23:39:48 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>You are sending ticks in the following order:&lt;br&gt;&lt;br&gt;AAAA 12:00:01 Trade&lt;br&gt;AAAA 12:00:02 Trade&lt;br&gt;AAAA 12:00:03 Trade&lt;br&gt;AAAA 12:00:04 Trade&lt;br&gt;AAAA 12:01:00 Bid&lt;br&gt;BBBB 12:00:01 Trade&lt;br&gt;BBBB 12:00:02 Trade&lt;br&gt;BBBB 12:00:03 Trade&lt;br&gt;BBBB 12:00:04 Trade&lt;br&gt;BBBB 12:01:00 Bid&lt;br&gt;etc.&lt;br&gt;&lt;br&gt;The problem is that the last AAAA tick is from 12:01:00.  Then you send the first BBBB tick, and the time is 12:00:01.  So this tick is received out of order.  When RightEdge got the tick for 12:01:00, it took that as the current time, which means that the 12:00 bar would have been completed at that point for all symbols in your system.  So when you get to the BBBB data it is too late to process that as part of the 12:00 bar.&lt;br&gt;&lt;br&gt;Basically you want to sort the ticks by timestamp before sending them out.  It may be more complicated in the real plugin, but in the code you sent us, you just need to add the following line after all the ticks have been added to the list but before calling the tickListener:&lt;br&gt;&lt;br&gt;ticks.Sort(delegate(SymbolTick t1, SymbolTick t2) { return t1.tick.time.CompareTo(t2.tick.time);});&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;Daniel&lt;br&gt;</description><pubDate>Fri, 24 Jul 2009 23:09:53 GMT</pubDate><dc:creator>dplaisted</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>UPDATE: I just sent it, and then a corrected version to fix a bug.</description><pubDate>Wed, 22 Jul 2009 17:55:49 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>You can email it to resupport at rightedgesystems.</description><pubDate>Wed, 22 Jul 2009 17:23:53 GMT</pubDate><dc:creator>billb</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>I am able to replicate the problem with a lightly modified version of the supplied random data realtime plugin. It works properly when compiled for and installed in ED1, and produces the same type of problems noted above in ED2.&lt;P&gt;Let me know if you would like the code. I have had problems posting stuff here -- quota errors -- so I can e-mail it. I can send either the C# file or the entire VCS Express 2008 projects, zipped.</description><pubDate>Wed, 22 Jul 2009 16:51:29 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>UPDATE: I compiled this same plugin for Edition 1, and it is working correctly there. I changed the tick type for the new-minute tick from current time to previous close (for my purposes, meaningless and harmless), because current time is an ED2 innovation.&lt;P&gt;Wondering whether the bar type in ED2 is the issue, I changed it there, too, to previous close. That does not help.&lt;/P&gt;&lt;P&gt;So this is an ED2 issue.</description><pubDate>Wed, 22 Jul 2009 14:04:09 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>I am getting an orange error banner at the bottom of RE saying "Data from [begin datetime] to [end datetime] was dropped because it is out of order."&lt;P&gt;I sending 5 ticks every one minute bar as suggested (4 trade, OHLC, and 1 current time at beg of next minute) on a symbol list of 7 symbols, freshly created, and purged/reentered to ensure no residual previous data.&lt;/P&gt;&lt;P&gt;One symbol is updating properly in RE every minute. The others are not displaying any data, apparently because RE is dropping the ticks I send. All symbols are processed identically.&lt;/P&gt;&lt;P&gt;Diagnostic code shows that I am properly receiving data from TDA, and am putting correct values into the tick's time and symbol fields before calling &lt;FONT size=2&gt;tickListener. I am sending timestamps of 1, 2, 3 and 4 seconds into the even minute for the trade ticks and on the even next minute for the current time tick, and am working off my computer's clock, eliminating the possibility that the TDA timestamps are the issue.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Assistance would be appreciated. Thanks.</description><pubDate>Wed, 22 Jul 2009 12:42:40 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>Sounds like what I need. Thanks.</description><pubDate>Fri, 17 Jul 2009 22:06:35 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>RightEdge bases it's time off of the ticks that come in from the data plugin, not off of your computer's internal clock.  (Some data plugins such as the TWS plugin don't get time updates from the broker with every tick so the time is partly based on the computer's clock, but this is up to the plugin to decide.)&lt;br&gt;&lt;br&gt;RightEdge won't generate a new bar for your system until it receives a tick that would be part of the next bar.  There is now a TickType of CurrentTime that you can use.  So to send a 1M bar that starts at 12:00, you would send the OHLC ticks with timestamps between 12:00:00 and 12:00:59, and then send a CurrentTime tick with a timestamp of 12:01:00 which would force the bar to be sent.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;Daniel</description><pubDate>Fri, 17 Jul 2009 21:15:48 GMT</pubDate><dc:creator>dplaisted</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>Hi Bill,&lt;P&gt;Please bear with me as I try to clarify how this works.&lt;/P&gt;&lt;P&gt;I will be receiving TDA's 1 minute bars whenever they send them, presumably every minute regardless of whether there were trades during that minute; if not, I can simulate this within my plugin, so we can assume that it will effectively happen. The record contains fields for OHLC, and my plugin would send to RE either 4 trade ticks, one for each value, or only 1 trade tick, the C value, depending on what the particular trading strategy looks at. My plugin may or may not send any non-trade ticks; let's assume that it will not.&lt;/P&gt;&lt;P&gt;The time I get a TDA 1 minute bar is not necessarily at a minute boundary per my computer's clock.&lt;/P&gt;&lt;P&gt;If I send RE one trade tick per minute, will it immediately generate a 1 minute bar with identical values for OHLC, and pass control to my trading strategy? This is what I wish to happen. Or is RE's bar creation on its own schedule, perhaps tied to my computer's clock, causing a lag of conceivably up to 59+ seconds between sending the tick to RE and RE generating the bar and invoking the trading logic?&lt;/P&gt;&lt;P&gt;The next question is whether there is a way I can I send 4 trade ticks in rapid succession (OHLC) each minute, and only after all 4 ticks have been sent, have RE immediately generate a 1 minute bar using those ticks, and pass control to my trading strategy.&lt;/P&gt;&lt;P&gt;BTW, your response seems to imply that if I send RE no ticks for a symbol within a 1 minute period, no bar will get generated for that minute for that symbol. Is this the case?</description><pubDate>Fri, 17 Jul 2009 18:56:47 GMT</pubDate><dc:creator>Steve2008</dc:creator></item><item><title>RE: Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>RE only processes when it receives a tick, so you could send a last trade tick (which contains the same value as the 'real' last trade) to force a new bar on the first second of the new minute.&lt;br&gt;&lt;br&gt;[quote][b]Steve2008 (7/17/2009)[/b][hr]I am working on a plugin for RE Edition2 for TD Ameritrade streaming data.&lt;br&gt;&lt;br&gt;I have it working using the TDA ActiveX interface, but with 100 symbols RE chews up so much CPU that it becomes unresponsive, andI want to use a lot more than 100 symbols. I don't know whether the issue is with the TDA interface, RE Edition 2, or both. (It could be my code, but I don't think so.) There is a third-party TDA native C#interface that is conceivably more efficient, but months ago I wrote a RE plugin for it and found a bug that makes it unusable for multiple symbols. A new version is in the works, but it is not clear when it will be available.&lt;br&gt;&lt;br&gt;I only need 1 minute bars, which are much less CPU-intensive than streaming data and will therefore probably alleviate the CPU bottleneck.TDA can deliver 1 minute bars, and I know from previous discussions here that I can feed these into RE by generating 4 ticks in my plugin: one each for OHLC of the bar. I have not yet programmed this, but it seems straightforward.&lt;br&gt;&lt;br&gt;My question regards time synchronization. I would like RE to complete its1 minute bar immediately after delivery of the ticks, and immediately invoke trading strategy logic. I want to avoid a situation where the RE timing loop for bar creation/strategy invocation is not synchronized with that of my data source, causing a time lag.&lt;br&gt;&lt;br&gt;What, if anything, can I do to ensure time synchronization?&lt;br&gt;&lt;br&gt;Thanks.[/quote]</description><pubDate>Fri, 17 Jul 2009 17:50:03 GMT</pubDate><dc:creator>billb</dc:creator></item><item><title>Synchronizing bar timing between RE and data source</title><link>http://www.rightedgesystems.com/forums/Topic8999-16-1.aspx</link><description>I am working on a plugin for RE Edition2 for TD Ameritrade streaming data.&lt;P&gt;I have it working using the TDA ActiveX interface, but with 100 symbols RE chews up so much CPU that it becomes unresponsive, and I want to use a lot more than 100 symbols. I don't know whether the issue is with the TDA interface, RE Edition 2, or both. (It could be my code, but I don't think so.) There is a third-party TDA native C# interface that is conceivably more efficient, but months ago I wrote a RE plugin for it and found a bug that makes it unusable for multiple symbols. A new version is in the works, but it is not clear when it will be available.&lt;/P&gt;&lt;P&gt;I only need 1 minute bars, which are much less CPU-intensive than streaming data and will therefore probably alleviate the CPU bottleneck. TDA can deliver 1 minute bars, and I know from previous discussions here that I can feed these into RE by generating 4 ticks in my plugin: one each for OHLC of the bar. I have not yet programmed this, but it seems straightforward.&lt;/P&gt;&lt;P&gt;My question regards time synchronization. I would like RE to complete its 1 minute bar immediately after delivery of the ticks, and immediately invoke trading strategy logic. I want to avoid a situation where the RE timing loop for bar creation/strategy invocation is not synchronized with that of my data source, causing a time lag.&lt;/P&gt;&lt;P&gt;What, if anything, can I do to ensure time synchronization?&lt;/P&gt;&lt;P&gt;Thanks.</description><pubDate>Fri, 17 Jul 2009 12:47:28 GMT</pubDate><dc:creator>Steve2008</dc:creator></item></channel></rss>
