[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/returnsManagement/time ReturnInte
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2009-02-28 18:43:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25809/b4_Business/a2_Strategies/returnsManagement/time Modified Files: ReturnIntervals.cs Log Message: A new constuctor without parameters is now available Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ReturnIntervals.cs 29 Sep 2008 21:17:14 -0000 1.9 --- ReturnIntervals.cs 28 Feb 2009 18:43:16 -0000 1.10 *************** *** 19,23 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; --- 19,23 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; *************** *** 46,56 **** private IIntervalsSelector intervalsSelector; ! public ReturnInterval this[ int index ] { ! get { return( (ReturnInterval) this.List[ index ] ); } ! set { this.List[ index ] = value; --- 46,56 ---- private IIntervalsSelector intervalsSelector; ! public ReturnInterval this[ int index ] { ! get { return( (ReturnInterval) this.List[ index ] ); } ! set { this.List[ index ] = value; *************** *** 67,72 **** if ( this.Count == 0 ) throw new Exception( "LastEndOfDayDateTime " + ! "cannot be used when ReturnIntervals has " + ! "no ReturnInterval added yet!" ); return this[ this.Count - 1 ].End; } --- 67,72 ---- if ( this.Count == 0 ) throw new Exception( "LastEndOfDayDateTime " + ! "cannot be used when ReturnIntervals has " + ! "no ReturnInterval added yet!" ); return this[ this.Count - 1 ].End; } *************** *** 78,83 **** if ( this.Count == 0 ) throw new Exception( "LastInterval " + ! "cannot be used when ReturnIntervals has " + ! "no ReturnInterval added yet!" ); ReturnInterval lastInterval = this[ this.Count - 1 ]; return lastInterval; --- 78,83 ---- if ( this.Count == 0 ) throw new Exception( "LastInterval " + ! "cannot be used when ReturnIntervals has " + ! "no ReturnInterval added yet!" ); ReturnInterval lastInterval = this[ this.Count - 1 ]; return lastInterval; *************** *** 135,139 **** { this.returnIntervals_initialize( firstDateTime, ! lastDateTime , benchmark , 1 );//default intervals are daily } --- 135,139 ---- { this.returnIntervals_initialize( firstDateTime, ! lastDateTime , benchmark , 1 );//default intervals are daily } *************** *** 145,149 **** /// <param name="lastDateTime"></param> /// <param name="benchmark"></param> ! /// <param name="intervalLength"></param> public ReturnIntervals( DateTime firstDateTime , DateTime lastDateTime , --- 145,149 ---- /// <param name="lastDateTime"></param> /// <param name="benchmark"></param> ! /// <param name="intervalLength"></param> public ReturnIntervals( DateTime firstDateTime , DateTime lastDateTime , *************** *** 167,170 **** --- 167,178 ---- /// <summary> + /// creates a ReturnIntervals with no ReturnInterval + /// </summary> + public ReturnIntervals() + { + } + + + /// <summary> /// It creates a ReturnIntervals with just a ReturnInterval /// </summary> *************** *** 178,182 **** this.marketDaysForBenchmark = QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! this.firstDateTime , this.lastDateTime ); } --- 186,190 ---- this.marketDaysForBenchmark = QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! this.firstDateTime , this.lastDateTime ); } *************** *** 200,215 **** foreach ( ReturnInterval returnInterval in this ) if ( !returnInterval.AreBordersCoveredBy( history ) ) ! areAllCovered = false; return areAllCovered; } #region setBordersHistory private bool beginsBeforeTheLastAdded( ReturnInterval ! returnInterval ) { bool beginsBefore = ( ( this.bordersHistory != null ) && ! ( this.bordersHistory.Count > 0 ) && ! ( returnInterval.BeginsBefore( ! this.bordersHistory.LastDateTime ) ) ); return beginsBefore; } --- 208,223 ---- foreach ( ReturnInterval returnInterval in this ) if ( !returnInterval.AreBordersCoveredBy( history ) ) ! areAllCovered = false; return areAllCovered; } #region setBordersHistory private bool beginsBeforeTheLastAdded( ReturnInterval ! returnInterval ) { bool beginsBefore = ( ( this.bordersHistory != null ) && ! ( this.bordersHistory.Count > 0 ) && ! ( returnInterval.BeginsBefore( ! this.bordersHistory.LastDateTime ) ) ); return beginsBefore; } *************** *** 219,230 **** if ( this.beginsBeforeTheLastAdded( returnInterval ) ) throw new Exception( "The first border of the given interval " + ! "begins before the last EndOfDayDateTime added to the history" ); } private bool beginsOnTheLastAddedTime( ReturnInterval returnInterval ) { bool returnValue = ! ( ( this.bordersHistory != null ) && ! ( this.bordersHistory.Count > 0 ) && ! ( this.bordersHistory.LastDateTime == returnInterval.Begin ) ); return returnValue; } --- 227,238 ---- if ( this.beginsBeforeTheLastAdded( returnInterval ) ) throw new Exception( "The first border of the given interval " + ! "begins before the last EndOfDayDateTime added to the history" ); } private bool beginsOnTheLastAddedTime( ReturnInterval returnInterval ) { bool returnValue = ! ( ( this.bordersHistory != null ) && ! ( this.bordersHistory.Count > 0 ) && ! ( this.bordersHistory.LastDateTime == returnInterval.Begin ) ); return returnValue; } *************** *** 254,261 **** --- 262,278 ---- } #endregion setBordersHistory + + #region Add + private void checkParameter( ReturnInterval returnInterval ) + { + if ( ( this.Count > 0 ) && ( returnInterval.Begin < this.LastDateTime ) ) + throw new Exception( "returnInterval must be later" ); + } public void Add( ReturnInterval returnInterval ) { + this.checkParameter( returnInterval ); this.List.Add( returnInterval ); } + #endregion Add #region appendIntervalsButDontGoBeyondLastDate *************** *** 272,276 **** if ( firstDate < currentLastDateTime ) throw new Exception( "firstDate cannot be smaller than " + ! "the end of the last interval already in this collection!" ); } } --- 289,293 ---- if ( firstDate < currentLastDateTime ) throw new Exception( "firstDate cannot be smaller than " + ! "the end of the last interval already in this collection!" ); } } *************** *** 379,383 **** lastDate ); if ( this.LastDateTime < lastDate ) ! // lastDate comes after the last interval already added this.AppendIntervalsButDontGoBeyondLastDate( lastDate ); ReturnInterval lastInterval = --- 396,400 ---- lastDate ); if ( this.LastDateTime < lastDate ) ! // lastDate comes after the last interval already added this.AppendIntervalsButDontGoBeyondLastDate( lastDate ); ReturnInterval lastInterval = |