Profile Picture

Strange issue with SystemData.CurrentDate

Posted By dwalton Last Year
Message
Posted Saturday April 23 2016
I have a trading system that executes monthly on the last trading day. To detect this I compare SystemData.CurrentDate to a database that contains the dates for the last trading day of the month. In general it works fine with one very strange exception. 

For some reason when I step through the code in the debugger, in May 2005, SystemData.CurrentDate increments from 5/27/2005 to 5/28/2005 (Saturday) and then right to 6/1/2005, skipping the correct bar date of 5/31/2005. I checked the data (Norgate) and the bar data is correct, meaning the dates on the bars increment from 5/27/2005 to 5/31/2005 as is correct. 

Why would RE execute the bar on 5/28/2005 (incorrectly) and increment straight to 6/1/2005? This seems like a bug to me but since I'm new to RE, it could easily be me not setting something up properly.
Posted Saturday April 23 2016
Update...
the strange behavior of RE incorrectly executing on a weekend bar and skipping a valid weekday after is more prevalent than I first thought. I'm seeing this behavior at these places too:
* Executing a bar on 7/30/2005 (Saturday) and skipping 8/1/2005 (Monday)
* Executing a bar on 10/1/2005 (Saturday) and skipping 10/3/2005 (Monday)

and there are many more but this gives you an idea. Thoughts?
Posted Sunday April 24 2016
So after digging in a little more I found that SystemData.CurrentDate is consistently one day ahead of the bar data date. I'm not sure why that is, but I fixed my issue but subtracting one day from SystemData.CurrentDate.
Posted Sunday April 24 2016
The current date is always 1 day ahead of the bar data date to prevent you from using data in your simulation that would not be available in reality.  For example, if you are simulating a Tuesday, the most recent data you would have is Monday's close.  You would not have access to Tuesday's close until the following trading day.

I find it helpful to imagine that the NewBar method is executing in the morning before the market opens.  Then if I place a Market On Open trade, it will execute at the current day's open.
Posted Tuesday April 26 2016
In RightEdge, a daily bar starts and ends at midnight, and it's usually the bar start time that is displayed as the date/time for the bar.  So yes, when processing the bar for a given day, the current simulation time will be the bar end time, or 12:00 AM the next day.

I'd suggest using the BarStartTime of the bar instead of subtracting one day from the current time.

Does this make sense?

It's also possible to use FilteredDailyFrequency if you want daily bars that start and end at market hours instead of at midnight.

Thanks,
Daniel
Posted Thursday April 28 2016
Daniel, thanks for the guidance. I'm making the check globally in the system class and use multiple symbols with different data starting times. So its much easier to just use SystemData.CurrentDate than go through each symbol looking for a valid bar and then get the start time. What is the concern in using the former?
Posted Friday April 29 2016
I can imagine that the CurrentTime might not always be the same as the last bar end time.  For example if a live system was suspended overnight and started in the morning, the current date might be the actual current time while the bar end time would still be at midnight.  I'm not saying RightEdge will ever necessarily work that way, but to me conceptually it could.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems