[Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting EndOfDayTimerHandler.cs,1.3
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-12-20 20:25:24
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15522/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandler.cs RunEfficientCTOPortfolio.cs Log Message: Updated script for TickerSelection Testing, using Efficient portfolio theory Index: EndOfDayTimerHandler.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandler.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EndOfDayTimerHandler.cs 17 Dec 2004 19:49:09 -0000 1.3 --- EndOfDayTimerHandler.cs 20 Dec 2004 20:25:11 -0000 1.4 *************** *** 91,107 **** #endregion ! #region FiveMinutesBeforeMarketCloseEventHandler ! private void fiveMinutesBeforeMarketCloseEventHandler_closePosition( string ticker ) { this.account.ClosePosition( ticker ); } ! private void fiveMinutesBeforeMarketCloseEventHandler_closePositions() { ! foreach ( string ticker in this.account.Portfolio.Keys ) ! fiveMinutesBeforeMarketCloseEventHandler_closePosition( ticker ); } ! private void fiveMinutesBeforeMarketCloseEventHandler_openPosition( string ticker ) { --- 91,116 ---- #endregion ! #region MarketCloseEventHandler ! private void marketCloseEventHandler_closePosition( string ticker ) { this.account.ClosePosition( ticker ); } ! private void marketCloseEventHandler_closePositions() { ! if(this.chosenTickers != null) ! { ! foreach( string ticker in this.chosenTickers) ! { ! for(int i = 0; i<this.account.Portfolio.Keys.Count; i++) ! { ! if(this.account.Portfolio[ticker]!=null) ! marketCloseEventHandler_closePosition( ticker ); ! } ! } ! } } ! private void marketCloseEventHandler_openPosition( string ticker ) { *************** *** 113,125 **** new Instrument( ticker ) , sharesToBeBought ) ); } ! private void fiveMinutesBeforeMarketCloseEventHandler_openPositions() { foreach ( string ticker in this.chosenTickers ) ! this.fiveMinutesBeforeMarketCloseEventHandler_openPosition( ticker ); } ! public void FiveMinutesBeforeMarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! this.fiveMinutesBeforeMarketCloseEventHandler_closePositions(); //fiveMinutesBeforeMarketCloseEventHandler_openPositions(); } --- 122,135 ---- new Instrument( ticker ) , sharesToBeBought ) ); } ! private void marketCloseEventHandler_openPositions() { foreach ( string ticker in this.chosenTickers ) ! this.marketCloseEventHandler_openPosition( ticker ); } ! public void MarketCloseEventHandler( Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) { ! ! this.marketCloseEventHandler_closePositions(); //fiveMinutesBeforeMarketCloseEventHandler_openPositions(); } *************** *** 181,193 **** { TickerSelector mostLiquid = new TickerSelector(SelectionType.Liquidity, ! false, "STOCKMI", currentDate, currentDate.AddDays(60), this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); IGenomeManager genManEfficientCTOPortfolio = ! new GenomeManagerForEfficientCTOPortfolio(this.eligibleTickers,currentDate, ! currentDate.AddDays(60), this.numberOfTickersToBeChosen, 0.005, 0.05); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; ! GO.GenerationNumber = 4; GO.MutationRate = 0.05; GO.Run(false); --- 191,203 ---- { TickerSelector mostLiquid = new TickerSelector(SelectionType.Liquidity, ! false, "STOCKMI", currentDate.AddDays(-30), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); IGenomeManager genManEfficientCTOPortfolio = ! new GenomeManagerForEfficientCTOPortfolio(this.eligibleTickers,currentDate.AddDays(-30), ! currentDate, this.numberOfTickersToBeChosen, 0.005, 0.05); GeneticOptimizer GO = new GeneticOptimizer(genManEfficientCTOPortfolio); //GO.KeepOnRunningUntilConvergenceIsReached = true; ! GO.GenerationNumber = 2; GO.MutationRate = 0.05; GO.Run(false); Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RunEfficientCTOPortfolio.cs 14 Dec 2004 21:25:46 -0000 1.2 --- RunEfficientCTOPortfolio.cs 20 Dec 2004 20:25:12 -0000 1.3 *************** *** 77,84 **** this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! new DateTime( 2002 , 1 , 1 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 2002 , 3 , 31 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.numIntervalDays = 7; } #region Run --- 77,84 ---- this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! new DateTime( 2004 , 10 , 4 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 2004 , 10 , 10 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.numIntervalDays = 1; } #region Run *************** *** 163,167 **** --- 163,179 ---- */ #endregion + + private void checkDateForReport(Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs) + { + Report report; + + if(endOfDayTimingEventArgs.EndOfDayDateTime.DateTime>=this.endDateTime.DateTime ) + { + this.endOfDayTimer.Stop(); + report = new Report( this.account ); + report.Show("CTO_Portfolio" , this.numIntervalDays , this.startDateTime , "CTO_Portfolio" ); + } + } public override void Run() { *************** *** 169,173 **** //this.run_FindBestPortfolioForNextTrade(); - Report report; run_initializeEndOfDayTimer(); run_initializeAccount(); --- 181,184 ---- *************** *** 178,185 **** this.endOfDayTimerHandler.MarketOpenEventHandler); ! this.endOfDayTimer.FiveMinutesBeforeMarketClose += ! new FiveMinutesBeforeMarketCloseEventHandler( ! this.endOfDayTimerHandler.FiveMinutesBeforeMarketCloseEventHandler ); ! this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( --- 189,200 ---- this.endOfDayTimerHandler.MarketOpenEventHandler); ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.endOfDayTimerHandler.MarketCloseEventHandler); ! ! this.endOfDayTimer.MarketClose += ! new MarketCloseEventHandler( ! this.checkDateForReport); ! this.endOfDayTimer.OneHourAfterMarketClose += new OneHourAfterMarketCloseEventHandler( *************** *** 191,197 **** //this.progressBarForm.Show(); this.endOfDayTimer.Start(); - report = new Report( this.account ); - report.Show("CTO_Portfolio" , this.numIntervalDays , this.startDateTime , "CTO_Portfolio" ); - } --- 206,209 ---- |