[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-serv22306/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTO.cs GenomeManagerForEfficientPortfolio.cs Log Message: Updated files for the EfficientPortfolio script. Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EndOfDayTimerHandlerCTO.cs 11 Apr 2005 18:52:31 -0000 1.7 --- EndOfDayTimerHandlerCTO.cs 14 Apr 2005 18:38:28 -0000 1.8 *************** *** 70,74 **** if(ticker != null) { ! this.AddOrderForTicker( ticker ); this.lastChosenTickers[idx] = ticker; } --- 70,74 ---- if(ticker != null) { ! this.addOrderForTicker( ticker ); this.lastChosenTickers[idx] = ticker; } *************** *** 145,150 **** DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); */ ! ! SelectorByLiquidity mostLiquid = new SelectorByLiquidity(this.tickerGroupID, false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); --- 145,153 ---- DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); */ ! SelectorByWinningOpenToClose selectorByWinningOpenToClose = ! new SelectorByWinningOpenToClose(this.tickerGroupID, false, currentDate, ! currentDate, this.numberOfEligibleTickers); ! DataTable winningOpenToCloseTickers = selectorByWinningOpenToClose.GetTableOfSelectedTickers(); ! SelectorByLiquidity mostLiquid = new SelectorByLiquidity(winningOpenToCloseTickers, false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EndOfDayTimerHandler.cs 11 Apr 2005 18:52:32 -0000 1.10 --- EndOfDayTimerHandler.cs 14 Apr 2005 18:38:27 -0000 1.11 *************** *** 100,104 **** } ! public virtual void AddOrderForTicker(string ticker ) { --- 100,104 ---- } ! protected virtual void addOrderForTicker(string ticker ) { Index: GenomeManagerForEfficientPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GenomeManagerForEfficientPortfolio.cs 11 Apr 2005 18:52:31 -0000 1.4 --- GenomeManagerForEfficientPortfolio.cs 14 Apr 2005 18:38:28 -0000 1.5 *************** *** 80,84 **** { get{return this.portfolioType;} ! set{this.portfolioType = value;} } --- 80,84 ---- { get{return this.portfolioType;} ! //set{this.portfolioType = value;} } *************** *** 107,122 **** public virtual double GetFitnessValue(Genome genome) { ! double returnValue; double portfolioVariance = this.getPortfolioVariance(genome.Genes()); double portfolioRateOfReturn = this.getPortfolioRateOfReturn(genome.Genes()); - this.variance = portfolioVariance; - this.rateOfReturn = portfolioRateOfReturn; - - NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portfolioVariance)); - if(this.portfolioType == PortfolioType.OnlyLong) - returnValue = normal.GetProbability(this.targetPerformance*0.75,this.targetPerformance*1.25); - else//only short orders are permitted - returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); return returnValue; } --- 107,131 ---- public virtual double GetFitnessValue(Genome genome) { ! double returnValue = 0; double portfolioVariance = this.getPortfolioVariance(genome.Genes()); double portfolioRateOfReturn = this.getPortfolioRateOfReturn(genome.Genes()); + if(!Double.IsInfinity(portfolioVariance) || + !Double.IsInfinity(portfolioRateOfReturn) || + !Double.IsNaN(portfolioVariance) || + !Double.IsNaN(portfolioRateOfReturn)) + //variance and rate of return are + //double values computed in the right way + { + this.variance = portfolioVariance; + this.rateOfReturn = portfolioRateOfReturn; + NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portfolioVariance)); + if(this.portfolioType == PortfolioType.OnlyLong) + //returnValue = normal.GetProbability(this.targetPerformance*0.75,this.targetPerformance*1.25); + returnValue = 1.0 - normal.GetProbability(this.targetPerformance); + else//only short orders are permitted + //returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); + returnValue = normal.GetProbability(this.targetPerformance); + } return returnValue; } Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandlerCTC.cs 11 Apr 2005 18:52:30 -0000 1.3 --- EndOfDayTimerHandlerCTC.cs 14 Apr 2005 18:38:27 -0000 1.4 *************** *** 136,140 **** this.lastChosenTickers[idx] = ticker; if(ticker != null) ! this.AddOrderForTicker( ticker ); idx++; } --- 136,140 ---- this.lastChosenTickers[idx] = ticker; if(ticker != null) ! this.addOrderForTicker( ticker ); idx++; } |