[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Pairs
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-11-17 19:54:05
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21278/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies Modified Files: PairsTradingStrategy.cs Log Message: - changed to work with the new OutOfSampleChooser - this.returnIntervals is not used anymore - now, the inefficiency is tested between two DateTime(s) Index: PairsTradingStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/Strategies/PairsTradingStrategy.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PairsTradingStrategy.cs 29 Sep 2008 21:21:35 -0000 1.5 --- PairsTradingStrategy.cs 17 Nov 2008 19:53:58 -0000 1.6 *************** *** 109,122 **** } ! protected override WeightedPositions getPositionsToBeOpened() { ! WeightedPositions weightedPositions = this.outOfSampleChooser.GetPositionsToBeOpened( this.bestTestingPositionsInSample , ! this.returnIntervals , this.historicalMarketValueProviderForChosingPositionsOutOfSample , this.inSampleReturnsManager ); ! return weightedPositions; } protected override LogItem getLogItem( EligibleTickers eligibleTickers ) --- 109,177 ---- } ! #region getPositionsToBeOpened ! ! #region getPositionsToBeOpened_withAtLeastASecondPhaseInterval ! ! #region getFirstDateTimeToTestInefficiency ! private DateTime ! getIntervalBeginForLastSecondPhaseInterval() { ! // this method will be invoked only if (this.returnIntervals.Count >= 2) ! int secondLastIntervalIndex = ! this.returnIntervals.Count - 2; ! ReturnInterval secondLastInterval = ! this.returnIntervals[ secondLastIntervalIndex ]; ! return secondLastInterval.End; ! } ! private DateTime getFirstDateTimeToTestInefficiency() ! { ! DateTime firstDateTimeToTestInefficiency = ! this.getIntervalBeginForLastSecondPhaseInterval(); ! return firstDateTimeToTestInefficiency; ! } ! #endregion getFirstDateTimeToTestInefficiency ! ! #region getLastDateTimeToTestInefficiency ! private DateTime ! getIntervalEndForLastSecondPhaseInterval() ! { ! return this.returnIntervals.LastInterval.Begin; ! } ! private DateTime getLastDateTimeToTestInefficiency() ! { ! DateTime lastDateTimeToTestInefficiency = ! this.getIntervalEndForLastSecondPhaseInterval(); ! return lastDateTimeToTestInefficiency; ! } ! #endregion getLastDateTimeToTestInefficiency ! ! private WeightedPositions getPositionsToBeOpened_withAtLeastASecondPhaseInterval() ! { ! DateTime firstDateTimeToTestInefficiency = ! this.getFirstDateTimeToTestInefficiency(); ! DateTime lastDateTimeToTestInefficiency = ! this.getLastDateTimeToTestInefficiency(); ! WeightedPositions positionsToBeOpened = this.outOfSampleChooser.GetPositionsToBeOpened( this.bestTestingPositionsInSample , ! firstDateTimeToTestInefficiency , ! lastDateTimeToTestInefficiency , ! // this.returnIntervals , this.historicalMarketValueProviderForChosingPositionsOutOfSample , this.inSampleReturnsManager ); ! return positionsToBeOpened; } + #endregion getPositionsToBeOpened_withAtLeastASecondPhaseInterval + + protected override WeightedPositions getPositionsToBeOpened() + { + WeightedPositions positionsToBeOpened = null; + if ( this.returnIntervals.Count >= 2 ) + // // at least a second phase interval exists + positionsToBeOpened = + this.getPositionsToBeOpened_withAtLeastASecondPhaseInterval(); + return positionsToBeOpened; + } + #endregion getPositionsToBeOpened protected override LogItem getLogItem( EligibleTickers eligibleTickers ) |