[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting RunTestOptimizedCTCPortfo
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:20:29
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17673 Modified Files: RunTestOptimizedCTCPortfolio.cs RunTestOptimizedOTCPortfolio.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: RunTestOptimizedOTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedOTCPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunTestOptimizedOTCPortfolio.cs 7 Jan 2006 10:35:39 -0000 1.1 --- RunTestOptimizedOTCPortfolio.cs 29 Sep 2008 21:19:53 -0000 1.2 *************** *** 3,7 **** RunTestOptimizedOTCPorfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunTestOptimizedOTCPorfolio.cs ! Copyright (C) 2003 Marco Milletti *************** *** 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; --- 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; *************** *** 38,42 **** using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; --- 38,42 ---- using QuantProject.Business.Financial.Accounting.Commissions; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 51,121 **** /// </summary> [Serializable] ! public class RunTestOptimizedOTCPorfolio : RunEfficientOTCPortfolio { ! ! public RunTestOptimizedOTCPorfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForOptimizationPeriod), endDate, targetReturn, ! portfolioType, maxRunningHours, ! numDaysBetweenEachOptimization) { ! //this.ScriptName = "TestOptimizedOTCPortfolio"; ! this.ScriptName = "TestOptimizedOTCWeightedPortfolio"; ! } ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCTest(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization); ! ! } ! ! public override void Run() ! { ! base.Run(); ! ((EndOfDayTimerHandlerOTCTest)this.endOfDayTimerHandler).Reset(); ! ! Report report = new Report( this.account , this.historicalQuoteProvider ); ! report.Create( "TestOptimizationOpenToCloseEfficientPortfolio", 1 , ! new EndOfDayDateTime( this.endDateTime.DateTime , ! EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); ! report.Show(); ! report.Text = this.getGenomeCounterInfo(); ! } ! ! protected override void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) ! { ! if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDateTime.DateTime || ! DateTime.Now >= this.startingTimeForScript.AddHours(this.maxRunningHours)) ! //last date is reached by the timer or maxRunning hours ! //are elapsed from the time script started ! { ! this.endOfDayTimer.Stop(); ! } ! } ! ! ! } } --- 51,124 ---- /// </summary> [Serializable] ! public class RunTestOptimizedOTCPorfolio : RunEfficientOTCPortfolio { ! ! public RunTestOptimizedOTCPorfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForOptimizationPeriod), endDate, targetReturn, ! portfolioType, maxRunningHours, ! numDaysBetweenEachOptimization) { ! //this.ScriptName = "TestOptimizedOTCPortfolio"; ! this.ScriptName = "TestOptimizedOTCWeightedPortfolio"; ! } ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCTest(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization); ! ! } ! ! public override void Run() ! { ! base.Run(); ! ((EndOfDayTimerHandlerOTCTest)this.endOfDayTimerHandler).Reset(); ! ! Report report = new Report( this.account , this.historicalMarketValueProvider ); ! report.Create( ! "TestOptimizationOpenToCloseEfficientPortfolio", 1 , ! HistoricalEndOfDayTimer.GetMarketClose( this.endDateTime ) , ! // new EndOfDayDateTime( this.endDateTime.DateTime , ! // EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); ! report.Show(); ! report.Text = this.getGenomeCounterInfo(); ! } ! ! protected override void checkDateForReport( ! Object sender , DateTime dateTime ) ! { ! if(dateTime>=this.endDateTime || ! DateTime.Now >= this.startingTimeForScript.AddHours(this.maxRunningHours)) ! //last date is reached by the timer or maxRunning hours ! //are elapsed from the time script started ! { ! this.endOfDayTimer.Stop(); ! } ! } ! ! ! } } Index: RunTestOptimizedCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunTestOptimizedCTCPortfolio.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** RunTestOptimizedCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.9 --- RunTestOptimizedCTCPortfolio.cs 29 Sep 2008 21:19:53 -0000 1.10 *************** *** 3,7 **** RunTestOptimizedCTCPortfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunTestOptimizedCTCPortfolio.cs ! Copyright (C) 2003 Marco Milletti *************** *** 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; --- 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; *************** *** 36,40 **** using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; --- 36,40 ---- using QuantProject.Business.Timing; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 48,52 **** /// <summary> /// Script to buy at close and sell at close ! /// after a specified number of market days /// the efficient portfolio /// The efficient portfolio's generation rules --- 48,52 ---- /// <summary> /// Script to buy at close and sell at close ! /// after a specified number of market days /// the efficient portfolio /// The efficient portfolio's generation rules *************** *** 60,130 **** public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPortfolio { ! ! public RunTestOptimizedCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, ! int numDaysWithNoPositions, ! double targetReturn, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double maxRunningHours, int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForOptimizationPeriod), endDate, ! numDaysOfPortfolioLife, numDaysForReturnCalculation, ! numDaysWithNoPositions, ! targetReturn, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! maxRunningHours, numDaysBetweenEachOptimization) { ! this.ScriptName = "TestOptimizedCTCPortfolio"; ! } - - protected override void run_initializeEndOfDayTimerHandler() - { - this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTCTest(this.tickerGroupID, this.numberOfEligibleTickers, - this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, - this.account, - this.generationNumberForGeneticOptimizer, - this.populationSizeForGeneticOptimizer, this.benchmark, - this.numDayOfPortfolioLife, - this.numDaysForReturnCalculation, - this.numDaysWithNoPositions, - this.targetReturn, - this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, - this.numDaysBetweenEachOptimization); - } - - - public override void Run() - { - base.Run(); - ((EndOfDayTimerHandlerCTCTest)this.endOfDayTimerHandler).Reset(); - Report report = new Report( this.account , this.historicalQuoteProvider ); - report.Create( "TestOptimizationCTCPortfolio", 1 , - new EndOfDayDateTime( this.endDateTime.DateTime , - EndOfDaySpecificTime.MarketClose ) , - this.benchmark ); - report.Show(); - report.Text = this.getGenomeCounterInfo(); - } - - protected override void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) - { - if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDateTime.DateTime || - DateTime.Now >= this.startingTimeForScript.AddHours(this.maxRunningHours)) - //last date is reached by the timer or maxRunning hours - //are elapsed from the time script started - { - this.endOfDayTimer.Stop(); - } ! } ! } } --- 60,147 ---- public class RunTestOptimizedCTCPortfolio : RunEfficientCTCPortfolio { ! ! public RunTestOptimizedCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime endDate, ! int numDaysOfPortfolioLife, int numDaysForReturnCalculation, ! int numDaysWithNoPositions, ! double targetReturn, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double maxRunningHours, int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! endDate.AddDays(-numDaysForOptimizationPeriod), endDate, ! numDaysOfPortfolioLife, numDaysForReturnCalculation, ! numDaysWithNoPositions, ! targetReturn, ! portfolioType, maxAcceptableCloseToCloseDrawdown, ! maxRunningHours, numDaysBetweenEachOptimization) { ! this.ScriptName = "TestOptimizedCTCPortfolio"; ! ! } ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTCTest(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, this.benchmark, ! this.numDayOfPortfolioLife, ! this.numDaysForReturnCalculation, ! this.numDaysWithNoPositions, ! this.targetReturn, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown, ! this.numDaysBetweenEachOptimization); ! } ! ! ! public override void Run() ! { ! base.Run(); ! ((EndOfDayTimerHandlerCTCTest)this.endOfDayTimerHandler).Reset(); ! Report report = new Report( this.account , this.historicalMarketValueProvider ); ! report.Create( ! "TestOptimizationCTCPortfolio", 1 , ! HistoricalEndOfDayTimer.GetMarketClose( this.endDateTime ) , ! // new EndOfDayDateTime( this.endDateTime.DateTime , ! // EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); ! report.Show(); ! report.Text = this.getGenomeCounterInfo(); ! } ! ! // protected override void checkDateForReport( ! // Object sender , DateTime dateTime) ! // { ! // if(dateTime.EndOfDayDateTime.DateTime>=this.endDateTime.DateTime || ! // DateTime.Now >= this.startingTimeForScript.AddHours(this.maxRunningHours)) ! // //last date is reached by the timer or maxRunning hours ! // //are elapsed from the time script started ! // { ! // this.endOfDayTimer.Stop(); ! // } ! // ! // } ! ! protected override void checkDateForReport( ! Object sender , DateTime dateTime) ! { ! if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) ! { ! if( dateTime >= this.endDateTime || ! DateTime.Now >= this.startingTimeForScript.AddHours(this.maxRunningHours)) ! //last date is reached by the timer or maxRunning hours ! //are elapsed from the time script started ! this.endOfDayTimer.Stop(); ! } } ! } } |