[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting RunEfficientOTC_WorstAtNi
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-09-29 21:20:11
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17425 Modified Files: RunEfficientOTC_WorstAtNightPortfolio.cs RunEfficientOTCCTOPortfolio.cs RunEfficientOTCPortfolio.cs RunEfficientOTCPortfolioMultiday.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: RunEfficientOTCPortfolioMultiday.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCPortfolioMultiday.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunEfficientOTCPortfolioMultiday.cs 29 Aug 2007 10:04:28 -0000 1.2 --- RunEfficientOTCPortfolioMultiday.cs 29 Sep 2008 21:19:16 -0000 1.3 *************** *** 3,7 **** RunEfficientOTCPorfolioMultiday.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientOTCPorfolioMultiday.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; *************** *** 46,50 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// The efficient portfolio's generation rules --- 46,50 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// The efficient portfolio's generation rules *************** *** 53,81 **** /// - choose the most efficient portfolio among these tickers /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolioMultiday : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCPortfolioMultiday(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 numDaysPortfolioLife): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "MultidayOpenCloseScripts_SharpeNoCoeff"; ! this.numDaysBetweenEachOptimization = numDaysPortfolioLife; ! } ! ! #region auxiliary overriden methods for Run ! ! /* delete remark delimitations for having ib commission protected override void run_initializeAccount() { --- 53,81 ---- /// - choose the most efficient portfolio among these tickers /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolioMultiday : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCPortfolioMultiday(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 numDaysPortfolioLife): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! this.ScriptName = "MultidayOpenCloseScripts_SharpeNoCoeff"; ! this.numDaysBetweenEachOptimization = numDaysPortfolioLife; ! } ! ! #region auxiliary overriden methods for Run ! ! /* delete remark delimitations for having ib commission protected override void run_initializeAccount() { *************** *** 87,138 **** } ! */ ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCMultiday(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 HistoricalRawQuoteProvider(); ! 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 ); ! } ! #endregion ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } --- 87,143 ---- } ! */ ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCMultiday(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 HistoricalRawQuoteProvider(); ! 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 ); ! } ! #endregion ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } Index: RunEfficientOTC_WorstAtNightPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTC_WorstAtNightPortfolio.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RunEfficientOTC_WorstAtNightPortfolio.cs 14 Jan 2008 23:43:47 -0000 1.3 --- RunEfficientOTC_WorstAtNightPortfolio.cs 29 Sep 2008 21:19:16 -0000 1.4 *************** *** 3,7 **** RunEfficientOTCPortfolio_WorstAtNight.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientOTCPortfolio_WorstAtNight.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,159 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient open to close daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolio_WorstAtNight : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; protected int numOfGenomesForCTOScanning; ! public RunEfficientOTCPortfolio_WorstAtNight(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 numOfGenomesForCTOScanning): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! // this.ScriptName = "OTC_WorstAtNight_SharpeRatioWithCoeff_OnlyMutation"; ! //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_WorstAtNight_SharpeRatioNoCoeff"; ! //this.ScriptName = "OpenCloseScripts"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.numOfGenomesForCTOScanning = numOfGenomesForCTOScanning; } ! ! ! // 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 EndOfDayTimerHandlerOTC_WorstAtNight(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, this.numDaysBetweenEachOptimization, ! this.numOfGenomesForCTOScanning); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); ! //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 ); ! } ! ! public override string SaveScriptResults_CreateFileName() ! { ! return DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! "From_" + this.tickerGroupID + "_" + ! + this.numberOfEligibleTickers + ! "_OptDays" + this.numDaysForOptimizationPeriod + "_Port" + ! this.numberOfTickersToBeChosen + "_GenNum" + ! this.generationNumberForGeneticOptimizer + ! "_PopSize" + this.populationSizeForGeneticOptimizer + ! "_GenomesScanned" + this.numOfGenomesForCTOScanning; } - - - //necessary far calling RunEfficientPortfolio.Run() - //in classes that inherit from this class - public override void Run() - { - base.Run(); - } } } --- 47,164 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient open to close daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolio_WorstAtNight : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; protected int numOfGenomesForCTOScanning; ! public RunEfficientOTCPortfolio_WorstAtNight(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 numOfGenomesForCTOScanning): ! base(tickerGroupID, numberOfEligibleTickers, ! numberOfTickersToBeChosen, numDaysForOptimizationPeriod, ! generationNumberForGeneticOptimizer, ! populationSizeForGeneticOptimizer, benchmark, ! startDate, endDate, targetReturn, ! portfolioType, maxRunningHours) ! { ! // this.ScriptName = "OTC_WorstAtNight_SharpeRatioWithCoeff_OnlyMutation"; ! //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_WorstAtNight_SharpeRatioNoCoeff"; ! //this.ScriptName = "OpenCloseScripts"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! this.numOfGenomesForCTOScanning = numOfGenomesForCTOScanning; } ! ! ! // 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 EndOfDayTimerHandlerOTC_WorstAtNight(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, this.numDaysBetweenEachOptimization, ! this.numOfGenomesForCTOScanning); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalRawQuoteProvider(); ! //this.historicalQuoteProvider = 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 ); ! } ! ! public override string SaveScriptResults_CreateFileName() ! { ! return DateTime.Now.Hour.ToString().PadLeft(2,'0') + "_" + ! DateTime.Now.Minute.ToString().PadLeft(2,'0') + "_" + ! "From_" + this.tickerGroupID + "_" + ! + this.numberOfEligibleTickers + ! "_OptDays" + this.numDaysForOptimizationPeriod + "_Port" + ! this.numberOfTickersToBeChosen + "_GenNum" + ! this.generationNumberForGeneticOptimizer + ! "_PopSize" + this.populationSizeForGeneticOptimizer + ! "_GenomesScanned" + this.numOfGenomesForCTOScanning; ! } ! ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); } } } Index: RunEfficientOTCCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCCTOPortfolio.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunEfficientOTCCTOPortfolio.cs 21 Oct 2005 18:07:45 -0000 1.1 --- RunEfficientOTCCTOPortfolio.cs 29 Sep 2008 21:19:16 -0000 1.2 *************** *** 3,7 **** RunEfficientOTCCTOPorfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientOTCCTOPorfolio.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; *************** *** 46,50 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// The efficient portfolio's generation rules --- 46,50 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient close to open daily portfolio /// The efficient portfolio's generation rules *************** *** 53,81 **** /// - choose the most efficient portfolio among these tickers /// </summary> ! [Serializable] ! public class RunEfficientOTCCTOPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCCTOPortfolio(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 = "OpenToClose_CloseToOpenScripts"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } ! ! #region auxiliary overriden methods for Run ! ! /* delete remark delimitations for having ib commission protected override void run_initializeAccount() { --- 53,81 ---- /// - choose the most efficient portfolio among these tickers /// </summary> ! [Serializable] ! public class RunEfficientOTCCTOPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCCTOPortfolio(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 = "OpenToClose_CloseToOpenScripts"; ! this.numDaysBetweenEachOptimization = numDaysBetweenEachOptimization; ! } ! ! #region auxiliary overriden methods for Run ! ! /* delete remark delimitations for having ib commission protected override void run_initializeAccount() { *************** *** 87,138 **** } ! */ ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCCTO(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 HistoricalRawQuoteProvider(); ! 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 ); ! } ! #endregion ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } --- 87,143 ---- } ! */ ! ! protected override void run_initializeEndOfDayTimerHandler() ! { ! this.endOfDayTimerHandler = new EndOfDayTimerHandlerOTCCTO(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 HistoricalRawQuoteProvider(); ! 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 ); ! } ! #endregion ! ! //necessary far calling RunEfficientPortfolio.Run() ! //in classes that inherit from this class ! public override void Run() ! { ! base.Run(); ! } } } Index: RunEfficientOTCPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientOTCPortfolio.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RunEfficientOTCPortfolio.cs 14 Aug 2008 23:29:40 -0000 1.4 --- RunEfficientOTCPortfolio.cs 29 Sep 2008 21:19:16 -0000 1.5 *************** *** 3,7 **** RunEfficientOTCPortfolio.cs ! Copyright (C) 2003 Marco Milletti --- 3,7 ---- RunEfficientOTCPortfolio.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,146 **** { /// <summary> ! /// Script to buy at open and sell at close /// the efficient open to close daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCPortfolio(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 = "OpenCloseScriptsSharpeRatioWithCoeff"; ! //this.ScriptName = "OTC_SharpeRatioWithCoeff_OnlyMutation"; ! //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_SharpeRatioNoCoeff"; //this.ScriptName = "OTC_ExpectancyScoreNoCoeff"; ! //this.ScriptName = "OpenCloseScripts"; ! 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 EndOfDayTimerHandlerOTC(this.tickerGroupID, - this.numberOfEligibleTickers, - this.numberOfTickersToBeChosen, - 10, - this.numDaysForOptimizationPeriod, - this.account, - this.generationNumberForGeneticOptimizer, - this.populationSizeForGeneticOptimizer, - this.benchmark, - this.targetReturn, - this.portfolioType, this.numDaysBetweenEachOptimization); - } - - protected override void run_initializeHistoricalQuoteProvider() - { - this.historicalQuoteProvider = new HistoricalRawQuoteProvider(); - // 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,151 ---- { /// <summary> ! /// Script to buy at open and sell at close /// the efficient open to close daily portfolio /// </summary> ! [Serializable] ! public class RunEfficientOTCPortfolio : RunEfficientPortfolio ! { ! protected int numDaysBetweenEachOptimization; ! public RunEfficientOTCPortfolio(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 = "OpenCloseScriptsSharpeRatioWithCoeff"; ! //this.ScriptName = "OTC_SharpeRatioWithCoeff_OnlyMutation"; ! //this.ScriptName = "OpenCloseScriptsSharpeRatio"; ! this.ScriptName = "OTC_SharpeRatioNoCoeff"; //this.ScriptName = "OTC_ExpectancyScoreNoCoeff"; ! //this.ScriptName = "OpenCloseScripts"; ! 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 EndOfDayTimerHandlerOTC(this.tickerGroupID, ! this.numberOfEligibleTickers, ! this.numberOfTickersToBeChosen, ! 10, ! this.numDaysForOptimizationPeriod, ! this.account, ! this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark, ! this.targetReturn, ! this.portfolioType, this.numDaysBetweenEachOptimization); ! } ! ! protected override void run_initializeHistoricalQuoteProvider() ! { ! this.historicalMarketValueProvider = new HistoricalRawQuoteProvider(); ! // this.historicalQuoteProvider = 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(); } } } |