[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting RunEfficientCTCPortfolio.
Brought to you by:
glauco_1
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv16912 Modified Files: RunEfficientCTCPortfolio.cs RunEfficientCTCWeeklyPortfolio.cs RunEfficientCTO_WorstAtDayPortfolio.cs RunEfficientCTOPortfolio.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: RunEfficientCTCWeeklyPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCWeeklyPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunEfficientCTCWeeklyPortfolio.cs 18 Sep 2005 21:13:36 -0000 1.2 --- RunEfficientCTCWeeklyPortfolio.cs 29 Sep 2008 21:18:58 -0000 1.3 *************** *** 3,7 **** RunEfficientCTCWeeklyPorfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientCTCWeeklyPorfolio.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; *************** *** 54,118 **** public class RunEfficientCTCWeeklyPortfolio : RunEfficientPortfolio { ! protected int numDaysForReturnCalculation; ! protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCWeeklyPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! int numDaysForReturnCalculation, ! double targetReturn, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double maxRunningHours): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsWeeklyEfficientPortfolio"; ! this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; } ! #region auxiliary overriden methods for Run ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTCWeekly(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, this.benchmark, ! this.numDaysForReturnCalculation, ! this.targetReturn, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); ! } ! ! #endregion } } --- 54,123 ---- public class RunEfficientCTCWeeklyPortfolio : RunEfficientPortfolio { ! protected int numDaysForReturnCalculation; ! protected double maxAcceptableCloseToCloseDrawdown; ! public RunEfficientCTCWeeklyPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, ! int numDaysForReturnCalculation, ! double targetReturn, ! PortfolioType portfolioType, double maxAcceptableCloseToCloseDrawdown, ! double maxRunningHours): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsWeeklyEfficientPortfolio"; ! this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; } ! #region auxiliary overriden methods for Run ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTCWeekly(this.tickerGroupID, this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, this.benchmark, ! this.numDaysForReturnCalculation, ! this.targetReturn, ! this.portfolioType, this.maxAcceptableCloseToCloseDrawdown); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); ! } ! ! ! #endregion } } Index: RunEfficientCTO_WorstAtDayPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTO_WorstAtDayPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunEfficientCTO_WorstAtDayPortfolio.cs 30 Jun 2007 18:52:48 -0000 1.1 --- RunEfficientCTO_WorstAtDayPortfolio.cs 29 Sep 2008 21:18:59 -0000 1.2 *************** *** 3,7 **** RunEfficientCTOPorfolio_WorstAtDay.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientCTOPorfolio_WorstAtDay.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; *************** *** 39,43 **** using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; --- 39,43 ---- using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 47,144 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientCTOPortfolio_WorstAtDay : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! protected int numOfGenomesForOTCScanning; ! public RunEfficientCTOPortfolio_WorstAtDay(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization, ! int numOfGenomesForOTCScanning): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "CTOWorstAtDay_NoCoeff_SharpeOTCCTO"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.numOfGenomesForOTCScanning = numOfGenomesForOTCScanning; ! } ! ! ! // delete remark delimitations for having ib commission ! // and a fixed percentage calculation of slippage ! protected override void run_initializeAccount() ! { ! this.account = new Account(this.ScriptName, ! this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer(this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor(this.endOfDayTimer , ! this.historicalQuoteProvider)); ! //, new FixedPercentageSlippageManager(this.historicalQuoteProvider, ! // this.endOfDayTimer,0.08)), ! //new IBCommissionManager()); ! ! } ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTO_WorstAtDay(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization, ! this.numOfGenomesForOTCScanning); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! this.endOfDayTimer.MarketOpen += ! new MarketOpenEventHandler( ! this.endOfDayTimerHandler.MarketOpenEventHandler); ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! ! ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } --- 47,149 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientCTOPortfolio_WorstAtDay : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! protected int numOfGenomesForOTCScanning; ! public RunEfficientCTOPortfolio_WorstAtDay(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization, ! int numOfGenomesForOTCScanning): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "CTOWorstAtDay_NoCoeff_SharpeOTCCTO"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.numOfGenomesForOTCScanning = numOfGenomesForOTCScanning; ! } ! ! ! // delete remark delimitations for having ib commission ! // and a fixed percentage calculation of slippage ! protected override void run_initializeAccount() ! { ! this.account = new Account(this.ScriptName, ! this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer(this.endOfDayTimer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor(this.endOfDayTimer , ! this.historicalMarketValueProvider)); ! //, new FixedPercentageSlippageManager(this.historicalQuoteProvider, ! // this.endOfDayTimer,0.08)), ! //new IBCommissionManager()); ! ! } ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTO_WorstAtDay(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization, ! this.numOfGenomesForOTCScanning); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! // this.endOfDayTimer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.endOfDayTimerHandler.MarketOpenEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! ! ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } Index: RunEfficientCTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTCPortfolio.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RunEfficientCTCPortfolio.cs 28 Dec 2005 23:29:39 -0000 1.13 --- RunEfficientCTCPortfolio.cs 29 Sep 2008 21:18:58 -0000 1.14 *************** *** 3,7 **** RunEfficientCTCPorfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientCTCPorfolio.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; *************** *** 47,51 **** /// <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 --- 47,51 ---- /// <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 *************** *** 59,133 **** public class RunEfficientCTCPortfolio : RunEfficientPortfolio { ! protected int numDayOfPortfolioLife; ! protected int numDaysWithNoPositions; ! protected int numDaysForReturnCalculation; ! protected double maxAcceptableCloseToCloseDrawdown; ! protected int numDaysBetweenEachOptimization; ! public RunEfficientCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, 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, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsDiscontinuosWithSharpe"; ! //this.ScriptName = "CloseToCloseScriptsDiscontinuosWithCoeff"; ! this.numDayOfPortfolioLife = numDaysOfPortfolioLife; ! this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.numDaysWithNoPositions = numDaysWithNoPositions; ! this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; } ! #region auxiliary overriden methods for Run ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTC(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); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); ! } ! ! #endregion } } --- 59,144 ---- public class RunEfficientCTCPortfolio : RunEfficientPortfolio { ! protected int numDayOfPortfolioLife; ! protected int numDaysWithNoPositions; ! protected int numDaysForReturnCalculation; ! protected double maxAcceptableCloseToCloseDrawdown; ! protected int numDaysBetweenEachOptimization; ! public RunEfficientCTCPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, 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, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) { ! this.ScriptName = "CloseToCloseScriptsDiscontinuosWithSharpe"; ! //this.ScriptName = "CloseToCloseScriptsDiscontinuosWithCoeff"; ! this.numDayOfPortfolioLife = numDaysOfPortfolioLife; ! this.numDaysForReturnCalculation = numDaysForReturnCalculation; ! this.numDaysWithNoPositions = numDaysWithNoPositions; ! this.maxAcceptableCloseToCloseDrawdown = maxAcceptableCloseToCloseDrawdown; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; } ! #region auxiliary overriden methods for Run ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTC(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); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! private void newDateTimeEventHandler( object sender , DateTime dateTime ) ! { ! if ( HistoricalEndOfDayTimer.IsMarketClose( dateTime ) ) ! this.checkDateForReport( sender , dateTime ); ! } ! ! protected override void run_addEventHandlers() ! { ! ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.newDateTimeEventHandler ); ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler); ! } ! ! ! #endregion } } Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** RunEfficientCTOPortfolio.cs 14 May 2006 18:21:47 -0000 1.27 --- RunEfficientCTOPortfolio.cs 29 Sep 2008 21:18:59 -0000 1.28 *************** *** 3,7 **** RunEfficientCTOPorfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientCTOPorfolio.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; *************** *** 39,43 **** using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; --- 39,43 ---- using QuantProject.Business.Financial.Accounting.Slippage; using QuantProject.Data.DataProviders; ! using QuantProject.Data.Selectors; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; using QuantProject.Presentation.Reporting.WindowsForm; *************** *** 47,140 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientCTOPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "CloseToOpenScriptsNoCoeffSharpeRatioCombined"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } ! ! ! // delete remark delimitations for having ib commission ! // and a fixed percentage calculation of slippage ! protected override void run_initializeAccount() ! { ! this.account = new Account(this.ScriptName, ! this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer(this.endOfDayTimer , ! this.historicalQuoteProvider ) , ! new HistoricalEndOfDayOrderExecutor(this.endOfDayTimer , ! this.historicalQuoteProvider)); ! //, new FixedPercentageSlippageManager(this.historicalQuoteProvider, ! // this.endOfDayTimer,0.08)), ! //new IBCommissionManager()); ! ! } ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTO(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! this.endOfDayTimer.MarketOpen += ! new MarketOpenEventHandler( ! this.endOfDayTimerHandler.MarketOpenEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! ! this.endOfDayTimer.OneHourAfterMarketClose += ! new OneHourAfterMarketCloseEventHandler( ! this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! ! ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } --- 47,145 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientCTOPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientCTOPortfolio(string tickerGroupID, int numberOfEligibleTickers, ! int numberOfTickersToBeChosen, int numDaysForOptimizationPeriod, ! int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate, double targetReturn, ! PortfolioType portfolioType, double maxRunningHours, ! int numDaysBetweenEachOptimization): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "CloseToOpenScriptsNoCoeffSharpeRatioCombined"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } ! ! ! // delete remark delimitations for having ib commission ! // and a fixed percentage calculation of slippage ! protected override void run_initializeAccount() ! { ! this.account = new Account(this.ScriptName, ! this.endOfDayTimer , ! new HistoricalEndOfDayDataStreamer(this.endOfDayTimer , ! this.historicalMarketValueProvider ) , ! new HistoricalEndOfDayOrderExecutor(this.endOfDayTimer , ! this.historicalMarketValueProvider)); ! //, new FixedPercentageSlippageManager(this.historicalQuoteProvider, ! // this.endOfDayTimer,0.08)), ! //new IBCommissionManager()); ! ! } ! ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerCTO(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, ! this.numDaysBetweenEachOptimization); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! protected override void run_addEventHandlers() ! { ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.endOfDayTimerHandler.NewDateTimeEventHandler ); ! this.endOfDayTimer.NewDateTime += ! new NewDateTimeEventHandler( this.checkDateForReport ); ! ! // this.endOfDayTimer.MarketOpen += ! // new MarketOpenEventHandler( ! // this.endOfDayTimerHandler.MarketOpenEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.endOfDayTimerHandler.MarketCloseEventHandler); ! // ! // this.endOfDayTimer.MarketClose += ! // new MarketCloseEventHandler( ! // this.checkDateForReport); ! // ! // this.endOfDayTimer.OneHourAfterMarketClose += ! // new OneHourAfterMarketCloseEventHandler( ! // this.endOfDayTimerHandler.OneHourAfterMarketCloseEventHandler ); ! } ! ! ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } |