[Quantproject-developers] QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOs
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:20:46
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16791/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO Modified Files: EndOfDayTimerHandlerBiasedPVO.cs EndOfDayTimerHandlerBiasedPVO_OTC.cs RunBiasedPVO.cs Log Message: The new revision moves toward an intraday enabled framework. EndOfDayDate time has been removed, DateTime is used now. The code has been changed accordingly. Index: EndOfDayTimerHandlerBiasedPVO_OTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/EndOfDayTimerHandlerBiasedPVO_OTC.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EndOfDayTimerHandlerBiasedPVO_OTC.cs 9 Mar 2008 22:40:51 -0000 1.2 --- EndOfDayTimerHandlerBiasedPVO_OTC.cs 29 Sep 2008 21:18:34 -0000 1.3 *************** *** 19,23 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; using System.Data; --- 19,23 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; using System.Data; *************** *** 49,249 **** { /// <summary> ! /// Implements MarketOpenEventHandler and MarketCloseEventHandler ! /// These handlers contain the core strategy for the Biased Portfolio Value ! /// Oscillator, using Open To Close returns ! /// </summary> ! [Serializable] ! public class EndOfDayTimerHandlerBiasedPVO_OTC : EndOfDayTimerHandlerBiasedPVO ! { ! ! public EndOfDayTimerHandlerBiasedPVO_OTC(string tickerGroupID, int numberOfEligibleTickers, ! double minPriceForTickersToBeChosen, ! double maxPriceForTickersToBeChosen, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! Account account, ! string pathOfFileContainingGenomes, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, ! string benchmark, ! int numOfDifferentGenomesToEvaluateOutOfSample, ! bool resetThresholdsBeforeCheckingOutOfSample, ! int numDaysForThresholdsReComputation, ! double numOfStdDevForThresholdsComputation, ! double maxCoefficientForDegreeComputationOfCrossingThreshold, ! bool buyOnlyPositionsThatAreMovingTogether, ! bool doNotOpenReversedPositionsThatHaveJustBeenClosed, ! int numDaysOfStayingOnTheMarket, ! int minLevelForOversoldThreshold, ! int maxLevelForOversoldThreshold, ! int minLevelForOverboughtThreshold, ! int maxLevelForOverboughtThreshold, ! int divisorForThresholdComputation, ! bool symmetricalThresholds, ! bool overboughtMoreThanOversoldForFixedPortfolio, ! int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double minimumAcceptableGain): ! base(tickerGroupID, numberOfEligibleTickers, ! minPriceForTickersToBeChosen, ! maxPriceForTickersToBeChosen, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! account, ! pathOfFileContainingGenomes, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, ! benchmark, ! numOfDifferentGenomesToEvaluateOutOfSample, ! resetThresholdsBeforeCheckingOutOfSample, ! numDaysForThresholdsReComputation, ! numOfStdDevForThresholdsComputation, ! maxCoefficientForDegreeComputationOfCrossingThreshold, ! buyOnlyPositionsThatAreMovingTogether, ! doNotOpenReversedPositionsThatHaveJustBeenClosed, ! 1, numDaysOfStayingOnTheMarket, ! minLevelForOversoldThreshold, ! maxLevelForOversoldThreshold, ! minLevelForOverboughtThreshold, ! maxLevelForOverboughtThreshold, ! divisorForThresholdComputation, ! symmetricalThresholds, ! overboughtMoreThanOversoldForFixedPortfolio, ! numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! minimumAcceptableGain) ! ! { ! } ! #region MarketOpen ! ! public override void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! if ( this.account.Portfolio.Count == 0 && ! this.weightedPositionsToEvaluateOutOfSample[0] != null ) ! //portfolio is empty and optimization has been already launched ! this.openPositions( (IndexBasedEndOfDayTimer)sender ); ! } ! ! protected override void openPositions_chooseGenome_resetThresholds(DateTime today) ! { for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) ! { this.currentOversoldThreshold[i] = (double)this.maxLevelForOversoldThreshold/ (double)this.divisorForThresholdComputation; ! this.currentOverboughtThreshold[i] = (double)this.maxLevelForOverboughtThreshold/ (double)this.divisorForThresholdComputation; ! } ! // UPDATE WITH DailyOpenToCloseIntervals ! // ReturnsManager returnsManager = new ReturnsManager( ! // new CloseToOpenIntervals(new EndOfDayDateTime(today.AddDays(-this.numDaysForThresholdsReComputation), EndOfDaySpecificTime.MarketClose), // new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketOpen), // this.benchmark), // new HistoricalAdjustedQuoteProvider() ); ! // //double returnsAverage; ! // double returnsStdDev; ! // for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) ! // { ! //// returnsAverage = BasicFunctions.GetSimpleAverage( ! //// this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); // returnsStdDev = BasicFunctions.GetStdDev( ! // this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); ! // this.currentOversoldThreshold[i] = -this.numOfStdDevForThresholdsComputation * returnsStdDev; ! // this.currentOverboughtThreshold[i] = this.numOfStdDevForThresholdsComputation * returnsStdDev; ! // } ! } ! //NEW IMPLEMENTATION of chooseBestGenome, now named chooseGenome ! //sets currentGenomeIndex with the first genome's index that crosses an overbought/oversold threshold with the ! //"acceptable" degree and sets currentWeightedPositionsGainOrLoss accordingly ! protected override void openPositions_chooseGenome(IndexBasedEndOfDayTimer timer) ! { ! DateTime today = timer.GetCurrentTime().DateTime; ! DateTime previousTradingDay = ! timer.GetPreviousDateTime(1); ! ReturnsManager returnsManager = new ReturnsManager( ! new CloseToOpenIntervals(new EndOfDayDateTime(previousTradingDay, EndOfDaySpecificTime.MarketClose), ! new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketOpen), ! this.benchmark), ! new HistoricalAdjustedQuoteProvider() ); ! if(this.resetThresholdsBeforeCheckingOutOfSample) ! this.openPositions_chooseGenome_resetThresholds(today); ! this.currentWeightedPositionsGainOrLoss = double.MinValue; ! double currentWeightedPositionsGainOrLoss_temp = double.MinValue; ! for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) ! { ! currentWeightedPositionsGainOrLoss_temp = ! this.getCurrentWeightedPositionsGainOrLoss( ! timer, returnsManager, i); if( currentWeightedPositionsGainOrLoss_temp != double.MinValue && ! ( this.buyOnlyPositionsThatAreMovingTogether == false || ! ( this.buyOnlyPositionsThatAreMovingTogether == true && ! this.areAllTickersMovingTogetherUpOrDown(timer, returnsManager, i) == true ) ) ) ! //currentWeightedPositionsGainOrLoss_temp has been properly computed and ! //only positions that are moving together can be bought ! { ! if( (currentWeightedPositionsGainOrLoss_temp >= this.currentOverboughtThreshold[i] && ! currentWeightedPositionsGainOrLoss_temp <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * ! this.currentOverboughtThreshold[i] ) || ! (currentWeightedPositionsGainOrLoss_temp <= - this.currentOversoldThreshold[i] && ! Math.Abs(currentWeightedPositionsGainOrLoss_temp) <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * ! this.currentOversoldThreshold[i] ) ) ! // if the current genome matches the requested criteria ! { this.currentGenomeIndex = i; this.currentWeightedPositionsGainOrLoss = currentWeightedPositionsGainOrLoss_temp; i = this.numOfDifferentGenomesToEvaluateOutOfSample; //exit from for ! } ! } ! } ! } ! #endregion ! public override void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) ! { ! if(this.account.Portfolio.Count > 0) ! { ! this.lastWeightedPositionsClosed = AccountManager.GetWeightedPositions(this.account); AccountManager.ClosePositions(this.account); ! } ! } ! ! #region OneHourAfterMarketCloseEventHandler ! ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) ! { ! DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! this.iGenomeManager = ! new GenomeManagerPVO_OTC(setOfTickersToBeOptimized, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfTickersToBeChosen, ! this.minLevelForOversoldThreshold, ! this.maxLevelForOversoldThreshold, ! this.minLevelForOverboughtThreshold, ! this.maxLevelForOverboughtThreshold, ! this.divisorForThresholdComputation, ! this.symmetricalThresholds, ! this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType, this.benchmark); ! GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, ! this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! this.seedForRandomGenerator); ! // if(setGenomeCounter) ! // this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.1; ! GO.CrossoverRate = 0.85; ! GO.Run(false); ! ! this.setTickers_updateTickersWeightsAndThresholdsAndAddGenomesForLog(GO, setOfTickersToBeOptimized.Rows.Count); ! ! } ! ! ! #endregion ! } } --- 49,252 ---- { /// <summary> ! /// Implements MarketOpenEventHandler and MarketCloseEventHandler ! /// These handlers contain the core strategy for the Biased Portfolio Value ! /// Oscillator, using Open To Close returns ! /// </summary> ! [Serializable] ! public class EndOfDayTimerHandlerBiasedPVO_OTC : EndOfDayTimerHandlerBiasedPVO ! { ! ! public EndOfDayTimerHandlerBiasedPVO_OTC(string tickerGroupID, int numberOfEligibleTickers, ! double minPriceForTickersToBeChosen, ! double maxPriceForTickersToBeChosen, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! Account account, ! string pathOfFileContainingGenomes, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, ! string benchmark, ! int numOfDifferentGenomesToEvaluateOutOfSample, ! bool resetThresholdsBeforeCheckingOutOfSample, ! int numDaysForThresholdsReComputation, ! double numOfStdDevForThresholdsComputation, ! double maxCoefficientForDegreeComputationOfCrossingThreshold, ! bool buyOnlyPositionsThatAreMovingTogether, ! bool doNotOpenReversedPositionsThatHaveJustBeenClosed, ! int numDaysOfStayingOnTheMarket, ! int minLevelForOversoldThreshold, ! int maxLevelForOversoldThreshold, ! int minLevelForOverboughtThreshold, ! int maxLevelForOverboughtThreshold, ! int divisorForThresholdComputation, ! bool symmetricalThresholds, ! bool overboughtMoreThanOversoldForFixedPortfolio, ! int numDaysBetweenEachOptimization, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double minimumAcceptableGain): ! base(tickerGroupID, numberOfEligibleTickers, ! minPriceForTickersToBeChosen, ! maxPriceForTickersToBeChosen, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! account, ! pathOfFileContainingGenomes, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, ! benchmark, ! numOfDifferentGenomesToEvaluateOutOfSample, ! resetThresholdsBeforeCheckingOutOfSample, ! numDaysForThresholdsReComputation, ! numOfStdDevForThresholdsComputation, ! maxCoefficientForDegreeComputationOfCrossingThreshold, ! buyOnlyPositionsThatAreMovingTogether, ! doNotOpenReversedPositionsThatHaveJustBeenClosed, ! 1, numDaysOfStayingOnTheMarket, ! minLevelForOversoldThreshold, ! maxLevelForOversoldThreshold, ! minLevelForOverboughtThreshold, ! maxLevelForOverboughtThreshold, ! divisorForThresholdComputation, ! symmetricalThresholds, ! overboughtMoreThanOversoldForFixedPortfolio, ! numDaysBetweenEachOptimization, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! minimumAcceptableGain) ! { ! ! } ! #region MarketOpen ! ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) ! { ! if ( this.account.Portfolio.Count == 0 && ! this.weightedPositionsToEvaluateOutOfSample[0] != null ) ! //portfolio is empty and optimization has been already launched ! this.openPositions( (IndexBasedEndOfDayTimer)sender ); ! } ! ! protected override void openPositions_chooseGenome_resetThresholds(DateTime today) ! { for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) ! { this.currentOversoldThreshold[i] = (double)this.maxLevelForOversoldThreshold/ (double)this.divisorForThresholdComputation; ! this.currentOverboughtThreshold[i] = (double)this.maxLevelForOverboughtThreshold/ (double)this.divisorForThresholdComputation; ! } ! // UPDATE WITH DailyOpenToCloseIntervals ! // ReturnsManager returnsManager = new ReturnsManager( ! // new CloseToOpenIntervals(new EndOfDayDateTime(today.AddDays(-this.numDaysForThresholdsReComputation), EndOfDaySpecificTime.MarketClose), // new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketOpen), // this.benchmark), // new HistoricalAdjustedQuoteProvider() ); ! // //double returnsAverage; ! // double returnsStdDev; ! // for(int i = 0; i < this.weightedPositionsToEvaluateOutOfSample.Length; i++) ! // { ! //// returnsAverage = BasicFunctions.GetSimpleAverage( ! //// this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); // returnsStdDev = BasicFunctions.GetStdDev( ! // this.weightedPositionsToEvaluateOutOfSample[i].GetReturns(returnsManager) ); ! // this.currentOversoldThreshold[i] = -this.numOfStdDevForThresholdsComputation * returnsStdDev; ! // this.currentOverboughtThreshold[i] = this.numOfStdDevForThresholdsComputation * returnsStdDev; ! // } ! } ! //NEW IMPLEMENTATION of chooseBestGenome, now named chooseGenome ! //sets currentGenomeIndex with the first genome's index that crosses an overbought/oversold threshold with the ! //"acceptable" degree and sets currentWeightedPositionsGainOrLoss accordingly ! protected override void openPositions_chooseGenome(IndexBasedEndOfDayTimer timer) ! { ! DateTime today = timer.GetCurrentDateTime(); ! DateTime previousTradingDay = ! timer.GetPreviousDateTime(1); ! ReturnsManager returnsManager = new ReturnsManager( ! new CloseToOpenIntervals( ! HistoricalEndOfDayTimer.GetMarketClose( previousTradingDay ) , ! HistoricalEndOfDayTimer.GetMarketOpen( today ) , ! // new EndOfDayDateTime(previousTradingDay, EndOfDaySpecificTime.MarketClose), ! // new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketOpen), ! this.benchmark), ! new HistoricalAdjustedQuoteProvider() ); ! if(this.resetThresholdsBeforeCheckingOutOfSample) ! this.openPositions_chooseGenome_resetThresholds(today); ! this.currentWeightedPositionsGainOrLoss = double.MinValue; ! double currentWeightedPositionsGainOrLoss_temp = double.MinValue; ! for(int i = 0; i < this.numOfDifferentGenomesToEvaluateOutOfSample; i++) ! { ! currentWeightedPositionsGainOrLoss_temp = ! this.getCurrentWeightedPositionsGainOrLoss( ! timer, returnsManager, i); if( currentWeightedPositionsGainOrLoss_temp != double.MinValue && ! ( this.buyOnlyPositionsThatAreMovingTogether == false || ! ( this.buyOnlyPositionsThatAreMovingTogether == true && ! this.areAllTickersMovingTogetherUpOrDown(timer, returnsManager, i) == true ) ) ) ! //currentWeightedPositionsGainOrLoss_temp has been properly computed and ! //only positions that are moving together can be bought ! { ! if( (currentWeightedPositionsGainOrLoss_temp >= this.currentOverboughtThreshold[i] && ! currentWeightedPositionsGainOrLoss_temp <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * ! this.currentOverboughtThreshold[i] ) || ! (currentWeightedPositionsGainOrLoss_temp <= - this.currentOversoldThreshold[i] && ! Math.Abs(currentWeightedPositionsGainOrLoss_temp) <= this.maxCoefficientForDegreeComputationOfCrossingThreshold * ! this.currentOversoldThreshold[i] ) ) ! // if the current genome matches the requested criteria ! { this.currentGenomeIndex = i; this.currentWeightedPositionsGainOrLoss = currentWeightedPositionsGainOrLoss_temp; i = this.numOfDifferentGenomesToEvaluateOutOfSample; //exit from for ! } ! } ! } ! } ! #endregion ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) ! { ! if(this.account.Portfolio.Count > 0) ! { ! this.lastWeightedPositionsClosed = AccountManager.GetWeightedPositions(this.account); AccountManager.ClosePositions(this.account); ! } ! } ! ! #region OneHourAfterMarketCloseEventHandler ! ! protected override void setTickers(DateTime currentDate, ! bool setGenomeCounter) ! { ! DataTable setOfTickersToBeOptimized = this.getSetOfTickersToBeOptimized(currentDate); ! this.iGenomeManager = ! new GenomeManagerPVO_OTC(setOfTickersToBeOptimized, ! currentDate.AddDays(-this.numDaysForOptimizationPeriod), ! currentDate, this.numberOfTickersToBeChosen, ! this.minLevelForOversoldThreshold, ! this.maxLevelForOversoldThreshold, ! this.minLevelForOverboughtThreshold, ! this.maxLevelForOverboughtThreshold, ! this.divisorForThresholdComputation, ! this.symmetricalThresholds, ! this.overboughtMoreThanOversoldForFixedPortfolio, ! this.portfolioType, this.benchmark); ! GeneticOptimizer GO = new GeneticOptimizer(this.iGenomeManager, ! this.populationSizeForGeneticOptimizer, ! this.generationNumberForGeneticOptimizer, ! this.seedForRandomGenerator); ! // if(setGenomeCounter) ! // this.genomeCounter = new GenomeCounter(GO); ! GO.MutationRate = 0.1; ! GO.CrossoverRate = 0.85; ! GO.Run(false); ! ! this.setTickers_updateTickersWeightsAndThresholdsAndAddGenomesForLog(GO, setOfTickersToBeOptimized.Rows.Count); ! ! } ! ! ! #endregion ! } } Index: RunBiasedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/RunBiasedPVO.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunBiasedPVO.cs 19 Aug 2008 17:13:03 -0000 1.5 --- RunBiasedPVO.cs 29 Sep 2008 21:18:34 -0000 1.6 *************** *** 196,201 **** w.Write("\r\nOptimization each (num of days): {0}\r", this.numDaysBetweenEachOptimization.ToString()); w.Write("\r\nBenchmark: {0}\r", this.benchmark); ! w.Write("\r\nStart date: {0}\r", this.startDateTime.DateTime.ToLongDateString()); ! w.Write("\r\nEnd date: {0}\r", this.endDateTime.DateTime.ToLongDateString()); w.Write("\r\nNum of genomes to check out of sample: {0}\r", this.numOfDifferentGenomesToEvaluateOutOfSample.ToString()); w.Write("\r\nReset thresholds out of sample: {0}\r", this.resetThresholdsBeforeCheckingOutOfSample.ToString()); --- 196,201 ---- w.Write("\r\nOptimization each (num of days): {0}\r", this.numDaysBetweenEachOptimization.ToString()); w.Write("\r\nBenchmark: {0}\r", this.benchmark); ! w.Write("\r\nStart date: {0}\r", this.startDateTime.ToLongDateString()); ! w.Write("\r\nEnd date: {0}\r", this.endDateTime.ToLongDateString()); w.Write("\r\nNum of genomes to check out of sample: {0}\r", this.numOfDifferentGenomesToEvaluateOutOfSample.ToString()); w.Write("\r\nReset thresholds out of sample: {0}\r", this.resetThresholdsBeforeCheckingOutOfSample.ToString()); *************** *** 262,266 **** this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentTime(), this.benchmark, new HistoricalAdjustedQuoteProvider()); --- 262,266 ---- this.checkDateForReport_createDirIfNotPresent(dirNameWhereToSaveReports); AccountReport accountReport = this.account.CreateReport(fileName,1, ! this.endOfDayTimer.GetCurrentDateTime(), this.benchmark, new HistoricalAdjustedQuoteProvider()); Index: EndOfDayTimerHandlerBiasedPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/BiasedPVO/EndOfDayTimerHandlerBiasedPVO.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EndOfDayTimerHandlerBiasedPVO.cs 19 Aug 2008 17:11:26 -0000 1.6 --- EndOfDayTimerHandlerBiasedPVO.cs 29 Sep 2008 21:18:34 -0000 1.7 *************** *** 142,147 **** //to avoid handlers in inherited classes ! public override void MarketOpenEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ; --- 142,147 ---- //to avoid handlers in inherited classes ! protected override void marketOpenEventHandler( ! Object sender , DateTime dateTime ) { ; *************** *** 224,235 **** protected virtual void openPositions_chooseGenome(IndexBasedEndOfDayTimer timer) { ! DateTime today = timer.GetCurrentTime().DateTime; DateTime firstMarketDayForOscillatingPeriod = timer.GetPreviousDateTime(this.numDaysForOscillatingPeriod); ReturnsManager returnsManager = new ReturnsManager( ! new CloseToCloseIntervals(new EndOfDayDateTime(firstMarketDayForOscillatingPeriod, EndOfDaySpecificTime.MarketClose), ! new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketClose), ! this.benchmark, ! this.numDaysForOscillatingPeriod), new HistoricalAdjustedQuoteProvider() ); if(this.resetThresholdsBeforeCheckingOutOfSample) --- 224,239 ---- protected virtual void openPositions_chooseGenome(IndexBasedEndOfDayTimer timer) { ! DateTime today = timer.GetCurrentDateTime(); DateTime firstMarketDayForOscillatingPeriod = timer.GetPreviousDateTime(this.numDaysForOscillatingPeriod); ReturnsManager returnsManager = new ReturnsManager( ! new CloseToCloseIntervals( ! HistoricalEndOfDayTimer.GetMarketClose( ! firstMarketDayForOscillatingPeriod ) , ! HistoricalEndOfDayTimer.GetMarketClose( today ) , ! // new EndOfDayDateTime(firstMarketDayForOscillatingPeriod, EndOfDaySpecificTime.MarketClose), ! // new EndOfDayDateTime(today, EndOfDaySpecificTime.MarketClose), ! this.benchmark, ! this.numDaysForOscillatingPeriod), new HistoricalAdjustedQuoteProvider() ); if(this.resetThresholdsBeforeCheckingOutOfSample) *************** *** 401,405 **** { bool returnValue; ! DateTime currentTime = timer.GetCurrentTime().DateTime; DateTime firstDateOfOscillatingPeriod = timer.GetPreviousDateTime(this.numDaysForOscillatingPeriod); --- 405,409 ---- { bool returnValue; ! DateTime currentTime = timer.GetCurrentDateTime(); DateTime firstDateOfOscillatingPeriod = timer.GetPreviousDateTime(this.numDaysForOscillatingPeriod); *************** *** 424,429 **** } ! public override void MarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { if(this.account.Portfolio.Count > 0) --- 428,433 ---- } ! protected override void marketCloseEventHandler( ! Object sender , DateTime dateTime ) { if(this.account.Portfolio.Count > 0) *************** *** 603,610 **** /// <param name="sender"></param> /// <param name="eventArgs"></param> ! public override void OneHourAfterMarketCloseEventHandler( ! Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.lastCloseDate = endOfDayTimingEventArgs.EndOfDayDateTime.DateTime; this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; --- 607,614 ---- /// <param name="sender"></param> /// <param name="eventArgs"></param> ! protected override void oneHourAfterMarketCloseEventHandler( ! Object sender , DateTime dateTime ) { ! this.lastCloseDate = dateTime; this.seedForRandomGenerator++; this.numDaysElapsedSinceLastOptimization++; *************** *** 615,622 **** if(this.pathOfFileContainingGenomes == null) //tickers have to be set by a new optimization process (in sample) ! this.setTickers(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime, false); //sets tickers to be chosen next Market Close event else//this.pathOfFileContainingGenomes != null ! this.setTickersFromFile(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime); //set tickers from file this.numDaysElapsedSinceLastOptimization = 0; --- 619,626 ---- if(this.pathOfFileContainingGenomes == null) //tickers have to be set by a new optimization process (in sample) ! this.setTickers(dateTime, false); //sets tickers to be chosen next Market Close event else//this.pathOfFileContainingGenomes != null ! this.setTickersFromFile(dateTime); //set tickers from file this.numDaysElapsedSinceLastOptimization = 0; *************** *** 625,629 **** #endregion - } } --- 629,632 ---- |