[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCount
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2006-09-17 21:48:45
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3064/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend Modified Files: GenomeManagerECT.cs EndOfDayTimerHandlerECT.cs Log Message: Minor changes: -formatting changes; -changes in parameters. Index: EndOfDayTimerHandlerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/EndOfDayTimerHandlerECT.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandlerECT.cs 7 Aug 2006 21:09:15 -0000 1.4 --- EndOfDayTimerHandlerECT.cs 17 Sep 2006 21:48:39 -0000 1.5 *************** *** 139,143 **** { if(lastHalfPeriodGain < 0.0) ! base.openPositions(); else if (lastHalfPeriodGain > 0.0 && this.portfolioType == PortfolioType.ShortAndLong) --- 139,143 ---- { if(lastHalfPeriodGain < 0.0) ! base.openPositions(this.chosenTickers); else if (lastHalfPeriodGain > 0.0 && this.portfolioType == PortfolioType.ShortAndLong) *************** *** 146,150 **** //short the portfolio try{ ! base.openPositions(); } catch(Exception ex) --- 146,150 ---- //short the portfolio try{ ! base.openPositions(this.chosenTickers); } catch(Exception ex) *************** *** 197,216 **** int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! // SelectorByAverageRawOpenPrice byPrice = ! // new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate, ! // currentDate.AddDays(-30), ! // numOfTickersInGroupAtCurrentDate, ! // 30,500, 0.0001,100); ! // SelectorByLiquidity mostLiquidSelector = ! // new SelectorByLiquidity(byPrice.GetTableOfSelectedTickers(), ! // false,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! // this.numberOfEligibleTickers); // SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromByPrice = SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromGroup = ! new SelectorByQuotationAtEachMarketDay(tickersFromGroup, false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! numOfTickersInGroupAtCurrentDate, this.benchmark); // SelectorByCloseToCloseVolatility lessVolatile = --- 197,216 ---- int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate, ! currentDate.AddDays(-30), ! numOfTickersInGroupAtCurrentDate, ! 20,500, 0.0001,100); ! SelectorByLiquidity mostLiquidSelector = ! new SelectorByLiquidity(byPrice.GetTableOfSelectedTickers() , ! false,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers); // SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromByPrice = SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromGroup = ! new SelectorByQuotationAtEachMarketDay(mostLiquidSelector.GetTableOfSelectedTickers(), false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers, this.benchmark); // SelectorByCloseToCloseVolatility lessVolatile = *************** *** 268,279 **** this.generationNumberForGeneticOptimizer, this.seedForRandomGenerator); ! GO.CrossoverRate = 0.50; if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, ! this.numDaysForReturnCalculation, this.portfolioType); this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; --- 268,284 ---- this.generationNumberForGeneticOptimizer, this.seedForRandomGenerator); ! if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); ! // GO.ElitismRate = 0.00; ! GO.MutationRate = 0.3; ! GO.CrossoverRate = 0.9; ! // GO.MinConvergenceRate = 0.75; ! // GO.KeepOnRunningUntilConvergenceIsReached = true; ! //GO.CrossoverRate = 0.5; GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count, ! this.numDaysForReturnCalculation, this.portfolioType, GO.GenerationCounter); this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; *************** *** 300,304 **** //it is the first close (OLD IMPLEMENTATION) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //sets tickers to be chosen next Market Close event this.numDaysElapsedSinceLastOptimization = 0; --- 305,309 ---- //it is the first close (OLD IMPLEMENTATION) { ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, true); //sets tickers to be chosen next Market Close event this.numDaysElapsedSinceLastOptimization = 0; Index: GenomeManagerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/GenomeManagerECT.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GenomeManagerECT.cs 7 Aug 2006 21:03:24 -0000 1.3 --- GenomeManagerECT.cs 17 Sep 2006 21:48:39 -0000 1.4 *************** *** 68,71 **** --- 68,73 ---- returnValue = ExtendedDataTable.GetArrayOfFloatFromColumn(tickerQuotes, Quotes.AdjustedCloseToCloseRatio); + + for(int i = 0; i<returnValue.Length; i++) returnValue[i] = returnValue[i] - 1.0f; *************** *** 121,149 **** { double[] returnValue = new double[this.PortfolioRatesOfReturn.Length]; ! double gainForTheLastHalfPeriod = 0.0; for(int i = this.numDaysForReturnCalculation - 1; i<this.PortfolioRatesOfReturn.Length - this.numDaysForReturnCalculation; i += this.numDaysForReturnCalculation) { ! gainForTheLastHalfPeriod = 0.0; for(int j=this.numDaysForReturnCalculation - 1; j > -1; j--) { ! gainForTheLastHalfPeriod = ! (1.0+gainForTheLastHalfPeriod) * this.PortfolioRatesOfReturn[i-j]; } ! for(int t=1;t<this.numDaysForReturnCalculation + 1;t++) { ! if(gainForTheLastHalfPeriod < 0.0) // if gain of first half period is negative returnValue[i+t] = this.PortfolioRatesOfReturn[i+t]; ! else if(gainForTheLastHalfPeriod > 0.0 && ! this.PortfolioType == PortfolioType.ShortAndLong) //if gain of first half period is positive and //original positions can be reversed returnValue[i+t] = - this.PortfolioRatesOfReturn[i+t]; ! else if(gainForTheLastHalfPeriod > 0.0 && ! this.PortfolioType != PortfolioType.ShortAndLong) //if gain of first half period is positive and //original positions can't be reversed --- 123,148 ---- { double[] returnValue = new double[this.PortfolioRatesOfReturn.Length]; ! double K;//initial capital invested at the beginning of the period for(int i = this.numDaysForReturnCalculation - 1; i<this.PortfolioRatesOfReturn.Length - this.numDaysForReturnCalculation; i += this.numDaysForReturnCalculation) { ! K = 1.0; for(int j=this.numDaysForReturnCalculation - 1; j > -1; j--) { ! K = K + K * this.PortfolioRatesOfReturn[i-j]; } ! for(int t=1;t<this.numDaysForReturnCalculation + 1;t++) { ! if(K < 1.0) // if gain of first half period is negative returnValue[i+t] = this.PortfolioRatesOfReturn[i+t]; ! else if(K > 1.0 && this.PortfolioType == PortfolioType.ShortAndLong) //if gain of first half period is positive and //original positions can be reversed returnValue[i+t] = - this.PortfolioRatesOfReturn[i+t]; ! else if(K > 1.0 && this.PortfolioType != PortfolioType.ShortAndLong) //if gain of first half period is positive and //original positions can't be reversed |