[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting GenomeManagerForEfficient
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-08-29 09:56:08
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16135/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientOTCCTOPortfolio.cs GenomeManagerForEfficientPortfolio.cs Log Message: Minor changes Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GenomeManagerForEfficientPortfolio.cs 3 Jan 2007 23:20:14 -0000 1.27 --- GenomeManagerForEfficientPortfolio.cs 29 Aug 2007 09:56:00 -0000 1.28 *************** *** 24,27 **** --- 24,28 ---- using System.Data; using System.Collections; + using QuantProject.ADT.Statistics; using QuantProject.ADT.Optimizing.Genetic; *************** *** 29,33 **** --- 30,36 ---- using QuantProject.Data; using QuantProject.Data.DataTables; + using QuantProject.Business.Strategies; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; + using QuantProject.Scripts.WalkForwardTesting.WalkForwardLag; namespace QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios *************** *** 60,71 **** protected GeneticOptimizer currentGeneticOptimizer; - static public string GetCleanTickerCode(string tickerCodeForLongOrShortTrade) - { - if(tickerCodeForLongOrShortTrade.StartsWith("-")) - return tickerCodeForLongOrShortTrade.Substring(1,tickerCodeForLongOrShortTrade.Length -1); - else - return tickerCodeForLongOrShortTrade; - } - //IGenomeManager implementation for properties public virtual int GenomeSize --- 63,66 ---- *************** *** 154,158 **** this.maxValueForGenes = - 1; break; ! case QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios.PortfolioType.ShortAndLong : //Both Long and Short orders are admitted this.minValueForGenes = - this.originalNumOfTickers; --- 149,153 ---- this.maxValueForGenes = - 1; break; ! default : //Both Long and Short orders are admitted this.minValueForGenes = - this.originalNumOfTickers; *************** *** 234,238 **** this.variance = portfolioVariance; this.rateOfReturn = averagePortfolioRateOfReturn; ! returnValue = this.getFitnessValue_calculate(); } --- 229,246 ---- this.variance = portfolioVariance; this.rateOfReturn = averagePortfolioRateOfReturn; ! SignedTickers signedTickers = ! new SignedTickers( ((GenomeMeaning)genome.Meaning).Tickers ); ! WeightedPositions weightedPositions = ! new WeightedPositions( ((GenomeMeaning)genome.Meaning).TickersPortfolioWeights, ! signedTickers ); ! if( this.portfolioType == PortfolioType.OnlyMixed && ! ( weightedPositions.NumberOfLongPositions == 0 || ! weightedPositions.NumberOfShortPositions == 0 ) ) ! // if both long and short positions have to be taken and ! // there aren't both long and short positions in portfolio ! returnValue = -1.0; ! else//short and long, only long or only short portfolio OR ! //Only Mixed portfolio with both long and short position ! returnValue = this.getFitnessValue_calculate(); } *************** *** 280,290 **** // in this implementation new gene values must be different from // the others already stored in the given genome - // the generation of new genes doesn't depend on gene's position - // within the genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); ! while(GenomeManipulator.IsTickerContainedInGenome(returnValue, ! genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), --- 288,295 ---- // in this implementation new gene values must be different from // the others already stored in the given genome int returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), genome.GetMaxValueForGenes(genePosition) + 1); ! while( GenomeManipulator.IsTickerContainedInGenome(returnValue,genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { returnValue = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePosition), *************** *** 303,317 **** genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); ! while(GenomeManipulator.IsTickerContainedInGenome(newValueForGene, ! genome) ) ! //the efficient portfolio, in this implementation, ! // can't have a long position and a short position ! // for the same ticker { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); } ! GenomeManagement.MutateOneGene(genome, ! genePositionToBeMutated, newValueForGene); } --- 308,318 ---- genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); ! while( GenomeManipulator.IsTickerContainedInGenome(newValueForGene,genome) ) ! //the portfolio can't have a long position and a short one for the same ticker { newValueForGene = GenomeManagement.RandomGenerator.Next(genome.GetMinValueForGenes(genePositionToBeMutated), genome.GetMaxValueForGenes(genePositionToBeMutated) + 1); } ! GenomeManagement.MutateOneGene(genome, genePositionToBeMutated, newValueForGene); } Index: GenomeManagerForEfficientOTCCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientOTCCTOPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GenomeManagerForEfficientOTCCTOPortfolio.cs 9 Apr 2007 18:02:18 -0000 1.4 --- GenomeManagerForEfficientOTCCTOPortfolio.cs 29 Aug 2007 09:56:00 -0000 1.5 *************** *** 38,42 **** /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCCTOPortfolio : GenomeManagerForEfficientPortfolio { --- 38,42 ---- /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCCTOPortfolio : GenomeManagerForWeightedEfficientPortfolio { |