[Quantproject-developers] QuantProject/b4_Business/a05_Timing EndOfDayHistory.cs, 1.1, 1.2
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-01-19 18:53:54
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12862/b4_Business/a05_Timing Modified Files: EndOfDayHistory.cs Log Message: - the property FirstEndOfDayDateTime has been added - the property LastEndOfDayDateTime has been improved (exception included) - the property History has been added Index: EndOfDayHistory.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/EndOfDayHistory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EndOfDayHistory.cs 16 Sep 2007 21:30:42 -0000 1.1 --- EndOfDayHistory.cs 19 Jan 2008 18:53:51 -0000 1.2 *************** *** 25,28 **** --- 25,29 ---- using System.Data; using QuantProject.ADT; + using QuantProject.ADT.Histories; using QuantProject.ADT.Statistics; *************** *** 36,43 **** public class EndOfDayHistory : AdvancedSortedList { - public EndOfDayDateTime LastEndOfDayDateTime - { - get { return (EndOfDayDateTime)this.GetKey( this.Count - 1 ); } - } /// <summary> /// Returns the ICollection of EndOfDayDateTimes on which the --- 37,40 ---- *************** *** 48,51 **** --- 45,113 ---- get { return this.Keys; } } + /// <summary> + /// The first EndOfDayDateTime value in the collection + /// </summary> + public EndOfDayDateTime FirstEndOfDayDateTime + { + get + { + if ( this.TimeLine.Count == 0 ) + throw new Exception( "This EndOfDayHistory collection is empty, " + + "thus FirstEndOfDayDateTime is meaningless!" ); + return (EndOfDayDateTime)(this.GetKey( 0 )); + } + } + /// <summary> + /// The last EndOfDayDateTime value in the collection + /// </summary> + public EndOfDayDateTime LastEndOfDayDateTime + { + get + { + if ( this.TimeLine.Count == 0 ) + throw new Exception( "This EndOfDayHistory collection is empty, " + + "thus LastEndOfDayDateTime is meaningless!" ); + int lastIndex = this.TimeLine.Count - 1; + return (EndOfDayDateTime)( this.GetKey( lastIndex ) ); + } + } + + #region History + private void addDateTimes( History history ) + { + DateTime currentDateTime = this.FirstEndOfDayDateTime.DateTime; + history.Add( currentDateTime , currentDateTime ); + foreach ( EndOfDayDateTime endOfDayDateTime + in this.Keys ) + if ( endOfDayDateTime.DateTime > currentDateTime ) + { + history.Add( endOfDayDateTime.DateTime , + endOfDayDateTime.DateTime ); + currentDateTime = endOfDayDateTime.DateTime; + } + } + private History getHistory() + { + History history = new History(); + if ( this.Count > 0 ) + this.addDateTimes( history ); + return history; + } + + + /// <summary> + /// Returns the collection of DateTime(s) for these EndOfDayDateTimes + /// </summary> + public History History + { + get + { + return this.getHistory(); + } + + + } + #endregion History + public EndOfDayHistory() : base() { |