Profile Picture

Lead bar error

Posted By Steve2008 7 Years Ago
Message
Posted Thursday September 02 2010
In an empty Data Store folder (using the default data storage technique) I downloaded one day's worth of one minute bars from 9/1/2010 from IQFeed for 1500 stocks. My IQFeed plugin excludes data outside market hours, and I have RE set to ignore data outside of market hours when live.

Then, prior to market hours the morning of 9/2, I started the live data feed on 500 symbols, which worked fine. (My IQFeed plugin modification sends real time ticks every minute to RE, which does not seem relevant to this problem.)

I then started a trading system with 10 lead bars, and synchronize bars set to true and got the following error, which shut down the trading system. The date and time noted is in the lead bar period.

I can replicate this with the "repl1" trading system I e-mailed to Daniel for the other issue, if I use the same 500 bar watch list. However, if I use the smaller 50 bar watchlist I sent to Daniel, things work normally. This means that the problem is specific to one or more symbols, but not to all symbols.

Except for excluding data outside of market hours, I did not otherwise modify the IQFeed plugin's handling of historical data.

Bar data error.  Received data for 9/1/2010 3:50:00 PM when current time is 9/1/2010 3:51:00 PM
   at RightEdge.Common.TimeFrequency.x672bb09993343f2e.ProcessBar(SingleBarEventArgs args)
   at RightEdge.Common.FrequencyManager.ProcessBar(SingleBarEventArgs newBar)
   at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewBar(Object sender, NewBarEventArgs e)
   at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
   at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
   at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
   at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
   at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
   at RightEdge.Shared.TradingModuleWrapper.Run(String filename)
   at RightEdge.Shared.TradingModuleWrapper.RunSystem(SharedSystemRunData systemRunData)
   at RightEdge.SystemProgress.InitAndRunSystem()


Edited: Thursday September 02 2010 by Steve2008
Posted Thursday September 02 2010
I just started a new empty Data Store folder and downloaded historical bars from 8/31 and 9/1, to be able to do a backtest for 9/1.

The backtest with repl1 on 1500 symbols worked normally, but the output panel showed something that seems anomalous: attempts to open positions during the lead bar period (10 lead bars) prior to the times when that should be happening, given that bar synchronization is turned on, and the system has a line that prevents trading until bar count is greater than or equal to 10. I've truncated the output below; the full version shows "Attempted to open position during the lead bar period" at 4 pm for all 1500 symbols except for the few that tried prior to 4 pm. Apparently the many 4 pm attempts should be happening, since at that point the bar count would be 10. If synchronization is working properly, the attempts before 4 pm should not be happening.

1 Attempted to open position during the lead bar period. SRT Position Manager 8/31/2010 3:06:00 PM
1 Attempted to open position during the lead bar period. DINE Position Manager 8/31/2010 3:10:00 PM
1 Attempted to open position during the lead bar period. LAWS Position Manager 8/31/2010 3:17:00 PM
1 Attempted to open position during the lead bar period. LAWS Position Manager 8/31/2010 3:20:00 PM
1 Attempted to open position during the lead bar period. MTEX Position Manager 8/31/2010 3:20:00 PM
1 Attempted to open position during the lead bar period. NLS Position Manager 8/31/2010 3:25:00 PM
1 Attempted to open position during the lead bar period. LAWS Position Manager 8/31/2010 3:35:00 PM
1 Attempted to open position during the lead bar period. PENX Position Manager 8/31/2010 3:36:00 PM
1 Attempted to open position during the lead bar period. LOJN Position Manager 8/31/2010 3:42:00 PM
1 Attempted to open position during the lead bar period. TMP Position Manager 8/31/2010 3:45:00 PM
1 Attempted to open position during the lead bar period. PCTI Position Manager 8/31/2010 3:46:00 PM
1 Attempted to open position during the lead bar period. SRT Position Manager 8/31/2010 3:46:00 PM
1 Attempted to open position during the lead bar period. LAWS Position Manager 8/31/2010 3:51:00 PM
1 Attempted to open position during the lead bar period. MTEX Position Manager 8/31/2010 3:51:00 PM
1 Attempted to open position during the lead bar period. NLS Position Manager 8/31/2010 3:53:00 PM
1 Attempted to open position during the lead bar period. GRB Position Manager 8/31/2010 3:56:00 PM
1 Attempted to open position during the lead bar period. CV Position Manager 8/31/2010 3:57:00 PM
1 Attempted to open position during the lead bar period. ENZ Position Manager 8/31/2010 3:57:00 PM
1 Attempted to open position during the lead bar period. DINE Position Manager 8/31/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. IVAC Position Manager 8/31/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. KRG Position Manager 8/31/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. OSTE Position Manager 8/31/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. DEL Position Manager 8/31/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. RLI Position Manager 8/31/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. TSFG Position Manager 8/31/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. AAPL Position Manager 8/31/2010 4:00:00 PM
1 Attempted to open position during the lead bar period. ABFS Position Manager 8/31/2010 4:00:00 PM
1 Attempted to open position during the lead bar period. ABT Position Manager 8/31/2010 4:00:00 PM
1 Attempted to open position during the lead bar period. ACF Position Manager 8/31/2010 4:00:00 PM
1 Attempted to open position during the lead bar period. ACI Position Manager 8/31/2010 4:00:00 PM


Edited: Thursday September 02 2010 by Steve2008
Posted Thursday September 02 2010
I'm able to start repl1 normally with the 500 symbol watchlist on live data after accumulating more than 10 bars of new live data.
Posted Thursday September 02 2010
The issue with real time data is very serious for me, as it precludes me from using RE with a system I am interested in running in live trading.
Posted Friday September 03 2010
Looking over the code, an explicit trade start date would put in you "lead bars" mode which could exceed actual number of lead bars.

However, the difficulty here is reproducing the scenario. I'll attempt with the S&P 500 and see if I can make it happen. It could be a combination of things though.

Steve2008 (9/2/2010)
The issue with real time data is very serious for me, as it precludes me from using RE with a system I am interested in running in live trading.
Posted Friday September 03 2010
Thanks for working on this.

The watchlist I used is the first 500 symbols, alphabetically, of the S&P 1500; I split the 1500 into 3 quasi-random watchlists to balance the load among processors in live trading. I can't duplicate the backtest issue with my months-out-of-date watchlists of the S&P 500 or S&P 400, but I can with the S&P 600. At least the backtest problem, and perhaps the live data problem, apparently requires some thinly traded stocks in the watchlist, to cause synchronize bars to attempt to add bars, and may be related to a malfunction of synchronize bars. You may want to try to duplicate the problem with the S&P 600 small cap index, or a subset, with one or more large-cap stocks like AAPL thrown in to ensure a downloaded bar each minute.

There is an explicit start trade date. However, since synchronize bars was turned on, I'm not sure how there could have been insufficient lead bars, unless synchronize bars is not working correctly.


Edited: Friday September 03 2010 by Steve2008
Posted Friday September 03 2010
Correction to below: The watchlist I used on these tests was NOT the S&P 500, but the first 500 alphabetic symbols of the S&P 1500. These problems cannot be replicated with the S&P 500 but can be with the S&P 600 with or without AAPL added.

-------------------

Update: I can reproduce both the simulation and live run problems using the S&P 500 and the repl1 system as follows:

1) I got the current S&P 500 components as of today from the S&P web site, copied them from Excel to Notepad, and replaced all instances of slash with dot, to conform to IQFeed symbol syntax.

2) I created a new "S&P 500 as of 2010 09 03" watchlist, with frequency of 1 minute, real time and historical data provider IQFeed, paper broker, historical start date of 9/1/2010. (Also works if IB is the broker; in this case, TWS does not need to be started, as the error happens before the broker connection error would have.)

3) My IQFeed plugin excludes both historical and real time data outside of stock market hours; this is essential.

4) In an empty Data Store folder, after market close on 9/3, I downloaded the historical data: 1 minute bars for 3 days: 9/1 through 9/3.

5) I ran a simulation for 9/2 (start date 9/2, end date 9/3, which is RE means do only 9/2), with the other properties unchanged from my email to Daniel, including 10 lead bars and an exit after 5 bars, and bar sync on. I get 9 pre-4 pm lead bar position open attempts that should not be happening, in addition to the hundreds of 4 pm ones that should be happening:

1 Attempted to open position during the lead bar period. BTH Position Manager 9/1/2010 3:56:00 PM
1 Attempted to open position during the lead bar period. CHG Position Manager 9/1/2010 3:57:00 PM
1 Attempted to open position during the lead bar period. APSG Position Manager 9/1/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. CLW Position Manager 9/1/2010 3:58:00 PM
1 Attempted to open position during the lead bar period. AGYS Position Manager 9/1/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. AZZ Position Manager 9/1/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. BH Position Manager 9/1/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. CV Position Manager 9/1/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. TRAK Position Manager 9/1/2010 3:59:00 PM
1 Attempted to open position during the lead bar period. A Position Manager 9/1/2010 4:00:00 PM

6) I started the live system without starting the data feed, and got the same kind of error message I did yesterday with the data feed active. This is a fatal error that shuts down the trading system. The advantage of not starting the data feed is easier and cleaner reproducability of the problem, which does not depend on the market being open and does not contaminate the data store with new data.

Bar data error.  Received data for 9/3/2010 3:58:00 PM when current time is 9/3/2010 3:59:00 PM
   at RightEdge.Common.TimeFrequency.x672bb09993343f2e.ProcessBar(SingleBarEventArgs args)
   at RightEdge.Common.FrequencyManager.ProcessBar(SingleBarEventArgs newBar)
   at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewBar(Object sender, NewBarEventArgs e)
   at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
   at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
   at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
   at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
   at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
   at RightEdge.Shared.TradingModuleWrapper.Run(String filename)
   at RightEdge.Shared.TradingModuleWrapper.RunSystem(SharedSystemRunData systemRunData)
   at RightEdge.SystemProgress.InitAndRunSystem()


Edited: Saturday September 04 2010 by Steve2008
Posted Friday September 03 2010
I will try to figure out what is going on this Monday, but let me clear up a few things now.

4) In an empty Data Store folder, after market close on 9/3, I downloaded the historical data: 1 minute bars for 3 days: 9/1 through 9/3.


By this you mean you went to the settings for the binary data store and told it to use an empty folder?

I get 9 pre-4 pm lead bar position open attempts that should not be happening, in addition to the hundreds of 4 pm ones that should be happening

I think what is happening here is that these symbols are missing some bars near 4:00 PM on 9/1. When loading the lead bars it will load 10 bars from the data store prior to 9/2. When the bars then get synchronized, new bars are created to fill the gaps, resulting in some symbols having more than 10 bars processed before 4:00 PM on 9/1, so it tries to submit orders for them. You can check the SystemData.InLeadBars property to determine whether you are in the lead bars or not.

The advantage of not starting the data feed is easier and cleaner reproducability of the problem, which does not depend on the market being open and does not contaminate the data store with new data.

Unless I'm misunderstanding something, this is incorrect. When you start a live system, RightEdge will start live data for you if it hasn't already been started.

Thanks,
Daniel
Posted Saturday September 04 2010
First, I need to make a correction. The watchlist I used on the above tests was NOT the S&P 500, but the first 500 alphabetic symbols of the S&P 1500 (for which I also created a new watchlist). I just verified that these problems cannot be replicated with the S&P 500 but can be with the S&P 600 with or without AAPL added.

To get the empty data store, with RE closed I renamed the existing Data Store folder and created a new folder by that name. I've been creating and renaming Data Store folders a lot during my testing; I find it more convenient than pointing the settings to different folders.

Thanks for your explanation of the extra lead bars for some symbols during backtesting. It sounds like this does not have any adverse effect.

RE generates the fatal error before it gets to the point where it automatically starts the data feed. In the tests I just did with the S&P 500, which did not generate an error, RE in fact did start IQFeed. Running IQFeed during non-market hours is not a problem because, due to the filter in my plugin, no new bars are added to the data store to complicate testing.

dplaisted (9/3/2010)
I will try to figure out what is going on this Monday, but let me clear up a few things now.

4) In an empty Data Store folder, after market close on 9/3, I downloaded the historical data: 1 minute bars for 3 days: 9/1 through 9/3.


By this you mean you went to the settings for the binary data store and told it to use an empty folder?

I get 9 pre-4 pm lead bar position open attempts that should not be happening, in addition to the hundreds of 4 pm ones that should be happening

I think what is happening here is that these symbols are missing some bars near 4:00 PM on 9/1. When loading the lead bars it will load 10 bars from the data store prior to 9/2. When the bars then get synchronized, new bars are created to fill the gaps, resulting in some symbols having more than 10 bars processed before 4:00 PM on 9/1, so it tries to submit orders for them. You can check the SystemData.InLeadBars property to determine whether you are in the lead bars or not.

The advantage of not starting the data feed is easier and cleaner reproducability of the problem, which does not depend on the market being open and does not contaminate the data store with new data.

Unless I'm misunderstanding something, this is incorrect. When you start a live system, RightEdge will start live data for you if it hasn't already been started.

Thanks,
Daniel

Edited: Saturday September 04 2010 by Steve2008
Posted Wednesday September 08 2010
This will be fixed in the next build. It is caused when the last lead bars loaded for a live system don't have the same date for all symbols. So as a workaround, you could make sure your data store has bars for 3:59 (or whatever the last bar time is) for all symbols.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems