[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoose
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-11-18 23:03:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9714/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers Modified Files: OutOfSampleChooser.cs Log Message: regions have been added to make the code more readable Index: OutOfSampleChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/PairsTrading/OutOfSampleChoosers/OutOfSampleChooser.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OutOfSampleChooser.cs 17 Nov 2008 19:51:04 -0000 1.3 --- OutOfSampleChooser.cs 18 Nov 2008 23:03:15 -0000 1.4 *************** *** 86,108 **** #region getInefficientCouples #region getReturnsManagerForLastSecondPhaseInterval ! private DateTime ! getIntervalBeginForLastSecondPhaseInterval( ! ReturnIntervals outOfSampleReturnIntervals ) ! { ! // this method will be invoked only if (this.returnIntervals.Count >= 2) ! int secondLastIntervalIndex = ! outOfSampleReturnIntervals.Count - 2; ! ReturnInterval secondLastInterval = ! outOfSampleReturnIntervals[ secondLastIntervalIndex ]; ! return secondLastInterval.End; ! } ! private DateTime ! getIntervalEndForLastSecondPhaseInterval( ! ReturnIntervals outOfSampleReturnIntervals ) ! { ! return outOfSampleReturnIntervals.LastInterval.Begin; ! } private ReturnInterval getReturnIntervalForLastSecondPhaseInterval( --- 86,112 ---- #region getInefficientCouples + + #region getArrayListOfInefficientCouples #region getReturnsManagerForLastSecondPhaseInterval ! // private DateTime ! // getIntervalBeginForLastSecondPhaseInterval( ! // ReturnIntervals outOfSampleReturnIntervals ) ! // { ! // // this method will be invoked only if (this.returnIntervals.Count >= 2) ! // int secondLastIntervalIndex = ! // outOfSampleReturnIntervals.Count - 2; ! // ReturnInterval secondLastInterval = ! // outOfSampleReturnIntervals[ secondLastIntervalIndex ]; ! // return secondLastInterval.End; ! // } ! // private DateTime ! // getIntervalEndForLastSecondPhaseInterval( ! // ReturnIntervals outOfSampleReturnIntervals ) ! // { ! // return outOfSampleReturnIntervals.LastInterval.Begin; ! // } ! ! #region getReturnIntervalsForLastSecondPhaseInterval private ReturnInterval getReturnIntervalForLastSecondPhaseInterval( *************** *** 140,143 **** --- 144,149 ---- return returnIntervalsForLastSecondPhaseInterval; } + #endregion getReturnIntervalsForLastSecondPhaseInterval + private ReturnsManager getReturnsManagerForLastSecondPhaseInterval( DateTime firstDateTimeToTestInefficiency , *************** *** 159,175 **** } #endregion getReturnsManagerForLastSecondPhaseInterval ! ! private double getReturnForTheLastSecondPhaseInterval( ! ReturnsManager returnsManagerForLastSecondPhaseInterval , ! WeightedPositions weightedPositions ) ! { ! // returnsManager should contain a single ReturnInterval, and ! // this ReturnInterval should be the last second phase interval ! double returnForTheLastSecondPhaseInterval = ! weightedPositions.GetReturn( 0 , ! returnsManagerForLastSecondPhaseInterval ); ! return returnForTheLastSecondPhaseInterval; ! } /// <summary> /// Inverts one of the two positions --- 165,172 ---- } #endregion getReturnsManagerForLastSecondPhaseInterval ! ! #region getInefficientCouples + #region addPositionsIfInefficiencyForCurrentCoupleIsInTheRange /// <summary> /// Inverts one of the two positions *************** *** 190,193 **** --- 187,203 ---- return candidateForPortfolio; } + + #region getPositionsIfInefficiencyIsInTheRange + private double getReturnForTheLastSecondPhaseInterval( + ReturnsManager returnsManagerForLastSecondPhaseInterval , + WeightedPositions weightedPositions ) + { + // returnsManager should contain a single ReturnInterval, and + // this ReturnInterval should be the last second phase interval + double returnForTheLastSecondPhaseInterval = + weightedPositions.GetReturn( 0 , + returnsManagerForLastSecondPhaseInterval ); + return returnForTheLastSecondPhaseInterval; + } // if the currentWeightedPositions' return satisfies the thresholds // then this method returns the WeightedPositions that might be opened. *************** *** 227,230 **** --- 237,242 ---- return weightedPositionsToBeOpened; } + #endregion getPositionsIfInefficiencyIsInTheRange + private void addPositionsIfInefficiencyForCurrentCoupleIsInTheRange( *************** *** 245,248 **** --- 257,262 ---- inefficientCouples.Add( weightedPositionsThatMightBeOpended ); } + #endregion addPositionsIfInefficiencyForCurrentCoupleIsInTheRange + protected ArrayList getInefficientCouples( TestingPositions[] bestTestingPositionsInSample , *************** *** 260,263 **** --- 274,279 ---- return inefficientCouples; } + #endregion getInefficientCouples + private ArrayList getArrayListOfInefficientCouples( *************** *** 280,283 **** --- 296,300 ---- return inefficientCouples; } + #endregion getArrayListOfInefficientCouples #region getInefficientCouplesFromArrayList *************** *** 371,375 **** inSampleReturnsManager ); return positionsToBeOpened; ! } #endregion getPositionsToBeOpened_actually --- 388,392 ---- inSampleReturnsManager ); return positionsToBeOpened; ! } #endregion getPositionsToBeOpened_actually |