[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCount
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2006-08-07 21:09:18
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24647/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend Modified Files: EndOfDayTimerHandlerECT.cs Log Message: Updated the base handler for tickerSelection strategies (OTC, etc.) and for other strategies (ECT, FixedPeriodOscillator, ImmediateTrendFollower). Index: EndOfDayTimerHandlerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/EndOfDayTimerHandlerECT.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandlerECT.cs 3 Aug 2006 21:31:16 -0000 1.3 --- EndOfDayTimerHandlerECT.cs 7 Aug 2006 21:09:15 -0000 1.4 *************** *** 61,64 **** --- 61,65 ---- private DateTime lastCloseDate; private IGenomeManager iGenomeManager; + private int seedForRandomGenerator; public EndOfDayTimerHandlerECT(string tickerGroupID, int numberOfEligibleTickers, *************** *** 88,91 **** --- 89,93 ---- // this.numDaysBetweenEachOptimization = 2* numDaysForReturnCalculation; this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; + this.seedForRandomGenerator = ConstantsProvider.SeedForRandomGenerator; } *************** *** 138,148 **** if(lastHalfPeriodGain < 0.0) base.openPositions(); ! else { SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); //short the portfolio ! try{ base.openPositions(); } ! catch(Exception ex){ ex = ex; } ! finally{SignedTicker.ChangeSignOfEachTicker(this.chosenTickers);} } } --- 140,158 ---- if(lastHalfPeriodGain < 0.0) base.openPositions(); ! else if (lastHalfPeriodGain > 0.0 && ! this.portfolioType == PortfolioType.ShortAndLong) { SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); //short the portfolio ! try{ ! base.openPositions(); ! } ! catch(Exception ex) ! { ! ex = ex; ! } ! finally{ ! SignedTicker.ChangeSignOfEachTicker(this.chosenTickers); ! } } } *************** *** 151,155 **** private void marketCloseEventHandler_closePositions() { - this.daysCounterWithPositions++; if(this.daysCounterWithPositions == this.numDaysForReturnCalculation || this.stopLossConditionReached) --- 161,164 ---- *************** *** 164,167 **** --- 173,178 ---- Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { + if(this.account.Portfolio.Count > 0) + this.daysCounterWithPositions++; //this.marketCloseEventHandler_updateStopLossCondition(); this.marketCloseEventHandler_closePositions(); *************** *** 186,194 **** int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate, ! currentDate.AddDays(-30), ! numOfTickersInGroupAtCurrentDate, ! 30,500, 0.0001,100); // SelectorByLiquidity mostLiquidSelector = --- 197,205 ---- int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! // SelectorByAverageRawOpenPrice byPrice = ! // new SelectorByAverageRawOpenPrice(tickersFromGroup,false,currentDate, ! // currentDate.AddDays(-30), ! // numOfTickersInGroupAtCurrentDate, ! // 30,500, 0.0001,100); // SelectorByLiquidity mostLiquidSelector = *************** *** 197,211 **** // this.numberOfEligibleTickers); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromByPrice = ! new SelectorByQuotationAtEachMarketDay(byPrice.GetTableOfSelectedTickers(), false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, numOfTickersInGroupAtCurrentDate, this.benchmark); ! SelectorByCloseToCloseVolatility lessVolatile = ! new SelectorByCloseToCloseVolatility(quotedAtEachMarketDayFromByPrice.GetTableOfSelectedTickers(), ! true,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! this.numberOfEligibleTickers); ! ! return lessVolatile.GetTableOfSelectedTickers(); //OLD for etf // SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, --- 208,224 ---- // this.numberOfEligibleTickers); ! // SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromByPrice = ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromGroup = ! new SelectorByQuotationAtEachMarketDay(tickersFromGroup, false, currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, numOfTickersInGroupAtCurrentDate, this.benchmark); ! // SelectorByCloseToCloseVolatility lessVolatile = ! // new SelectorByCloseToCloseVolatility(quotedAtEachMarketDayFromByPrice.GetTableOfSelectedTickers(), ! // true,currentDate.AddDays(-this.numDaysForOptimizationPeriod), currentDate, ! // this.numberOfEligibleTickers); ! // ! // return lessVolatile.GetTableOfSelectedTickers(); ! return quotedAtEachMarketDayFromGroup.GetTableOfSelectedTickers(); //OLD for etf // SelectorByGroup temporizedGroup = new SelectorByGroup(this.tickerGroupID, *************** *** 254,258 **** this.populationSizeForGeneticOptimizer, this.generationNumberForGeneticOptimizer, ! ConstantsProvider.SeedForRandomGenerator); if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); --- 267,272 ---- this.populationSizeForGeneticOptimizer, this.generationNumberForGeneticOptimizer, ! this.seedForRandomGenerator); ! GO.CrossoverRate = 0.50; if(setGenomeCounter) this.genomeCounter = new GenomeCounter(GO); *************** *** 260,264 **** GO.Run(false); this.addGenomeToBestGenomes(GO.BestGenome,((GenomeManagerForEfficientPortfolio)this.iGenomeManager).FirstQuoteDate, ! ((GenomeManagerForEfficientPortfolio)this.iGenomeManager).LastQuoteDate, setOfTickersToBeOptimized.Rows.Count); this.chosenTickers = ((GenomeMeaning)GO.BestGenome.Meaning).Tickers; this.chosenTickersPortfolioWeights = ((GenomeMeaning)GO.BestGenome.Meaning).TickersPortfolioWeights; --- 274,279 ---- 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; *************** *** 277,281 **** { this.lastCloseDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; ! ConstantsProvider.SeedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; this.orders.Clear(); --- 292,296 ---- { this.lastCloseDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; ! this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; this.orders.Clear(); |