[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/returnsManagement ReturnsManager.
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2007-08-04 19:59:13
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16358/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Bug fixed: returns were not properly computed Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReturnsManager.cs 1 Aug 2007 23:11:02 -0000 1.2 --- ReturnsManager.cs 4 Aug 2007 19:59:08 -0000 1.3 *************** *** 134,153 **** return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History returns , int i ) { ! DateTime currentDateTimeForReturn = ! (DateTime)this.timeLineForQuotes.GetByIndex( i ); ! 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; } --- 134,154 ---- return areAllCovered; } ! private float selectReturnWithRespectToTheTimeLine( History quotes , int i ) { ! float currentQuote = (float)quotes.GetByIndex( i ); ! float nextQuote = (float)quotes.GetByIndex( i + 1 ); ! float currentReturn = nextQuote / currentQuote - 1; ! return currentReturn; } ! private float[] selectReturnsWithRespectToTheTimeLine( History quotes ) { // 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 - 1 ]; ! for ( int i = 0 ; i < this.timeLineForQuotes.Count - 1 ; i++ ) returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( quotes , i ); return returnsWithRespectToTheTimeLine; } |