[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading PairsTradingStra
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-03-06 20:21:02
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6251/b7_Scripts/WalkForwardTesting/PairsTrading Modified Files: PairsTradingStrategy.cs Log Message: the arePositionsToBeClosed() method has been fixed (it was completely buggy) Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/PairsTradingStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PairsTradingStrategy.cs 27 Feb 2008 21:12:36 -0000 1.1 --- PairsTradingStrategy.cs 6 Mar 2008 20:20:50 -0000 1.2 *************** *** 85,95 **** } private bool arePositionsToBeClosed() { ! bool endsTheLastInterval = ! ( this.now().IsEqualTo( ! this.lastIntervalAppended().End ) ); ! return ( endsTheLastInterval ); } protected override bool marketOpenEventHandler_arePositionsToBeOpened() --- 85,111 ---- } + #region arePositionsToBeClosed + private ReturnInterval getSecondLastReturnInterval() + { + int indexForTheSecondLastReturnInterval = + this.returnIntervals.Count - 2; + ReturnInterval secondLastReturnInterval = + this.returnIntervals[ indexForTheSecondLastReturnInterval ]; + return secondLastReturnInterval; + } private bool arePositionsToBeClosed() { ! bool areToBeClosed = false; ! if ( this.returnIntervals.Count > 1 ) ! // at least two intervals have already been ! // added, out of sample ! { ! ReturnInterval secondLastReturnInterval = ! this.getSecondLastReturnInterval(); ! areToBeClosed = this.now().IsEqualTo( secondLastReturnInterval.End ); ! } ! return ( areToBeClosed ); } + #endregion arePositionsToBeClosed protected override bool marketOpenEventHandler_arePositionsToBeOpened() |