[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/InSample BasicChooserFromSavedBac
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-04-25 17:17:34
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19178/b4_Business/a2_Strategies/InSample Modified Files: BasicChooserFromSavedBackTestLog.cs Log Message: Added if for avoiding run time error when null events are fired Index: BasicChooserFromSavedBackTestLog.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample/BasicChooserFromSavedBackTestLog.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicChooserFromSavedBackTestLog.cs 10 Apr 2008 23:11:32 -0000 1.2 --- BasicChooserFromSavedBackTestLog.cs 25 Apr 2008 17:17:19 -0000 1.3 *************** *** 46,49 **** --- 46,51 ---- public event NewMessageEventHandler NewMessage; + protected int numberOfBestTestingPositionsToBeReturned; + protected TestingPositions[] bestTestingPositionsInSample; protected string backTestLogFullPath; protected BackTestLog backTestLog; *************** *** 58,61 **** --- 60,77 ---- } + private void setBackTestLog() + { + if( this.backTestLog == null ) + { + object savedObject = ObjectArchiver.Extract( + this.backTestLogFullPath); + if( savedObject is BackTestLog ) + this.backTestLog = (BackTestLog)savedObject; + else // savedObject is not a BackTestLog + throw new Exception("The loaded object is not " + + " a BackTestLog!"); + } + } + /// <summary> /// Abstract BasicChooserFromSavedBackTestLog to be used for *************** *** 64,70 **** /// </summary> public BasicChooserFromSavedBackTestLog( ! string backTestLogFullPath) { this.backTestLogFullPath = backTestLogFullPath; } --- 80,89 ---- /// </summary> public BasicChooserFromSavedBackTestLog( ! string backTestLogFullPath, int numberOfBestTestingPositionsToBeReturned) { this.backTestLogFullPath = backTestLogFullPath; + this.numberOfBestTestingPositionsToBeReturned = + numberOfBestTestingPositionsToBeReturned; + this.setBackTestLog(); } *************** *** 72,89 **** EndOfDayDateTime lastInSampleDateOfOptimizedTestingPositions ); ! protected void analyzeInSample_setBackTestLog() { ! if( this.backTestLog == null ) ! { ! object savedObject = ObjectArchiver.Extract( ! this.backTestLogFullPath); ! if( savedObject is BackTestLog ) ! this.backTestLog = (BackTestLog)savedObject; ! else // savedObject is not a BackTestLog ! throw new Exception("The loaded object is not " + ! " a BackTestLog!"); ! } } ! /// <summary> /// Returns the best TestingPositions --- 91,104 ---- EndOfDayDateTime lastInSampleDateOfOptimizedTestingPositions ); ! private void analyzeInSample_fireEvents() { ! if(this.NewProgress != null) ! this.NewProgress( this , ! new NewProgressEventArgs( 1 , 1 ) ); ! if(this.NewMessage != null) ! this.NewMessage( this , ! new NewMessageEventArgs( "AnalyzeInSample is complete" ) ); } ! /// <summary> /// Returns the best TestingPositions *************** *** 96,107 **** ReturnsManager returnsManager ) { ! this.analyzeInSample_setBackTestLog(); ! TestingPositions[] bestTestingPositionsInSample = this.getTestingPositionsFromBackTestLog( returnsManager.ReturnIntervals.LastEndOfDayDateTime ); ! this.NewProgress( this , ! new NewProgressEventArgs( 1 , 1 ) ); ! this.NewMessage( this , ! new NewMessageEventArgs( "AnalyzeInSample is complete" ) ); return bestTestingPositionsInSample; } --- 111,118 ---- ReturnsManager returnsManager ) { ! this.bestTestingPositionsInSample = this.getTestingPositionsFromBackTestLog( returnsManager.ReturnIntervals.LastEndOfDayDateTime ); ! this.analyzeInSample_fireEvents(); return bestTestingPositionsInSample; } |