[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/returnsManagement ReturnsManager.
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2007-08-01 23:11:06
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10130/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: - public int NumberOfReturns has been added - History.GetDateTime() is now used, to avoid casting and make runtime errors unlikely - minor bug fixes Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReturnsManager.cs 13 Jul 2007 09:47:47 -0000 1.1 --- ReturnsManager.cs 1 Aug 2007 23:11:02 -0000 1.2 *************** *** 54,60 **** } protected DateTime firstDateTime { ! get { return (DateTime)this.timeLineForQuotes[ 0 ]; } } protected DateTime lastDateTime --- 54,67 ---- } + /// <summary> + /// Number of returns, that is TimeLine's elements minus 1 + /// </summary> + public int NumberOfReturns + { + get { return this.TimeLine.Count - 1; } + } protected DateTime firstDateTime { ! get { return this.timeLineForQuotes.GetDateTime( 0 ); } } protected DateTime lastDateTime *************** *** 63,67 **** { int lastIndex = this.timeLineForQuotes.Count - 1; ! return (DateTime)this.timeLineForQuotes[ lastIndex ]; } } --- 70,74 ---- { int lastIndex = this.timeLineForQuotes.Count - 1; ! return this.timeLineForQuotes.GetDateTime( lastIndex ); } } *************** *** 91,95 **** { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = timeLineForQuotes; this.commonInitialization(); } --- 98,102 ---- { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = timeLine; this.commonInitialization(); } *************** *** 122,131 **** { bool areAllCovered = true; ! foreach ( DateTime dateTime in this.timeLineForQuotes ) if ( !returns.ContainsKey( dateTime ) ) areAllCovered = false; return areAllCovered; } ! private float selectReturnOnValidDateTime( History returns , int i ) { --- 129,138 ---- { bool areAllCovered = true; ! foreach ( DateTime dateTime in this.timeLineForQuotes.TimeLine ) if ( !returns.ContainsKey( dateTime ) ) areAllCovered = false; return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History returns , int i ) { *************** *** 134,152 **** return (float)returns[ currentDateTimeForReturn ]; } ! private float[] selectReturnsOnValidDateTimes( History returns ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsOnValidDateTimes = new float[ this.timeLineForQuotes.Count ]; for ( int i = 0 ; i < this.timeLineForQuotes.Count ; i++ ) ! returnsOnValidDateTimes[ i ] = ! this.selectReturnOnValidDateTime( returns , i ); ! return returnsOnValidDateTimes; } ! private void setReturnsActually( string ticker , History returns ) { float[] arrayOfReturns = ! this.selectReturnsOnValidDateTimes( returns ); this.tickersReturns.Add( ticker , arrayOfReturns ); } --- 141,159 ---- return (float)returns[ currentDateTimeForReturn ]; } ! private float[] selectReturnsWithRespectToTheTimeLine( History returns ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsWithRespectToTheTimeLine = new float[ this.timeLineForQuotes.Count ]; for ( int i = 0 ; i < this.timeLineForQuotes.Count ; i++ ) ! returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( returns , i ); ! return returnsWithRespectToTheTimeLine; } ! private void setReturnsActually( string ticker , History quotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheTimeLine( quotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } *************** *** 176,180 **** } #endregion GetReturns ! #region GetReturns /// <summary> /// Gives out the returnIndex_th return for the given ticker --- 183,187 ---- } #endregion GetReturns ! #region GetReturn /// <summary> /// Gives out the returnIndex_th return for the given ticker *************** *** 223,227 **** private float getReturnsStandardDeviation( string ticker ) { ! return (float)this.tickersReturnsStandardDeviations[ ticker ]; } /// <summary> --- 230,234 ---- private float getReturnsStandardDeviation( string ticker ) { ! return Convert.ToSingle( this.tickersReturnsStandardDeviations[ ticker ] ); } /// <summary> |