[Quantproject-developers] QuantProject/b4_Business/a05_Timing EndOfDayDateTime.cs, 1.4, 1.5
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-01-19 18:51:57
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12062/b4_Business/a05_Timing Modified Files: EndOfDayDateTime.cs Log Message: - the property Description has been added (useful for fast debugging in SharpDevelop) - the method public bool IsLessThan( EndOfDayDateTime dateTimeToCompareTo ) has been added - the method public bool IsLessThanOrEqualTo( EndOfDayDateTime dateTimeToCompareTo ) has been added - the method public bool IsEqualTo( EndOfDayDateTime dateTimeToCompareTo ) has been added - the method public EndOfDayDateTime GetNextMarketStatusSwitch() has been added Index: EndOfDayDateTime.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/EndOfDayDateTime.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayDateTime.cs 30 Jan 2005 19:57:37 -0000 1.4 --- EndOfDayDateTime.cs 19 Jan 2008 18:51:53 -0000 1.5 *************** *** 46,49 **** --- 46,59 ---- set { endOfDaySpecificTime = value; } } + + public string Description + { + get + { + string description = this.dateTime.ToString() + " - " + + this.endOfDaySpecificTime.ToString(); + return description; + } + } public EndOfDayDateTime( DateTime dateTime , EndOfDaySpecificTime endOfDaySpecificTime ) *************** *** 94,97 **** --- 104,140 ---- } /// <summary> + /// True iif this object does not come before dateTimeToCompareTo + /// </summary> + /// <param name="dateTimeToCompareTo"></param> + /// <returns></returns> + public bool IsLessThan( EndOfDayDateTime dateTimeToCompareTo ) + { + bool isLessThan = + ( this.CompareTo( dateTimeToCompareTo ) < 0 ); + return isLessThan; + } + /// <summary> + /// True iif this object does not come after dateTimeToCompareTo + /// </summary> + /// <param name="dateTimeToCompareTo"></param> + /// <returns></returns> + public bool IsLessThanOrEqualTo( EndOfDayDateTime dateTimeToCompareTo ) + { + bool isLessThanOrEqual = + ( this.CompareTo( dateTimeToCompareTo ) <= 0 ); + return isLessThanOrEqual; + } + /// <summary> + /// True iif this object is equal to dateTimeToCompareTo + /// </summary> + /// <param name="dateTimeToCompareTo"></param> + /// <returns></returns> + public bool IsEqualTo( EndOfDayDateTime dateTimeToCompareTo ) + { + bool isEqualTo = + ( this.CompareTo( dateTimeToCompareTo ) == 0 ); + return isEqualTo; + } + /// <summary> /// Returns a deep copy of the current instance /// </summary> *************** *** 103,106 **** --- 146,178 ---- this.endOfDaySpecificTime ); } + /// <summary> + /// Returns either the next market close or the next market open, + /// whichever is the nearest (all days are considered as market + /// days, week-ends included) + /// We have a market status switch when the market opens and when + /// the market closes + /// </summary> + /// <returns></returns> + public EndOfDayDateTime GetNextMarketStatusSwitch() + { + EndOfDayDateTime nextMarketStatusSwitch; + if ( this.EndOfDaySpecificTime < EndOfDaySpecificTime.MarketOpen ) + nextMarketStatusSwitch = new EndOfDayDateTime( + this.DateTime , EndOfDaySpecificTime.MarketOpen ); + else + { + // this.EndOfDaySpecificTime >= EndOfDaySpecificTime.MarketOpen + if ( this.EndOfDaySpecificTime < EndOfDaySpecificTime.MarketClose ) + // ( this.EndOfDaySpecificTime >= EndOfDaySpecificTime.MarketOpen ) + // AND ( this.EndOfDaySpecificTime < EndOfDaySpecificTime.MarketClose ) + nextMarketStatusSwitch = new EndOfDayDateTime( + this.DateTime , EndOfDaySpecificTime.MarketClose ); + else + // ( this.EndOfDaySpecificTime >= EndOfDaySpecificTime.MarketClose ) + nextMarketStatusSwitch = new EndOfDayDateTime( + this.DateTime.AddDays( 1 ) , EndOfDaySpecificTime.MarketOpen ); + } + return nextMarketStatusSwitch; + } #region MoveNext private EndOfDaySpecificTime getNextSpecificTime( ) |