[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting GenomeManagerForEfficientOT
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4734/b7_Scripts/TickerSelectionTesting Modified Files: GenomeManagerForEfficientOTCPortfolio.cs GenomeManagerForEfficientCTOPortfolio.cs GenomeManagerForEfficientCTCPortfolio.cs Log Message: Updated genome managers for Open to Close and Close to Open strategies Index: GenomeManagerForEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTOPortfolio.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GenomeManagerForEfficientCTOPortfolio.cs 7 Jan 2006 10:35:39 -0000 1.17 --- GenomeManagerForEfficientCTOPortfolio.cs 14 May 2006 18:36:37 -0000 1.18 *************** *** 40,44 **** public class GenomeManagerForEfficientCTOPortfolio : GenomeManagerForEfficientPortfolio { ! public GenomeManagerForEfficientCTOPortfolio(DataTable setOfInitialTickers, DateTime firstQuoteDate, --- 40,44 ---- public class GenomeManagerForEfficientCTOPortfolio : GenomeManagerForEfficientPortfolio { ! private GenomeManagerForEfficientOTCPortfolio genManOTC; public GenomeManagerForEfficientCTOPortfolio(DataTable setOfInitialTickers, DateTime firstQuoteDate, *************** *** 56,59 **** --- 56,65 ---- { this.retrieveData(); + this.genManOTC = new GenomeManagerForEfficientOTCPortfolio(setOfInitialTickers, + firstQuoteDate, + lastQuoteDate, + numberOfTickersInPortfolio, + targetPerformance, + portfolioType); } private float[] getArrayOfRatesOfReturn_getCloseToOpenRates(Quotes tickerQuotes) *************** *** 79,82 **** --- 85,119 ---- return returnValue; } + public override double GetFitnessValue(Genome genome) + { + double returnValue = 0; + this.portfolioRatesOfReturn = this.getPortfolioRatesOfReturn(genome.Genes()); + double averagePortfolioRateOfReturn = + BasicFunctions.SimpleAverage(this.portfolioRatesOfReturn); + + double portfolioVariance = + BasicFunctions.Variance(this.portfolioRatesOfReturn); + + if(!Double.IsInfinity(portfolioVariance) && + !Double.IsInfinity(averagePortfolioRateOfReturn) && + !Double.IsNaN(portfolioVariance) && + !Double.IsNaN(averagePortfolioRateOfReturn) && + portfolioVariance > 0.0) + //both variance and rate of return are + //double values computed in the right way: + // so it's possible to assign fitness + { + this.variance = portfolioVariance; + this.rateOfReturn = averagePortfolioRateOfReturn; + //returnValue = this.getFitnessValue_calculate(); + returnValue = this.getFitnessValue_calculate() - + this.genManOTC.GetFitnessValue(genome); + + } + + return returnValue; + } + + /*using LPM protected override double getFitnessValue_calculate() Index: GenomeManagerForEfficientOTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientOTCPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GenomeManagerForEfficientOTCPortfolio.cs 7 Jan 2006 10:35:39 -0000 1.1 --- GenomeManagerForEfficientOTCPortfolio.cs 14 May 2006 18:36:37 -0000 1.2 *************** *** 38,42 **** /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCPortfolio : GenomeManagerForWeightedEfficientPortfolio { --- 38,42 ---- /// </summary> [Serializable] ! public class GenomeManagerForEfficientOTCPortfolio : GenomeManagerForEfficientPortfolio { *************** *** 96,105 **** } */ ! /* protected override double getFitnessValue_calculate() { return this.RateOfReturn/Math.Sqrt(this.Variance); } ! */ } --- 96,105 ---- } */ ! protected override double getFitnessValue_calculate() { return this.RateOfReturn/Math.Sqrt(this.Variance); } ! } Index: GenomeManagerForEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTCPortfolio.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GenomeManagerForEfficientCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.12 --- GenomeManagerForEfficientCTCPortfolio.cs 14 May 2006 18:36:37 -0000 1.13 *************** *** 108,112 **** returnValue = QuantProject.Data.DataTables.Quotes.GetArrayOfCloseToCloseRatios(ticker, ! this.firstQuoteDate, this.lastQuoteDate, this.numDaysForReturnCalculation); --- 108,112 ---- returnValue = QuantProject.Data.DataTables.Quotes.GetArrayOfCloseToCloseRatios(ticker, ! ref this.firstQuoteDate, this.lastQuoteDate, this.numDaysForReturnCalculation); *************** *** 151,155 **** try { ! float[] closeToCloseRatios = Quotes.GetArrayOfCloseToCloseRatios(ticker, this.firstQuoteDate, this.lastQuoteDate, this.numDaysForReturnCalculation, --- 151,155 ---- try { ! float[] closeToCloseRatios = Quotes.GetArrayOfCloseToCloseRatios(ticker, ref this.firstQuoteDate, this.lastQuoteDate, this.numDaysForReturnCalculation, *************** *** 169,175 **** protected override double getFitnessValue_calculate() { ! return (this.RateOfReturn/Math.Sqrt(this.Variance))* ! -this.shiftedPortfolioRateOfReturn * ! -this.ShiftedPortfolioRatesOfReturn[this.ShiftedPortfolioRatesOfReturn.Length -1]; } --- 169,182 ---- protected override double getFitnessValue_calculate() { ! // return (this.RateOfReturn/Math.Sqrt(this.Variance))* ! // -this.shiftedPortfolioRateOfReturn * ! // -this.ShiftedPortfolioRatesOfReturn[this.ShiftedPortfolioRatesOfReturn.Length -1]; ! double sharpeRatioWaveUp = this.RateOfReturn/ ! Math.Sqrt(this.Variance); ! double sharpeRatioWaveDown = this.shiftedPortfolioRateOfReturn/ ! Math.Sqrt(BasicFunctions.Variance(this.shiftedPortfolioRatesOfReturn)); ! ! return sharpeRatioWaveUp - sharpeRatioWaveDown; ! } |