[Quantproject-developers] QuantProject/b4_Business/a2_Strategies EndOfDayStrategyBackTester.cs, 1.1
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:18:11
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20549/a2_Strategies Modified Files: EndOfDayStrategyBackTester.cs Log Message: A new feature has been added, to allow the user to force the script to complete and produce a report, without having to wait for the conditions written in the code. The user can to request an immediate completion of the script, by creating a file with name stop.txt in the folder where the .exe file is launched. Index: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EndOfDayStrategyBackTester.cs 24 Nov 2008 21:03:42 -0000 1.15 --- EndOfDayStrategyBackTester.cs 28 Mar 2010 14:18:03 -0000 1.16 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.IO; using QuantProject.ADT; *************** *** 233,236 **** --- 234,251 ---- #region Run + + private void checkIfAFileStopTxtIsAlreadyInTheExecutionFolder() + { + bool isAFileStopTxtIsInTheExecutionFolder = + this.checkIfAFileStopTxtIsInTheExecutionFolder(); + if ( isAFileStopTxtIsInTheExecutionFolder ) + throw new Exception( + "The backtester has been asket to run, but a file stop.txt is " + + "in the execution folder. A file stop.txt should be put " + + "in the execution folder when the user wants to stop the " + + "backtest. Such a file should not be in the execution " + + "folder when the backtest begins." ); + } + #region run_addEventHandlers private void handlerToAddCashToStart( *************** *** 312,315 **** --- 327,331 ---- public void Run() { + this.checkIfAFileStopTxtIsAlreadyInTheExecutionFolder(); this.startingTimeForScript = DateTime.Now; *************** *** 328,331 **** --- 344,363 ---- #region isTimeToStop + + #region checkIfAFileStopTxtIsInTheExecutionFolder + private string getFullPathFileName() + { + string currentDirectory = Environment.CurrentDirectory; + string fullPathFileName = currentDirectory + "\\stop.txt"; + return fullPathFileName; + } + private bool checkIfAFileStopTxtIsInTheExecutionFolder() + { + string fullPathFileName = this.getFullPathFileName(); + bool isFileStopTxtInTheExecutionFolder = File.Exists( fullPathFileName ); + return isFileStopTxtInTheExecutionFolder; + } + #endregion checkIfAFileStopTxtIsInTheExecutionFolder + private bool getIsMaxScriptRealTimeElapsed() { *************** *** 338,341 **** --- 370,375 ---- private bool isTimeToStop( DateTime currentTime ) { + bool isFileStopTxtInTheExecutionFolder = + this.checkIfAFileStopTxtIsInTheExecutionFolder(); bool isMaxScriptRealTimeElapsed = this.getIsMaxScriptRealTimeElapsed(); *************** *** 345,348 **** --- 379,383 ---- return ( ( currentTime > this.lastDateTime ) || + isFileStopTxtInTheExecutionFolder || ( isMaxScriptRealTimeElapsed && stopBacktestIfMaxRunningHoursHasBeenReached ) || |