[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting EndOfDayTimerHandler.cs,1.1
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27684/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTCTest.cs EndOfDayTimerHandlerCTO.cs EndOfDayTimerHandlerCTOTest.cs GenomeManagerForEfficientCTCPortfolio.cs GenomeManagerForEfficientPortfolio.cs RunEfficientCTCPortfolio.cs RunEfficientCTOPortfolio.cs RunEfficientPortfolio.cs RunLastChosenPortfolioOutOfSample.cs RunTestOptimizedCTCPortfolio.cs RunTestOptimizedCTOPortfolio.cs Log Message: - "Porfolio" fixed to "Portfolio"; - added GenomeCounter to the base EndOfDayTimerHandler; - modified setTickers methods in close to close and open to close Handlers in order to provide the use of GenomeCounter object; - showed in form.Text property GenomeCounter's info for the RunTestOptimizedCTCPortfolio and RunTestOptimizedCTOPortfolio Index: RunTestOptimizedCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTOPortfolio.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunTestOptimizedCTOPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.5 --- RunTestOptimizedCTOPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.6 *************** *** 50,57 **** /// </summary> [Serializable] ! public class RunTestOptimizedCTOPorfolio : RunEfficientCTOPorfolio { ! public RunTestOptimizedCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 50,57 ---- /// </summary> [Serializable] ! public class RunTestOptimizedCTOPortfolio : RunEfficientCTOPortfolio { ! public RunTestOptimizedCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, *************** *** 98,101 **** --- 98,102 ---- this.benchmark ); report.Show(); + report.Text = this.getGenomeCounterInfo(); } Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** EndOfDayTimerHandler.cs 24 Jun 2005 22:52:25 -0000 1.13 --- EndOfDayTimerHandler.cs 27 Jul 2005 22:30:55 -0000 1.14 *************** *** 66,69 **** --- 66,75 ---- protected PortfolioType portfolioType; + + protected GenomeCounter genomeCounter; + public GenomeCounter GenomeCounter + { + get{return this.genomeCounter;} + } public string[] LastChosenTickers Index: RunEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCPortfolio.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunEfficientCTCPortfolio.cs 25 Jul 2005 22:36:56 -0000 1.9 --- RunEfficientCTCPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.10 *************** *** 57,61 **** /// </summary> [Serializable] ! public class RunEfficientCTCPorfolio : RunEfficientPorfolio { protected int numDayOfPortfolioLife; --- 57,61 ---- /// </summary> [Serializable] ! public class RunEfficientCTCPortfolio : RunEfficientPortfolio { protected int numDayOfPortfolioLife; *************** *** 63,67 **** protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 63,67 ---- protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunTestOptimizedCTCPortfolio.cs 25 Jul 2005 22:35:43 -0000 1.3 --- RunTestOptimizedCTCPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.4 *************** *** 57,61 **** /// </summary> [Serializable] ! public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPorfolio { --- 57,61 ---- /// </summary> [Serializable] ! public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPortfolio { *************** *** 107,110 **** --- 107,111 ---- this.benchmark ); report.Show(); + report.Text = this.getGenomeCounterInfo(); } Index: GenomeManagerForEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTCPortfolio.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GenomeManagerForEfficientCTCPortfolio.cs 25 Jul 2005 22:49:54 -0000 1.8 --- GenomeManagerForEfficientCTCPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.9 *************** *** 40,44 **** public class GenomeManagerForEfficientCTCPortfolio : GenomeManagerForEfficientPortfolio { - private int numDaysOfPortfolioLife; private int numDaysForReturnCalculation; --- 40,43 ---- *************** *** 47,51 **** DateTime lastQuoteDate, int numberOfTickersInPortfolio, - int numDaysOfPortfolioLife, int numDaysForReturnCalculation, double targetPerformance, --- 46,49 ---- *************** *** 61,65 **** { - this.numDaysOfPortfolioLife = numDaysOfPortfolioLife; this.numDaysForReturnCalculation = numDaysForReturnCalculation; this.retrieveData(); --- 59,62 ---- Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EndOfDayTimerHandlerCTO.cs 25 Jul 2005 22:52:02 -0000 1.14 --- EndOfDayTimerHandlerCTO.cs 27 Jul 2005 22:30:55 -0000 1.15 *************** *** 46,49 **** --- 46,50 ---- protected int numDaysBetweenEachOptimization; private int numDaysElapsedSinceLastOptimization; + public EndOfDayTimerHandlerCTO(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, *************** *** 132,137 **** } ! ! protected virtual void setTickers(DateTime currentDate) { --- 133,138 ---- } ! protected virtual void setTickers(DateTime currentDate, ! bool setGenomeCounter) { *************** *** 152,156 **** GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer); GO.Run(false); --- 153,160 ---- GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! ConstantsProvider.SeedForRandomGenerator); ! if(setGenomeCounter) ! this.genomeCounter = new GenomeCounter(GO); GO.Run(false); *************** *** 184,188 **** this.numDaysBetweenEachOptimization) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //sets tickers to be chosen next Market Open event this.numDaysElapsedSinceLastOptimization = 0; --- 188,192 ---- this.numDaysBetweenEachOptimization) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //sets tickers to be chosen next Market Open event this.numDaysElapsedSinceLastOptimization = 0; Index: RunLastChosenPortfolioOutOfSample.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunLastChosenPortfolioOutOfSample.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunLastChosenPortfolioOutOfSample.cs 25 Jun 2005 09:50:44 -0000 1.2 --- RunLastChosenPortfolioOutOfSample.cs 27 Jul 2005 22:30:56 -0000 1.3 *************** *** 52,56 **** /// </summary> [Serializable] ! public class RunLastChosenPortfolioOutOfSample : RunEfficientPorfolio { private string[] tickers; --- 52,56 ---- /// </summary> [Serializable] ! public class RunLastChosenPortfolioOutOfSample : RunEfficientPortfolio { private string[] tickers; Index: EndOfDayTimerHandlerCTOTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTOTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EndOfDayTimerHandlerCTOTest.cs 26 Jun 2005 14:53:07 -0000 1.5 --- EndOfDayTimerHandlerCTOTest.cs 27 Jul 2005 22:30:55 -0000 1.6 *************** *** 45,48 **** --- 45,49 ---- { private static bool optimized; + public EndOfDayTimerHandlerCTOTest(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, *************** *** 61,69 **** } ! protected override void setTickers(DateTime currentDate) { ! if(!EndOfDayTimerHandlerCTOTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity)); EndOfDayTimerHandlerCTOTest.optimized = true; } --- 62,74 ---- } ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) { ! //setGenomeCounter never used; it is necessary for overriding ! ! if(!EndOfDayTimerHandlerCTOTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity), ! true); EndOfDayTimerHandlerCTOTest.optimized = true; } Index: RunEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientPortfolio.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RunEfficientPortfolio.cs 25 Jun 2005 09:50:44 -0000 1.10 --- RunEfficientPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.11 *************** *** 2,6 **** QuantProject - Quantitative Finance Library ! RunEfficientPorfolio.cs Copyright (C) 2003 Marco Milletti --- 2,6 ---- QuantProject - Quantitative Finance Library ! RunEfficientPortfolio.cs Copyright (C) 2003 Marco Milletti *************** *** 51,55 **** /// </summary> [Serializable] ! public class RunEfficientPorfolio { protected string tickerGroupID; --- 51,55 ---- /// </summary> [Serializable] ! public class RunEfficientPortfolio { protected string tickerGroupID; *************** *** 108,112 **** } ! public RunEfficientPorfolio(string benchmark, DateTime startDate, DateTime endDate, PortfolioType portfolioType, --- 108,112 ---- } ! public RunEfficientPortfolio(string benchmark, DateTime startDate, DateTime endDate, PortfolioType portfolioType, *************** *** 126,130 **** } ! public RunEfficientPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 126,130 ---- } ! public RunEfficientPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, *************** *** 155,158 **** --- 155,170 ---- //this.numIntervalDays = 3; } + + protected string getGenomeCounterInfo() + { + string returnValue = ""; + if(this.endOfDayTimerHandler.GenomeCounter != null) + returnValue = "Total generated genomes: " + + this.endOfDayTimerHandler.GenomeCounter.TotalEvaluatedGenomes.ToString() + + "; Current fitness: " + + this.endOfDayTimerHandler.GenomeCounter.BestFitness.ToString(); + return returnValue; + } + #region Run Index: EndOfDayTimerHandlerCTCTest.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTCTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerCTCTest.cs 26 Jun 2005 14:53:07 -0000 1.2 --- EndOfDayTimerHandlerCTCTest.cs 27 Jul 2005 22:30:55 -0000 1.3 *************** *** 71,79 **** } ! protected override void setTickers(DateTime currentDate) { if(!EndOfDayTimerHandlerCTCTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity)); EndOfDayTimerHandlerCTCTest.optimized = true; } --- 71,82 ---- } ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) { + //setGenomeCounter never used; it is necessary for overriding if(!EndOfDayTimerHandlerCTCTest.optimized) { ! base.setTickers(currentDate.AddDays(this.numDaysForLiquidity), ! true); EndOfDayTimerHandlerCTCTest.optimized = true; } Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RunEfficientCTOPortfolio.cs 24 Jun 2005 22:52:25 -0000 1.20 --- RunEfficientCTOPortfolio.cs 27 Jul 2005 22:30:56 -0000 1.21 *************** *** 54,61 **** /// </summary> [Serializable] ! public class RunEfficientCTOPorfolio : RunEfficientPorfolio { protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, --- 54,61 ---- /// </summary> [Serializable] ! public class RunEfficientCTOPortfolio : RunEfficientPortfolio { protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GenomeManagerForEfficientPortfolio.cs 25 Jul 2005 22:47:57 -0000 1.13 --- GenomeManagerForEfficientPortfolio.cs 27 Jul 2005 22:30:55 -0000 1.14 *************** *** 120,123 **** --- 120,124 ---- this.portfolioType = portfolioType; this.setMinAndMaxValueForGenes(); + GenomeManagement.SetRandomGenerator(QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator); } *************** *** 203,207 **** public Genome[] GetChilds(Genome parent1, Genome parent2) { ! return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, this.constToDiscoverDuplicateGenes); --- 204,208 ---- public Genome[] GetChilds(Genome parent1, Genome parent2) { ! return GenomeManagement.MixGenesWithoutDuplicates(parent1, parent2, this.constToDiscoverDuplicateGenes); Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EndOfDayTimerHandlerCTC.cs 25 Jul 2005 22:59:57 -0000 1.10 --- EndOfDayTimerHandlerCTC.cs 27 Jul 2005 22:30:55 -0000 1.11 *************** *** 147,151 **** ! protected virtual void setTickers(DateTime currentDate) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); --- 147,152 ---- ! protected virtual void setTickers(DateTime currentDate, ! bool setGenomeCounter) { DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); *************** *** 164,174 **** currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfTickersToBeChosen, ! this.numDaysOfPortfolioLife, this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer); ! //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; --- 165,178 ---- currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfTickersToBeChosen, ! this.numDaysForReturnCalculation, this.targetReturn, this.portfolioType); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTCPortfolio, this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! ConstantsProvider.SeedForRandomGenerator); ! if(setGenomeCounter) ! this.genomeCounter = new GenomeCounter(GO); ! GO.Run(false); this.chosenTickers = (string[])GO.BestGenome.Meaning; *************** *** 191,195 **** { this.orders.Clear(); ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //it sets tickers to be chosen at next close } --- 195,199 ---- { this.orders.Clear(); ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //it sets tickers to be chosen at next close } |