[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases FixedLen
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:19:50
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17302/FixedLengthTwoPhases Modified Files: FixedLengthTwoPhasesMain.cs FixedLengthTwoPhasesStrategy.cs Log Message: The new revision moves toward an intraday enabled framework. EndOfDayDate time has been removed, DateTime is used now. The code has been changed accordingly. Index: FixedLengthTwoPhasesStrategy.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/FixedLengthTwoPhasesStrategy.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FixedLengthTwoPhasesStrategy.cs 16 Aug 2008 19:35:59 -0000 1.8 --- FixedLengthTwoPhasesStrategy.cs 29 Sep 2008 21:19:08 -0000 1.9 *************** *** 19,23 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; --- 19,23 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; *************** *** 44,47 **** --- 44,48 ---- /// first phase, then goes with the opposite for the second phase /// </summary> + [Serializable] public class FixedLengthTwoPhasesStrategy : SymmetricEndOfDayStrategyForBacktester *************** *** 66,70 **** IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! IHistoricalQuoteProvider historicalQuoteProvider , RankBasedOutOfSampleChooser outOfSampleChooser ) : --- 67,71 ---- IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , ! HistoricalMarketValueProvider historicalMarketValueProvider , RankBasedOutOfSampleChooser outOfSampleChooser ) : *************** *** 76,80 **** eligiblesSelector , inSampleChooser , ! historicalQuoteProvider ) { this.outOfSampleChooser = outOfSampleChooser; --- 77,81 ---- eligiblesSelector , inSampleChooser , ! historicalMarketValueProvider ) { this.outOfSampleChooser = outOfSampleChooser; *************** *** 97,102 **** bool arePositionsToBeClosed = ( ( this.Account.Portfolio.Count > 0 ) && ! ( this.now().IsEqualTo( ! this.lastIntervalAppended().Begin ) ) ); return arePositionsToBeClosed; } --- 98,103 ---- bool arePositionsToBeClosed = ( ( this.Account.Portfolio.Count > 0 ) && ! ( this.now() == ! this.lastIntervalAppended().Begin ) ); return arePositionsToBeClosed; } *************** *** 114,119 **** { bool beginsTheLastInterval = ! ( this.now().IsEqualTo( ! this.lastIntervalAppended().Begin ) ); bool lastIntervalIsALongPeriod = this.lastAppendedIntervalIsALongPeriod(); --- 115,120 ---- { bool beginsTheLastInterval = ! ( this.now() == ! this.lastIntervalAppended().Begin ); bool lastIntervalIsALongPeriod = this.lastAppendedIntervalIsALongPeriod(); *************** *** 135,139 **** WeightedPositions weightedPositions = this.outOfSampleChooser.GetPositionsToBeOpened( ! this.bestTestingPositionsInSample ); return weightedPositions; } --- 136,140 ---- WeightedPositions weightedPositions = this.outOfSampleChooser.GetPositionsToBeOpened( ! this.bestTestingPositionsInSample ); return weightedPositions; } *************** *** 309,318 **** // new FixedLengthTwoPhasesLogItem( this.now() ); // logItem.BestWeightedPositionsInSample = this.bestWeightedPositionsInSample; ! //// this.wFLagWeightedPositionsChooser.WFLagChosenPositions , ! //// this.wFLagWeightedPositionsChooser.GenerationWhenChosenPositionsWereFound , ! //// this.now().DateTime ); ! //// this.NewChosenPositions( ! //// this , new WFLagNewChosenPositionsEventArgs( ! //// wFLagLogItem ) ); // } // public void OneHourAfterMarketCloseEventHandler( --- 310,319 ---- // new FixedLengthTwoPhasesLogItem( this.now() ); // logItem.BestWeightedPositionsInSample = this.bestWeightedPositionsInSample; ! //// this.wFLagWeightedPositionsChooser.WFLagChosenPositions , ! //// this.wFLagWeightedPositionsChooser.GenerationWhenChosenPositionsWereFound , ! //// this.now().DateTime ); ! //// this.NewChosenPositions( ! //// this , new WFLagNewChosenPositionsEventArgs( ! //// wFLagLogItem ) ); // } // public void OneHourAfterMarketCloseEventHandler( Index: FixedLengthTwoPhasesMain.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/FixedLengthTwoPhases/FixedLengthTwoPhasesMain.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FixedLengthTwoPhasesMain.cs 18 Aug 2008 21:13:20 -0000 1.10 --- FixedLengthTwoPhasesMain.cs 29 Sep 2008 21:19:08 -0000 1.11 *************** *** 54,60 **** private Benchmark benchmark; private int numberOfPortfolioPositions; ! private IHistoricalQuoteProvider historicalQuoteProviderForInSample; ! private IHistoricalQuoteProvider ! historicalQuoteProviderForTheBacktesterAccount; public FixedLengthTwoPhasesMain() --- 54,60 ---- private Benchmark benchmark; private int numberOfPortfolioPositions; ! private HistoricalMarketValueProvider historicalMarketValueProviderForInSample; ! private HistoricalMarketValueProvider ! historicalMarketValueProviderForTheBacktesterAccount; public FixedLengthTwoPhasesMain() *************** *** 62,68 **** this.benchmark = new Benchmark( "CCE" ); this.numberOfPortfolioPositions = 2; ! this.historicalQuoteProviderForInSample = new HistoricalRawQuoteProvider(); ! this.historicalQuoteProviderForTheBacktesterAccount = new HistoricalRawQuoteProvider(); } --- 62,68 ---- this.benchmark = new Benchmark( "CCE" ); this.numberOfPortfolioPositions = 2; ! this.historicalMarketValueProviderForInSample = new HistoricalRawQuoteProvider(); ! this.historicalMarketValueProviderForTheBacktesterAccount = new HistoricalRawQuoteProvider(); } *************** *** 126,131 **** double mutationRate = 0.02; double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 10000; ! int generationNumberForGeneticOptimizer = 5; int seedForRandomGenerator = QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; --- 126,131 ---- double mutationRate = 0.02; double elitismRate = 0.001; ! int populationSizeForGeneticOptimizer = 2000; ! int generationNumberForGeneticOptimizer = 3; int seedForRandomGenerator = QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator; *************** *** 136,140 **** benchmark , decoderForWeightedPositions , fitnessEvaluator , ! this.historicalQuoteProviderForInSample , crossoverRate , mutationRate , elitismRate , populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , --- 136,140 ---- benchmark , decoderForWeightedPositions , fitnessEvaluator , ! this.historicalMarketValueProviderForInSample , crossoverRate , mutationRate , elitismRate , populationSizeForGeneticOptimizer , generationNumberForGeneticOptimizer , *************** *** 155,167 **** } ! protected override IEndOfDayStrategyForBacktester getEndOfDayStrategy() { // int numberOfPortfolioPositions = 2; int numDaysForInSampleOptimization = 180; // uncomment the following line for a faster script ! numDaysForInSampleOptimization = 5; numDaysForInSampleOptimization = 45; ! int numDaysBetweenEachOtpimization = 3; IIntervalsSelector intervalsSelector = --- 155,167 ---- } ! protected override IStrategyForBacktester getStrategyForBacktester() { // int numberOfPortfolioPositions = 2; int numDaysForInSampleOptimization = 180; // uncomment the following line for a faster script ! // numDaysForInSampleOptimization = 8; numDaysForInSampleOptimization = 45; ! int numDaysBetweenEachOtpimization = 7; IIntervalsSelector intervalsSelector = *************** *** 179,183 **** benchmark , intervalsSelector , eligiblesSelector , inSampleChooser , ! this.historicalQuoteProviderForInSample , outOfSampleChooser ); // IEndOfDayStrategyForBacktester endOfDayStrategyForBacktester = --- 179,183 ---- benchmark , intervalsSelector , eligiblesSelector , inSampleChooser , ! this.historicalMarketValueProviderForInSample , outOfSampleChooser ); // IEndOfDayStrategyForBacktester endOfDayStrategyForBacktester = *************** *** 206,217 **** DateTime firstDateTime = new DateTime( 2006 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2008 , 4 , 1 ); ! double maxRunningHours = 8; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! backTestId , this.endOfDayStrategy , ! this.historicalQuoteProviderForTheBacktesterAccount , accountProvider , firstDateTime , lastDateTime , --- 206,217 ---- DateTime firstDateTime = new DateTime( 2006 , 1 , 1 ); ! DateTime lastDateTime = new DateTime( 2007 , 12 , 31 ); ! double maxRunningHours = 0.01; EndOfDayStrategyBackTester endOfDayStrategyBackTester = new EndOfDayStrategyBackTester( ! backTestId , this.strategyForBacktester , ! this.historicalMarketValueProviderForTheBacktesterAccount , accountProvider , firstDateTime , lastDateTime , |